diff --git a/.github/actions/setup-kind/action.yml b/.github/actions/setup-kind/action.yml index 709b28afd8..e81c2c2707 100644 --- a/.github/actions/setup-kind/action.yml +++ b/.github/actions/setup-kind/action.yml @@ -12,7 +12,7 @@ runs: steps: - id: helm name: Set up Helm - uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0 + uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 with: version: v3.21.1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cfa18e45b6..bc4d80869b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,11 +34,11 @@ jobs: fetch-depth: 0 - name: Set up Helm - uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0 + uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 with: version: v3.21.1 - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: 3.14 diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 8ad8e878e0..6e72411ffe 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -34,7 +34,7 @@ jobs: echo "${{ secrets.PGP_KEY_PASSPHRASE }}" > /tmp/passphrase-file.txt - name: Set up Helm - uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0 + uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 with: version: v3.21.1 diff --git a/charts/cluster/README.md b/charts/cluster/README.md index b3e61c4ecd..f0374394cc 100644 --- a/charts/cluster/README.md +++ b/charts/cluster/README.md @@ -138,6 +138,7 @@ Kubernetes: `>=1.29.0-0` | backups.google.path | string | `"/"` | | | backups.instanceSidecarConfiguration | object | `{}` | The configuration for the Barman Cloud Plugin sidecar that runs in the instance pods. See: https://cloudnative-pg.io/plugin-barman-cloud/docs/next/plugin-barman-cloud.v1/#instancesidecarconfiguration | | backups.method | string | `"barmanObjectStore"` | One of `barmanObjectStore` (default) or `plugin` | +| backups.pluginConfiguration | object | `{}` | | | backups.provider | string | `"s3"` | One of `s3`, `azure` or `google` | | backups.retentionPolicy | string | `"30d"` | Retention policy for backups | | backups.s3.accessKey | string | `""` | | diff --git a/charts/cluster/templates/_external_clusters.tpl b/charts/cluster/templates/_external_clusters.tpl index dc86484716..d94f49ecff 100644 --- a/charts/cluster/templates/_external_clusters.tpl +++ b/charts/cluster/templates/_external_clusters.tpl @@ -26,7 +26,7 @@ externalClusters: {{ with $pluginConfigurationParameters }} {{- toYaml . | nindent 8 -}} {{ end }} - barmanObjectname: {{ include "cluster.fullname" . }}-recovery + barmanObjectName: {{ include "cluster.fullname" . }}-recovery serverName: {{ .Values.recovery.clusterName }} {{- end }} {{- else if eq .Values.mode "replica" }} diff --git a/charts/cluster/templates/_helpers.tpl b/charts/cluster/templates/_helpers.tpl index c642655635..6628bac870 100644 --- a/charts/cluster/templates/_helpers.tpl +++ b/charts/cluster/templates/_helpers.tpl @@ -230,3 +230,13 @@ Given a list of objects, returns the first item that matches the key value pairs {{- define "cluster.barmanPluginEnabled" -}} {{- eq (include "helpers.hasKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io") (list "isWALArchiver" true)))) "true" -}} {{- end -}} + +{{- define "cluster.barmanPluginRequired" -}} + {{- $required := false -}} + {{- if and .Values.backups.enabled (eq .Values.backups.method "plugin") -}} + {{- if eq .Values.backups.pluginConfiguration.name "barman-cloud.cloudnative-pg.io" -}} + {{- $required = true -}} + {{- end -}} + {{- end -}} + {{- $required -}} +{{- end -}} diff --git a/charts/cluster/templates/backup-objectstore.yaml b/charts/cluster/templates/backup-objectstore.yaml index 0c23c12c25..7bedc6ee58 100644 --- a/charts/cluster/templates/backup-objectstore.yaml +++ b/charts/cluster/templates/backup-objectstore.yaml @@ -1,13 +1,14 @@ -{{- if and .Values.backups.enabled (eq (include "cluster.barmanPluginEnabled" .) "true") }} +{{- if eq (include "cluster.barmanPluginRequired" .) "true" }} apiVersion: barmancloud.cnpg.io/v1 kind: ObjectStore metadata: name: {{ include "cluster.fullname" . }}-backups namespace: {{ include "cluster.namespace" . }} - {{- with .Values.cluster.annotations }} annotations: - {{- toYaml . | nindent 4 }} - {{- end }} + "helm.sh/hook": pre-install,pre-upgrade,pre-rollback + {{- with .Values.cluster.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "cluster.labels" . | nindent 4 }} {{- with .Values.cluster.additionalLabels }} @@ -28,7 +29,6 @@ spec: encryption: {{ .Values.backups.data.encryption }} {{- end }} jobs: {{ .Values.backups.data.jobs }} - {{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.backups "secretPrefix" "backup" }} {{- include "cluster.barmanObjectStoreConfig" $d | nindent 2 }} instanceSidecarConfiguration: diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index c2b0d98e88..623188e6df 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -153,23 +153,23 @@ spec: {{ include "cluster.externalClusters" . | nindent 2 -}} {{ include "cluster.backup" . | nindent 2 -}} - {{- $plugins := len .Values.cluster.plugins -}} - {{- if and (gt $plugins 0) (or (gt $plugins 1) (and .Values.backups.enabled (eq (include "cluster.barmanPluginEnabled" .) "true") (eq .Values.backups.method "plugin"))) }} + {{- if or (gt (len .Values.cluster.plugins) 0) (eq (include "cluster.barmanPluginRequired" .) "true") }} plugins: {{ $pluginsWithoutBarman := include "helpers.omitKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYamlArray }} {{- range $pluginsWithoutBarman -}} - {{ toYaml . | indent 6 | trim }} {{- end }} - {{- if and .Values.backups.enabled (eq (include "cluster.barmanPluginEnabled" .) "true") (eq .Values.backups.method "plugin") }} - {{- $barmanPlugin := include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYaml -}} - - name: {{ $barmanPlugin.name }} - enabled: true - isWALArchiver: true + {{- if or (eq (include "cluster.barmanPluginEnabled" .) "true") (eq (include "cluster.barmanPluginRequired" .) "true") }} + {{- $barmanPlugin := include "helpers.fetchKeyValue" (list .Values.cluster.plugins (list (list "name" "barman-cloud.cloudnative-pg.io"))) | fromYaml }} + - name: barman-cloud.cloudnative-pg.io + enabled: {{ eq $barmanPlugin.enabled nil | ternary (eq (include "cluster.barmanPluginRequired" .) "true") $barmanPlugin.enabled }} + isWALArchiver: {{ eq $barmanPlugin.isWALArchiver nil | ternary (eq (include "cluster.barmanPluginRequired" .) "true") $barmanPlugin.isWALArchiver }} parameters: - {{- $parameters := (omit (coalesce $barmanPlugin.parameters dict) "barmanObjectName") -}} - {{ with $parameters }} - {{ toYaml . | indent 8 | trim }} + {{- $parameters := (coalesce $barmanPlugin.parameters dict) -}} + {{- $parametersWithoutObjectName := (omit $parameters "barmanObjectName") }} + {{ with $parametersWithoutObjectName }} + {{- toYaml . | indent 8 | trim }} {{- end }} - barmanObjectName: {{ include "cluster.fullname" . }}-backups + barmanObjectName: {{ $parameters.barmanObjectName | default (printf "%s-backups" (include "cluster.fullname" .)) }} {{- end }} {{- end }} diff --git a/charts/cluster/templates/recovery-objectstore.yaml b/charts/cluster/templates/recovery-objectstore.yaml index 8ae69b967e..d1b2f8c4d5 100644 --- a/charts/cluster/templates/recovery-objectstore.yaml +++ b/charts/cluster/templates/recovery-objectstore.yaml @@ -4,10 +4,11 @@ kind: ObjectStore metadata: name: {{ include "cluster.fullname" . }}-recovery namespace: {{ include "cluster.namespace" . }} - {{- with .Values.cluster.annotations }} annotations: - {{- toYaml . | nindent 4 }} - {{- end }} + "helm.sh/hook": pre-install,pre-upgrade,pre-rollback + {{- with .Values.cluster.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "cluster.labels" . | nindent 4 }} {{- with .Values.cluster.additionalLabels }} @@ -17,7 +18,6 @@ spec: configuration: {{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}} {{- include "cluster.barmanObjectStoreConfig" $d | indent 2 }} - retentionPolicy: {{ .Values.recovery.retentionPolicy }} instanceSidecarConfiguration: {{- .Values.recovery.instanceSidecarConfiguration | toYaml | nindent 4 }} {{- end }} diff --git a/charts/cluster/templates/recovery-s3-creds.yaml b/charts/cluster/templates/recovery-s3-creds.yaml index d70ed2120f..cf170a647b 100644 --- a/charts/cluster/templates/recovery-s3-creds.yaml +++ b/charts/cluster/templates/recovery-s3-creds.yaml @@ -1,4 +1,4 @@ -{{- if and (eq .Values.mode "recovery" ) (eq .Values.recovery.method "object_store") (eq .Values.recovery.provider "s3") (not .Values.recovery.s3.inheritFromIAMRole) .Values.recovery.secret.create }} +{{- if and (eq .Values.mode "recovery" ) (eq .Values.recovery.provider "s3") (not (has .Values.recovery.method (list "backup" "import" "pg_basebackup"))) (not .Values.recovery.s3.inheritFromIAMRole) .Values.recovery.secret.create }} apiVersion: v1 kind: Secret metadata: diff --git a/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml b/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml index bc381b893f..4d8c6b1d17 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/00-minio_cleanup.yaml @@ -8,7 +8,7 @@ spec: restartPolicy: OnFailure containers: - name: minio-cleanup - image: minio/mc + image: minio/mc:latest command: ['sh', '-c'] args: - | diff --git a/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml index 22735eee56..141de74506 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/01-barman-plugin-backup-restore_cluster.yaml @@ -4,14 +4,12 @@ cluster: instances: 2 storage: size: 256Mi - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true backups: enabled: true method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-backup.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-backup.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/03-backup.yaml rename to charts/cluster/test/barman-plugin-backup-restore/02-backup.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-backup_completed-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-backup_completed-assert.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/03-backup_completed-assert.yaml rename to charts/cluster/test/barman-plugin-backup-restore/02-backup_completed-assert.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-checkpoint.yaml b/charts/cluster/test/barman-plugin-backup-restore/02-checkpoint.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/03-checkpoint.yaml rename to charts/cluster/test/barman-plugin-backup-restore/02-checkpoint.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/03-backup_running-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/03-backup_running-assert.yaml deleted file mode 100644 index e708dd4429..0000000000 --- a/charts/cluster/test/barman-plugin-backup-restore/03-backup_running-assert.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: postgresql.cnpg.io/v1 -kind: Backup -metadata: - name: post-init-backup -spec: - cluster: - name: barman-plugin-backup-restore-cluster - method: plugin - pluginConfiguration: - name: barman-cloud.cloudnative-pg.io -status: - phase: running diff --git a/charts/cluster/test/barman-plugin-backup-restore/02-data_write-assert.yaml b/charts/cluster/test/barman-plugin-backup-restore/03-data_write-assert.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/02-data_write-assert.yaml rename to charts/cluster/test/barman-plugin-backup-restore/03-data_write-assert.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/02-data_write.yaml b/charts/cluster/test/barman-plugin-backup-restore/03-data_write.yaml similarity index 100% rename from charts/cluster/test/barman-plugin-backup-restore/02-data_write.yaml rename to charts/cluster/test/barman-plugin-backup-restore/03-data_write.yaml diff --git a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml index 45b23c4407..8b6cb27f59 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/05-recovery_backup_pitr_cluster.yaml @@ -5,15 +5,12 @@ cluster: instances: 2 storage: size: 256Mi - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true recovery: method: plugin pluginConfiguration: name: barman-cloud.cloudnative-pg.io + clusterName: "barman-plugin-backup-restore-cluster" provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: @@ -29,13 +26,14 @@ recovery: accessKey: "minio" secretKey: "minio123" region: "local" - clusterName: "barman-plugin-backup-restore-cluster" - retentionPolicy: "30d" scheduledBackups: [] + retentionPolicy: "30d" backups: enabled: true method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: diff --git a/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml index ebd6f539fd..61fb0fdba8 100644 --- a/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-backup-restore/chainsaw-test.yaml @@ -35,29 +35,14 @@ spec: kind: Cluster - podLogs: selector: cnpg.io/cluster=barman-plugin-backup-restore-cluster - - name: Write some data to the cluster - timeouts: - apply: 1s - assert: 30s - try: - - apply: - file: ./02-data_write.yaml - - assert: - file: ./02-data_write-assert.yaml - catch: - - describe: - apiVersion: batch/v1 - kind: Job - - podLogs: - selector: batch.kubernetes.io/job-name=data-test - name: Create a backup try: - apply: - file: ./03-backup.yaml + file: ./02-backup.yaml - apply: - file: ./03-checkpoint.yaml + file: ./02-checkpoint.yaml - assert: - file: ./03-backup_completed-assert.yaml + file: ./02-backup_completed-assert.yaml catch: - describe: apiVersion: postgresql.cnpg.io/v1 @@ -67,6 +52,21 @@ spec: kind: Cluster - podLogs: selector: cnpg.io/cluster=barman-plugin-backup-restore-cluster + - name: Write some data to the cluster + timeouts: + apply: 1s + assert: 30s + try: + - apply: + file: ./03-data_write.yaml + - assert: + file: ./03-data_write-assert.yaml + catch: + - describe: + apiVersion: batch/v1 + kind: Job + - podLogs: + selector: batch.kubernetes.io/job-name=data-test - name: Write more data to the database after the backup try: - apply: @@ -117,4 +117,6 @@ spec: try: - script: content: | + kubectl --namespace $NAMESPACE delete scheduledbackups.postgresql.cnpg.io --all + kubectl --namespace $NAMESPACE delete backups.postgresql.cnpg.io --all helm uninstall --namespace $NAMESPACE barman-plugin-backup-restore diff --git a/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster-assert.yaml b/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster-assert.yaml new file mode 100644 index 0000000000..6d3310f623 --- /dev/null +++ b/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster-assert.yaml @@ -0,0 +1,14 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-explicit-config-cluster +spec: + plugins: + - name: foo.example.com + enabled: true + isWALArchiver: false + parameters: + foo: bar + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true diff --git a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml b/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster.yaml similarity index 55% rename from charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml rename to charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster.yaml index 9abd52993e..dce181cf13 100644 --- a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster.yaml +++ b/charts/cluster/test/barman-plugin-explicit/01-barman_plugin_explicit_config_cluster.yaml @@ -1,17 +1,24 @@ type: postgresql mode: standalone cluster: - instances: 2 + instances: 1 storage: size: 256Mi plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true + - name: foo.example.com + enabled: true + isWALArchiver: false + parameters: + foo: bar + - name: barman-cloud.cloudnative-pg.io + enabled: true + isWALArchiver: true backups: enabled: true - method: barmanObjectStore + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: @@ -23,9 +30,8 @@ backups: encryption: "" s3: bucket: "mybucket" - path: "/barman-plugin-migration/v1" + path: "/barman-plugin-scheduledbackups/v1" accessKey: "minio" secretKey: "minio123" region: "local" - scheduledBackups: [] retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster-assert.yaml b/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster-assert.yaml new file mode 100644 index 0000000000..e595e8bd2f --- /dev/null +++ b/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster-assert.yaml @@ -0,0 +1,17 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: barman-plugin-config-override-cluster +spec: + plugins: + - name: foo.example.com + enabled: true + isWALArchiver: false + parameters: + foo: bar + - name: barman-cloud.cloudnative-pg.io + enabled: false + isWALArchiver: false + parameters: + foo: bar + barmanObjectName: asd diff --git a/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster.yaml b/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster.yaml new file mode 100644 index 0000000000..a06a6eef10 --- /dev/null +++ b/charts/cluster/test/barman-plugin-explicit/02-barman_plugin_config_override_cluster.yaml @@ -0,0 +1,40 @@ +type: postgresql +mode: standalone +cluster: + instances: 1 + storage: + size: 256Mi + plugins: + - name: foo.example.com + enabled: true + isWALArchiver: false + parameters: + foo: bar + - name: barman-cloud.cloudnative-pg.io + enabled: false + isWALArchiver: false + parameters: + foo: bar + barmanObjectName: asd + +backups: + enabled: true + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io + 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: "/barman-plugin-scheduledbackups/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + retentionPolicy: "30d" diff --git a/charts/cluster/test/barman-plugin-explicit/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-explicit/chainsaw-test.yaml new file mode 100644 index 0000000000..0fd08835e8 --- /dev/null +++ b/charts/cluster/test/barman-plugin-explicit/chainsaw-test.yaml @@ -0,0 +1,41 @@ +# Tests the Barman Cloud CNPG-I Plugin with explicit plugin configuration +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: barman-plugin-explicit +spec: + timeouts: + apply: 1s + assert: 5s + cleanup: 1m + steps: + - name: Install a cluster with a custom plugin section + try: + - script: + content: | + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./01-barman_plugin_explicit_config_cluster.yaml \ + --wait \ + barman-plugin-explicit-config ../../ + - assert: + file: ./01-barman_plugin_explicit_config_cluster-assert.yaml + - name: Install the cluster with a custom plugin section that overrides the default configuration + try: + - script: + content: | + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./02-barman_plugin_config_override_cluster.yaml \ + --wait \ + barman-plugin-config-override ../../ + - assert: + file: ./02-barman_plugin_config_override_cluster-assert.yaml + - name: Cleanup + try: + - script: + content: | + helm --namespace $NAMESPACE uninstall barman-plugin-explicit-config + helm --namespace $NAMESPACE uninstall barman-plugin-config-override diff --git a/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml b/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml index 92b77ba8c6..a06dbb2bf8 100644 --- a/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml +++ b/charts/cluster/test/barman-plugin-migration/00-minio_cleanup.yaml @@ -8,7 +8,7 @@ spec: restartPolicy: OnFailure containers: - name: minio-cleanup - image: minio/mc + image: minio/mc:latest command: ['sh', '-c'] args: - | diff --git a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-healthy-assert.yaml similarity index 81% rename from charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster-assert.yaml rename to charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-healthy-assert.yaml index 27991bd3c8..56204cb54b 100644 --- a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster-assert.yaml +++ b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-healthy-assert.yaml @@ -10,6 +10,8 @@ spec: - name: barman-cloud.cloudnative-pg.io enabled: true isWALArchiver: true + parameters: + barmanObjectName: barman-plugin-migration-cluster-backups --- apiVersion: barmancloud.cnpg.io/v1 kind: ObjectStore diff --git a/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml new file mode 100644 index 0000000000..6682a100fa --- /dev/null +++ b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster-upgrading-assert.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Event +reason: UpgradingInstance +involvedObject: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + name: barman-plugin-migration-cluster diff --git a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster.yaml similarity index 83% rename from charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml rename to charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster.yaml index 9ecad0b1a7..430dae6cff 100644 --- a/charts/cluster/test/barman-plugin-migration/04.2-barman-plugin-migration_cluster.yaml +++ b/charts/cluster/test/barman-plugin-migration/04-barman-plugin-migration_cluster.yaml @@ -4,14 +4,12 @@ cluster: instances: 2 storage: size: 256Mi - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true backups: enabled: true method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: diff --git a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml b/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml deleted file mode 100644 index 7aed154fc2..0000000000 --- a/charts/cluster/test/barman-plugin-migration/04.1-barman-plugin-migration_cluster-assert.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: postgresql.cnpg.io/v1 -kind: Cluster -metadata: - name: barman-plugin-migration-cluster -status: - readyInstances: 2 - phase: Cluster in healthy state ---- -apiVersion: barmancloud.cnpg.io/v1 -kind: ObjectStore -metadata: - name: barman-plugin-migration-cluster-backups diff --git a/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml b/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml index c1fa64a4c1..8a0ff0dc64 100644 --- a/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml +++ b/charts/cluster/test/barman-plugin-migration/05-backup_running-assert.yaml @@ -1,12 +1,7 @@ -apiVersion: postgresql.cnpg.io/v1 -kind: Backup -metadata: +apiVersion: v1 +kind: Event +reason: Starting +involvedObject: + apiVersion: postgresql.cnpg.io/v1 + kind: Backup name: post-migrate-backup -spec: - cluster: - name: barman-plugin-migration-cluster - method: plugin - pluginConfiguration: - name: barman-cloud.cloudnative-pg.io -status: - phase: running diff --git a/charts/cluster/test/barman-plugin-migration/08-data_test.yaml b/charts/cluster/test/barman-plugin-migration/08-data_test.yaml index 694a7ba252..5fb4faf395 100644 --- a/charts/cluster/test/barman-plugin-migration/08-data_test.yaml +++ b/charts/cluster/test/barman-plugin-migration/08-data_test.yaml @@ -12,7 +12,7 @@ spec: - name: DB_URI valueFrom: secretKeyRef: - name: recovery-backup-pitr-superuser + name: recovery-backup-pitr-cluster-superuser key: uri image: alpine:3.19 command: ['sh', '-c'] diff --git a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml index 71bfe56249..9cfea96fb9 100644 --- a/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-migration/chainsaw-test.yaml @@ -55,7 +55,7 @@ spec: - name: Write some data to the cluster timeouts: apply: 1s - assert: 30s + assert: 1m try: - apply: file: 03-data_write.yaml @@ -71,25 +71,21 @@ spec: try: - script: content: | - 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 - helm upgrade \ --namespace $NAMESPACE \ - --values ./04.1-barman-plugin-migration_cluster.yaml \ + --values ./04-barman-plugin-migration_cluster.yaml \ --wait \ barman-plugin-migration ../../ - assert: - file: ./04.1-barman-plugin-migration_cluster-assert.yaml - - script: - content: | - helm upgrade \ - --namespace $NAMESPACE \ - --values ./04.2-barman-plugin-migration_cluster.yaml \ - --wait \ - barman-plugin-migration ../../ - - script: - content: sleep 1 + file: ./04-barman-plugin-migration_cluster-upgrading-assert.yaml - assert: - file: ./04.2-barman-plugin-migration_cluster-assert.yaml + file: ./04-barman-plugin-migration_cluster-healthy-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - podLogs: + selector: cnpg.io/cluster=barman-plugin-migration-cluster - name: Create a buckup with the Barman CNPG-I plugin try: - apply: @@ -170,4 +166,6 @@ spec: try: - script: content: | + kubectl --namespace $NAMESPACE delete scheduledbackups.postgresql.cnpg.io --all + kubectl --namespace $NAMESPACE delete backups.postgresql.cnpg.io --all helm uninstall --namespace $NAMESPACE barman-plugin-migration diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml index 7ee8bc0340..4fef8e057d 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/00-minio_cleanup.yaml @@ -8,7 +8,7 @@ spec: restartPolicy: OnFailure containers: - name: minio-cleanup - image: minio/mc + image: minio/mc:latest command: ['sh', '-c'] args: - | diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml index 2cdb63446b..3962add8c6 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml @@ -4,14 +4,12 @@ cluster: instances: 1 storage: size: 256Mi - plugins: - - name: barman-cloud.cloudnative-pg.io - enabled: true - isWALArchiver: true backups: enabled: true method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io provider: s3 endpointURL: "https://minio.minio.svc.cluster.local" endpointCA: diff --git a/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml b/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml index 7a29e05cc3..e84283ba58 100644 --- a/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml +++ b/charts/cluster/test/barman-plugin-scheduledbackups/chainsaw-test.yaml @@ -28,4 +28,6 @@ spec: try: - script: content: | - helm uninstall --namespace $NAMESPACE scheduledbackups + kubectl --namespace $NAMESPACE delete scheduledbackups.postgresql.cnpg.io --all + kubectl --namespace $NAMESPACE delete backups.postgresql.cnpg.io --all + helm --namespace $NAMESPACE uninstall scheduledbackups diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index b3df291d82..29c5acb352 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -133,6 +133,10 @@ "description": "One of `barmanObjectStore` (default) or `plugin`", "type": "string" }, + "pluginConfiguration": { + "required": [], + "type": "object" + }, "provider": { "default": "s3", "description": "One of `s3`, `azure` or `google`", diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 42020c3fa8..1f570d603d 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -466,6 +466,9 @@ backups: # -- One of `barmanObjectStore` (default) or `plugin` method: barmanObjectStore + pluginConfiguration: {} +# name: barman-cloud.cloudnative-pg.io + # Barman Object Store configuration applicable to both `barmanObjectStore` and `plugin` methods when using # the `barman-cloud.cloudnative-pg.io` plugin. diff --git a/charts/plugin-barman-cloud/templates/deployment.yaml b/charts/plugin-barman-cloud/templates/deployment.yaml index 893fdc2fc8..630113b74d 100644 --- a/charts/plugin-barman-cloud/templates/deployment.yaml +++ b/charts/plugin-barman-cloud/templates/deployment.yaml @@ -78,7 +78,12 @@ spec: initialDelaySeconds: 10 periodSeconds: 10 tcpSocket: - port: 9090 + port: 8081 + livenessProbe: + initialDelaySeconds: 10 + periodSeconds: 10 + tcpSocket: + port: 8081 resources: {{- toYaml .Values.resources | nindent 10 }} securityContext: diff --git a/charts/plugin-barman-cloud/test/simple-deployment/01-simple_deployment-assert.yaml b/charts/plugin-barman-cloud/test/simple-deployment/01-simple_deployment-assert.yaml index 37e11d27bf..961ae76fad 100644 --- a/charts/plugin-barman-cloud/test/simple-deployment/01-simple_deployment-assert.yaml +++ b/charts/plugin-barman-cloud/test/simple-deployment/01-simple_deployment-assert.yaml @@ -23,7 +23,12 @@ spec: initialDelaySeconds: 10 periodSeconds: 10 tcpSocket: - port: 9090 + port: 8081 + livenessProbe: + initialDelaySeconds: 10 + periodSeconds: 10 + tcpSocket: + port: 8081 resources: limits: cpu: 100m