diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 49a90db..af071ac 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -16,7 +16,9 @@ spec: {{- if .Values.statefulSet.enabled }} serviceName: {{ include "pgdog.fullname" . }}-headless {{- end }} + {{- if not .Values.externallyManagedReplicas }} replicas: {{ .Values.replicas }} + {{- end }} selector: matchLabels: {{- include "pgdog.selectorLabels" . | nindent 6 }} diff --git a/test/test.sh b/test/test.sh index 3439762..f32d2fd 100755 --- a/test/test.sh +++ b/test/test.sh @@ -175,6 +175,14 @@ expect_fail() { fi } +workload() { + helm template test-release "$CHART_DIR" --show-only templates/deployment.yaml "$@" +} +for stateful in true false; do + expect "replicas stay configurable" "$(workload --set statefulSet.enabled="$stateful" --set replicas=0 | yq '.spec.replicas')" "0" + expect "external controller owns replicas" "$(workload --set statefulSet.enabled="$stateful" --set externallyManagedReplicas=true | yq '.spec | has("replicas")')" "false" +done + expect "extension points render as set" "$(pod_spec "$TEST_DIR/values-pod-extensions.yaml")" \ '{"automount":false,"shareProcessNamespace":true,"containers":["pgdog","reloader"],"lifecycle":{"preStop":{"exec":{"command":["/bin/sh","-c","sleep 30"]}}}}' expect "defaults render none of them" "$(pod_spec "$TEST_DIR/values-default.yaml")" \ diff --git a/values.yaml b/values.yaml index 81f836a..87681ec 100644 --- a/values.yaml +++ b/values.yaml @@ -93,6 +93,9 @@ port: 6432 # replicas indicates how many instances of PgDog will run (HA). replicas: 2 +# Omit spec.replicas when an external controller (e.g. an HPA) owns the count. +externallyManagedReplicas: false + # priorityClassName assigns a PriorityClass to pgdog pods for scheduling priority. # Not set by default; omitted from the pod spec unless explicitly specified. # Example: priorityClassName: production-critical