diff --git a/docs/TENANTS.md b/docs/TENANTS.md index 9b0c26348c..db3c669429 100644 --- a/docs/TENANTS.md +++ b/docs/TENANTS.md @@ -124,9 +124,10 @@ node-level signature reads first; do not add a shared pull credential. Platform-authored resources in a registration dir are reconciled by flux-system (not your tenant SA), which is why they may use the ClusterSecretStore where your own resources may not (the Kyverno policy carves out flux-system-applied -resources). KRO-rendered Tenant children get no such exception. KRO's bind -permission names the constructor's four exact roles, including `tenant-edit`, -rather than the unrelated built-in `edit` role. +resources, and the External Secrets controller's own spec-preserving updates of +them, such as adding its cleanup finalizer). KRO-rendered Tenant children get no +such exception. KRO's bind permission names the constructor's four exact roles, +including `tenant-edit`, rather than the unrelated built-in `edit` role. - The release and template-sync workflows mint a **GitHub App token** from the org-level `APP_CLIENT_ID` variable and `APP_PRIVATE_KEY` secret — already available to diff --git a/k8s/bases/infrastructure/vault-config/job.yaml b/k8s/bases/infrastructure/vault-config/job.yaml index c2f5be2da2..8caf7b95ec 100644 --- a/k8s/bases/infrastructure/vault-config/job.yaml +++ b/k8s/bases/infrastructure/vault-config/job.yaml @@ -1094,16 +1094,29 @@ spec: path "secret/data/apps/umami/*" { capabilities = ["create", "update", "read"] } - # ZITADEL's master key, generated once by its create-only - # PushSecret (vault-seed), and the customer Dex's ZITADEL - # client, which the customer-identity setup CronJob issues and - # a PushSecret copies here. Exact keys only. + # ZITADEL's master key and the portal's Dex client secret, each + # seeded by a create-only PushSecret (vault-seed), and the + # customer Dex's ZITADEL client, which the customer-identity + # setup CronJob issues and a PushSecret copies here. Exact keys + # only. path "secret/data/apps/customer-identity/zitadel" { capabilities = ["create", "update", "read"] } path "secret/data/apps/customer-identity/dex-zitadel-client" { capabilities = ["create", "update", "read"] } + path "secret/data/apps/customer-identity/portal-client" { + capabilities = ["create", "update", "read"] + } + # The portal database's two login passwords (create-only seed) + # and its CA certificate, pushed from the business-site + # namespace for the portal's projected Secret. Exact keys only. + path "secret/data/apps/business-site/portal-db" { + capabilities = ["create", "update", "read"] + } + path "secret/data/apps/business-site/portal-db-ca" { + capabilities = ["create", "update", "read"] + } path "secret/data/apps/actual-budget/*" { capabilities = ["create", "update", "read"] } @@ -1173,6 +1186,15 @@ spec: path "secret/metadata/apps/customer-identity/dex-zitadel-client" { capabilities = ["create", "update", "read"] } + path "secret/metadata/apps/customer-identity/portal-client" { + capabilities = ["create", "update", "read"] + } + path "secret/metadata/apps/business-site/portal-db" { + capabilities = ["create", "update", "read"] + } + path "secret/metadata/apps/business-site/portal-db-ca" { + capabilities = ["create", "update", "read"] + } path "secret/metadata/apps/actual-budget/*" { capabilities = ["create", "update", "read"] } diff --git a/k8s/bases/infrastructure/vault-seed/external-secret-generated-business-site-portal-db-migrator.yaml b/k8s/bases/infrastructure/vault-seed/external-secret-generated-business-site-portal-db-migrator.yaml new file mode 100644 index 0000000000..c59ff23349 --- /dev/null +++ b/k8s/bases/infrastructure/vault-seed/external-secret-generated-business-site-portal-db-migrator.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: generated-business-site-portal-db-migrator + namespace: openbao +spec: + refreshInterval: "0" + target: + name: generated-business-site-portal-db-migrator + creationPolicy: Owner + dataFrom: + - sourceRef: + generatorRef: + apiVersion: generators.external-secrets.io/v1alpha1 + kind: Password + name: business-site-portal-db-migrator diff --git a/k8s/bases/infrastructure/vault-seed/external-secret-generated-business-site-portal-db-web.yaml b/k8s/bases/infrastructure/vault-seed/external-secret-generated-business-site-portal-db-web.yaml new file mode 100644 index 0000000000..762403797e --- /dev/null +++ b/k8s/bases/infrastructure/vault-seed/external-secret-generated-business-site-portal-db-web.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: generated-business-site-portal-db-web + namespace: openbao +spec: + refreshInterval: "0" + target: + name: generated-business-site-portal-db-web + creationPolicy: Owner + dataFrom: + - sourceRef: + generatorRef: + apiVersion: generators.external-secrets.io/v1alpha1 + kind: Password + name: business-site-portal-db-web diff --git a/k8s/bases/infrastructure/vault-seed/external-secret-generated-customer-identity-portal-client.yaml b/k8s/bases/infrastructure/vault-seed/external-secret-generated-customer-identity-portal-client.yaml new file mode 100644 index 0000000000..4b180b0ef5 --- /dev/null +++ b/k8s/bases/infrastructure/vault-seed/external-secret-generated-customer-identity-portal-client.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: generated-customer-identity-portal-client + namespace: openbao +spec: + refreshInterval: "0" + target: + name: generated-customer-identity-portal-client + creationPolicy: Owner + dataFrom: + - sourceRef: + generatorRef: + apiVersion: generators.external-secrets.io/v1alpha1 + kind: Password + name: customer-identity-portal-client diff --git a/k8s/bases/infrastructure/vault-seed/kustomization.yaml b/k8s/bases/infrastructure/vault-seed/kustomization.yaml index 62a08ad36e..4917c6f2aa 100644 --- a/k8s/bases/infrastructure/vault-seed/kustomization.yaml +++ b/k8s/bases/infrastructure/vault-seed/kustomization.yaml @@ -29,6 +29,15 @@ resources: - password-customer-identity-zitadel-masterkey.yaml - external-secret-generated-customer-identity-zitadel-masterkey.yaml - push-secret-push-customer-identity-zitadel-masterkey.yaml + - password-customer-identity-portal-client.yaml + - external-secret-generated-customer-identity-portal-client.yaml + - push-secret-push-customer-identity-portal-client.yaml + - password-business-site-portal-db-migrator.yaml + - password-business-site-portal-db-web.yaml + - external-secret-generated-business-site-portal-db-migrator.yaml + - external-secret-generated-business-site-portal-db-web.yaml + - push-secret-push-business-site-portal-db-migrator.yaml + - push-secret-push-business-site-portal-db-web.yaml - push-secret-seed-r2-credentials.yaml - push-secret-seed-wedding-db-backup-r2.yaml - push-secret-seed-github-app.yaml diff --git a/k8s/bases/infrastructure/vault-seed/password-business-site-portal-db-migrator.yaml b/k8s/bases/infrastructure/vault-seed/password-business-site-portal-db-migrator.yaml new file mode 100644 index 0000000000..40582e42d3 --- /dev/null +++ b/k8s/bases/infrastructure/vault-seed/password-business-site-portal-db-migrator.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: generators.external-secrets.io/v1alpha1 +kind: Password +metadata: + name: business-site-portal-db-migrator + namespace: openbao +spec: + length: 32 + digits: 8 + symbols: 0 + noUpper: false + allowRepeat: true diff --git a/k8s/bases/infrastructure/vault-seed/password-business-site-portal-db-web.yaml b/k8s/bases/infrastructure/vault-seed/password-business-site-portal-db-web.yaml new file mode 100644 index 0000000000..ac77e41c5e --- /dev/null +++ b/k8s/bases/infrastructure/vault-seed/password-business-site-portal-db-web.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: generators.external-secrets.io/v1alpha1 +kind: Password +metadata: + name: business-site-portal-db-web + namespace: openbao +spec: + length: 32 + digits: 8 + symbols: 0 + noUpper: false + allowRepeat: true diff --git a/k8s/bases/infrastructure/vault-seed/password-customer-identity-portal-client.yaml b/k8s/bases/infrastructure/vault-seed/password-customer-identity-portal-client.yaml new file mode 100644 index 0000000000..25b8b1a81e --- /dev/null +++ b/k8s/bases/infrastructure/vault-seed/password-customer-identity-portal-client.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: generators.external-secrets.io/v1alpha1 +kind: Password +metadata: + name: customer-identity-portal-client + namespace: openbao +spec: + length: 48 + digits: 12 + symbols: 0 + noUpper: false + allowRepeat: true diff --git a/k8s/bases/infrastructure/vault-seed/push-secret-push-business-site-portal-db-migrator.yaml b/k8s/bases/infrastructure/vault-seed/push-secret-push-business-site-portal-db-migrator.yaml new file mode 100644 index 0000000000..0534c75340 --- /dev/null +++ b/k8s/bases/infrastructure/vault-seed/push-secret-push-business-site-portal-db-migrator.yaml @@ -0,0 +1,25 @@ +--- +# The portal database's migration and web passwords +# (apps/business-site/external-secret-portal-db-logins.yaml, and the web one +# also in the portal's settings). Create-only, so a rebuilt cluster that +# restores OpenBao keeps the passwords its restored database uses. +apiVersion: external-secrets.io/v1alpha1 +kind: PushSecret +metadata: + name: push-business-site-portal-db-migrator + namespace: openbao +spec: + refreshInterval: 1h + updatePolicy: IfNotExists + secretStoreRefs: + - name: openbao + kind: ClusterSecretStore + selector: + secret: + name: generated-business-site-portal-db-migrator + data: + - match: + secretKey: password + remoteRef: + remoteKey: apps/business-site/portal-db + property: migrator-password diff --git a/k8s/bases/infrastructure/vault-seed/push-secret-push-business-site-portal-db-web.yaml b/k8s/bases/infrastructure/vault-seed/push-secret-push-business-site-portal-db-web.yaml new file mode 100644 index 0000000000..ace11b5bb4 --- /dev/null +++ b/k8s/bases/infrastructure/vault-seed/push-secret-push-business-site-portal-db-web.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: external-secrets.io/v1alpha1 +kind: PushSecret +metadata: + name: push-business-site-portal-db-web + namespace: openbao +spec: + refreshInterval: 1h + updatePolicy: IfNotExists + secretStoreRefs: + - name: openbao + kind: ClusterSecretStore + selector: + secret: + name: generated-business-site-portal-db-web + data: + - match: + secretKey: password + remoteRef: + remoteKey: apps/business-site/portal-db + property: web-password diff --git a/k8s/bases/infrastructure/vault-seed/push-secret-push-customer-identity-portal-client.yaml b/k8s/bases/infrastructure/vault-seed/push-secret-push-customer-identity-portal-client.yaml new file mode 100644 index 0000000000..c304a88610 --- /dev/null +++ b/k8s/bases/infrastructure/vault-seed/push-secret-push-customer-identity-portal-client.yaml @@ -0,0 +1,25 @@ +--- +# The portal's client secret at the customer Dex: read by Dex +# (apps/customer-identity/external-secret-dex-portal-client.yaml) and by the +# business-site portal. Create-only, so both keep the same value across a +# rebuilt cluster that restores OpenBao. +apiVersion: external-secrets.io/v1alpha1 +kind: PushSecret +metadata: + name: push-customer-identity-portal-client + namespace: openbao +spec: + refreshInterval: 1h + updatePolicy: IfNotExists + secretStoreRefs: + - name: openbao + kind: ClusterSecretStore + selector: + secret: + name: generated-customer-identity-portal-client + data: + - match: + secretKey: password + remoteRef: + remoteKey: apps/customer-identity/portal-client + property: client-secret diff --git a/k8s/providers/hetzner/apps/business-site/certificate-portal-db-ca.yaml b/k8s/providers/hetzner/apps/business-site/certificate-portal-db-ca.yaml new file mode 100644 index 0000000000..bfb0d9535a --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/certificate-portal-db-ca.yaml @@ -0,0 +1,27 @@ +# The ten-year CA for business-site-portal-db (cluster-portal-db.yaml); its +# server certificate is certificate-portal-db-server.yaml. The server Secret also +# carries the CA's ca.crt, +# which is what clients trust: the portal (through OpenBao, see +# push-secret-portal-db-ca.yaml) and the migration job. +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: business-site-portal-db-ca + namespace: business-site +spec: + isCA: true + commonName: business-site-portal-db-ca + secretName: business-site-portal-db-ca + duration: 87600h + renewBefore: 8760h + privateKey: + algorithm: ECDSA + size: 256 + rotationPolicy: Never + usages: + - cert sign + - crl sign + issuerRef: + name: business-site-portal-db-selfsigned + kind: Issuer + group: cert-manager.io diff --git a/k8s/providers/hetzner/apps/business-site/certificate-portal-db-replication.yaml b/k8s/providers/hetzner/apps/business-site/certificate-portal-db-replication.yaml new file mode 100644 index 0000000000..0ffcae85d5 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/certificate-portal-db-replication.yaml @@ -0,0 +1,30 @@ +# The streaming_replica client certificate for business-site-portal-db, issued +# under the ten-year CA (certificate-portal-db-ca.yaml). The Cluster uses this +# Secret both as its replication certificate and, through its ca.crt, as its +# client CA (cluster-portal-db.yaml). Without it CNPG generates its own client +# CA in a Secret named business-site-portal-db-ca, which is the ten-year CA's +# own Secret, and refuses to start. +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: business-site-portal-db-replication + namespace: business-site +spec: + secretName: business-site-portal-db-replication + # Instances reload the certificate when cert-manager renews it. + secretTemplate: + labels: + cnpg.io/reload: "" + commonName: streaming_replica + duration: 2160h + renewBefore: 720h + privateKey: + algorithm: ECDSA + size: 256 + rotationPolicy: Always + usages: + - client auth + issuerRef: + name: business-site-portal-db-ca + kind: Issuer + group: cert-manager.io diff --git a/k8s/providers/hetzner/apps/business-site/certificate-portal-db-server.yaml b/k8s/providers/hetzner/apps/business-site/certificate-portal-db-server.yaml new file mode 100644 index 0000000000..bce4953f5c --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/certificate-portal-db-server.yaml @@ -0,0 +1,35 @@ +# The database's server certificate, issued under the ten-year CA +# (certificate-portal-db-ca.yaml). It renews; the CA does not. +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: business-site-portal-db-server + namespace: business-site +spec: + secretName: business-site-portal-db-server + # Instances reload the certificate when cert-manager renews it. + secretTemplate: + labels: + cnpg.io/reload: "" + duration: 2160h + renewBefore: 720h + privateKey: + algorithm: ECDSA + size: 256 + rotationPolicy: Always + usages: + - server auth + dnsNames: + - business-site-portal-db-rw + - business-site-portal-db-rw.business-site + - business-site-portal-db-rw.business-site.svc + - business-site-portal-db-r + - business-site-portal-db-r.business-site + - business-site-portal-db-r.business-site.svc + - business-site-portal-db-ro + - business-site-portal-db-ro.business-site + - business-site-portal-db-ro.business-site.svc + issuerRef: + name: business-site-portal-db-ca + kind: Issuer + group: cert-manager.io diff --git a/k8s/providers/hetzner/apps/business-site/cilium-network-policy-portal-db-coroot.yaml b/k8s/providers/hetzner/apps/business-site/cilium-network-policy-portal-db-coroot.yaml new file mode 100644 index 0000000000..30e35ef463 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/cilium-network-policy-portal-db-coroot.yaml @@ -0,0 +1,24 @@ +# Let Coroot's cluster-agent (observability namespace) reach the +# business-site-portal-db instances on 5432 for its Postgres integration +# (cluster-portal-db.yaml). Additive: it admits only the cluster-agent, and only +# to the database pods. +apiVersion: cilium.io/v2 +kind: CiliumNetworkPolicy +metadata: + name: business-site-portal-db-coroot + namespace: business-site +spec: + endpointSelector: + matchLabels: + cnpg.io/cluster: business-site-portal-db + ingress: + - fromEndpoints: + - matchLabels: + k8s:io.kubernetes.pod.namespace: observability + app.kubernetes.io/managed-by: coroot-operator + app.kubernetes.io/part-of: coroot + app.kubernetes.io/component: coroot-cluster-agent + toPorts: + - ports: + - port: "5432" + protocol: TCP diff --git a/k8s/providers/hetzner/apps/business-site/cilium-network-policy-portal-db.yaml b/k8s/providers/hetzner/apps/business-site/cilium-network-policy-portal-db.yaml new file mode 100644 index 0000000000..5411dd9135 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/cilium-network-policy-portal-db.yaml @@ -0,0 +1,76 @@ +# The portal database's pods. The portal's own path to it and to its customer +# Dex is cilium-network-policy-portal-egress.yaml. Platform-applied and additive +# to the tenant's own policies. +# +# Database pods: the portal's web pods, the migration job, the other instance +# and the CNPG operator may connect; they reach the API server (CNPG instance +# manager), R2 for backups and DNS. Coroot's cluster-agent has its own policy +# (cilium-network-policy-portal-db-coroot.yaml). +apiVersion: cilium.io/v2 +kind: CiliumNetworkPolicy +metadata: + name: business-site-portal-db + namespace: business-site +spec: + endpointSelector: + matchLabels: + cnpg.io/cluster: business-site-portal-db + ingress: + - fromEndpoints: + - matchLabels: + app.kubernetes.io/name: business-site + - matchLabels: + app.kubernetes.io/name: business-site-portal-migration + toPorts: + - ports: + - port: "5432" + protocol: TCP + - fromEndpoints: + - matchLabels: + cnpg.io/cluster: business-site-portal-db + toPorts: + - ports: + - port: "5432" + protocol: TCP + - port: "8000" + protocol: TCP + - fromEndpoints: + - matchLabels: + k8s:io.kubernetes.pod.namespace: cnpg-system + toPorts: + - ports: + - port: "8000" + protocol: TCP + - port: "5432" + protocol: TCP + egress: + - toEndpoints: + - matchLabels: + cnpg.io/cluster: business-site-portal-db + toPorts: + - ports: + - port: "5432" + protocol: TCP + - port: "8000" + protocol: TCP + - toEntities: + - kube-apiserver + - toFQDNs: + - matchPattern: "*.r2.cloudflarestorage.com" + toPorts: + - ports: + - port: "443" + protocol: TCP + - toEndpoints: + - matchLabels: + k8s:io.kubernetes.pod.namespace: kube-system + k8s-app: kube-dns + toPorts: + - ports: + - port: "53" + protocol: UDP + - port: "53" + protocol: TCP + rules: + dns: + - matchPattern: "*" diff --git a/k8s/providers/hetzner/apps/business-site/cilium-network-policy-portal-egress.yaml b/k8s/providers/hetzner/apps/business-site/cilium-network-policy-portal-egress.yaml new file mode 100644 index 0000000000..38c80f5776 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/cilium-network-policy-portal-egress.yaml @@ -0,0 +1,41 @@ +# Platform-applied, additive to the tenant's own policies. The portal's web pods +# and migration job: their database, and for the web +# pods the customer Dex's public name (discovery, token exchange). +apiVersion: cilium.io/v2 +kind: CiliumNetworkPolicy +metadata: + name: business-site-portal-egress + namespace: business-site +spec: + endpointSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: [business-site, business-site-portal-migration] + egress: + - toEndpoints: + - matchLabels: + cnpg.io/cluster: business-site-portal-db + toPorts: + - ports: + - port: "5432" + protocol: TCP + - toFQDNs: + - matchName: login.devantler.tech + toPorts: + - ports: + - port: "443" + protocol: TCP + - toEndpoints: + - matchLabels: + k8s:io.kubernetes.pod.namespace: kube-system + k8s-app: kube-dns + toPorts: + - ports: + - port: "53" + protocol: UDP + - port: "53" + protocol: TCP + rules: + dns: + - matchPattern: "*" diff --git a/k8s/providers/hetzner/apps/business-site/cluster-portal-db.yaml b/k8s/providers/hetzner/apps/business-site/cluster-portal-db.yaml new file mode 100644 index 0000000000..00e4e1d9bd --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/cluster-portal-db.yaml @@ -0,0 +1,102 @@ +# The portal's PostgreSQL store (business-site#302): invitations, memberships, +# sessions and the customer records the portal keeps. Not rebuildable, so it is +# backed up off-cluster to R2 and Flux never prunes it. +# +# Two logins, as server/MIGRATIONS.md requires: `portal_migrator` owns the +# `portal` database and runs the schema migrations; `portal_web` is the web +# runtime, with only the table privileges the migration job grants it. The +# portal refuses to start if the runtime login could change the schema. +# +# Server TLS uses the long-lived CA in certificate-portal-db-ca.yaml instead of +# CNPG's own rotating one, because the portal pins the CA at startup. +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: business-site-portal-db + namespace: business-site + annotations: + kustomize.toolkit.fluxcd.io/prune: disabled +spec: + # renovate: datasource=docker depName=ghcr.io/cloudnative-pg/postgresql + imageName: ghcr.io/cloudnative-pg/postgresql:18.7-system-trixie + instances: 2 + priorityClassName: hcloud-volume-workload + env: + - name: PLATFORM_DATABASE_PRIORITY_CLASS + value: hcloud-volume-workload + # Hetzner Cloud volumes pinned to the baseline workers, like + # customer-identity-db: CNPG already keeps a second copy, and the shared + # Longhorn pool cannot spare three replicas per instance. Temporary: these + # two claims move to Longhorn V2 with the database migration (#5842). + storage: + size: 10Gi + storageClass: hcloud + affinity: + nodeSelector: + platform.devantler.tech/baseline-worker: "true" + # Every certificate comes from the ten-year CA. The client CA and the + # replication certificate are set explicitly: left out, CNPG would generate + # its client CA in business-site-portal-db-ca, the ten-year CA's own Secret. + certificates: + serverTLSSecret: business-site-portal-db-server + serverCASecret: business-site-portal-db-server + clientCASecret: business-site-portal-db-replication + replicationTLSSecret: business-site-portal-db-replication + # Coroot's Postgres integration, as every platform database has. + inheritedMetadata: + annotations: + coroot.com/postgres-scrape: "true" + coroot.com/postgres-scrape-port: "5432" + coroot.com/postgres-scrape-credentials-secret-name: business-site-portal-db-coroot-monitor + coroot.com/postgres-scrape-credentials-secret-username-key: username + coroot.com/postgres-scrape-credentials-secret-password-key: password + coroot.com/postgres-scrape-param-sslmode: require + postgresql: + synchronous: + method: any + number: 1 + dataDurability: preferred + parameters: + pg_stat_statements.max: "10000" + pg_stat_statements.track: all + bootstrap: + initdb: + database: portal + owner: portal_migrator + secret: + name: business-site-portal-db-migrator + postInitApplicationSQL: + - REVOKE CREATE ON SCHEMA public FROM PUBLIC + managed: + roles: + - name: portal_migrator + ensure: present + login: true + passwordSecret: + name: business-site-portal-db-migrator + # The web runtime: no role memberships, no ownership. Its table + # privileges come from the migration job (--runtime-role portal_web). + - name: portal_web + ensure: present + login: true + inherit: false + passwordSecret: + name: business-site-portal-db-web + - name: coroot_monitor + ensure: present + login: true + inRoles: + - pg_monitor + passwordSecret: + name: business-site-portal-db-coroot-monitor + resources: + requests: + cpu: 50m + memory: 256Mi + limits: + memory: 512Mi + plugins: + - name: barman-cloud.cloudnative-pg.io + isWALArchiver: true + parameters: + barmanObjectName: business-site-portal-db diff --git a/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-backup.yaml b/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-backup.yaml new file mode 100644 index 0000000000..4d6fb2db25 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-backup.yaml @@ -0,0 +1,33 @@ +# R2 credentials for business-site-portal-db's Barman Cloud backups, from the +# shared backup key in OpenBao infrastructure/backup/r2. +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: business-site-portal-db-backup-r2 + namespace: business-site +spec: + refreshInterval: 1h + secretStoreRef: + name: openbao + kind: ClusterSecretStore + target: + name: business-site-portal-db-backup-r2 + creationPolicy: Owner + template: + # CNPG reloads the instances when a rotated key lands here. + metadata: + labels: + cnpg.io/reload: "" + data: + ACCESS_KEY_ID: "{{ .ACCESS_KEY_ID }}" + SECRET_ACCESS_KEY: "{{ .SECRET_ACCESS_KEY }}" + REGION: "auto" + data: + - secretKey: ACCESS_KEY_ID + remoteRef: + key: infrastructure/backup/r2 + property: access_key_id + - secretKey: SECRET_ACCESS_KEY + remoteRef: + key: infrastructure/backup/r2 + property: secret_access_key diff --git a/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-coroot-monitor.yaml b/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-coroot-monitor.yaml new file mode 100644 index 0000000000..b9883681b8 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-coroot-monitor.yaml @@ -0,0 +1,26 @@ +--- +# Coroot's read-only monitoring login (pg_monitor only). +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: business-site-portal-db-coroot-monitor + namespace: business-site +spec: + refreshInterval: "0" + target: + name: business-site-portal-db-coroot-monitor + creationPolicy: Owner + template: + type: kubernetes.io/basic-auth + metadata: + labels: + cnpg.io/reload: "true" + data: + username: coroot_monitor + password: "{{ .password }}" + dataFrom: + - sourceRef: + generatorRef: + apiVersion: generators.external-secrets.io/v1alpha1 + kind: Password + name: business-site-portal-db-coroot-monitor diff --git a/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-migrator.yaml b/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-migrator.yaml new file mode 100644 index 0000000000..b61b456741 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-migrator.yaml @@ -0,0 +1,35 @@ +# The portal database's migration login (cluster-portal-db.yaml); the runtime +# login is external-secret-portal-db-web.yaml. Both passwords +# are generated once into OpenBao apps/business-site/portal-db by +# infrastructure/vault-seed (create-only), because the portal's own projected +# Secret (external-secret-runtime.yaml) is assembled from OpenBao and cannot +# read Kubernetes Secrets. CNPG reads the basic-auth pair; the migration job +# reads `database-url`. +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: business-site-portal-db-migrator + namespace: business-site +spec: + refreshInterval: 1h + secretStoreRef: + name: openbao + kind: ClusterSecretStore + target: + name: business-site-portal-db-migrator + creationPolicy: Owner + template: + engineVersion: v2 + type: kubernetes.io/basic-auth + metadata: + labels: + cnpg.io/reload: "true" + data: + username: portal_migrator + password: "{{ .password }}" + database-url: "postgres://portal_migrator:{{ .password }}@business-site-portal-db-rw.business-site.svc:5432/portal?sslmode=verify-full&sslrootcert=/run/portal-migration/ca.crt" + data: + - secretKey: password + remoteRef: + key: apps/business-site/portal-db + property: migrator-password diff --git a/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-web.yaml b/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-web.yaml new file mode 100644 index 0000000000..d1eae5c62e --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/external-secret-portal-db-web.yaml @@ -0,0 +1,30 @@ +# The portal database's runtime login, portal_web (cluster-portal-db.yaml). Its +# password comes from OpenBao apps/business-site/portal-db, like the migration +# login's (external-secret-portal-db-migrator.yaml). +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: business-site-portal-db-web + namespace: business-site +spec: + refreshInterval: 1h + secretStoreRef: + name: openbao + kind: ClusterSecretStore + target: + name: business-site-portal-db-web + creationPolicy: Owner + template: + engineVersion: v2 + type: kubernetes.io/basic-auth + metadata: + labels: + cnpg.io/reload: "true" + data: + username: portal_web + password: "{{ .password }}" + data: + - secretKey: password + remoteRef: + key: apps/business-site/portal-db + property: web-password diff --git a/k8s/providers/hetzner/apps/business-site/external-secret-runtime.yaml b/k8s/providers/hetzner/apps/business-site/external-secret-runtime.yaml new file mode 100644 index 0000000000..211d10cd08 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/external-secret-runtime.yaml @@ -0,0 +1,55 @@ +# The business-site WebApp's one projected Secret, assembled on the platform +# side because the WebApp has no environment variables and projects a single +# Secret (/run/webapp-inputs). It carries the public company disclosure and, +# for the portal, its settings file, its Dex client secret and its database +# CA. The package selects it in its WebApp; until then nothing reads it. +# +# portal-settings is the portal's on/off switch. While sign-in is off it holds +# no settings, so the public site never depends on the portal database or the +# customer Dex. Switching on is a reviewed change to this template that adds +# the settings and the production activation profile (business-site#302). +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: business-site-runtime + namespace: business-site +spec: + refreshInterval: 1h + target: + name: business-site-runtime + creationPolicy: Owner + template: + engineVersion: v2 + data: + company-disclosure: "{{ .company_disclosure }}" + portal-settings: | + # Portal sign-in is off (business-site#302). + portal-client-secret: "{{ .portal_client_secret }}" + portal-database-ca: "{{ .portal_database_ca }}" + data: + # The tenant's own owner-maintained disclosure, read through its own + # namespaced store exactly as the package's disclosure ExternalSecret does. + - secretKey: company_disclosure + sourceRef: + storeRef: + name: openbao + kind: SecretStore + remoteRef: + key: apps/business-site/public-disclosure + property: company-disclosure + - secretKey: portal_client_secret + sourceRef: + storeRef: + name: openbao + kind: ClusterSecretStore + remoteRef: + key: apps/customer-identity/portal-client + property: client-secret + - secretKey: portal_database_ca + sourceRef: + storeRef: + name: openbao + kind: ClusterSecretStore + remoteRef: + key: apps/business-site/portal-db-ca + property: ca diff --git a/k8s/providers/hetzner/apps/business-site/issuer-portal-db-ca.yaml b/k8s/providers/hetzner/apps/business-site/issuer-portal-db-ca.yaml new file mode 100644 index 0000000000..ddf8eebc6b --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/issuer-portal-db-ca.yaml @@ -0,0 +1,10 @@ +# Issues the portal database's server certificate (certificate-portal-db-server.yaml) +# from the ten-year CA. +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: business-site-portal-db-ca + namespace: business-site +spec: + ca: + secretName: business-site-portal-db-ca diff --git a/k8s/providers/hetzner/apps/business-site/issuer-portal-db-selfsigned.yaml b/k8s/providers/hetzner/apps/business-site/issuer-portal-db-selfsigned.yaml new file mode 100644 index 0000000000..046f4771cf --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/issuer-portal-db-selfsigned.yaml @@ -0,0 +1,11 @@ +# Signs the portal database's own long-lived CA (certificate-portal-db-ca.yaml). The +# portal reads the database CA once at startup and the WebApp cannot be +# restarted by Reloader, so the CA must not rotate the way CNPG's built-in +# 90-day CA does. Only the server certificate renews, under the same CA. +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: business-site-portal-db-selfsigned + namespace: business-site +spec: + selfSigned: {} diff --git a/k8s/providers/hetzner/apps/business-site/kustomization.yaml b/k8s/providers/hetzner/apps/business-site/kustomization.yaml index cbba52fd77..7221106f62 100644 --- a/k8s/providers/hetzner/apps/business-site/kustomization.yaml +++ b/k8s/providers/hetzner/apps/business-site/kustomization.yaml @@ -6,3 +6,25 @@ resources: - cilium-network-policy-dns-visibility.yaml - certificate.yaml - reference-grant.yaml + # The portal's database (business-site#302), platform-applied: CA and server + # certificate, logins, the cluster, its backups, its CA in OpenBao and its + # network boundary. + - issuer-portal-db-selfsigned.yaml + - issuer-portal-db-ca.yaml + - certificate-portal-db-ca.yaml + - certificate-portal-db-server.yaml + - certificate-portal-db-replication.yaml + - external-secret-portal-db-migrator.yaml + - external-secret-portal-db-web.yaml + - password-portal-db-coroot-monitor.yaml + - external-secret-portal-db-coroot-monitor.yaml + - external-secret-portal-db-backup.yaml + - object-store-portal-db.yaml + - scheduled-backup-portal-db.yaml + - cluster-portal-db.yaml + - push-secret-portal-db-ca.yaml + - cilium-network-policy-portal-db.yaml + - cilium-network-policy-portal-db-coroot.yaml + - cilium-network-policy-portal-egress.yaml + # The WebApp's one projected Secret: disclosure and the portal's inputs. + - external-secret-runtime.yaml diff --git a/k8s/providers/hetzner/apps/business-site/object-store-portal-db.yaml b/k8s/providers/hetzner/apps/business-site/object-store-portal-db.yaml new file mode 100644 index 0000000000..62efc943da --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/object-store-portal-db.yaml @@ -0,0 +1,27 @@ +# Off-cluster backups for business-site-portal-db: WAL archiving plus the +# daily base backup (scheduled-backup-portal-db.yaml), 30 days of point-in-time +# recovery. +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: business-site-portal-db + namespace: business-site +spec: + retentionPolicy: 30d + configuration: + destinationPath: s3://${r2_bucket}/cnpg/business-site-portal-db + endpointURL: ${r2_endpoint} + s3Credentials: + accessKeyId: + name: business-site-portal-db-backup-r2 + key: ACCESS_KEY_ID + secretAccessKey: + name: business-site-portal-db-backup-r2 + key: SECRET_ACCESS_KEY + region: + name: business-site-portal-db-backup-r2 + key: REGION + wal: + compression: gzip + data: + compression: gzip diff --git a/k8s/providers/hetzner/apps/business-site/password-portal-db-coroot-monitor.yaml b/k8s/providers/hetzner/apps/business-site/password-portal-db-coroot-monitor.yaml new file mode 100644 index 0000000000..348e665d3b --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/password-portal-db-coroot-monitor.yaml @@ -0,0 +1,14 @@ +# Generates the password of Coroot's read-only monitoring login +# (external-secret-portal-db-coroot-monitor.yaml). +--- +apiVersion: generators.external-secrets.io/v1alpha1 +kind: Password +metadata: + name: business-site-portal-db-coroot-monitor + namespace: business-site +spec: + length: 32 + digits: 8 + symbols: 0 + noUpper: false + allowRepeat: true diff --git a/k8s/providers/hetzner/apps/business-site/push-secret-portal-db-ca.yaml b/k8s/providers/hetzner/apps/business-site/push-secret-portal-db-ca.yaml new file mode 100644 index 0000000000..8493a691c2 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/push-secret-portal-db-ca.yaml @@ -0,0 +1,22 @@ +# Publishes the portal database's CA certificate (public trust material, not a +# secret) to OpenBao apps/business-site/portal-db-ca, where the portal's +# projected Secret reads it (external-secret-runtime.yaml). +apiVersion: external-secrets.io/v1alpha1 +kind: PushSecret +metadata: + name: business-site-portal-db-ca + namespace: business-site +spec: + refreshInterval: 1h + secretStoreRefs: + - name: openbao + kind: ClusterSecretStore + selector: + secret: + name: business-site-portal-db-server + data: + - match: + secretKey: ca.crt + remoteRef: + remoteKey: apps/business-site/portal-db-ca + property: ca diff --git a/k8s/providers/hetzner/apps/business-site/scheduled-backup-portal-db.yaml b/k8s/providers/hetzner/apps/business-site/scheduled-backup-portal-db.yaml new file mode 100644 index 0000000000..df91915d77 --- /dev/null +++ b/k8s/providers/hetzner/apps/business-site/scheduled-backup-portal-db.yaml @@ -0,0 +1,17 @@ +# The daily base backup of business-site-portal-db to its R2 object store +# (object-store-portal-db.yaml). +apiVersion: postgresql.cnpg.io/v1 +kind: ScheduledBackup +metadata: + name: business-site-portal-db-daily + namespace: business-site +spec: + # 6-field CNPG cron: 03:45 UTC daily. + schedule: "0 45 3 * * *" + immediate: true + backupOwnerReference: self + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io + cluster: + name: business-site-portal-db diff --git a/k8s/providers/hetzner/apps/customer-identity/cilium-network-policy.yaml b/k8s/providers/hetzner/apps/customer-identity/cilium-network-policy.yaml index 6c97224538..e565d8b8a4 100644 --- a/k8s/providers/hetzner/apps/customer-identity/cilium-network-policy.yaml +++ b/k8s/providers/hetzner/apps/customer-identity/cilium-network-policy.yaml @@ -1,7 +1,8 @@ -# ZITADEL and its database. Only the Gateway reaches ZITADEL (8080); only -# ZITADEL, the other instance and the CNPG operator reach the database. -# Egress: the namespace itself, the API server (CNPG instance manager), R2 -# for backups, and the business site's SES SMTP endpoint for ZITADEL's +# ZITADEL, the customer Dex and their database. Only the Gateway reaches +# ZITADEL (8080) and Dex (5556); only the namespace itself and the CNPG +# operator reach the database. Egress: the namespace itself, the API server +# (CNPG instance manager), R2 for backups, ZITADEL's public name for Dex's +# connector, and the business site's SES SMTP endpoint for ZITADEL's # invitation and recovery mail (platform#5400). apiVersion: cilium.io/v2 kind: CiliumNetworkPolicy @@ -17,6 +18,8 @@ spec: - ports: - port: "8080" protocol: TCP + - port: "5556" + protocol: TCP - fromEndpoints: - matchLabels: k8s:io.kubernetes.pod.namespace: customer-identity @@ -41,6 +44,12 @@ spec: - ports: - port: "443" protocol: TCP + - toFQDNs: + - matchName: accounts.devantler.tech + toPorts: + - ports: + - port: "443" + protocol: TCP - toFQDNs: - matchName: email-smtp.eu-central-1.amazonaws.com toPorts: diff --git a/k8s/providers/hetzner/apps/customer-identity/cluster.yaml b/k8s/providers/hetzner/apps/customer-identity/cluster.yaml index 184391e907..68f14e3fd7 100644 --- a/k8s/providers/hetzner/apps/customer-identity/cluster.yaml +++ b/k8s/providers/hetzner/apps/customer-identity/cluster.yaml @@ -83,6 +83,13 @@ spec: login: true passwordSecret: name: customer-identity-db-zitadel + # The customer Dex's login, owner of the customer_dex database only + # (database-dex.yaml). + - name: customer_dex + ensure: present + login: true + passwordSecret: + name: customer-identity-db-dex # Coroot's read-only monitoring login: pg_monitor only, no access to # ZITADEL's data. - name: coroot_monitor diff --git a/k8s/providers/hetzner/apps/customer-identity/database-dex.yaml b/k8s/providers/hetzner/apps/customer-identity/database-dex.yaml new file mode 100644 index 0000000000..285bd6bb23 --- /dev/null +++ b/k8s/providers/hetzner/apps/customer-identity/database-dex.yaml @@ -0,0 +1,17 @@ +# The customer Dex's own database in customer-identity-db: its signing keys, +# authorization requests and codes. Separate from ZITADEL's database and owned +# by its own login. Kept if this manifest is removed. +apiVersion: postgresql.cnpg.io/v1 +kind: Database +metadata: + name: customer-identity-db-customer-dex + namespace: customer-identity + annotations: + kustomize.toolkit.fluxcd.io/prune: disabled +spec: + name: customer_dex + owner: customer_dex + ensure: present + databaseReclaimPolicy: retain + cluster: + name: customer-identity-db diff --git a/k8s/providers/hetzner/apps/customer-identity/external-secret-db-dex.yaml b/k8s/providers/hetzner/apps/customer-identity/external-secret-db-dex.yaml new file mode 100644 index 0000000000..d269e3f1fa --- /dev/null +++ b/k8s/providers/hetzner/apps/customer-identity/external-secret-db-dex.yaml @@ -0,0 +1,28 @@ +# The customer Dex's database login, owner of `customer_dex` only +# (database-dex.yaml). Generated once in-cluster; CNPG sets the role's password +# from it (cluster.yaml) and Dex reads it (helm-release-dex.yaml). +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: customer-identity-db-dex + namespace: customer-identity +spec: + refreshInterval: "0" + target: + name: customer-identity-db-dex + creationPolicy: Owner + template: + engineVersion: v2 + type: kubernetes.io/basic-auth + metadata: + labels: + cnpg.io/reload: "true" + data: + username: customer_dex + password: "{{ .password }}" + dataFrom: + - sourceRef: + generatorRef: + apiVersion: generators.external-secrets.io/v1alpha1 + kind: Password + name: customer-identity-db-dex diff --git a/k8s/providers/hetzner/apps/customer-identity/external-secret-dex-portal-client.yaml b/k8s/providers/hetzner/apps/customer-identity/external-secret-dex-portal-client.yaml new file mode 100644 index 0000000000..db2c44b22e --- /dev/null +++ b/k8s/providers/hetzner/apps/customer-identity/external-secret-dex-portal-client.yaml @@ -0,0 +1,21 @@ +# The portal's client secret at the customer Dex (static client +# `business-portal`). Generated once into OpenBao by infrastructure/vault-seed; +# the business-site portal reads the same entry. +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: customer-dex-portal-client + namespace: customer-identity +spec: + refreshInterval: 1h + secretStoreRef: + name: openbao + kind: ClusterSecretStore + target: + name: customer-dex-portal-client + creationPolicy: Owner + data: + - secretKey: client-secret + remoteRef: + key: apps/customer-identity/portal-client + property: client-secret diff --git a/k8s/providers/hetzner/apps/customer-identity/helm-release-dex.yaml b/k8s/providers/hetzner/apps/customer-identity/helm-release-dex.yaml new file mode 100644 index 0000000000..8ebcc43d79 --- /dev/null +++ b/k8s/providers/hetzner/apps/customer-identity/helm-release-dex.yaml @@ -0,0 +1,183 @@ +# The business-site portal's own customer Dex (ADR 0021): the portal's one +# OIDC issuer, https://login.devantler.tech, with ZITADEL as its only +# connector. Separate from the platform's infrastructure Dex (namespace `dex`): +# its own issuer, clients, secrets and store. It reuses that Dex's signed, +# source-built image (platform#5811), so admission verifies its signature. +# +# The configuration follows the business-site preparer's `dexConfig` +# (`go run ./cmd/customer-identity-config --prepare`), with three platform +# changes: TLS ends at the Gateway, so Dex serves plain HTTP inside the +# cluster; the approval screen is skipped, because the portal is our own +# first-party client; and values come from environment variables. +# +# The subject Dex issues the portal encodes the ZITADEL user ID and the +# connector ID `customer-zitadel`. Keep the issuer and connector ID: changing +# either changes every customer's portal identity. +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: customer-dex + namespace: customer-identity + labels: + helm.toolkit.fluxcd.io/remediation: enabled +spec: + interval: 10m + timeout: 10m + chart: + spec: + chart: dex + version: 0.26.0 + sourceRef: + kind: HelmRepository + name: dex + values: + replicaCount: 2 + image: + repository: ghcr.io/devantler-tech/platform-dex + tag: "v2.46.1-security.1-cd65a4e40d53beafd8a8eec9b5a32a71986de2d5@sha256:cffb54b332b8d957ca4c8611814ee1685837370ce5fa7069dacdbc39c0c2afc7" + pullPolicy: IfNotPresent + # PostgreSQL storage: Dex needs no Kubernetes API access. + rbac: + create: false + createClusterScoped: false + # Dex reads its client credentials at startup. + deploymentAnnotations: + reloader.stakater.com/auto: "true" + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 0 + maxSurge: 1 + podDisruptionBudget: + enabled: true + maxUnavailable: 1 + podSecurityContext: + runAsNonRoot: true + runAsUser: 65534 + runAsGroup: 65534 + fsGroup: 65534 + seccompProfile: + type: RuntimeDefault + securityContext: + runAsNonRoot: true + runAsUser: 65534 + runAsGroup: 65534 + readOnlyRootFilesystem: true + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + seccompProfile: + type: RuntimeDefault + resources: + requests: + cpu: 10m + memory: 32Mi + limits: + cpu: 500m + memory: 128Mi + volumes: + - name: tmp + emptyDir: {} + # Only the CA certificate, not the CNPG CA's private key. + - name: db-ca + secret: + secretName: customer-identity-db-ca + defaultMode: 0440 + items: + - key: ca.crt + path: ca.crt + volumeMounts: + - name: tmp + mountPath: /tmp + - name: db-ca + mountPath: /db-ca + readOnly: true + envVars: + # Refuse to start with a broken connector instead of serving without it. + - name: DEX_CONTINUE_ON_CONNECTOR_FAILURE + value: "false" + - name: CUSTOMER_DEX_DB_PASSWORD + valueFrom: + secretKeyRef: + name: customer-identity-db-dex + key: password + - name: CUSTOMER_ZITADEL_CLIENT_ID + valueFrom: + secretKeyRef: + name: customer-dex-zitadel-client + key: client-id + - name: CUSTOMER_ZITADEL_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: customer-dex-zitadel-client + key: client-secret + - name: CUSTOMER_PORTAL_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: customer-dex-portal-client + key: client-secret + config: + issuer: https://login.devantler.tech + frontend: + issuer: Devantler Tech + storage: + type: postgres + config: + host: customer-identity-db-rw.customer-identity.svc + port: 5432 + database: customer_dex + user: customer_dex + password: $CUSTOMER_DEX_DB_PASSWORD + ssl: + mode: verify-full + caFile: /db-ca/ca.crt + web: + http: 0.0.0.0:5556 + logger: + level: warn + format: json + excludeFields: + - email + - username + - preferred_username + - groups + expiry: + authRequests: 5m + idTokens: 5m + signingKeys: 6h + oauth2: + grantTypes: + - authorization_code + responseTypes: + - code + skipApprovalScreen: true + pkce: + enforce: true + codeChallengeMethodsSupported: + - S256 + enablePasswordDB: false + connectors: + - type: oidc + id: customer-zitadel + name: Devantler Tech account + config: + issuer: https://accounts.devantler.tech + clientID: $CUSTOMER_ZITADEL_CLIENT_ID + clientSecret: $CUSTOMER_ZITADEL_CLIENT_SECRET + redirectURI: https://login.devantler.tech/callback + scopes: + - profile + - email + getUserInfo: true + insecureSkipEmailVerified: false + insecureEnableGroups: false + insecureSkipVerify: false + pkceChallenge: S256 + staticClients: + - id: business-portal + name: Devantler Tech portal + secretEnv: CUSTOMER_PORTAL_CLIENT_SECRET + # The portal is served at the root of its own host. + redirectURIs: + - https://portal.devantler.tech/callback diff --git a/k8s/providers/hetzner/apps/customer-identity/helm-release.yaml b/k8s/providers/hetzner/apps/customer-identity/helm-release.yaml index 103f037790..f0fc0a6b94 100644 --- a/k8s/providers/hetzner/apps/customer-identity/helm-release.yaml +++ b/k8s/providers/hetzner/apps/customer-identity/helm-release.yaml @@ -234,7 +234,7 @@ spec: AllowExternalIDP: false AllowRegister: false AllowUsernamePassword: true - DefaultRedirectURI: https://portal.devantler.tech/portal + DefaultRedirectURI: https://portal.devantler.tech/ DisableLoginWithPhone: true ExternalLoginCheckLifetime: 15m ForceMFA: true diff --git a/k8s/providers/hetzner/apps/customer-identity/helm-repository-dex.yaml b/k8s/providers/hetzner/apps/customer-identity/helm-repository-dex.yaml new file mode 100644 index 0000000000..8501a57ee2 --- /dev/null +++ b/k8s/providers/hetzner/apps/customer-identity/helm-repository-dex.yaml @@ -0,0 +1,9 @@ +apiVersion: source.toolkit.fluxcd.io/v1 +kind: HelmRepository +metadata: + name: dex + namespace: customer-identity +spec: + # Dex's official chart repository, as the infrastructure Dex uses. + url: https://charts.dexidp.io + interval: 60m diff --git a/k8s/providers/hetzner/apps/customer-identity/http-route-dex.yaml b/k8s/providers/hetzner/apps/customer-identity/http-route-dex.yaml new file mode 100644 index 0000000000..094053f4f9 --- /dev/null +++ b/k8s/providers/hetzner/apps/customer-identity/http-route-dex.yaml @@ -0,0 +1,27 @@ +# login.devantler.tech: the portal's customer Dex (helm-release-dex.yaml). The +# portal's issuer, so it stays fixed. Customers pass through it on the way to +# ZITADEL and back. The listener is in +# infrastructure/patches/add-devantler-tech-listeners.yaml; certificate.yaml +# already covers the name. +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: customer-dex + namespace: customer-identity +spec: + parentRefs: + - name: platform + namespace: kube-system + sectionName: https-login-devantler-tech + hostnames: + - login.devantler.tech + rules: + - filters: + - type: ResponseHeaderModifier + responseHeaderModifier: + set: + - name: Strict-Transport-Security + value: max-age=63072000; includeSubDomains; preload + backendRefs: + - name: customer-dex + port: 5556 diff --git a/k8s/providers/hetzner/apps/customer-identity/kustomization.yaml b/k8s/providers/hetzner/apps/customer-identity/kustomization.yaml index 9e9a3dac58..9e5b549d61 100644 --- a/k8s/providers/hetzner/apps/customer-identity/kustomization.yaml +++ b/k8s/providers/hetzner/apps/customer-identity/kustomization.yaml @@ -1,5 +1,6 @@ # Customer sign-in for the business-site portal (business-site#302): ZITADEL -# with its own CNPG database. Production-only, like the business-site tenant +# and the portal's customer Dex, with one CNPG cluster holding a database +# for each. Production-only, like the business-site tenant # it serves. The portal stays switched off until #302's checks pass. apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization @@ -21,6 +22,14 @@ resources: - external-secret-first-admin.yaml - helm-repository.yaml - helm-release.yaml + # The portal's customer Dex. + - password-db-dex.yaml + - external-secret-db-dex.yaml + - database-dex.yaml + - external-secret-dex-portal-client.yaml + - helm-repository-dex.yaml + - helm-release-dex.yaml + - http-route-dex.yaml - cilium-network-policy.yaml - certificate.yaml - reference-grant.yaml diff --git a/k8s/providers/hetzner/apps/customer-identity/password-db-dex.yaml b/k8s/providers/hetzner/apps/customer-identity/password-db-dex.yaml new file mode 100644 index 0000000000..caa68582a9 --- /dev/null +++ b/k8s/providers/hetzner/apps/customer-identity/password-db-dex.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: generators.external-secrets.io/v1alpha1 +kind: Password +metadata: + name: customer-identity-db-dex + namespace: customer-identity +spec: + length: 32 + digits: 8 + symbols: 0 + noUpper: false + allowRepeat: true diff --git a/k8s/providers/hetzner/infrastructure/patches/add-devantler-tech-listeners.yaml b/k8s/providers/hetzner/infrastructure/patches/add-devantler-tech-listeners.yaml index e3f470cf01..f142a7c8af 100644 --- a/k8s/providers/hetzner/infrastructure/patches/add-devantler-tech-listeners.yaml +++ b/k8s/providers/hetzner/infrastructure/patches/add-devantler-tech-listeners.yaml @@ -104,3 +104,25 @@ kinds: - group: gateway.networking.k8s.io kind: HTTPRoute +# The portal's customer Dex (apps/customer-identity/http-route-dex.yaml), on the +# same customer-identity certificate. +- op: add + path: /spec/listeners/- + value: + name: https-login-devantler-tech + hostname: login.devantler.tech + port: 443 + protocol: HTTPS + tls: + mode: Terminate + certificateRefs: + - kind: Secret + group: "" + namespace: customer-identity + name: customer-identity-tls + allowedRoutes: + namespaces: + from: All + kinds: + - group: gateway.networking.k8s.io + kind: HTTPRoute diff --git a/scripts/validate-eks-ci-role-policy/approved-surface.txt b/scripts/validate-eks-ci-role-policy/approved-surface.txt index 0f047ecabe..8c1ce95952 100644 --- a/scripts/validate-eks-ci-role-policy/approved-surface.txt +++ b/scripts/validate-eks-ci-role-policy/approved-surface.txt @@ -60,7 +60,9 @@ helm.toolkit.fluxcd.io/v2|HelmRelease|cnpg-system|plugin-barman-cloud 74682cb45a helm.toolkit.fluxcd.io/v2|HelmRelease|crossplane-system|crossplane fb717f7c9adb21b0f772e6a84554900e568a2675c91d375d1bb6ee76c2a0b1f3 -helm.toolkit.fluxcd.io/v2|HelmRelease|customer-identity|zitadel f6fb7a8b2d084beb33aeb0a08b1b82eeeac495cbbe498b65154a57c8c353a905 +helm.toolkit.fluxcd.io/v2|HelmRelease|customer-identity|customer-dex 1733d0b05966c1c28a4c6a1c1caa221208958b04d36bdd6d2e1672ce0587c795 + +helm.toolkit.fluxcd.io/v2|HelmRelease|customer-identity|zitadel eeb9881018664637cdefc9c5c0afd6953aa958e5dbfbc9cd8c5d521501e52431 helm.toolkit.fluxcd.io/v2|HelmRelease|dex|dex e2cbe6e6b5ace19ebded8d0e75f508277dd450c079ed51062d13649e148904b9 @@ -434,6 +436,8 @@ source.toolkit.fluxcd.io/v1|HelmRepository|cnpg-system|cloudnative-pg 2ca8952aaa source.toolkit.fluxcd.io/v1|HelmRepository|crossplane-system|crossplane f47ce87b7611344b0d38ff450e6f789a60711bd657a2ff063253c5fcbd30e754 +source.toolkit.fluxcd.io/v1|HelmRepository|customer-identity|dex 4c7411e28d76b21561f4902a60751464114ab3f8bde47b8cae3b57a3fea121f0 + source.toolkit.fluxcd.io/v1|HelmRepository|customer-identity|zitadel f156b723dae5eac81d6b84453a416739de755378d12a665970576b0ce199b219 source.toolkit.fluxcd.io/v1|HelmRepository|dex|dex d251b34144fb4d376b47526e24b3520a1cc696159aa72f1a8c06fa67aadbda7f