diff --git a/.github/actions/setup-kuttl/action.yml b/.github/actions/setup-kuttl/action.yml new file mode 100644 index 000000000..1948c7871 --- /dev/null +++ b/.github/actions/setup-kuttl/action.yml @@ -0,0 +1,35 @@ +name: Setup KUTTL +description: Installs Krew and KUTTL +outputs: + kubectl-krew-path: + description: The path to the kubectl-krew binary + value: ${{ steps.krew.outputs.path }} + kubectl-kuttl-path: + description: The path to the kubectl-kuttl binary + value: ${{ steps.kuttl.outputs.path }} +runs: + using: composite + steps: + - id: krew + name: Install Krew + shell: bash + run: | + set -x; cd "$(mktemp -d)" + OS="$(uname | tr '[:upper:]' '[:lower:]')" + ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" + KREW="krew-${OS}_${ARCH}" + curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" + tar zxvf "${KREW}.tar.gz" + ./"${KREW}" install krew + echo "${KREW_ROOT:-$HOME/.krew}/bin/" >> $GITHUB_PATH + echo "path=${KREW_ROOT:-$HOME/.krew}/bin/kubectl-krew" >> "$GITHUB_OUTPUT" + + - id: kuttl + name: Install KUTTL + shell: bash + env: + KREW_PATH: ${{steps.krew.outputs.path}} + run: | + export PATH="$(dirname $KREW_PATH):$PATH" + kubectl krew install kuttl + echo "path=$(which kubectl-kuttl)" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/tests-cluster-standalone.yml b/.github/workflows/tests-cluster-standalone.yml index d162c84e3..37aed2635 100644 --- a/.github/workflows/tests-cluster-standalone.yml +++ b/.github/workflows/tests-cluster-standalone.yml @@ -4,6 +4,12 @@ on: pull_request: branches-ignore: - 'gh-pages' + paths: + - .github/ + - charts/cluster/ + - tests/cluster/ + - tests/minio.yaml + - kuttl-test.yaml jobs: test-cluster-standalone: @@ -20,20 +26,12 @@ jobs: - name: Deploy the operator uses: ./.github/actions/deploy-operator - - name: Deploy a standalone cluster - run: | - helm upgrade --install \ - --values charts/cluster/examples/basic.yaml \ - --namespace database \ - --create-namespace \ - --wait \ - database ./charts/cluster + - name: Install KUTTL + uses: ./.github/actions/setup-kuttl - - name: Verify that the cluster is ready - uses: ./.github/actions/verify-cluster-ready - with: - cluster-name: database-cluster - ready-instances: 1 + - name: Run KUTTL tests + run: | + kubectl kuttl test test-cluster-pgbouncer: runs-on: ubuntu-22.04 diff --git a/.github/workflows/tests-operator.yml b/.github/workflows/tests-operator.yml index 3177e32f5..8f345cd96 100644 --- a/.github/workflows/tests-operator.yml +++ b/.github/workflows/tests-operator.yml @@ -4,6 +4,9 @@ on: pull_request: branches-ignore: - 'gh-pages' + paths: + - .github/ + - charts/cloudnative-pg/ jobs: deploy_operator: diff --git a/README.md b/README.md index 67eccbd93..517cb6639 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,11 @@ helm upgrade --install database \ Refer to the [Cluster Chart documentation](charts/cluster/README.md) for advanced configuration options. +## Provenance + +The charts support Helm Provenance and Integrity. +Here is a link to the [PGP key](provenance.gpg) used by GitHub Actions to sign the charts. + ## Contributing Please read the [code of conduct](CODE-OF-CONDUCT.md) and the diff --git a/RELEASE.md b/RELEASE.md index d328344e0..7abb58685 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -86,10 +86,8 @@ In order to create a new release of the `cloudnative-pg` chart, follow these ste 10. Wait for all the checks to pass 11. Two approvals are required in order to merge the PR, if you are a maintainer approve the PR yourself and ask for another approval, otherwise ask for two approvals directly. -12. Merge the PR squashing all commits and **taking care to keep the commit message to be - `Release cloudnative-pg-vX.Y.Z`** -13. A release `cloudnative-pg-vX.Y.Z` should be automatically created by an action, which will then trigger the release - action. Verify they both are successful. +12. Merge the PR squashing all commits and **taking care to keep the commit message to be `Release cloudnative-pg-vX.Y.Z`** +13. A release `cloudnative-pg-vX.Y.Z` should be automatically created. 14. Once done you should be able to run: ```bash helm repo add cnpg https://cloudnative-pg.github.io/charts @@ -137,9 +135,8 @@ In order to create a new release of the `cluster` chart, follow these steps: 10. Two approvals are required in order to merge the PR, if you are a maintainer approve the PR yourself and ask for another approval, otherwise ask for two approvals directly. -11. Merge the PR squashing all commits and **taking care to keep the commit - message to be `Release cluster-vX.Y.Z`** -12. A release `cluster-vX.Y.Z` should be automatically created by an action, which will ten trigger the release action. +11. Merge the PR squashing all commits and **taking care to keep the commit message to be `Release cluster-vX.Y.Z`** +12. A release `cluster-vX.Y.Z` should be automatically created. Verify they both are successful. 13. Once done you should be able to run: ```bash diff --git a/charts/cluster/README.md b/charts/cluster/README.md index fb2fdb814..e7d6566e4 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -150,6 +150,8 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat | cluster.annotations | object | `{}` | | | cluster.certificates | string | `nil` | The configuration for the CA and related certificates. See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-CertificatesConfiguration | | cluster.enableSuperuserAccess | bool | `true` | When this option is enabled, the operator will use the SuperuserSecret to update the postgres user password. If the secret is not present, the operator will automatically create one. When this option is disabled, the operator will ignore the SuperuserSecret content, delete it when automatically created, and then blank the password of the postgres user by setting it to NULL. | +| cluster.env | list | `[]` | Env follows the Env format to pass environment variables to the pods created in the cluster | +| cluster.envFrom | list | `[]` | EnvFrom follows the EnvFrom format to pass environment variables sources to the pods to be used by Env | | cluster.imageName | string | `""` | Name of the container image, supporting both tags (:) and digests for deterministic and repeatable deployments: :@sha256: | | cluster.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy. One of Always, Never or IfNotPresent. If not defined, it defaults to IfNotPresent. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images | | cluster.imagePullSecrets | list | `[]` | The list of pull secrets to be used to pull the images. See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-LocalObjectReference | diff --git a/charts/cluster/README.md.gotmpl b/charts/cluster/README.md.gotmpl index 956e1431e..fb07f77ef 100644 --- a/charts/cluster/README.md.gotmpl +++ b/charts/cluster/README.md.gotmpl @@ -141,7 +141,6 @@ Alternatively a ticket and a PR if you have found that something needs a change TODO ---- * IAM Role for S3 Service Account -* Automatic provisioning of a Alert Manager configuration - +* Replica Cluster {{ template "helm-docs.versionFooter" . }} diff --git a/charts/cluster/templates/_barman_object_store.tpl b/charts/cluster/templates/_barman_object_store.tpl index f002800e5..40bca8cf3 100644 --- a/charts/cluster/templates/_barman_object_store.tpl +++ b/charts/cluster/templates/_barman_object_store.tpl @@ -1,7 +1,7 @@ {{- define "cluster.barmanObjectStoreConfig" -}} -{{- if .scope.endpointURL }} - endpointURL: {{ .scope.endpointURL }} +{{- with .scope.endpointURL }} + endpointURL: {{ . }} {{- end }} {{- if or (.scope.endpointCA.create) (.scope.endpointCA.name) }} @@ -14,6 +14,10 @@ destinationPath: {{ .scope.destinationPath }} {{- end }} +{{- with .scope.destinationPath }} + destinationPath: {{ . }} +{{- end }} + {{- if eq .scope.provider "s3" }} {{- if empty .scope.endpointURL }} endpointURL: "https://s3.{{ required "You need to specify S3 region if endpointURL is not specified." .scope.s3.region }}.amazonaws.com" diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index 9634dc8f0..13c2a692c 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -64,5 +64,12 @@ spec: - name: {{ include "cluster.fullname" . }}-monitoring key: custom-queries {{- end }} + + env: + {{- toYaml .Values.cluster.env | nindent 4 }} + + envFrom: + {{- toYaml .Values.cluster.envFrom | nindent 4 }} + {{ include "cluster.bootstrap" . | nindent 2 }} {{ include "cluster.backup" . | nindent 2 }} diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index 0c7c1bbe0..fde24354a 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -173,6 +173,12 @@ "enableSuperuserAccess": { "type": "boolean" }, + "env": { + "type": "array" + }, + "envFrom": { + "type": "array" + }, "imageName": { "type": "string" }, diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index bff9d2202..b8bc7a464 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -171,7 +171,7 @@ cluster: # -- Configuration of the PostgreSQL server. # See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-PostgresConfiguration postgresql: {} - # max_connections: 300 + # max_connections: "300" # -- BootstrapInitDB is the configuration of the bootstrap process when initdb is used. # See: https://cloudnative-pg.io/documentation/current/bootstrap/ @@ -186,6 +186,11 @@ cluster: additionalLabels: {} annotations: {} + # -- Env follows the Env format to pass environment variables to the pods created in the cluster + env: [] + + # -- EnvFrom follows the EnvFrom format to pass environment variables sources to the pods to be used by Env + envFrom: [] backups: # -- You need to configure backups manually, so backups are disabled by default. @@ -194,7 +199,9 @@ backups: # -- Overrides the provider specific default endpoint. Defaults to: # S3: https://s3..amazonaws.com" endpointURL: "" # Leave empty if using the default S3 endpoint - # -- Specifies a CA bundle to validate a privately signed certificate. + + # -- Specify a secret containing the CA bundle of the barman endpoint. Useful when using self-signed certificates to + # avoid errors with certificate issuer and barman-cloud-wal-archive endpointCA: # -- Creates a secret with the given value if true, otherwise uses an existing secret. create: false diff --git a/kubeconfig b/kubeconfig new file mode 100644 index 000000000..616c34d93 --- /dev/null +++ b/kubeconfig @@ -0,0 +1,17 @@ +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJME1ESXhOREl3TURJMU1Gb1hEVE0wTURJeE1USXdNREkxTUZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTVRYClJuQWlqO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W4ydlNldEJLUmVlN1lMWXdBUE1HUHhaMW50WVNXM1p4dm9SYWFmTVZhRWlPKzhNWWMKa0RnPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + server: https://127.0.0.1:44771 + name: cluster +contexts: +- context: + cluster: cluster + user: user + name: cluster +current-context: cluster +preferences: {} +users: +- name: user + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJWU94aHVNQW5FU0F3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRBeU1UUXlNREF5TlRCYUZ3MHlOVEF5TVRNeU1EQXlOVEJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQW9oV0xUUTJ1MUgrTDVnbGMKOFAwU0lLWWJRUUVvSDJXU3lQaVNMeUdUekY0VXNsMzh2RVRRVk1NaUswdnZTWkVBUkV6bGdpL3pSaHlPVklZNgp3Lzh3bjFtRStpa1NDVEdqaDBVSU94c0czODJJNk9aa0RZb1hSQmxKQ3ZTWHBFY2E2RjJLcVZuOVYyYzduYzFOCnRPRURqVzRoRXR4N2NyWHZiUkE3V2tPK2t4RHhQNTFvMHQxdUpTUHpCOTE0Y3NkYlp1OVloaEhsWkJqOGpNQ2kKbGZGdkxlV0x6bHZyN0NaT242eEV3VmlvV1NsMWtEZjlqVDhxNVFlcFNkekZTeTJpLzNvTjgwZ0M4QnJDM2VOYgoreWtSWTVJd253eEV1VXp6YVlLUkNaa3I5akhhVmZMQkQzcEZHYWhRVk1Ea1BoUkcwVjJBSUkraDRrNTF4UmhICmFnWWtod0lEQVFBQm8xWXdWREFPQmdOVkhROEJBZjhFQ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R1QjgzQksvdmZCbFg4cUFQWVdrWFBZUUhEOHZOdmtHY0NnWUFFV2VLWDQzUXNiTHhCUE1uaDdkekYKQVJRVHY1UlVLSUR0UWRGK2NEWmd6b1g3Y2FmLzlGbFA3aURtNFZtNVE3MXd0UHZsSVkyUzBSZjFWVSthOURBRAp4MEpZM2xjWU1OTzdCUFIwN1k2aEtKbU5IeUtNS0Nrc21sc2ZOUWduVzhxWnZVV1dTdTN1d0ZkRUxPVzNNQXhwCmUyRTEwTE5seDlYMWNNQVdwNVh6QVFLQmdRQzFRODBFbWRSZ2NTMVRrYm1vTWpVdUFCcnNxam1OTCtZWmlWNmYKK0VGWWpsZEZZODZzVDJrRkFxT2pNeXFIQ1hQR2YxVERRK0pDMUZjbXh4RTd6NmVIeWIrMnRpdkd1WGYwbmNKYwo0VDRNenVOWGRHUWRxVTZVWlp1Tmw0a2ZVeTY1WVJ2K3p3RG1lWHFxSUxLeUtMUlVqV2V3eEZnMDhYY0J6S0c1Ck1hWlM5d0tCZ0ZCWWthU3pHdW5HaXMyWXFPTmtpRUF1ZU1nWVUreEhkUVJMZkZnWkJ6NzVPR2tVbkU0Tk9MQk0KTmNNRTJEaHNZa20yZnVTaE5NR1lEZEx6VXJJK1QwbXVWVkVTWGY1em5CUWllRHU4UEZCNGR5OTRpZGZ1ZE0vdwpad2NrektINDUyU3NmWk5YSVZyMDd0em84OUVPWjIzQzRzMDV4Y3hJc2l0WEVVeGRTemxlCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg== diff --git a/kuttl-test.yaml b/kuttl-test.yaml new file mode 100644 index 000000000..29689751a --- /dev/null +++ b/kuttl-test.yaml @@ -0,0 +1,29 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestSuite +commands: + - command: + helm upgrade + --install + --namespace cnpg-system + --create-namespace + --wait + cnpg ./charts/cloudnative-pg + - command: + helm repo add minio-operator https://operator.min.io + - command: + helm upgrade + --install + --namespace minio-system + --create-namespace + --wait + operator minio-operator/operator + - command: + helm upgrade + --install + --namespace minio + --create-namespace + --wait + --values ./tests/minio.yaml + tenant minio-operator/tenant +testDirs: + - ./tests diff --git a/tests/cluster/00-assert.yaml b/tests/cluster/00-assert.yaml new file mode 100644 index 000000000..b6bfd8f4f --- /dev/null +++ b/tests/cluster/00-assert.yaml @@ -0,0 +1,10 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 120 +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: standalone-cluster +status: + readyInstances: 2 diff --git a/tests/cluster/00-cluster.yaml b/tests/cluster/00-cluster.yaml new file mode 100644 index 000000000..e35be41ad --- /dev/null +++ b/tests/cluster/00-cluster.yaml @@ -0,0 +1,11 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: kubectl -n $NAMESPACE create secret generic kube-root-ca.crt --from-literal=ca.crt="$(kubectl -n kube-system get configmaps kube-root-ca.crt -o jsonpath='{.data.ca\.crt}')" --dry-run=client -o yaml | kubectl apply -f - + - namespaced: true + command: + helm upgrade + --install + --values ./standalone.yaml + --wait + standalone ../../charts/cluster diff --git a/tests/cluster/01-assert.yaml b/tests/cluster/01-assert.yaml new file mode 100644 index 000000000..d93fd5a3c --- /dev/null +++ b/tests/cluster/01-assert.yaml @@ -0,0 +1,14 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 60 +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + cluster: + name: standalone-cluster + method: barmanObjectStore +status: + phase: running diff --git a/tests/cluster/01-backup.yaml b/tests/cluster/01-backup.yaml new file mode 100644 index 000000000..c3afd4676 --- /dev/null +++ b/tests/cluster/01-backup.yaml @@ -0,0 +1,8 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + method: barmanObjectStore + cluster: + name: standalone-cluster diff --git a/tests/cluster/02-assert.yaml b/tests/cluster/02-assert.yaml new file mode 100644 index 000000000..8563f1d47 --- /dev/null +++ b/tests/cluster/02-assert.yaml @@ -0,0 +1,14 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 180 +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + cluster: + name: standalone-cluster + method: barmanObjectStore +status: + phase: completed diff --git a/tests/cluster/02-backup-checkpoint.yaml b/tests/cluster/02-backup-checkpoint.yaml new file mode 100644 index 000000000..e5c5c665e --- /dev/null +++ b/tests/cluster/02-backup-checkpoint.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: backup-checkpoint +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: create-checkpoint + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: standalone-cluster-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + END_TIME=$(( $(date +%s) + 60 )) + while [ $(date +%s) -lt $END_TIME ]; do + psql "$DB_URI" -c "SELECT pg_switch_wal();CHECKPOINT;" + sleep 10 + done diff --git a/tests/cluster/standalone.yaml b/tests/cluster/standalone.yaml new file mode 100644 index 000000000..65764ae25 --- /dev/null +++ b/tests/cluster/standalone.yaml @@ -0,0 +1,24 @@ +mode: standalone +cluster: + instances: 2 + storage: + size: 256Mi +backups: + enabled: true + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/tests/minio.yaml b/tests/minio.yaml new file mode 100644 index 000000000..6bcb77acc --- /dev/null +++ b/tests/minio.yaml @@ -0,0 +1,9 @@ +tenant: + pools: + - servers: 1 + name: pool0 + volumesPerServer: 1 + size: 1Gi + buckets: + - name: mybucket + region: local