Skip to content

Commit 3a46f56

Browse files
authored
Merge pull request #20 from vshn/postgres/barman-object-store
Add configuration for barman object store
2 parents 3cfc7c2 + 3734bc2 commit 3a46f56

File tree

15 files changed

+1038
-911
lines changed

15 files changed

+1038
-911
lines changed

Makefile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,25 @@ prepare: ## Prepare the charts for testing
6565
@echo 'Check for uncommitted changes ...'
6666
git diff --exit-code
6767

68-
.PHONY: push-local
6968
VERSION=0.0.0
7069
REGISTRY=registry.127.0.0.1.nip.io:8443
71-
push-local: ## Pushes the chart to a local OCI registry
72-
helm package charts/vshnmariadb --version $(VERSION)
73-
helm push vshnmariadb-$(VERSION).tgz oci://$(REGISTRY)/vshnmariadb --insecure-skip-tls-verify
74-
rm vshnmariadb-$(VERSION).tgz
70+
CHART ?=
71+
CHARTS := $(notdir $(wildcard $(CHARTS_DIR)/*))
72+
73+
.PHONY: push-local
74+
push-local: ## Pushes a chart to a local OCI registry (CHART=name)
75+
ifndef CHART
76+
$(error CHART is required. Usage: make push-local CHART=vshnpostgresql)
77+
endif
78+
helm package $(CHARTS_DIR)/$(CHART) --version $(VERSION)
79+
helm push $(CHART)-$(VERSION).tgz oci://$(REGISTRY)/$(CHART) --insecure-skip-tls-verify
80+
rm $(CHART)-$(VERSION).tgz
81+
82+
.PHONY: push-local-all
83+
push-local-all: ## Pushes all charts to a local OCI registry
84+
@for chart in $(CHARTS); do \
85+
echo "Pushing $$chart..."; \
86+
helm package $(CHARTS_DIR)/$$chart --version $(VERSION); \
87+
helm push $$chart-$(VERSION).tgz oci://$(REGISTRY)/$$chart --insecure-skip-tls-verify; \
88+
rm $$chart-$(VERSION).tgz; \
89+
done

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ helm repo add appcat https://charts.appcat.ch
1616
| Downloads & Changelog | Chart |
1717
| --- | --- |
1818
| [![chart downloads](https://img.shields.io/github/downloads/vshn/appcat-charts/vshnmariadb-0.0.12/total)](https://github.com/vshn/appcat-charts/releases/tag/vshnmariadb-0.0.12) | [vshnmariadb](charts/vshnmariadb/README.md) |
19-
| [![chart downloads](https://img.shields.io/github/downloads/vshn/appcat-charts/vshnpostgresql-0.5.0/total)](https://github.com/vshn/appcat-charts/releases/tag/vshnpostgresql-0.5.0) | [vshnpostgresql](charts/vshnpostgresql/README.md) |
19+
| [![chart downloads](https://img.shields.io/github/downloads/vshn/appcat-charts/vshnpostgresql-0.6.0/total)](https://github.com/vshn/appcat-charts/releases/tag/vshnpostgresql-0.6.0) | [vshnpostgresql](charts/vshnpostgresql/README.md) |
2020

2121
## Add / Update Charts
2222

charts/vshnpostgresql/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ apiVersion: v2
2020
name: vshnpostgresql
2121
description: A Helm chart for PostgreSQL clusters using the CloudNativePG operator
2222
type: application
23-
version: 0.5.0
24-
appVersion: 0.5.0
23+
version: 0.6.0
24+
appVersion: 0.6.0
2525
maintainers:
2626
- name: Schedar Team
2727
email: info@vshn.ch

charts/vshnpostgresql/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# vshnpostgresql
22

3-
![Version: 0.5.0](https://img.shields.io/badge/Version-0.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.5.0](https://img.shields.io/badge/AppVersion-0.5.0-informational?style=flat-square)
3+
![Version: 0.6.0](https://img.shields.io/badge/Version-0.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.6.0](https://img.shields.io/badge/AppVersion-0.6.0-informational?style=flat-square)
44

55
A Helm chart for PostgreSQL clusters using the CloudNativePG operator
66

@@ -85,7 +85,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentati
8585
| backups.azure.storageKey | string | `""` | |
8686
| backups.azure.storageSasToken | string | `""` | |
8787
| backups.data.compression | string | `"gzip"` | Data compression method. One of `` (for no compression), `gzip`, `bzip2` or `snappy`. |
88-
| backups.data.encryption | string | `"AES256"` | Whether to instruct the storage provider to encrypt data files. One of `` (use the storage container default), `AES256` or `aws:kms`. |
88+
| backups.data.encryption | string | `""` | Whether to instruct the storage provider to encrypt data files. One of `` (use the storage container default), `AES256` or `aws:kms`. |
8989
| backups.data.jobs | int | `2` | Number of data files to be archived or restored in parallel. |
9090
| backups.destinationPath | string | `""` | Overrides the provider specific default path. Defaults to: S3: s3://<bucket><path> Azure: https://<storageAccount>.<serviceName>.core.windows.net/<containerName><path> Google: gs://<bucket><path> |
9191
| backups.enabled | bool | `false` | You need to configure backups manually, so backups are disabled by default. |
@@ -111,7 +111,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentati
111111
| backups.secret.create | bool | `true` | Whether to create a secret for the backup credentials |
112112
| backups.secret.name | string | `""` | Name of the backup credentials secret |
113113
| backups.wal.compression | string | `"gzip"` | WAL compression method. One of `` (for no compression), `gzip`, `bzip2` or `snappy`. |
114-
| backups.wal.encryption | string | `"AES256"` | Whether to instruct the storage provider to encrypt WAL files. One of `` (use the storage container default), `AES256` or `aws:kms`. |
114+
| backups.wal.encryption | string | `""` | Whether to instruct the storage provider to encrypt WAL files. One of `` (use the storage container default), `AES256` or `aws:kms`. |
115115
| backups.wal.maxParallel | int | `1` | Number of WAL files to be archived or restored in parallel. |
116116
| cluster.additionalLabels | object | `{}` | |
117117
| cluster.affinity | object | `{"topologyKey":"topology.kubernetes.io/zone"}` | Affinity/Anti-affinity rules for Pods. See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-AffinityConfiguration |
@@ -137,6 +137,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentati
137137
| cluster.monitoring.podMonitor.relabelings | list | `[]` | The list of relabelings for the PodMonitor. Applied to samples before scraping. |
138138
| cluster.monitoring.prometheusRule.enabled | bool | `true` | Whether to enable the PrometheusRule automated alerts |
139139
| cluster.monitoring.prometheusRule.excludeRules | list | `[]` | Exclude specified rules |
140+
| cluster.plugins | list | `[]` | The plugins configuration, containing any plugin to be loaded with the corresponding configuration |
140141
| cluster.postgresGID | int | `-1` | The GID of the postgres user inside the image, defaults to 26 |
141142
| cluster.postgresUID | int | `-1` | The UID of the postgres user inside the image, defaults to 26 |
142143
| cluster.postgresql.ldap | object | `{}` | PostgreSQL LDAP configuration (see https://cloudnative-pg.io/documentation/current/postgresql_conf/#ldap-configuration) |

charts/vshnpostgresql/templates/_backup.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{{- if .Values.backups.enabled }}
33
backup:
44
target: "prefer-standby"
5+
{{ if (eq (include "cluster.useBarmanCloudPlugin" .) "false") }}
56
retentionPolicy: {{ .Values.backups.retentionPolicy }}
67
barmanObjectStore:
78
wal:
@@ -19,5 +20,6 @@ backup:
1920

2021
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.backups "secretPrefix" "backup" }}
2122
{{- include "cluster.barmanObjectStoreConfig" $d | nindent 2 }}
23+
{{- end }}
2224
{{- end }}
2325
{{- end }}

charts/vshnpostgresql/templates/_bootstrap.tpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,19 @@ bootstrap:
7777
recoveryTarget:
7878
targetTime: {{ . }}
7979
{{- end }}
80-
{{ with .Values.recovery.database }}
80+
{{- with .Values.recovery.database }}
8181
database: {{ . }}
8282
{{- end }}
83-
{{ with .Values.recovery.owner }}
83+
{{- with .Values.recovery.owner }}
8484
owner: {{ . }}
8585
{{- end }}
8686
{{- if eq .Values.recovery.method "backup" }}
8787
backup:
8888
name: {{ .Values.recovery.backupName }}
89-
{{- else if eq .Values.recovery.method "object_store" }}
89+
{{- else if and (eq .Values.recovery.method "object_store") (eq (include "cluster.useBarmanCloudPlugin" .) "false") }}
9090
source: objectStoreRecoveryCluster
91+
{{- else if and (eq .Values.recovery.method "object_store") (eq (include "cluster.useBarmanCloudPlugin" .) "true") }}
92+
source: origin
9193
{{- end }}
9294
{{- end }}
9395
{{- else if eq .Values.mode "replica" }}

charts/vshnpostgresql/templates/_external_clusters.tpl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1+
12
{{- define "cluster.externalClusters" -}}
2-
externalClusters:
33
{{- if eq .Values.mode "standalone" }}
44
{{- else if eq .Values.mode "recovery" }}
5+
externalClusters:
56
{{- if eq .Values.recovery.method "pg_basebackup" }}
67
- name: pgBaseBackupSource
78
{{- include "cluster.externalSourceCluster" .Values.recovery.pgBaseBackup.source | nindent 4 }}
89
{{- else if eq .Values.recovery.method "import" }}
910
- name: importSource
1011
{{- include "cluster.externalSourceCluster" .Values.recovery.import.source | nindent 4 }}
11-
{{- else if eq .Values.recovery.method "object_store" }}
12+
{{- else if and (eq .Values.recovery.method "object_store") (eq (include "cluster.useBarmanCloudPlugin" .) "false") }}
1213
- name: objectStoreRecoveryCluster
1314
barmanObjectStore:
1415
serverName: {{ .Values.recovery.clusterName }}
1516
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}}
1617
{{- include "cluster.barmanObjectStoreConfig" $d | nindent 4 }}
18+
{{- else if and (eq .Values.recovery.method "object_store") (eq (include "cluster.useBarmanCloudPlugin" .) "true") }}
19+
- name: origin
20+
plugin:
21+
name: barman-cloud.cloudnative-pg.io
22+
parameters:
23+
barmanObjectName: {{ include "cluster.fullname" $ }}-object-store
24+
serverName: {{ .Values.recovery.clusterName | default (include "cluster.fullname" .) }}
1725
{{- end }}
1826
{{- else if eq .Values.mode "replica" }}
27+
externalClusters:
1928
- name: originCluster
2029
{{- if not (empty .Values.replica.origin.objectStore.provider) }}
2130
barmanObjectStore:

charts/vshnpostgresql/templates/_helpers.tpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,19 @@ Postgres GID
144144
{{- 26 -}}
145145
{{- end -}}
146146
{{- end -}}
147+
148+
149+
{{/*
150+
Check if barman-cloud plugin exists and is enabled
151+
*/}}
152+
{{- define "cluster.useBarmanCloudPlugin" -}}
153+
{{- $hasPlugin := false }}
154+
{{- if .Values.cluster.plugins }}
155+
{{- range .Values.cluster.plugins }}
156+
{{- if and (eq .name "barman-cloud.cloudnative-pg.io") .enabled }}
157+
{{- $hasPlugin = true }}
158+
{{- end }}
159+
{{- end }}
160+
{{- end }}
161+
{{- $hasPlugin }}
162+
{{- end }}

