From 62b1ea3d59295943ca4330ce5d951a078bfec539 Mon Sep 17 00:00:00 2001 From: tegwick Date: Sun, 9 Aug 2026 01:39:57 +0200 Subject: [PATCH] Deploy tenant authority for user portal --- sso-mfa/k8s/tenant-engine/runtime.yaml | 102 +++++++++++++++++++++++++ sso-mfa/k8s/user-engine/runtime.yaml | 10 ++- 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 sso-mfa/k8s/tenant-engine/runtime.yaml diff --git a/sso-mfa/k8s/tenant-engine/runtime.yaml b/sso-mfa/k8s/tenant-engine/runtime.yaml new file mode 100644 index 0000000..c22c70d --- /dev/null +++ b/sso-mfa/k8s/tenant-engine/runtime.yaml @@ -0,0 +1,102 @@ +apiVersion: v1 +kind: Namespace +metadata: {name: flex-auth, labels: {net-kingdom/component: flex-auth}} +--- +apiVersion: v1 +kind: Namespace +metadata: {name: tenant-engine, labels: {net-kingdom/component: tenant-engine}} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: {name: flex-auth-tenant-engine, namespace: flex-auth} +spec: + replicas: 1 + selector: {matchLabels: {app.kubernetes.io/name: flex-auth-tenant-engine}} + template: + metadata: {labels: {app.kubernetes.io/name: flex-auth-tenant-engine}} + spec: + automountServiceAccountToken: false + securityContext: {runAsNonRoot: true, seccompProfile: {type: RuntimeDefault}} + containers: + - name: flex-auth + image: forgejo.coulomb.social/coulomb/flex-auth@sha256:c25fc34a6cd7e64d955f8723ec70e176a583d5ae71d76280c4e2d89fba0fe0aa + args: ["serve", "--addr", "0.0.0.0:8080", "--registry", "/opt/flex-auth/examples/tenant-engine/registry_snapshot.json", "--policy", "/opt/flex-auth/examples/tenant-engine/policy_package.md"] + ports: [{name: http, containerPort: 8080}] + securityContext: {allowPrivilegeEscalation: false, capabilities: {drop: ["ALL"]}, readOnlyRootFilesystem: true} + resources: {requests: {cpu: 25m, memory: 32Mi}, limits: {cpu: 300m, memory: 192Mi}} + readinessProbe: {httpGet: {path: /healthz, port: http}, periodSeconds: 5} + livenessProbe: {httpGet: {path: /healthz, port: http}, periodSeconds: 20} +--- +apiVersion: v1 +kind: Service +metadata: {name: flex-auth-tenant-engine, namespace: flex-auth} +spec: {selector: {app.kubernetes.io/name: flex-auth-tenant-engine}, ports: [{name: http, port: 8080, targetPort: http}]} +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: {name: tenant-engine-data, namespace: tenant-engine} +spec: {accessModes: [ReadWriteOnce], resources: {requests: {storage: 1Gi}}} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: {name: tenant-engine, namespace: tenant-engine} +spec: + replicas: 1 + strategy: {type: Recreate} + selector: {matchLabels: {app.kubernetes.io/name: tenant-engine}} + template: + metadata: {labels: {app.kubernetes.io/name: tenant-engine}} + spec: + automountServiceAccountToken: false + securityContext: {runAsNonRoot: true, fsGroup: 10001, seccompProfile: {type: RuntimeDefault}} + containers: + - name: tenant-engine + image: forgejo.coulomb.social/coulomb/tenant-engine@sha256:2249e8c6ee44ae36081cddc52daf9c3f63acd18a95a5d620ab4fa7ac85149207 + ports: [{name: http, containerPort: 8090}] + env: + - {name: TENANT_ENGINE_DATABASE_PATH, value: /data/tenant-engine.db} + - {name: TENANT_ENGINE_FLEX_AUTH_URL, value: "http://flex-auth-tenant-engine.flex-auth.svc.cluster.local:8080"} + volumeMounts: [{name: data, mountPath: /data}] + securityContext: {allowPrivilegeEscalation: false, capabilities: {drop: ["ALL"]}, readOnlyRootFilesystem: true} + resources: {requests: {cpu: 25m, memory: 48Mi}, limits: {cpu: 300m, memory: 192Mi}} + readinessProbe: {httpGet: {path: /health, port: http}, periodSeconds: 5} + livenessProbe: {httpGet: {path: /health, port: http}, periodSeconds: 20} + volumes: [{name: data, persistentVolumeClaim: {claimName: tenant-engine-data}}] +--- +apiVersion: v1 +kind: Service +metadata: {name: tenant-engine, namespace: tenant-engine} +spec: {selector: {app.kubernetes.io/name: tenant-engine}, ports: [{name: http, port: 8090, targetPort: http}]} +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: {name: flex-auth-tenant-engine, namespace: flex-auth} +spec: + podSelector: {matchLabels: {app.kubernetes.io/name: flex-auth-tenant-engine}} + policyTypes: [Ingress, Egress] + ingress: + - from: + - namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: tenant-engine}} + podSelector: {matchLabels: {app.kubernetes.io/name: tenant-engine}} + ports: [{protocol: TCP, port: 8080}] + egress: [] +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: {name: tenant-engine, namespace: tenant-engine} +spec: + podSelector: {matchLabels: {app.kubernetes.io/name: tenant-engine}} + policyTypes: [Ingress, Egress] + ingress: + - from: + - namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: user-engine}} + podSelector: {matchLabels: {app.kubernetes.io/name: user-engine}} + ports: [{protocol: TCP, port: 8090}] + egress: + - to: + - namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: flex-auth}} + podSelector: {matchLabels: {app.kubernetes.io/name: flex-auth-tenant-engine}} + ports: [{protocol: TCP, port: 8080}] + - to: + - namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: kube-system}} + ports: [{protocol: UDP, port: 53}, {protocol: TCP, port: 53}] diff --git a/sso-mfa/k8s/user-engine/runtime.yaml b/sso-mfa/k8s/user-engine/runtime.yaml index 9fcc4bd..023b04c 100644 --- a/sso-mfa/k8s/user-engine/runtime.yaml +++ b/sso-mfa/k8s/user-engine/runtime.yaml @@ -45,7 +45,7 @@ spec: seccompProfile: {type: RuntimeDefault} containers: - name: portal - image: forgejo.coulomb.social/coulomb/user-engine@sha256:cef2fdb19fd001a9d2a64742f58dacdcf2ff5868ce50685c91eaad7880645fd0 + image: forgejo.coulomb.social/coulomb/user-engine@sha256:ffca598fab9c035b58a40ae6c2be365497743a7594bc584124ab231383f25d8a imagePullPolicy: IfNotPresent ports: [{name: http, containerPort: 8080}] env: @@ -63,6 +63,8 @@ spec: - {name: USER_ENGINE_OIDC_BACKEND_URL, value: "http://keycape.sso.svc.cluster.local:8080"} - {name: USER_ENGINE_PUBLIC_REGISTRATION, value: "false"} - {name: USER_ENGINE_PROVISIONING_URL, value: "http://identity-provisioner.sso.svc.cluster.local:8080"} + - {name: USER_ENGINE_TENANT_MANAGEMENT_URL, value: "http://tenant-engine.tenant-engine.svc.cluster.local:8090"} + - {name: USER_ENGINE_TENANT_MANAGEMENT_TOKEN, value: "internal-service-boundary"} - name: USER_ENGINE_PROVISIONING_TOKEN valueFrom: secretKeyRef: {name: identity-provisioner-client, key: token} @@ -127,6 +129,12 @@ spec: podSelector: matchLabels: {app.kubernetes.io/name: identity-provisioner} ports: [{protocol: TCP, port: 8080}] + - to: + - namespaceSelector: + matchLabels: {kubernetes.io/metadata.name: tenant-engine} + podSelector: + matchLabels: {app.kubernetes.io/name: tenant-engine} + ports: [{protocol: TCP, port: 8090}] - to: - namespaceSelector: matchLabels: {kubernetes.io/metadata.name: kube-system}