From 0ffa0ba5d15b321947d9e2c4eedebfc990853c2a Mon Sep 17 00:00:00 2001 From: Shard Date: Sun, 6 Sep 2026 03:43:31 -0400 Subject: [PATCH] Deploy Aeternalis through Argo CD with verified PostgreSQL and SRS TLS --- .gitea/workflows/build.yaml | 7 +++- deploy/SRS.md | 38 ++++++++++++++++++++ deploy/argocd-application.yaml | 22 ++++++++++++ deploy/chart/templates/database-service.yaml | 21 +++++++++++ deploy/chart/templates/network-policy.yaml | 3 ++ deploy/chart/templates/worlds.yaml | 15 ++++++++ deploy/chart/values.yaml | 8 +++++ deploy/values-srs.yaml | 32 +++++++++++++++++ 8 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 deploy/SRS.md create mode 100644 deploy/argocd-application.yaml create mode 100644 deploy/chart/templates/database-service.yaml create mode 100644 deploy/values-srs.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index e25d07b..31b0e61 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -2,6 +2,7 @@ name: Verify, publish, and promote on: push: branches: [master, main] + paths-ignore: [deploy/values-srs.yaml] pull_request: jobs: @@ -36,7 +37,11 @@ jobs: - run: npx playwright install --with-deps chromium - run: npm run test:e2e - uses: azure/setup-helm@v4.3.0 - - run: helm lint deploy/chart && helm template aeternalis deploy/chart > /tmp/aeternalis.yaml + - run: | + helm lint deploy/chart + helm template aeternalis deploy/chart > /tmp/aeternalis.yaml + helm lint deploy/chart -f deploy/values-srs.yaml + helm template aeternalis deploy/chart -f deploy/values-srs.yaml > /tmp/aeternalis-srs.yaml publish: if: gitea.event_name == 'push' diff --git a/deploy/SRS.md b/deploy/SRS.md new file mode 100644 index 0000000..96346e8 --- /dev/null +++ b/deploy/SRS.md @@ -0,0 +1,38 @@ +# SRS deployment + +Argo CD application: `argocd/aeternalis`, namespace `aeternalis`. +Endpoint: `https://srs.aeternalisgames.com` (NGINX HTTPS/443). +The chart uses `letsencrypt-godaddy`, matching SOR, and the `srs-tls` +certificate secret. One initial world is configured at the requested hostname. + +Production configuration is `deploy/values-srs.yaml`. CI publishes a SHA-tagged +image to `registry.aeternalisgames.com/aeternalis/aeternalis`, then promotes its +immutable digest into that values file. Values-only promotion commits do not +start another build. Argo CD uses the chart and values from this repository. +Do not sync the bootstrap image; wait for successful publication and promotion. + +External prerequisites (not stored in Git): + +- `aeternalis-runtime`: DATABASE_URL, OIDC_ISSUER, OIDC_CLIENT_ID, + OIDC_CLIENT_SECRET. PostgreSQL uses database `aeternalis`, dedicated login + `aeternalis_app`, and `sslmode=verify-full`. +- `postgres-ca` ConfigMap: `ca.crt`, mounted at `/etc/postgres-ca/ca.crt`. + It trusts the database certificate, whose DNS identity is `pg-forge-01`. + A selectorless Service and EndpointSlice resolve that name to the existing + PostgreSQL host. Review/update this trust bundle when its certificate rotates. +- `harbor-pull`: registry credential for pulling this project's images. +- Argo CD repository access: a Kubernetes repository Secret, not CI kubeconfig. + +OIDC uses the existing `aeternalis` realm and dedicated confidential client +`aeternalis-web`, authorization-code flow with PKCE S256, and exact callback +`https://srs.aeternalisgames.com/auth/callback`. Existing realm users and policy +are preserved. No user passwords or admin credentials are added to the app. + +NetworkPolicy permits DNS, PostgreSQL at `172.10.1.127:5432`, and the internal +NGINX address `172.10.1.160:443` used by the identity provider. Update the explicit +allowlists if infrastructure addresses change; do not disable production TLS. + +Validate with Helm lint/template for both defaults and SRS values, Kubernetes +server-side dry-run, CI tests, registry digest readback, Argo CD Synced/Healthy, +HTTPS `/readyz`, certificate hostname/chain validation, and OIDC redirect checks. +A complete interactive login/playtest still requires a real realm user. diff --git a/deploy/argocd-application.yaml b/deploy/argocd-application.yaml new file mode 100644 index 0000000..0b8e9bf --- /dev/null +++ b/deploy/argocd-application.yaml @@ -0,0 +1,22 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: aeternalis + namespace: argocd +spec: + project: default + source: + repoURL: https://git.aeternalisgames.com/Stone/aeternalis.git + targetRevision: master + path: deploy/chart + helm: + releaseName: aeternalis + valueFiles: [../values-srs.yaml] + destination: + server: https://kubernetes.default.svc + namespace: aeternalis + syncPolicy: + automated: + prune: false + selfHeal: true + syncOptions: [CreateNamespace=true, ServerSideApply=true] diff --git a/deploy/chart/templates/database-service.yaml b/deploy/chart/templates/database-service.yaml new file mode 100644 index 0000000..95e34a4 --- /dev/null +++ b/deploy/chart/templates/database-service.yaml @@ -0,0 +1,21 @@ +{{- if .Values.externalDatabase.address }} +# Preserve the certificate's DNS identity while routing to the external database. +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.externalDatabase.name | quote }} +spec: + ports: [{ name: postgres, port: 5432, targetPort: 5432 }] +--- +apiVersion: discovery.k8s.io/v1 +kind: EndpointSlice +metadata: + name: {{ .Values.externalDatabase.name | quote }} + labels: + kubernetes.io/service-name: {{ .Values.externalDatabase.name | quote }} +addressType: IPv4 +ports: [{ name: postgres, protocol: TCP, port: 5432 }] +endpoints: + - addresses: [{{ .Values.externalDatabase.address | quote }}] + conditions: { ready: true } +{{- end }} diff --git a/deploy/chart/templates/network-policy.yaml b/deploy/chart/templates/network-policy.yaml index e9cb0be..05489fe 100644 --- a/deploy/chart/templates/network-policy.yaml +++ b/deploy/chart/templates/network-policy.yaml @@ -11,6 +11,9 @@ spec: - from: - namespaceSelector: matchLabels: { kubernetes.io/metadata.name: {{ .Values.networkPolicy.ingressNamespace | quote }} } + {{- range .Values.networkPolicy.ingressCIDRs }} + - ipBlock: { cidr: {{ . | quote }} } + {{- end }} ports: [{ protocol: TCP, port: 8080 }] egress: - to: diff --git a/deploy/chart/templates/worlds.yaml b/deploy/chart/templates/worlds.yaml index 69f8b05..e76d98f 100644 --- a/deploy/chart/templates/worlds.yaml +++ b/deploy/chart/templates/worlds.yaml @@ -23,6 +23,12 @@ spec: automountServiceAccountToken: false terminationGracePeriodSeconds: 30 imagePullSecrets: {{ $root.Values.imagePullSecrets | toJson }} + {{- if $root.Values.databaseCA.configMap }} + volumes: + - name: postgres-ca + configMap: + name: {{ $root.Values.databaseCA.configMap | quote }} + {{- end }} securityContext: runAsNonRoot: true runAsUser: 65532 @@ -32,6 +38,12 @@ spec: - name: world image: {{ if $root.Values.image.digest }}{{ printf "%s@%s" $root.Values.image.repository $root.Values.image.digest | quote }}{{ else }}{{ printf "%s:%s" $root.Values.image.repository $root.Values.image.tag | quote }}{{ end }} imagePullPolicy: IfNotPresent + {{- if $root.Values.databaseCA.configMap }} + volumeMounts: + - name: postgres-ca + mountPath: /etc/postgres-ca + readOnly: true + {{- end }} ports: [{ name: http, containerPort: 8080 }] securityContext: readOnlyRootFilesystem: true @@ -64,6 +76,9 @@ kind: Ingress metadata: name: {{ $root.Release.Name }}-{{ .id }} annotations: + {{- if $root.Values.ingress.clusterIssuer }} + cert-manager.io/cluster-issuer: {{ $root.Values.ingress.clusterIssuer | quote }} + {{- end }} nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" nginx.ingress.kubernetes.io/proxy-body-size: "8k" diff --git a/deploy/chart/values.yaml b/deploy/chart/values.yaml index adefe07..5267658 100644 --- a/deploy/chart/values.yaml +++ b/deploy/chart/values.yaml @@ -5,9 +5,15 @@ image: imagePullSecrets: - name: harbor-pull existingSecret: aeternalis-runtime +databaseCA: + configMap: "" +externalDatabase: + name: pg-forge-01 + address: "" ingress: className: nginx tlsSecret: aeternalis-tls + clusterIssuer: "" worlds: - id: world-001 seed: "734291" @@ -30,6 +36,8 @@ resources: networkPolicy: enabled: true ingressNamespace: ingress-nginx + # Node addresses for ingress controllers using host networking. + ingressCIDRs: [] # Explicitly set actual database and OIDC provider IP ranges before deployment. databaseCIDRs: [] identityCIDRs: [] diff --git a/deploy/values-srs.yaml b/deploy/values-srs.yaml new file mode 100644 index 0000000..84b9916 --- /dev/null +++ b/deploy/values-srs.yaml @@ -0,0 +1,32 @@ +# Runtime credentials and PostgreSQL CA are provisioned outside Git. +image: + repository: registry.aeternalisgames.com/aeternalis/aeternalis + tag: bootstrap + digest: "" +imagePullSecrets: + - name: harbor-pull +existingSecret: aeternalis-runtime +databaseCA: + configMap: postgres-ca +externalDatabase: + name: pg-forge-01 + address: 172.10.1.127 +ingress: + className: nginx + clusterIssuer: letsencrypt-godaddy + tlsSecret: srs-tls +worlds: + - id: world-001 + seed: "734291" + host: srs.aeternalisgames.com +networkPolicy: + enabled: true + ingressNamespace: kube-system + ingressCIDRs: + - 172.10.1.135/32 + - 172.10.1.146/32 + - 172.10.1.160/32 + - 172.10.1.196/32 + databaseCIDRs: [172.10.1.127/32] + identityCIDRs: [172.10.1.160/32] + dnsNamespace: kube-system