charts/vshnpostgresql/templates/cluster.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ spec:
6767
name: {{ . }}
6868
{{ end }}
6969
enablePDB: {{ .Values.cluster.enablePDB }}
70+
{{- with .Values.cluster.plugins }}
71+
plugins:
72+
{{- toYaml . | nindent 4}}
73+
{{- end }}
7074
postgresql:
7175
{{- if or (eq .Values.type "timescaledb") (not (empty .Values.cluster.postgresql.shared_preload_libraries)) }}
7276
shared_preload_libraries:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{ if eq (include "cluster.useBarmanCloudPlugin" .) "true" }}
2+
apiVersion: barmancloud.cnpg.io/v1
3+
kind: ObjectStore
4+
metadata:
5+
name: {{ include "cluster.fullname" $ }}-object-store
6+
namespace: {{ include "cluster.namespace" $ }}
7+
spec:
8+
{{- with .Values.backups.retentionPolicy }}
9+
retentionPolicy: {{ . }}
10+
{{- end }}
11+
configuration:
12+
{{- if and (eq .Values.mode "recovery") (eq .Values.recovery.method "object_store") -}}
13+
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}}
14+
{{- include "cluster.barmanObjectStoreConfig" $d | indent 2 }}
15+
{{- else }}
16+
wal:
17+
compression: {{ .Values.backups.wal.compression }}
18+
{{- if and .Values.backups.wal.encryption (ne .Values.backups.wal.encryption "") }}
19+
encryption: {{ .Values.backups.wal.encryption }}
20+
{{- end }}
21+
maxParallel: {{ .Values.backups.wal.maxParallel }}
22+
data:
23+
compression: {{ .Values.backups.data.compression }}
24+
{{- if and .Values.backups.data.encryption (ne .Values.backups.data.encryption "") }}
25+
encryption: {{ .Values.backups.data.encryption }}
26+
{{- end }}
27+
jobs: {{ .Values.backups.data.jobs }}
28+
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.backups "secretPrefix" "backup" -}}
29+
{{- include "cluster.barmanObjectStoreConfig" $d | indent 2 }}
30+
{{- end }}
31+
{{- end }}

0 commit comments

Comments
 (0)