Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat
| cluster.monitoring.podMonitor.relabelings | list | `[]` | The list of relabelings for the PodMonitor. Applied to samples before scraping. |
| cluster.monitoring.prometheusRule.enabled | bool | `true` | Whether to enable the PrometheusRule automated alerts |
| cluster.monitoring.prometheusRule.excludeRules | list | `[]` | Exclude specified rules |
| cluster.plugins | list | `[]` | The plugins configuration, containing any plugin to be loaded with the corresponding configuration |
| cluster.postgresGID | int | `-1` | The GID of the postgres user inside the image, defaults to 26 |
| cluster.postgresUID | int | `-1` | The UID of the postgres user inside the image, defaults to 26 |
| cluster.postgresql.ldap | object | `{}` | PostgreSQL LDAP configuration (see https://cloudnative-pg.io/documentation/current/postgresql_conf/#ldap-configuration) |
Expand Down
2 changes: 2 additions & 0 deletions charts/cluster/templates/_backup.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{{- if .Values.backups.enabled }}
backup:
target: "prefer-standby"
{{ if (eq (include "cluster.useBarmanCloudPlugin" .) "false") }}
retentionPolicy: {{ .Values.backups.retentionPolicy }}
barmanObjectStore:
wal:
Expand All @@ -19,5 +20,6 @@ backup:

{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.backups "secretPrefix" "backup" }}
{{- include "cluster.barmanObjectStoreConfig" $d | nindent 2 }}
{{- end}}
{{- end }}
{{- end }}
20 changes: 15 additions & 5 deletions charts/cluster/templates/_bootstrap.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,35 @@ externalClusters:
recoveryTarget:
targetTime: {{ . }}
{{- end }}
{{ with .Values.recovery.database }}
{{- with .Values.recovery.database }}
database: {{ . }}
{{- end }}
{{ with .Values.recovery.owner }}
{{- with .Values.recovery.owner }}
owner: {{ . }}
{{- end }}
{{- if eq .Values.recovery.method "backup" }}
backup:
name: {{ .Values.recovery.backupName }}
{{- else if eq .Values.recovery.method "object_store" }}
{{- else if and (eq .Values.recovery.method "object_store") (eq (include "cluster.useBarmanCloudPlugin" .) "false") }}
source: objectStoreRecoveryCluster

externalClusters:
- name: objectStoreRecoveryCluster
barmanObjectStore:
serverName: {{ .Values.recovery.clusterName }}
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}}
{{- include "cluster.barmanObjectStoreConfig" $d | nindent 4 }}
{{- end }}
{{- include "cluster.barmanObjectStoreConfig" $d | indent 4 }}
{{- else if and (eq .Values.recovery.method "object_store") (eq (include "cluster.useBarmanCloudPlugin" .) "true") }}
source: origin

externalClusters:
- name: origin
plugin:
name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: {{ include "cluster.fullname" $ }}-object-store
serverName: {{ .Values.recovery.clusterName | default (include "cluster.fullname" .) }}
{{- end }}
{{- end }}
{{- else }}
{{ fail "Invalid cluster mode!" }}
Expand Down
16 changes: 16 additions & 0 deletions charts/cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,19 @@ Postgres GID
{{- 26 -}}
{{- end -}}
{{- end -}}


{{/*
Check if barman-cloud plugin exists and is enabled
*/}}
{{- define "cluster.useBarmanCloudPlugin" -}}
{{- $hasPlugin := false }}
{{- if .Values.cluster.plugins }}
{{- range .Values.cluster.plugins }}
{{- if and (eq .name "barman-cloud.cloudnative-pg.io") .enabled }}
{{- $hasPlugin = true }}
{{- end }}
{{- end }}
{{- end }}
{{- $hasPlugin }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ spec:
name: {{ . }}
{{ end }}
enablePDB: {{ .Values.cluster.enablePDB }}
{{- with .Values.cluster.plugins }}
plugins:
{{- toYaml . | nindent 4}}
{{- end }}
postgresql:
{{- if or (eq .Values.type "timescaledb") (not (empty .Values.cluster.postgresql.shared_preload_libraries)) }}
shared_preload_libraries:
Expand Down
30 changes: 30 additions & 0 deletions charts/cluster/templates/objectStore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{ if eq (include "cluster.useBarmanCloudPlugin" .) "true" }}
apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
name: {{ include "cluster.fullname" $ }}-object-store
spec:
{{- with .Values.backups.retentionPolicy }}
retentionPolicy: {{ . }}
{{- end }}
configuration:
{{- if and (eq .Values.mode "recovery") (eq .Values.recovery.method "object_store") -}}
{{- $d := dict "chartFullname" (include "cluster.fullname" .) "scope" .Values.recovery "secretPrefix" "recovery" -}}
{{- include "cluster.barmanObjectStoreConfig" $d | indent 2 }}
{{- else }}
wal:
compression: {{ .Values.backups.wal.compression }}
{{- if .Values.backups.wal.encryption }}
encryption: {{ .Values.backups.wal.encryption }}
{{- end }}
maxParallel: {{ .Values.backups.wal.maxParallel }}
data:
compression: {{ .Values.backups.data.compression }}
{{- if .Values.backups.data.encryption }}
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 | indent 2 }}
{{- end }}
{{- end }}
8 changes: 7 additions & 1 deletion charts/cluster/templates/scheduled-backups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ metadata:
spec:
immediate: true
schedule: {{ .schedule | quote }}
method: {{ .method }}
backupOwnerReference: {{ .backupOwnerReference }}
cluster:
name: {{ include "cluster.fullname" $context }}
{{- if (eq (include "cluster.useBarmanCloudPlugin" $context ) "true") }}
pluginConfiguration:
name: barman-cloud.cloudnative-pg.io
method: plugin
{{ else }}
method: {{ .method }}
{{- end }}
{{ end -}}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ spec:
limits:
cpu: 100m
memory: 256Mi
plugins:
- name: cnpg-i-plugin-example.my-org.io
enabled: true
parameters:
key1: value1
key2: value2
priorityClassName: mega-high
primaryUpdateStrategy: supervised
primaryUpdateMethod: restart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ cluster:
inRoles:
- pg_monitor
- pg_signal_backend
plugins:
- name: cnpg-i-plugin-example.my-org.io
enabled: true
parameters:
key1: value1
key2: value2
postgresql:
ldap:
server: 'openldap.default.svc.cluster.local'
Expand Down
21 changes: 21 additions & 0 deletions charts/cluster/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,27 @@
}
}
},
"plugins": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"isWALArchiver": {
"type": "boolean"
},
"parameters": {
"type": "object"
}
},
"required": ["name"]
}
},
"postgresGID": {
"type": "integer"
},
Expand Down
7 changes: 7 additions & 0 deletions charts/cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ cluster:
# - name: custom-queries-secret
# key: custom-queries

plugins: []
# - name: cnpg-i-plugin-example.my-org.io
# enabled: true
# parameters:
# key1: value1
# key2: value2

postgresql:
# -- PostgreSQL configuration options (postgresql.conf)
parameters: {}
Expand Down