diff --git a/README.md b/README.md index 7f794d2..875c399 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ The example enables Ingress and uses example hostnames. Set your own values for bucket must already exist unless `bucketBootstrap.enabled` is explicitly enabled. PostgreSQL uses a persistent volume claim; set `postgresql.persistence.storageClass` and its size as appropriate for your -cluster. +cluster. Set `postgresql.enabled: false` when supplying an external PostgreSQL +service; configure the application Secret's `database-url` for that service. ## Chart releases diff --git a/chart/asciinema/templates/postgresql.yaml b/chart/asciinema/templates/postgresql.yaml index b5c8671..5dd3abe 100644 --- a/chart/asciinema/templates/postgresql.yaml +++ b/chart/asciinema/templates/postgresql.yaml @@ -1,3 +1,4 @@ +{{- if .Values.postgresql.enabled }} apiVersion: v1 kind: Service metadata: @@ -123,4 +124,5 @@ spec: resources: requests: storage: {{ .Values.postgresql.persistence.size }} +{{- end }} {{- end }} diff --git a/chart/asciinema/values.schema.json b/chart/asciinema/values.schema.json index d53a17f..817bfc8 100644 --- a/chart/asciinema/values.schema.json +++ b/chart/asciinema/values.schema.json @@ -10,7 +10,12 @@ "config": {"type": "object"}, "service": {"type": "object"}, "ingress": {"type": "object"}, - "postgresql": {"type": "object"}, + "postgresql": { + "type": "object", + "properties": { + "enabled": {"type": "boolean"} + } + }, "resources": {"type": "object"}, "cache": {"type": "object"}, "tmp": {"type": "object"}, diff --git a/chart/asciinema/values.yaml b/chart/asciinema/values.yaml index 4d73c1a..7a56185 100644 --- a/chart/asciinema/values.yaml +++ b/chart/asciinema/values.yaml @@ -52,6 +52,7 @@ ingress: host: "" postgresql: + enabled: true name: postgresql image: repository: postgres diff --git a/test.sh b/test.sh index e243cf5..3f52253 100755 --- a/test.sh +++ b/test.sh @@ -13,8 +13,18 @@ grep -Fq 'name: asciinema-secrets' /tmp/asciinema-rendered.yaml grep -Fq 'kind: StatefulSet' /tmp/asciinema-rendered.yaml grep -Fq 'kind: Ingress' /tmp/asciinema-rendered.yaml +helm template asciinema "$chart" --namespace asciinema \ + --values "$project_dir/examples/values.yaml" --set postgresql.enabled=false \ + > /tmp/asciinema-external-postgresql-rendered.yaml +if grep -Eq '^kind: (StatefulSet|PersistentVolumeClaim)$' /tmp/asciinema-external-postgresql-rendered.yaml; then + echo 'PostgreSQL resources must be omitted when postgresql.enabled=false.' >&2 + exit 1 +fi + if command -v kubeconform >/dev/null 2>&1; then kubeconform -strict -summary /tmp/asciinema-rendered.yaml -elif command -v docker >/dev/null 2>&1; then +elif command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then docker run --rm --interactive ghcr.io/yannh/kubeconform:v0.7.0 -strict -summary < /tmp/asciinema-rendered.yaml +else + echo 'Skipping kubeconform; neither kubeconform nor a running Docker daemon is available.' fi