feat(common): allow for CNPG UID/GID (#31499)

**Description**


⚒️ Fixes  #27350

**⚙️ Type of change**

- [x] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [ ] ⚖️ My code follows the style guidelines of this project
- [ ] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [ ] ⬆️ I increased versions for any altered app according to semantic
versioning
- [ ] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):` or `chore(chart-name):`

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._

---------

Co-authored-by: Stavros Kois <s.kois@outlook.com>
This commit is contained in:
Kjeld Schouten
2025-02-01 21:25:13 +00:00
committed by GitHub
co-authored by Stavros Kois
parent bf71ab8fc5
commit 8a7f540e51
3 changed files with 80 additions and 1 deletions
@@ -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:
@@ -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:
@@ -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 }}