diff --git a/README.md b/README.md index 62781fd..da84b42 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@ helm repo update brunner.ninja helm show values brunner.ninja/mumble ``` -For a separate cluster, create a TLS Secret, a `mumble-secrets` Secret containing `database-password`, `superuser-password`, and `registration-password`, and a PostgreSQL credential Secret if enabling the subchart. Put Secret *names*, database host, domain/registration details, and networking policy in a values file. See `values.example.yaml`. `./install.sh VALUES_FILE` performs a local Helm upgrade/install with `--wait`; `./test.sh` validates the chart. Do not run `install.sh` against the brunner.ninja cluster after Argo CD adoption. +For a separate cluster, create a TLS Secret and a `mumble-secrets` Secret containing `database-password`, `superuser-password`, and `registration-password`. Put Secret *names*, database host, domain/registration details, and networking policy in a values file. See `values.example.yaml`. `./install.sh VALUES_FILE` performs a local Helm upgrade/install with `--wait`; `./test.sh` validates the chart. Do not run `install.sh` against the brunner.ninja cluster after Argo CD adoption. -The PostgreSQL subchart is optional. With `postgresql.enabled=true`, set `postgresql.auth.existingSecret` to a stable Secret with separate PostgreSQL administrator and Mumble database passwords; configure `postgresql.auth.secretKeys` to identify their keys. The same Mumble database password must be available to the application via `mumble-secrets/database-password`. This chart does not render plaintext credentials. Set `postgresql.primary.persistence.*` for durable storage and a retention policy. With the subchart disabled, Mumble's init container bootstraps its role and database on an existing PostgreSQL server using the separate administrator Secret. +The PostgreSQL subchart is optional. With `postgresql.enabled=true`, set `postgresql.auth.existingSecret` to a stable Secret with separate PostgreSQL administrator and Mumble database passwords; configure `postgresql.auth.secretKeys` to identify their keys. The same Mumble database password must be available to the application via `mumble-secrets/database-password`. This chart does not render plaintext credentials. Set `postgresql.primary.persistence.*` for durable storage and a retention policy. With the subchart disabled, the default `database.bootstrap.enabled=true` makes Mumble's init container provision its role and database on an existing PostgreSQL server using the separate administrator Secret. Set `database.bootstrap.enabled=false` when another controller, such as CloudNativePG, owns database/user creation and credentials. -The homelab deployment is selected in [homelab-gitops](https://code.brunner.ninja/feedc0de/homelab-gitops/src/branch/main/apps/mumble). It uses the optional PostgreSQL subchart and keeps the existing `default/mumble` Service and Deployment names, the `mumble-secrets` and TLS Secrets, and TCP/UDP port 64738. The old shared PostgreSQL database is deliberately left intact as rollback data. `bootstrap-homelab-secrets.sh` is a guarded, one-time secret recovery/bootstrap helper; it does not deploy workloads. Back up the dedicated PostgreSQL PVC and both Mumble Secrets together. +The homelab deployment is selected in [homelab-gitops](https://code.brunner.ninja/feedc0de/homelab-gitops/src/branch/main/apps/mumble). The chart supports three PostgreSQL modes: its optional Bitnami subchart, an external server that the chart bootstraps, or an externally managed database with chart-side bootstrap disabled. The homelab uses CloudNativePG in its own `mumble` namespace. `bootstrap-homelab-secrets.sh` is a guarded, one-time secret recovery/bootstrap helper; it does not deploy workloads. Back up the PostgreSQL data and all Mumble Secrets together. `service.additionalServices` optionally creates named additional Services on the same TCP/UDP ports. Each entry creates `mumble-` and accepts Service `spec` fields such as `type` and `externalIPs`. For example, the homelab uses `service.additionalServices.funkfeuer.spec` with `type: ClusterIP` and `externalIPs: [10.12.4.170]`. This reaches a ready Mumble pod from an address routed to a cluster node and leaves the primary LoadBalancer Service and its client-IP policy unchanged. diff --git a/chart/mumble/templates/workload.yaml b/chart/mumble/templates/workload.yaml index 526bd3b..205ff96 100644 --- a/chart/mumble/templates/workload.yaml +++ b/chart/mumble/templates/workload.yaml @@ -135,7 +135,7 @@ spec: limits: cpu: 20m memory: 16Mi -{{- if not .Values.postgresql.enabled }} +{{- if and (not .Values.postgresql.enabled) .Values.database.bootstrap.enabled }} - name: bootstrap-postgresql image: {{ .Values.images.postgresqlClient | quote }} imagePullPolicy: IfNotPresent diff --git a/chart/mumble/values.schema.json b/chart/mumble/values.schema.json index 5ce384e..e6d9747 100644 --- a/chart/mumble/values.schema.json +++ b/chart/mumble/values.schema.json @@ -3,9 +3,8 @@ "type": "object", "properties": { "image": {"type": "object", "properties": {"repository": {"type": "string", "minLength": 1}, "tag": {"type": "string"}}}, - "service": {"type": "object", "properties": {"type": {"enum": ["LoadBalancer", "ClusterIP"]}, "loadBalancerIP": {"type": "string"}, "externalTrafficPolicy": {"enum": ["Local", "Cluster"]}, "annotations": {"type": "object", "additionalProperties": {"type": "string"}}}}, - "service": {"type": "object", "properties": {"additionalServices": {"type": "object", "additionalProperties": {"type": "object", "required": ["spec"], "properties": {"spec": {"type": "object", "properties": {"type": {"enum": ["ClusterIP", "NodePort", "LoadBalancer"]}, "externalIPs": {"type": "array", "items": {"type": "string", "format": "ipv4"}}}}}}}}}, - "database": {"type": "object", "properties": {"host": {"type": "string", "minLength": 1}}}, + "service": {"type": "object", "properties": {"type": {"enum": ["LoadBalancer", "ClusterIP"]}, "loadBalancerIP": {"type": "string"}, "externalTrafficPolicy": {"enum": ["Local", "Cluster"]}, "annotations": {"type": "object", "additionalProperties": {"type": "string"}}, "additionalServices": {"type": "object", "additionalProperties": {"type": "object", "required": ["spec"], "properties": {"spec": {"type": "object", "properties": {"type": {"enum": ["ClusterIP", "NodePort", "LoadBalancer"]}, "externalIPs": {"type": "array", "items": {"type": "string", "format": "ipv4"}}}}}}}}}, + "database": {"type": "object", "properties": {"host": {"type": "string", "minLength": 1}, "bootstrap": {"type": "object", "properties": {"enabled": {"type": "boolean"}}}}}, "secrets": {"type": "object", "properties": {"mumble": {"type": "string", "minLength": 1}, "postgresql": {"type": "string", "minLength": 1}, "tls": {"type": "string", "minLength": 1}}}, "config": {"type": "object", "properties": {"welcomeText": {"type": "string"}, "registrationName": {"type": "string"}, "registrationURL": {"type": "string"}, "registrationHostname": {"type": "string"}, "registrationLocation": {"type": "string"}}}, "resources": {"type": "object"} diff --git a/chart/mumble/values.yaml b/chart/mumble/values.yaml index 1f475da..03a3a28 100644 --- a/chart/mumble/values.yaml +++ b/chart/mumble/values.yaml @@ -14,6 +14,8 @@ service: additionalServices: {} database: host: postgresql + bootstrap: + enabled: true secrets: mumble: mumble-secrets postgresql: postgresql diff --git a/test.sh b/test.sh index 930de46..d93a62a 100755 --- a/test.sh +++ b/test.sh @@ -35,5 +35,12 @@ assert direct_service['spec']['externalIPs'] == ['10.12.4.170'] assert direct_service['spec']['type'] == 'ClusterIP' assert 'externalTrafficPolicy' not in direct_service['spec'] assert {port['protocol'] for port in direct_service['spec']['ports']} == {'TCP', 'UDP'} +external = render('--set', 'postgresql.enabled=false', '--set', 'database.host=postgresql.example.net') +external_pod = next(doc for doc in external if doc['kind'] == 'Deployment')['spec']['template']['spec'] +assert [container['name'] for container in external_pod['initContainers']] == ['render-config', 'bootstrap-postgresql'] +cnpg = render('--set', 'postgresql.enabled=false', '--set', 'database.bootstrap.enabled=false', '--set', 'database.host=mumble-postgresql-rw.mumble.svc.cluster.local') +cnpg_pod = next(doc for doc in cnpg if doc['kind'] == 'Deployment')['spec']['template']['spec'] +assert [container['name'] for container in cnpg_pod['initContainers']] == ['render-config'] +assert cnpg_pod['initContainers'][0]['env'][0]['value'] == 'mumble-postgresql-rw.mumble.svc.cluster.local' print('Mumble chart renders staged PostgreSQL and active Mumble without cleartext credentials.') PY