diff --git a/charts/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml b/charts/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml index d318a7bd451..4acbce836f5 100644 --- a/charts/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml +++ b/charts/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml @@ -40,6 +40,8 @@ tests: imageName: ghcr.io/cloudnative-pg/postgresql:16.3 primaryUpdateStrategy: unsupervised primaryUpdateMethod: switchover + postgresUID: 26 + postgresGID: 26 logLevel: info instances: 2 nodeMaintenanceWindow: diff --git a/charts/library/common-test/tests/cnpg/cluster_spec_test.yaml b/charts/library/common-test/tests/cnpg/cluster_spec_test.yaml index 8c837e251c0..ce0f4dd929b 100644 --- a/charts/library/common-test/tests/cnpg/cluster_spec_test.yaml +++ b/charts/library/common-test/tests/cnpg/cluster_spec_test.yaml @@ -36,6 +36,77 @@ tests: imageName: ghcr.io/cloudnative-pg/postgresql:16.3 primaryUpdateStrategy: unsupervised primaryUpdateMethod: switchover + postgresUID: 26 + postgresGID: 26 + logLevel: info + instances: 2 + nodeMaintenanceWindow: + reusePVC: true + inProgress: false + resources: + limits: + cpu: 4000m + memory: 8Gi + requests: + cpu: 10m + memory: 50Mi + storage: + pvcTemplate: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Gi + walStorage: + pvcTemplate: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Gi + bootstrap: + initdb: + secret: + name: test-release-name-common-test-cnpg-my-pg-user + database: test-db + owner: test-user + dataChecksums: true + - it: should work with custom UID/GID + set: + postgres16Image: + repository: ghcr.io/cloudnative-pg/postgresql + tag: "16.3" + pullPolicy: IfNotPresent + cnpg: + my-pg: + enabled: true + user: test-user + database: test-db + password: test-password + cluster: + postgresUID: 666 + postgresGID: 666 + asserts: + - documentIndex: &clusterDoc 0 + isKind: + of: Cluster + - documentIndex: *clusterDoc + isAPIVersion: + of: postgresql.cnpg.io/v1 + - documentIndex: *clusterDoc + equal: + path: metadata.name + value: test-release-name-common-test-cnpg-my-pg + - documentIndex: *clusterDoc + equal: + path: spec + value: + enableSuperuserAccess: true + imageName: ghcr.io/cloudnative-pg/postgresql:16.3 + postgresUID: 666 + postgresGID: 666 + primaryUpdateStrategy: unsupervised + primaryUpdateMethod: switchover logLevel: info instances: 2 nodeMaintenanceWindow: @@ -69,7 +140,6 @@ tests: database: test-db owner: test-user dataChecksums: true - - it: should respect changed fallbackDefaults set: postgres15Image: @@ -192,6 +262,8 @@ tests: imageName: some-image primaryUpdateStrategy: supervised primaryUpdateMethod: restart + postgresUID: 26 + postgresGID: 26 logLevel: debug instances: 3 initdb: @@ -239,6 +311,8 @@ tests: imageName: some-image primaryUpdateStrategy: supervised primaryUpdateMethod: restart + postgresUID: 26 + postgresGID: 26 logLevel: debug instances: 3 nodeMaintenanceWindow: diff --git a/charts/library/common/templates/class/cnpg/_cluster.tpl b/charts/library/common/templates/class/cnpg/_cluster.tpl index 63d628547b2..a949fff4cdd 100644 --- a/charts/library/common/templates/class/cnpg/_cluster.tpl +++ b/charts/library/common/templates/class/cnpg/_cluster.tpl @@ -177,6 +177,9 @@ metadata: {{- end }} spec: imageName: {{ $imageName }} + {{/* This ignores `0` on purpose. */}} + postgresUID: {{ $objectData.cluster.postgresUID | default 26 }} + postgresGID: {{ $objectData.cluster.postgresGID | default 26 }} enableSuperuserAccess: {{ $enableSuperUser }} primaryUpdateStrategy: {{ $primaryUpdateStrategy }} primaryUpdateMethod: {{ $primaryUpdateMethod }}