diff --git a/charts/postgres-cluster-upgrade/Chart.yaml b/charts/postgres-cluster-upgrade/Chart.yaml new file mode 100644 index 0000000..02e2234 --- /dev/null +++ b/charts/postgres-cluster-upgrade/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: postgres-cluster-upgrade +version: 0.1.0 +description: Chart for upgrading a cloudnative-pg cluster in the same namespace +keywords: + - database + - postgres + - upgrade +sources: + - https://github.com/cloudnative-pg/cloudnative-pg +maintainers: + - name: alexlebens +icon: https://avatars.githubusercontent.com/u/100373852?s=48&v=4 +appVersion: v1.22.1 diff --git a/charts/postgres-cluster-upgrade/README.md b/charts/postgres-cluster-upgrade/README.md new file mode 100644 index 0000000..c9f0b8b --- /dev/null +++ b/charts/postgres-cluster-upgrade/README.md @@ -0,0 +1,17 @@ +## Introduction + +[CloudNative PG](https://github.com/cloudnative-pg/cloudnative-pg) + +CloudNativePG is the Kubernetes operator that covers the full lifecycle of a highly available PostgreSQL database cluster with a primary/standby architecture, using native streaming replication. + +This chart bootstraps a [CNPG](https://github.com/cloudnative-pg/cloudnative-pg) cluster on a [Kubernetes](https://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes +- Helm +- CloudNative PG Operator + +## Parameters + +See the [values files](values.yaml). diff --git a/charts/postgres-cluster-upgrade/templates/backup.yaml b/charts/postgres-cluster-upgrade/templates/backup.yaml new file mode 100644 index 0000000..60391ae --- /dev/null +++ b/charts/postgres-cluster-upgrade/templates/backup.yaml @@ -0,0 +1,17 @@ +{{- if .Values.backup.inititeBackup }} +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: "postgresql-{{ .Release.Name }}-cluster-upgrade-backup" + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: "postgresql-{{ .Release.Name }}-cluster-upgrade-backup" + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: database + app.kubernetes.io/part-of: {{ .Release.Name }} +spec: + method: barmanObjectStore + cluster: + name: "postgresql-{{ .Release.Name }}-cluster-upgrade" +{{- end }} diff --git a/charts/postgres-cluster-upgrade/templates/postgresql-cluster.yaml b/charts/postgres-cluster-upgrade/templates/postgresql-cluster.yaml new file mode 100644 index 0000000..927ed95 --- /dev/null +++ b/charts/postgres-cluster-upgrade/templates/postgresql-cluster.yaml @@ -0,0 +1,68 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: "postgresql-{{ .Release.Name }}-cluster-upgrade" + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: "postgresql-{{ .Release.Name }}-cluster-upgrade" + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: database + app.kubernetes.io/part-of: {{ .Release.Name }} +spec: + imageName: "{{ .Values.cluster.image.repository }}:{{ .Values.cluster.image.tag }}" + instances: {{ .Values.cluster.instances }} + affinity: + enablePodAntiAffinity: true + topologyKey: kubernetes.io/hostname + postgresql: + parameters: + {{- toYaml .Values.cluster.parameters | nindent 6 }} + resources: + {{- toYaml .Values.cluster.resources | nindent 4 }} + storage: + storageClass: {{ .Values.cluster.storage.data.storageClass }} + size: {{ .Values.cluster.storage.data.size }} + walStorage: + storageClass: {{ .Values.cluster.storage.wal.storageClass }} + size: {{ .Values.cluster.storage.wal.size }} + monitoring: + enablePodMonitor: true + + bootstrap: + initdb: + import: + type: {{ .Values.upgrade.importType }} + databases: + {{- toYaml .Values.upgrade.importDatabases | nindent 10 }} + source: + externalCluster: "postgresql-{{ .Release.Name }}-cluster" + externalClusters: + - name: "postgresql-{{ .Release.Name }}-cluster" + connectionParameters: + host: "postgresql-{{ .Release.Name }}-cluster-rw" + user: app + dbname: app + password: + name: "postgresql-{{ .Release.Name }}-cluster-app" + key: password + + {{- if .Values.backup.backupEnabled }} + backup: + retentionPolicy: "{{ .Values.backup.retentionPolicy }}" + barmanObjectStore: + destinationPath: "s3://{{ .Values.backup.bucket }}/{{ .Values.cluster.name }}/postgresql/{{ .Release.Name }}-cluster" + endpointURL: {{ .Values.backup.endpointURL }} + serverName: "postgresql-{{ .Release.Name }}-cluster-backup-index-{{ .Values.backup.backupIndex }}" + s3Credentials: + accessKeyId: + name: "postgresql-{{ .Release.Name }}-cluster-backup-secret" + key: ACCESS_KEY_ID + secretAccessKey: + name: "postgresql-{{ .Release.Name }}-cluster-backup-secret" + key: ACCESS_SECRET_KEY + data: + compression: {{ .Values.cluster.compression }} + wal: + compression: {{ .Values.cluster.compression }} + {{- end }} diff --git a/charts/postgres-cluster-upgrade/values.yaml b/charts/postgres-cluster-upgrade/values.yaml new file mode 100644 index 0000000..07cb1a4 --- /dev/null +++ b/charts/postgres-cluster-upgrade/values.yaml @@ -0,0 +1,37 @@ +cluster: + name: + image: + repository: ghcr.io/cloudnative-pg/postgresql + tag: 16.2 + instances: 1 + parameters: + shared_buffers: 128MB + max_slot_wal_keep_size: 2000MB + hot_standby_feedback: "on" + compression: snappy + resources: + requests: + memory: 512Mi + cpu: 100m + limits: + memory: 2Gi + cpu: 1500m + hugepages-2Mi: 512Mi + storage: + data: + storageClass: default + size: 10Gi + wal: + storageClass: default + size: 2Gi +upgrade: + importType: microservice + importDatabases: + - app +backup: + backupEnabled: true + inititeBackup: false + retentionPolicy: 3d + backupIndex: 1 + endpointURL: + bucket: