# Copyright abcdesktop.io # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: pyos-role rules: - apiGroups: [''] resources: ['pods'] verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] - apiGroups: [''] resources: ['events'] verbs: [ "get", "list", "watch" ] - apiGroups: [''] resources: ['pods/exec'] verbs: ["create", "get", "list", "watch", "update", "patch", "delete"] - apiGroups: [''] resources: ['pods/ephemeralcontainers'] verbs: ["create", "get", "list", "watch", "update", "patch", "delete"] - apiGroups: [''] resources: ['secrets'] verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] - apiGroups: [''] resources: ['configmaps'] verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] - apiGroups: [''] resources: ['pods/log'] verbs: ['get', 'list', 'watch' ] - apiGroups: [""] resources: ["persistentvolumes"] verbs: ["get", "list", "create", "patch", "delete"] - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["get", "list", "watch", "update", "create", "delete"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: pyos-rbac subjects: - kind: ServiceAccount name: pyos-serviceaccount roleRef: kind: Role name: pyos-role apiGroup: rbac.authorization.k8s.io --- apiVersion: v1 kind: ServiceAccount metadata: name: pyos-serviceaccount --- apiVersion: v1 kind: ConfigMap metadata: name: abcdesktop-version-config data: versionConfig.json: | { "ABCDESKTOP_VERSION": "4.5", "ABCDESKTOP_APPLICATIONS_LIST_URL": "https://raw.githubusercontent.com/abcdesktopio/images/refs/heads/main/appLists/appList.4.5.json" } --- apiVersion: v1 kind: ConfigMap metadata: name: configmap-mongodb-scripts labels: abcdesktop/role: mongodb data: init-container.sh: | #!/bin/bash set -euo pipefail echo "🧩 Preparing MongoDB configuration..." mkdir -p /work/config cp /input/mongod.conf /work/config/mongod.conf mkdir -p /var/log/mongodb touch /var/log/mongodb/mongod.log echo "🧩 Preparing MongoDB done..." mongod.conf: | net: bindIp: 0.0.0.0 port: 27017 security: authorization: enabled storage: dbPath: /data/db # systemLog: # destination: file # path: /var/log/mongodb/mongod.log # logAppend: true init.js: | // init.js - executed automatically by MongoDB at first startup print("🏁 Running init.js ..."); const fs = require('fs'); const targetDbList = fs.readFileSync('/etc/abcdesktop/MONGO_DBS_LIST', 'utf8').trim(); const rootUser = fs.readFileSync('/etc/abcdesktop/admin/MONGO_ROOT_USERNAME', 'utf8').trim(); const rootPass = fs.readFileSync('/etc/abcdesktop/admin/MONGO_ROOT_PASSWORD', 'utf8').trim(); const usersStr = fs.readFileSync('/etc/abcdesktop/MONGO_USERS_LIST', 'utf8').trim(); // auth against admin const adminDb = db.getSiblingDB('admin'); adminDb.auth(rootUser, rootPass); print('Successfully authenticated admin user'); print('List of database'); print(targetDbList); const targetDbs = targetDbList.split(','); for (targetDbStr of targetDbs) { print('use ' + targetDbStr); // we'll create the users here const targetDb = db.getSiblingDB(targetDbStr); // user-defined roles should be stored in the admin db let customRoles = []; try { const rolesResult = adminDb.getRoles({rolesInfo: 1, showBuiltinRoles: false}); // Check if rolesResult is an array or an object with a roles property if (Array.isArray(rolesResult)) { customRoles = rolesResult .map(role => role.role) .filter(Boolean); } else if (rolesResult && rolesResult.roles && Array.isArray(rolesResult.roles)) { customRoles = rolesResult.roles .map(role => role.role) .filter(Boolean); } print('Custom roles found: ' + JSON.stringify(customRoles)); } catch (err) { print('Warning: Could not retrieve custom roles: ' + err.message); customRoles = []; } // parse the list of users, and create each user as needed if (usersStr && usersStr.trim()) { usersStr .trim() .split(';') .map(s => s.split(':')) .forEach(user => { const username = user[0]; const rolesStr = user[1]; const password = user[2]; if (!username || !rolesStr || !password) { print('Skipping invalid user entry: ' + JSON.stringify(user)); return; } const roles = rolesStr.split(','); const userDoc = { user: username, pwd: password, }; userDoc.roles = roles.map(role => { if (customRoles.indexOf(role) === -1) { // is this a built-in role? return role; // yes, just use the role name } return {role: role, db: 'admin'}; // no, user-defined, specify the long format }); try { print('Creating user: ' + username + ' in database: ' + targetDbStr); targetDb.createUser(userDoc); print('Successfully created user: ' + username); } catch (err) { print('Error creating user ' + username + ': ' + err.message); if (err.message.toLowerCase().indexOf('duplicate') === -1) { // if not a duplicate user throw err; // rethrow } else { print('User ' + username + ' already exists, skipping...'); } } }); } else { print('No users to create for database: ' + targetDbStr); } } print("🏁 init.js completed successfully ✅"); --- apiVersion: v1 kind: Secret metadata: name: secret-mongodb labels: abcdesktop/role: mongodb type: Opaque stringData: MONGO_ROOT_USERNAME: 'root' MONGO_ROOT_PASSWORD: 'Oge5iQw9dGBvRDd' MONGO_USERNAME: 'pyos' MONGO_PASSWORD: 'Az4MeYWUjZDg4Zjhk' MONGO_USERS_LIST: 'pyos:readWrite:Az4MeYWUjZDg4Zjhk' MONGO_DBS_LIST: 'image,fail2ban,loginHistory,applications,profiles,desktop' MONGODB_URL: 'mongodb://pyos:Az4MeYWUjZDg4Zjhk@mongodb' --- apiVersion: v1 kind: ConfigMap metadata: name: abcdesktop-passwd-templatefile data: passwd: | {{ uid }}:x:{{ uidNumber }}:{{ gidNumber }}:{{ gecos }}:{{ homeDirectory }}:{{ loginShell }} --- apiVersion: v1 kind: ConfigMap metadata: name: abcdesktop-group-templatefile data: group: | sudo:x:27:{{ uid }} lpadmin:x:101:root,{{ uid }} {{ gid }}:x:{{ gidNumber }}:{{ uid }} --- apiVersion: v1 kind: ConfigMap metadata: name: abcdesktop-shadow-templatefile data: shadow: | {{ uid }}:{{ sha512 }}:19080:0:99999:7::: --- apiVersion: v1 kind: ConfigMap metadata: name: abcdesktop-gshadow-templatefile data: gshadow: | sudo:*::{{ uid }} lpadmin:!::root,{{ uid }} {{ gid }}:!::{{ uid }} --- apiVersion: apps/v1 kind: StatefulSet metadata: name: mongodb-od labels: run: mongodb-od type: database abcdesktop/role: mongodb spec: serviceName: mongodb replicas: 1 # MONGO_REPLICAS selector: matchLabels: run: mongodb-od template: metadata: labels: run: mongodb-od type: database netpol/mongodb: 'true' netpol/dns: 'true' spec: securityContext: fsGroup: 999 terminationGracePeriodSeconds: 10 automountServiceAccountToken: false # --- InitContainer to prepare configuration initContainers: - name: prepare-config image: ghcr.io/abcdesktopio/mongo:safe8.2 imagePullPolicy: Always securityContext: allowPrivilegeEscalation: false runAsNonRoot: true runAsUser: 999 runAsGroup: 999 resources: limits: cpu: 500m memory: 512Mi requests: cpu: 100m memory: 128Mi command: - sh - -c - /scripts/init-container.sh volumeMounts: - name: init-container-script mountPath: /scripts/init-container.sh subPath: init-container.sh readOnly: true - name: config mountPath: /input/mongod.conf subPath: mongod.conf - name: prepared-config mountPath: /work/config - name: logs mountPath: /var/log/mongodb # --- Main MongoDB container containers: - name: mongodb image: ghcr.io/abcdesktopio/mongo:safe8.2 imagePullPolicy: Always securityContext: allowPrivilegeEscalation: false runAsNonRoot: true runAsUser: 999 runAsGroup: 999 # DO NOT use `command`, keep docker-entrypoint.sh args: ["--config=/etc/mongodb/mongod.conf"] ports: - containerPort: 27017 name: mongodb volumeMounts: - name: prepared-config mountPath: /etc/mongodb - name: abcdesktop mountPath: /etc/abcdesktop readOnly: true - name: init-script mountPath: /docker-entrypoint-initdb.d/init.js subPath: init.js readOnly: true - name: logs mountPath: /var/log/mongodb - name: data mountPath: /data/db env: - name: MONGO_INITDB_ROOT_USERNAME_FILE value: /etc/abcdesktop/admin/MONGO_ROOT_USERNAME - name: MONGO_INITDB_ROOT_PASSWORD_FILE value: /etc/abcdesktop/admin/MONGO_ROOT_PASSWORD readinessProbe: tcpSocket: port: 27017 initialDelaySeconds: 10 periodSeconds: 10 failureThreshold: 6 livenessProbe: tcpSocket: port: 27017 initialDelaySeconds: 60 periodSeconds: 20 timeoutSeconds: 10 failureThreshold: 3 successThreshold: 1 resources: limits: cpu: 2 memory: 4Gi requests: cpu: 100m memory: 128Mi # --- Non-persistent volumes volumes: - name: init-container-script configMap: name: configmap-mongodb-scripts items: - key: init-container.sh path: init-container.sh defaultMode: 0755 - name: config configMap: name: configmap-mongodb-scripts items: - key: mongod.conf path: mongod.conf - name: abcdesktop secret: secretName: secret-mongodb items: - key: MONGO_ROOT_USERNAME path: admin/MONGO_ROOT_USERNAME mode: 0400 - key: MONGO_ROOT_PASSWORD path: admin/MONGO_ROOT_PASSWORD mode: 0400 - key: MONGO_USERNAME path: MONGO_USERNAME mode: 0400 - key: MONGO_PASSWORD path: MONGO_PASSWORD mode: 0400 - key: MONGO_USERS_LIST path: MONGO_USERS_LIST mode: 0400 - key: MONGO_DBS_LIST path: MONGO_DBS_LIST mode: 0400 - name: init-script configMap: name: configmap-mongodb-scripts items: - key: init.js path: init.js - name: prepared-config emptyDir: {} - name: logs emptyDir: {} # --- Non-persistent volume for MongoDB data - name: data emptyDir: {} --- apiVersion: apps/v1 kind: Deployment metadata: name: memcached-od labels: abcdesktop/role: memcached spec: selector: matchLabels: run: memcached-od replicas: 1 template: metadata: labels: run: memcached-od type: database spec: automountServiceAccountToken: false securityContext: fsGroup: 11211 containers: - name: memcached # like image: memcached:alpine imagePullPolicy: Always image: ghcr.io/abcdesktopio/oc.memcached:4.5 securityContext: runAsNonRoot: true runAsUser: 11211 runAsGroup: 11211 allowPrivilegeEscalation: false resources: limits: cpu: 0.2 memory: 64Mi requests: cpu: 0.1 memory: 16Mi ports: - containerPort: 11211 --- apiVersion: apps/v1 kind: Deployment metadata: name: router-od labels: abcdesktop/role: router spec: replicas: 1 selector: matchLabels: name: router-od template: metadata: labels: name: router-od run: router-od type: router-od # list netpool to permit router to connect to netpol/speedtest: 'true' netpol/pyos: 'true' netpol/ocuser: 'true' netpol/dns: 'true' netpol/nginx: 'true' netpol/console: 'true' spec: automountServiceAccountToken: false dnsPolicy: ClusterFirst securityContext: fsGroup: 1000 containers: - name: nginx-router imagePullPolicy: Always image: ghcr.io/abcdesktopio/route:4.5 securityContext: runAsNonRoot: true runAsUser: 1000 runAsGroup: 1000 allowPrivilegeEscalation: false ports: - containerPort: 8000 name: http livenessProbe: httpGet: path: /healthz port: 8000 failureThreshold: 1 periodSeconds: 10 startupProbe: httpGet: path: /healthz port: 8000 failureThreshold: 5 periodSeconds: 5 resources: limits: cpu: 0.5 memory: 512Mi requests: cpu: 0.1 memory: 16Mi env: # # overwrite default values for development # you should not change the default values # # - name: SPEEDTEST_FQDN # value: speedtest.abcdesktop.svc.cluster.local # - name: PYOS_FQDN # value: pyos.abcdesktop.svc.cluster.local # - name: CONSOLE_FQDN # value: console.abcdesktop.svc.cluster.local # - name: WEBSITE_FQDN # value: website.abcdesktop.svc.cluster.local - name: JWT_DESKTOP_PAYLOAD_PRIVATE_KEY value: "/config.payload/abcdesktop_jwt_desktop_payload_private_key.pem" - name: JWT_DESKTOP_SIGNING_PUBLIC_KEY value: "/config.signing/abcdesktop_jwt_desktop_signing_public_key.pem" - name: NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeName - name: POD_NAME valueFrom: fieldRef: fieldPath: metadata.name - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - name: POD_IP valueFrom: fieldRef: fieldPath: status.podIP volumeMounts: # keys for JWT signing and payload - name: jwtsigningkeys mountPath: "/config.signing" readOnly: true - name: jwtpayloadkeys mountPath: "/config.payload" readOnly: true # non-persistent volumes for nginx # - name: etc-nginx-scgi-temp # mountPath: /etc/nginx/scgi_temp # readOnly: false #- name: etc-nginx-uwsgi-temp # mountPath: /etc/nginx/uwsgi_temp # readOnly: false #- name: etc-nginx-fastcgi-temp # mountPath: /etc/nginx/fastcgi_temp # readOnly: false #- name: usr-local-openresty-log # mountPath: /usr/local/openresty/nginx/logs # readOnly: false #- name: var-run-openresty # mountPath: /var/run/openresty # readOnly: false #- name: etc-nginx-client-body-temp # mountPath: /etc/nginx/client_body_temp # readOnly: false #- name: etc-nginx-proxy-temp # mountPath: /etc/nginx/proxy_temp # readOnly: false #- name: var-log-nginx # mountPath: /var/log/nginx # readOnly: false #- name: tmp # mountPath: /tmp # readOnly: false volumes: - name: jwtsigningkeys secret: secretName: abcdesktopjwtdesktopsigning - name: jwtpayloadkeys secret: secretName: abcdesktopjwtdesktoppayload #- name: etc-nginx-scgi-temp #emptyDir: {} #- name: etc-nginx-uwsgi-temp #emptyDir: {} #- name: etc-nginx-fastcgi-temp #emptyDir: {} #- name: usr-local-openresty-log #emptyDir: {} #- name: etc-nginx-client-body-temp #emptyDir: {} #- name: var-nginx-log #emptyDir: {} #- name: etc-nginx-proxy-temp #emptyDir: {} #- name: var-log-nginx #emptyDir: {} #- name: tmp #emptyDir: {} --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx-od labels: abcdesktop/role: website spec: replicas: 1 selector: matchLabels: name: nginx-od template: metadata: labels: name: nginx-od run: nginx-od type: frontend spec: automountServiceAccountToken: false securityContext: fsGroup: 101 containers: - name: nginx imagePullPolicy: Always image: ghcr.io/abcdesktopio/oc.nginx:4.5 securityContext: runAsNonRoot: true runAsUser: 101 runAsGroup: 101 allowPrivilegeEscalation: false ports: - containerPort: 8000 name: http livenessProbe: httpGet: path: / port: 8000 failureThreshold: 1 periodSeconds: 10 startupProbe: httpGet: path: / port: 8000 failureThreshold: 5 periodSeconds: 5 resources: limits: cpu: 0.5 memory: 128Mi requests: cpu: 0.1 memory: 8Mi --- apiVersion: apps/v1 kind: Deployment metadata: name: speedtest-od labels: abcdesktop/role: speedtest spec: selector: matchLabels: run: speedtest-od replicas: 1 template: metadata: labels: run: speedtest-od spec: automountServiceAccountToken: false securityContext: fsGroup: 1000 containers: - name: speedtest securityContext: runAsUser: 1000 runAsGroup: 1000 allowPrivilegeEscalation: false runAsNonRoot: true imagePullPolicy: Always resources: limits: cpu: 0.5 memory: 128Mi requests: cpu: 0.1 memory: 32Mi # like image: ghcr.io/librespeed/speedtest:master-alpine image: ghcr.io/abcdesktopio/oc.speedtest:4.5 ports: - containerPort: 8080 --- apiVersion: apps/v1 kind: Deployment metadata: name: pyos-od labels: abcdesktop/role: pyos spec: replicas: 1 selector: matchLabels: name: pyos-od template: metadata: labels: name: pyos-od run: pyos-od netpol/https: 'true' netpol/ldaps: 'true' netpol/auth: 'true' netpol/cifs: 'true' netpol/api: 'true' netpol/dns: 'true' netpol/mongodb: 'true' netpol/memcached: 'true' netpol/graylog: 'true' netpol/router: 'true' netpol/nginx: 'true' spec: serviceAccountName: pyos-serviceaccount dnsPolicy: ClusterFirst securityContext: fsGroup: 2048 containers: - name : pyos imagePullPolicy: Always image: ghcr.io/abcdesktopio/pyos:4.5.alpine_latest securityContext: runAsUser: 2048 runAsGroup: 2048 runAsNonRoot: true allowPrivilegeEscalation: false volumeMounts: - name: jwtsigningkeys mountPath: "/config.signing" readOnly: true - name: jwtusersigningkeys mountPath: "/config.usersigning" readOnly: true - name: jwtpayloadkeys mountPath: "/config.payload" readOnly: true - name: volume-abcdesktop-config mountPath: /var/pyos/od.config subPath: od.config readOnly: true - name: volume-abcdesktop-passwd-templatefile mountPath: /var/pyos/passwd subPath: passwd readOnly: true - name: volume-abcdesktop-group-templatefile mountPath: /var/pyos/group subPath: group readOnly: true - name: volume-abcdesktop-shadow-templatefile mountPath: /var/pyos/shadow subPath: shadow readOnly: true - name: volume-abcdesktop-gshadow-templatefile mountPath: /var/pyos/gshadow subPath: gshadow readOnly: true ports: - containerPort: 8000 livenessProbe: httpGet: path: /API/healthz port: 8000 timeoutSeconds: 5 periodSeconds: 10 failureThreshold: 3 startupProbe: httpGet: path: /API/healthz port: 8000 initialDelaySeconds: 10 timeoutSeconds: 5 periodSeconds: 10 failureThreshold: 30 resources: limits: cpu: 1 memory: 2048Mi requests: cpu: 0.1 memory: 256Mi env: - name: NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeName - name: POD_NAME valueFrom: fieldRef: fieldPath: metadata.name - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - name: POD_IP valueFrom: fieldRef: fieldPath: status.podIP - name: MONGODB_URL valueFrom: secretKeyRef: name: secret-mongodb key: MONGODB_URL - name: OAUTHLIB_RELAX_TOKEN_SCOPE value: "1" volumes: - name: jwtusersigningkeys secret: secretName: abcdesktopjwtusersigning - name: jwtsigningkeys secret: secretName: abcdesktopjwtdesktopsigning - name: jwtpayloadkeys secret: secretName: abcdesktopjwtdesktoppayload - name: volume-abcdesktop-config configMap: name: abcdesktop-config - name: volume-abcdesktop-passwd-templatefile configMap: name: abcdesktop-passwd-templatefile - name: volume-abcdesktop-group-templatefile configMap: name: abcdesktop-group-templatefile - name: volume-abcdesktop-shadow-templatefile configMap: name: abcdesktop-shadow-templatefile - name: volume-abcdesktop-gshadow-templatefile configMap: name: abcdesktop-gshadow-templatefile --- apiVersion: apps/v1 kind: Deployment metadata: name: console-od labels: abcdesktop/role: console spec: selector: matchLabels: run: console-od replicas: 1 template: metadata: labels: run: console-od type: admin-console spec: automountServiceAccountToken: false securityContext: fsGroup: 101 containers: - name: console imagePullPolicy: Always image: ghcr.io/abcdesktopio/console:4.5 securityContext: runAsNonRoot: true runAsUser: 101 runAsGroup: 101 allowPrivilegeEscalation: false ports: - containerPort: 8000 env: - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace resources: limits: cpu: 0.5 memory: 128Mi requests: cpu: 0.1 memory: 16Mi volumeMounts: - name: version-config-volume mountPath: /usr/share/nginx/html/config/versionConfig.json subPath: versionConfig.json readOnly: true volumes: - name: version-config-volume configMap: name: abcdesktop-version-config --- apiVersion: apps/v1 kind: Deployment metadata: name: openldap-od labels: abcdesktop/role: openldap spec: selector: matchLabels: run: openldap-od replicas: 1 template: metadata: labels: run: openldap-od netpol/dns: 'true' spec: automountServiceAccountToken: false securityContext: fsGroup: 101 containers: - name: openldap # abcdesktopio/docker-test-openldap:master # is same as https://github.com/rroemhild/docker-test-openldap # but with user support image: ghcr.io/abcdesktopio/kube-test-openldap:4.5 imagePullPolicy: Always securityContext: runAsNonRoot: true runAsUser: 100 runAsGroup: 101 allowPrivilegeEscalation: false resources: limits: cpu: 0.5 memory: 2048Mi requests: cpu: 0.1 memory: 128Mi ports: - containerPort: 389 - containerPort: 636 --- apiVersion: v1 kind: Service metadata: name: desktop labels: abcdesktop/role: desktop spec: clusterIP: None selector: type: x11server --- kind: Service apiVersion: v1 metadata: name: memcached labels: abcdesktop/role: memcached spec: selector: run: memcached-od ports: - port: 11211 protocol: TCP targetPort: 11211 --- kind: Service apiVersion: v1 metadata: name: mongodb labels: abcdesktop/role: mongodb spec: selector: run: mongodb-od ports: - protocol: TCP port: 27017 targetPort: 27017 --- kind: Service apiVersion: v1 metadata: name: speedtest labels: abcdesktop/role: speedtest spec: selector: run: speedtest-od ports: - protocol: TCP port: 80 targetPort: 8080 --- kind: Service apiVersion: v1 metadata: name: pyos labels: abcdesktop/role: pyos spec: selector: run: pyos-od ports: - port: 8000 protocol: TCP targetPort: 8000 --- kind: Service apiVersion: v1 metadata: name: console labels: abcdesktop/role: console spec: selector: run: console-od ports: - port: 80 protocol: TCP targetPort: 8000 --- kind: Service apiVersion: v1 metadata: name: http-router labels: abcdesktop/role: router spec: selector: run: router-od ports: - protocol: TCP port: 80 targetPort: 8000 name: http --- kind: Service apiVersion: v1 metadata: name: website labels: abcdesktop/role: website spec: selector: run: nginx-od ports: - protocol: TCP port: 80 name: http targetPort: 8000 --- kind: Service apiVersion: v1 metadata: name: openldap labels: abcdesktop/role: openldap spec: selector: run: openldap-od ports: - name: ldap protocol: TCP port: 389 targetPort: 10389 - name: ldaps protocol: TCP port: 636 targetPort: 10636