mirror of
https://github.com/k8s-at-home/charts.git
synced 2025-02-03 07:49:03 +00:00
[postgres-cluster] New chart to create Postgres clusters with local storage (#739)
* first release of postgres-cluster * increase path version * Fix .Values access * Use common.labels.selectorLabels * 1.0.4 - Use .Value and not $.Value * 1.0.5 - fix schedule * 1.0.6 * 1.0.6 - Remove unneded service * 1.0.8 * 1.0.9 - fix .Value.replicaNodes * 1.0.10 * move chart * WIP * Ready for test * update readme * fix secret name * Merge branch 'postgres-cluster' * add labels * gen secret * fix labels * keep DB content * Ready to submit * rename chart Co-authored-by: angelnu <git@angelnucom> Co-authored-by: ᗪєνιη ᗷυнʟ <onedr0p@users.noreply.github.com>
This commit is contained in:
parent
64b0f9e85c
commit
8c7886aca6
1
.github/ct-install.yaml
vendored
1
.github/ct-install.yaml
vendored
@ -8,6 +8,7 @@ excluded-charts:
|
|||||||
- charts/stable/alertmanager-bot
|
- charts/stable/alertmanager-bot
|
||||||
- charts/stable/dnsmadeeasy-webhook
|
- charts/stable/dnsmadeeasy-webhook
|
||||||
- charts/stable/ser2sock
|
- charts/stable/ser2sock
|
||||||
|
- charts/stable/zalando-postgres-cluster
|
||||||
- charts/stable/zigbee2mqtt
|
- charts/stable/zigbee2mqtt
|
||||||
chart-repos:
|
chart-repos:
|
||||||
- bitnami=https://charts.bitnami.com/bitnami
|
- bitnami=https://charts.bitnami.com/bitnami
|
||||||
|
24
charts/stable/zalando-postgres-cluster/.helmignore
Normal file
24
charts/stable/zalando-postgres-cluster/.helmignore
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Patterns to ignore when building packages.
|
||||||
|
# This supports shell glob matching, relative path matching, and
|
||||||
|
# negation (prefixed with !). Only one pattern per line.
|
||||||
|
.DS_Store
|
||||||
|
# Common VCS dirs
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.bzr/
|
||||||
|
.bzrignore
|
||||||
|
.hg/
|
||||||
|
.hgignore
|
||||||
|
.svn/
|
||||||
|
# Common backup files
|
||||||
|
*.swp
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
.vscode/
|
||||||
|
# OWNERS file for Kubernetes
|
||||||
|
OWNERS
|
12
charts/stable/zalando-postgres-cluster/CHANGELOG.md
Normal file
12
charts/stable/zalando-postgres-cluster/CHANGELOG.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Changelog
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
|
||||||
|
## [1.0.0]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Initial version
|
20
charts/stable/zalando-postgres-cluster/Chart.yaml
Normal file
20
charts/stable/zalando-postgres-cluster/Chart.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
version: 1.0.0
|
||||||
|
description: Creates a postgres cluster using the Zalando Postgres operator and local storage
|
||||||
|
name: zalando-postgres-cluster
|
||||||
|
appVersion: 1.0.0
|
||||||
|
keywords:
|
||||||
|
- postgres
|
||||||
|
- operator
|
||||||
|
- zalando
|
||||||
|
home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/zalando-postgres-cluster
|
||||||
|
icon: https://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Postgresql_elephant.svg/1200px-Postgresql_elephant.svg.png
|
||||||
|
sources:
|
||||||
|
- https://github.com/zalando/postgres-operator
|
||||||
|
maintainers:
|
||||||
|
- name: angelnu
|
||||||
|
email: git@angelnu.com
|
||||||
|
dependencies:
|
||||||
|
- name: common
|
||||||
|
repository: https://library-charts.k8s-at-home.com
|
||||||
|
version: 2.1.0
|
142
charts/stable/zalando-postgres-cluster/README.md
Normal file
142
charts/stable/zalando-postgres-cluster/README.md
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
# zalando-postgres-cluster
|
||||||
|
|
||||||
|
![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square)
|
||||||
|
|
||||||
|
Creates a postgres cluster using the Zalando Postgres operator and local storage
|
||||||
|
|
||||||
|
**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new/choose)**
|
||||||
|
|
||||||
|
## Source Code
|
||||||
|
|
||||||
|
* <https://github.com/zalando/postgres-operator>
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
| Repository | Name | Version |
|
||||||
|
|------------|------|---------|
|
||||||
|
| https://library-charts.k8s-at-home.com | common | 2.1.0 |
|
||||||
|
|
||||||
|
## TL;DR
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm repo add k8s-at-home https://k8s-at-home.com/charts/
|
||||||
|
helm repo update
|
||||||
|
helm install zalando-postgres-cluster k8s-at-home/zalando-postgres-cluster
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installing the Chart
|
||||||
|
|
||||||
|
To install the chart with the release name `zalando-postgres-cluster`
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm install zalando-postgres-cluster k8s-at-home/zalando-postgres-cluster
|
||||||
|
```
|
||||||
|
|
||||||
|
## Uninstalling the Chart
|
||||||
|
|
||||||
|
To uninstall the `zalando-postgres-cluster` deployment
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm uninstall zalando-postgres-cluster
|
||||||
|
```
|
||||||
|
|
||||||
|
The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values.
|
||||||
|
Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common).
|
||||||
|
|
||||||
|
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm install zalando-postgres-cluster \
|
||||||
|
--set env.TZ="America/New York" \
|
||||||
|
k8s-at-home/zalando-postgres-cluster
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart.
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm install zalando-postgres-cluster k8s-at-home/zalando-postgres-cluster -f values.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Custom configuration
|
||||||
|
|
||||||
|
This chart is a wrapper for the [Zalando postgres operator](https://github.com/zalando/postgres-operator) to create
|
||||||
|
a high available Postgres cluster using nodes local storage.
|
||||||
|
|
||||||
|
Features added by this wrapper:
|
||||||
|
- creates an storage class using local storage in the nodes specified in `persistentVolumes.replicaNodes`. These replicas survive
|
||||||
|
a tear-down and tear-up of the cluster.
|
||||||
|
- (optional) does sql dumps to an existing PVC with K8S cronjobs. The Operator only supports backups to cloud, not NFS PVC for example.
|
||||||
|
- Define the password for the DB so that it can be used accross tear-down and tear-up of the cluster.
|
||||||
|
|
||||||
|
## Values
|
||||||
|
|
||||||
|
**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common)
|
||||||
|
|
||||||
|
| Key | Type | Default | Description |
|
||||||
|
|-----|------|---------|-------------|
|
||||||
|
| controllerType | string | `""` | |
|
||||||
|
| dumpBackup.existingClaim | string | `nil` | |
|
||||||
|
| dumpBackup.image.pullPolicy | string | `"IfNotPresent"` | |
|
||||||
|
| dumpBackup.image.repository | string | `"postgres"` | |
|
||||||
|
| dumpBackup.image.tag | string | `"latest"` | |
|
||||||
|
| dumpBackup.resources.requests.cpu | string | `"5m"` | |
|
||||||
|
| dumpBackup.resources.requests.memory | string | `"10Mi"` | |
|
||||||
|
| dumpBackup.schedule | string | `"@daily"` | Backup schedule for postgres dumps |
|
||||||
|
| dumpBackup.subpath | string | `nil` | Persistent volume claim subpath for the backups @default: <subpathPrefix/<release-name> |
|
||||||
|
| dumpBackup.subpathPrefix | string | `"backup/db"` | Persistent volume claim subpath prefix for the backups |
|
||||||
|
| persistentVolumes.accessModes[0] | string | `"ReadWriteOnce"` | |
|
||||||
|
| persistentVolumes.annotations | object | `{}` | |
|
||||||
|
| persistentVolumes.hostPath | string | `nil` | Local path for the persistent volumes @default: <hostPathPrefix/<release-name> |
|
||||||
|
| persistentVolumes.hostPathPrefix | string | `"/run/db"` | Local prefix for persistent volumes NOTE: The default is in tempfs - you should change to a persistent place for production!!! |
|
||||||
|
| persistentVolumes.labels | object | `{}` | |
|
||||||
|
| persistentVolumes.reclaimPolicy | string | `"Retain"` | persistentVolumeReclaimPolicy for the persistent volumes Recicle will delete content once DB is deleted while Retain (default) will keep it. |
|
||||||
|
| persistentVolumes.replicaNodes | list | `["node1.example.com","node2.example.com"]` | Replica nodes Must set with at least 2 nodes for the cluster to be highly available |
|
||||||
|
| postgresql.databases | object | `{"postgres":"postgres"}` | databases to create and their user |
|
||||||
|
| postgresql.numberOfInstances | string | `nil` | Number of replicas It will be automatically set with the number of replicaNodes so any values set here are ignored. |
|
||||||
|
| postgresql.postgresql.version | string | `"13"` | Postgres version to deploy - see which versions are supported by the operator |
|
||||||
|
| postgresql.teamId | string | `nil` | team Id for the DB cluster |
|
||||||
|
| postgresql.users | object | `{"postgres":["superuser","createdb"]}` | DB users to create (see operator) |
|
||||||
|
| postgresql.volume.size | string | `"1Gi"` | Size of the persistance volume to allocate |
|
||||||
|
| postgresql.volume.storageClass | string | `nil` | Name of the storage class |
|
||||||
|
| service.enabled | bool | `false` | |
|
||||||
|
| superuser.password | string | `nil` | Superuser password |
|
||||||
|
| superuser.secret | string | `nil` | Superuser k8s secret name. It must match the patter used by the operator |
|
||||||
|
| superuser.user | string | `nil` | Superuser user used for cronjobs |
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/commonREADME.md#Changelog).
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
### [1.0.0]
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
|
||||||
|
- N/A
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
|
||||||
|
- N/A
|
||||||
|
|
||||||
|
#### Removed
|
||||||
|
|
||||||
|
- N/A
|
||||||
|
|
||||||
|
[1.0.0]: #1.0.0
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
- See the [Docs](https://docs.k8s-at-home.com/our-helm-charts/getting-started/)
|
||||||
|
- Open an [issue](https://github.com/k8s-at-home/charts/issues/new/choose)
|
||||||
|
- Ask a [question](https://github.com/k8s-at-home/organization/discussions)
|
||||||
|
- Join our [Discord](https://discord.gg/sTMX7Vh) community
|
||||||
|
|
||||||
|
----------------------------------------------
|
||||||
|
Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0)
|
145
charts/stable/zalando-postgres-cluster/README.md.gotmpl
Normal file
145
charts/stable/zalando-postgres-cluster/README.md.gotmpl
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
{{- define "custom.repository.organization" -}}
|
||||||
|
k8s-at-home
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.repository.url" -}}
|
||||||
|
https://github.com/k8s-at-home/charts
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.helm.url" -}}
|
||||||
|
https://k8s-at-home.com/charts/
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.helm.path" -}}
|
||||||
|
{{ template "custom.repository.organization" . }}/{{ template "chart.name" . }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.notes" -}}
|
||||||
|
**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new/choose)**
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.requirements" -}}
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
{{ template "chart.kubeVersionLine" . }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.dependencies" -}}
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
{{ template "chart.requirementsTable" . }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.install.tldr" -}}
|
||||||
|
## TL;DR
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm repo add {{ template "custom.repository.organization" . }} {{ template "custom.helm.url" . }}
|
||||||
|
helm repo update
|
||||||
|
helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }}
|
||||||
|
```
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.install" -}}
|
||||||
|
## Installing the Chart
|
||||||
|
|
||||||
|
To install the chart with the release name `{{ template "chart.name" . }}`
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }}
|
||||||
|
```
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.uninstall" -}}
|
||||||
|
## Uninstalling the Chart
|
||||||
|
|
||||||
|
To uninstall the `{{ template "chart.name" . }}` deployment
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm uninstall {{ template "chart.name" . }}
|
||||||
|
```
|
||||||
|
|
||||||
|
The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release.
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.configuration.header" -}}
|
||||||
|
## Configuration
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.configuration.readValues" -}}
|
||||||
|
Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values.
|
||||||
|
Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common).
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.configuration.example.set" -}}
|
||||||
|
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm install {{ template "chart.name" . }} \
|
||||||
|
--set env.TZ="America/New York" \
|
||||||
|
{{ template "custom.helm.path" . }}
|
||||||
|
```
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.configuration.example.file" -}}
|
||||||
|
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart.
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }} -f values.yaml
|
||||||
|
```
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.valuesSection" -}}
|
||||||
|
## Values
|
||||||
|
|
||||||
|
**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common)
|
||||||
|
|
||||||
|
{{ template "chart.valuesTable" . }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.support" -}}
|
||||||
|
## Support
|
||||||
|
|
||||||
|
- See the [Docs](https://docs.k8s-at-home.com/our-helm-charts/getting-started/)
|
||||||
|
- Open an [issue](https://github.com/k8s-at-home/charts/issues/new/choose)
|
||||||
|
- Ask a [question](https://github.com/k8s-at-home/organization/discussions)
|
||||||
|
- Join our [Discord](https://discord.gg/sTMX7Vh) community
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{ template "chart.header" . }}
|
||||||
|
|
||||||
|
{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}
|
||||||
|
|
||||||
|
{{ template "chart.description" . }}
|
||||||
|
|
||||||
|
{{ template "custom.notes" . }}
|
||||||
|
|
||||||
|
{{ template "chart.sourcesSection" . }}
|
||||||
|
|
||||||
|
{{ template "custom.requirements" . }}
|
||||||
|
|
||||||
|
{{ template "custom.dependencies" . }}
|
||||||
|
|
||||||
|
{{ template "custom.install.tldr" . }}
|
||||||
|
|
||||||
|
{{ template "custom.install" . }}
|
||||||
|
|
||||||
|
{{ template "custom.uninstall" . }}
|
||||||
|
|
||||||
|
{{ template "custom.configuration.header" . }}
|
||||||
|
|
||||||
|
{{ template "custom.configuration.readValues" . }}
|
||||||
|
|
||||||
|
{{ template "custom.configuration.example.set" . }}
|
||||||
|
|
||||||
|
{{ template "custom.configuration.example.file" . }}
|
||||||
|
|
||||||
|
{{ template "custom.custom.configuration" . }}
|
||||||
|
|
||||||
|
{{ template "custom.valuesSection" . }}
|
||||||
|
|
||||||
|
{{ template "custom.changelog" . }}
|
||||||
|
|
||||||
|
{{ template "custom.support" . }}
|
||||||
|
|
||||||
|
{{ template "helm-docs.versionFooter" . }}
|
@ -0,0 +1,27 @@
|
|||||||
|
{{- define "custom.changelog.header" -}}
|
||||||
|
## Changelog
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.changelog" -}}
|
||||||
|
{{ template "custom.changelog.header" . }}
|
||||||
|
|
||||||
|
All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/commonREADME.md#Changelog).
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
### [1.0.0]
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
|
||||||
|
- N/A
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
|
||||||
|
- N/A
|
||||||
|
|
||||||
|
#### Removed
|
||||||
|
|
||||||
|
- N/A
|
||||||
|
|
||||||
|
[1.0.0]: #1.0.0
|
||||||
|
{{- end -}}
|
@ -0,0 +1,17 @@
|
|||||||
|
{{- define "custom.custom.configuration.header" -}}
|
||||||
|
## Custom configuration
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "custom.custom.configuration" -}}
|
||||||
|
{{ template "custom.custom.configuration.header" . }}
|
||||||
|
|
||||||
|
This chart is a wrapper for the [Zalando postgres operator](https://github.com/zalando/postgres-operator) to create
|
||||||
|
a high available Postgres cluster using nodes local storage.
|
||||||
|
|
||||||
|
Features added by this wrapper:
|
||||||
|
- creates an storage class using local storage in the nodes specified in `persistentVolumes.replicaNodes`. These replicas survive
|
||||||
|
a tear-down and tear-up of the cluster.
|
||||||
|
- (optional) does sql dumps to an existing PVC with K8S cronjobs. The Operator only supports backups to cloud, not NFS PVC for example.
|
||||||
|
- Define the password for the DB so that it can be used accross tear-down and tear-up of the cluster.
|
||||||
|
|
||||||
|
{{- end -}}
|
@ -0,0 +1,56 @@
|
|||||||
|
{{- if .Values.dumpBackup.existingClaim -}}
|
||||||
|
# ------------------- CronJob ------------------- #
|
||||||
|
apiVersion: batch/v1beta1
|
||||||
|
kind: CronJob
|
||||||
|
metadata:
|
||||||
|
name: {{ include "common.names.fullname" . }}-backup
|
||||||
|
labels:
|
||||||
|
{{- include "common.labels" . | nindent 4 }}
|
||||||
|
spec:
|
||||||
|
schedule: {{ .Values.dumpBackup.schedule | quote }}
|
||||||
|
concurrencyPolicy: Replace
|
||||||
|
jobTemplate:
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
name: {{ include "common.names.fullname" . }}-backup
|
||||||
|
labels:
|
||||||
|
{{- include "common.labels.selectorLabels" . | nindent 12 }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: backup
|
||||||
|
image: "{{ .Values.dumpBackup.image.repository}}:{{ .Values.dumpBackup.image.tag}}"
|
||||||
|
imagePullPolicy: {{ .Values.dumpBackup.image.imagePullPolicy}}
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -ce
|
||||||
|
- |
|
||||||
|
echo "$(date) - Start dump"
|
||||||
|
pg_dumpall > /backup/new && mv /backup/new /backup/backup
|
||||||
|
echo "$(date) - End dump"
|
||||||
|
ls -lh /backup
|
||||||
|
resources:
|
||||||
|
{{- .Values.dumpBackup.resources | toYaml | nindent 16 }}
|
||||||
|
env:
|
||||||
|
- name: PGHOST
|
||||||
|
value: {{ include "zalando-postgres-cluster.db" . }}
|
||||||
|
- name: PGUSER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ include "zalando-postgres-cluster.superuser_secret" . }}
|
||||||
|
key: username
|
||||||
|
- name: PGPASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ include "zalando-postgres-cluster.superuser_secret" . }}
|
||||||
|
key: password
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /backup
|
||||||
|
name: backup-volume
|
||||||
|
subPath: {{ include "zalando-postgres-cluster.backupPVCSubpath" . }}
|
||||||
|
restartPolicy: OnFailure
|
||||||
|
volumes:
|
||||||
|
- name: backup-volume
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: {{ .Values.dumpBackup.existingClaim }}
|
||||||
|
{{- end -}}
|
37
charts/stable/zalando-postgres-cluster/templates/common.yaml
Normal file
37
charts/stable/zalando-postgres-cluster/templates/common.yaml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{{/* Make sure all variables are set properly */}}
|
||||||
|
{{- include "common.values.setup" . }}
|
||||||
|
|
||||||
|
{{- define "zalando-postgres-cluster.db" -}}
|
||||||
|
{{- include "common.names.fullname" .|lower -}}-postgres
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "zalando-postgres-cluster.superuser" -}}
|
||||||
|
{{- default (keys .Values.postgresql.users | first ) .Values.superuser.user -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "zalando-postgres-cluster.superuser_secret" -}}
|
||||||
|
{{ default (printf "%s.%s.credentials.postgresql.acid.zalan.do" (include "zalando-postgres-cluster.superuser" .) (include "zalando-postgres-cluster.db" .)) .Values.superuser.secret }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "zalando-postgres-cluster.superuser_password" -}}
|
||||||
|
{{- default (randAlphaNum 50) .Values.superuser.password -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "zalando-postgres-cluster.storageClass" -}}
|
||||||
|
{{- default (include "common.names.fullname" .|lower ) .Values.postgresql.volume.storageClass -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "zalando-postgres-cluster.pvName" -}}
|
||||||
|
{{- include "common.names.fullname" .|lower -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "zalando-postgres-cluster.localPath" -}}
|
||||||
|
{{- default (printf "%s/%s" .Values.persistentVolumes.hostPathPrefix (include "common.names.fullname" .)) .Values.persistentVolumes.hostPath -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "zalando-postgres-cluster.backupPVCSubpath" -}}
|
||||||
|
{{- default (printf "%s/%s" .Values.dumpBackup.subpathPrefix (include "common.names.fullname" .)) .Values.dumpBackup.subpath -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/* Render the templates */}}
|
||||||
|
{{ include "common.all" . }}
|
18
charts/stable/zalando-postgres-cluster/templates/db.yaml
Normal file
18
charts/stable/zalando-postgres-cluster/templates/db.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{{- if not .Values.postgresql.volume.storageClass -}}
|
||||||
|
{{- $_ := set .Values.postgresql.volume "storageClass" (include "zalando-postgres-cluster.storageClass" .) }}
|
||||||
|
{{- end}}
|
||||||
|
|
||||||
|
{{- if not .Values.postgresql.teamId -}}
|
||||||
|
{{- $_ := set .Values.postgresql "teamId" (include "common.names.fullname" .) }}
|
||||||
|
{{- end}}
|
||||||
|
|
||||||
|
{{- $_ := set .Values.postgresql "numberOfInstances" (len $.Values.persistentVolumes.replicaNodes) }}
|
||||||
|
|
||||||
|
apiVersion: "acid.zalan.do/v1"
|
||||||
|
kind: postgresql
|
||||||
|
metadata:
|
||||||
|
name: {{ include "zalando-postgres-cluster.db" . }}
|
||||||
|
labels:
|
||||||
|
{{- include "common.labels" . | nindent 4 }}
|
||||||
|
spec:
|
||||||
|
{{- .Values.postgresql | toYaml | nindent 2 }}
|
@ -0,0 +1,40 @@
|
|||||||
|
{{- range $i:= untilStep 0 (len $.Values.persistentVolumes.replicaNodes) 1 -}}
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: {{ include "zalando-postgres-cluster.pvName" $ }}-{{ $i }}
|
||||||
|
labels:
|
||||||
|
{{- include "common.labels" $ | nindent 4 }}
|
||||||
|
{{- if gt (len $.Values.persistentVolumes.labels) 0 }}
|
||||||
|
{{- $.Values.persistentVolumes.labels | toYaml | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if gt (len $.Values.persistentVolumes.annotations) 0 }}
|
||||||
|
annotations:
|
||||||
|
{{- $.Values.persistentVolumes.annotations | toYaml | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
finalizers:
|
||||||
|
- kubernetes.io/pv-protection
|
||||||
|
spec:
|
||||||
|
storageClassName: {{ include "zalando-postgres-cluster.storageClass" $ }}
|
||||||
|
volumeMode: Filesystem
|
||||||
|
capacity:
|
||||||
|
storage: "{{ $.Values.postgresql.volume.size }}"
|
||||||
|
accessModes:
|
||||||
|
{{- $.Values.persistentVolumes.accessModes | toYaml | nindent 4 }}
|
||||||
|
hostPath:
|
||||||
|
path: {{ include "zalando-postgres-cluster.localPath" $ }}
|
||||||
|
#Since it is created directly this does not delete it from cluster
|
||||||
|
persistentVolumeReclaimPolicy: "{{ $.Values.persistentVolumes.reclaimPolicy }}"
|
||||||
|
|
||||||
|
{{- $e := index $.Values.persistentVolumes.replicaNodes $i }}
|
||||||
|
nodeAffinity:
|
||||||
|
required:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- {{ $e }}
|
||||||
|
|
||||||
|
{{ end }}
|
16
charts/stable/zalando-postgres-cluster/templates/secret.yaml
Normal file
16
charts/stable/zalando-postgres-cluster/templates/secret.yaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
{{- include "common.labels" . | nindent 4 }}
|
||||||
|
application: spilo
|
||||||
|
team: {{ include "common.names.fullname" . }}
|
||||||
|
# xref: https://github.com/helm/helm/issues/3053
|
||||||
|
# xref: https://github.com/helm/helm/pull/5290
|
||||||
|
"helm.sh/hook": "pre-install"
|
||||||
|
"helm.sh/hook-delete-policy": "before-hook-creation"
|
||||||
|
name: {{ include "zalando-postgres-cluster.superuser_secret" . }}
|
||||||
|
stringData:
|
||||||
|
username: {{ include "zalando-postgres-cluster.superuser" . }}
|
||||||
|
password: {{ include "zalando-postgres-cluster.superuser_password" . }}
|
||||||
|
type: Opaque
|
@ -0,0 +1,10 @@
|
|||||||
|
apiVersion: storage.k8s.io/v1
|
||||||
|
kind: StorageClass
|
||||||
|
metadata:
|
||||||
|
name: {{ include "zalando-postgres-cluster.storageClass" . }}
|
||||||
|
labels:
|
||||||
|
{{- include "common.labels" . | nindent 4 }}
|
||||||
|
annotations:
|
||||||
|
provisioner: kubernetes.io/no-provisioner
|
||||||
|
reclaimPolicy: Delete
|
||||||
|
volumeBindingMode: WaitForFirstConsumer
|
@ -0,0 +1,42 @@
|
|||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: "{{ include "common.names.fullname" .|lower }}-test-db"
|
||||||
|
labels:
|
||||||
|
{{ include "common.labels" . | nindent 4 }}
|
||||||
|
annotations:
|
||||||
|
"helm.sh/hook": test-success
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
name: "{{ include "common.names.fullname" .|lower }}-test-db"
|
||||||
|
labels:
|
||||||
|
{{ include "common.labels" . | nindent 8 }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: psql
|
||||||
|
image: "{{ .Values.dumpBackup.image.repository}}:{{ .Values.dumpBackup.image.tag}}"
|
||||||
|
imagePullPolicy: {{ .Values.dumpBackup.image.imagePullPolicy}}
|
||||||
|
command: ['sh']
|
||||||
|
args:
|
||||||
|
- "-ecx"
|
||||||
|
- |
|
||||||
|
echo ";"|psql
|
||||||
|
|
||||||
|
env:
|
||||||
|
- name: PGHOST
|
||||||
|
value: {{ include "zalando-postgres-cluster.db" . | quote }}
|
||||||
|
- name: PGSSLMODE
|
||||||
|
value: require
|
||||||
|
- name: PGUSER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ include "zalando-postgres-cluster.superuser_secret" . }}
|
||||||
|
key: username
|
||||||
|
- name: PGPASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ include "zalando-postgres-cluster.superuser_secret" . }}
|
||||||
|
key: password
|
||||||
|
restartPolicy: Never
|
||||||
|
|
83
charts/stable/zalando-postgres-cluster/values.yaml
Normal file
83
charts/stable/zalando-postgres-cluster/values.yaml
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
# See all operator values at https://github.com/zalando/postgres-operator/blob/master/docs/reference/cluster_manifest.md
|
||||||
|
postgresql:
|
||||||
|
# -- team Id for the DB cluster
|
||||||
|
teamId:
|
||||||
|
volume:
|
||||||
|
# -- Size of the persistance volume to allocate
|
||||||
|
size: "1Gi"
|
||||||
|
# -- (string) Name of the storage class
|
||||||
|
# @default -- chart fullname
|
||||||
|
storageClass:
|
||||||
|
# -- Number of replicas
|
||||||
|
# It will be automatically set with the number of replicaNodes so any values set here are ignored.
|
||||||
|
numberOfInstances:
|
||||||
|
# -- DB users to create (see operator)
|
||||||
|
users:
|
||||||
|
postgres:
|
||||||
|
- superuser
|
||||||
|
- createdb
|
||||||
|
|
||||||
|
# -- databases to create and their user
|
||||||
|
databases:
|
||||||
|
postgres: postgres
|
||||||
|
postgresql:
|
||||||
|
# -- Postgres version to deploy - see which versions are supported by the operator
|
||||||
|
version: "13"
|
||||||
|
|
||||||
|
superuser:
|
||||||
|
# -- Superuser user used for cronjobs
|
||||||
|
# @default -- first user in postgresql.users
|
||||||
|
user:
|
||||||
|
# -- Superuser password
|
||||||
|
# @default -- randomly generated on first install of the chart
|
||||||
|
password:
|
||||||
|
# -- Superuser k8s secret name. It must match the patter used by the operator
|
||||||
|
# @default -- <user>.<db name>.credentials.postgresql.acid.zalan.do
|
||||||
|
secret:
|
||||||
|
|
||||||
|
persistentVolumes:
|
||||||
|
# -- Local prefix for persistent volumes
|
||||||
|
# NOTE: The default is in tempfs - you should change to a persistent place for production!!!
|
||||||
|
hostPathPrefix: "/run/db"
|
||||||
|
# -- Local path for the persistent volumes
|
||||||
|
# @default: <hostPathPrefix/<release-name>
|
||||||
|
hostPath:
|
||||||
|
# -- persistentVolumeReclaimPolicy for the persistent volumes
|
||||||
|
# Recicle will delete content once DB is deleted while Retain (default) will keep it.
|
||||||
|
reclaimPolicy: Retain
|
||||||
|
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
# -- Replica nodes
|
||||||
|
# Must set with at least 2 nodes for the cluster to be highly available
|
||||||
|
replicaNodes:
|
||||||
|
- node1.example.com
|
||||||
|
- node2.example.com
|
||||||
|
labels: {}
|
||||||
|
# foo: a
|
||||||
|
annotations: {}
|
||||||
|
|
||||||
|
|
||||||
|
dumpBackup:
|
||||||
|
# Enable backups to a PVC
|
||||||
|
existingClaim:
|
||||||
|
# -- Backup schedule for postgres dumps
|
||||||
|
schedule: "@daily"
|
||||||
|
# -- Persistent volume claim subpath prefix for the backups
|
||||||
|
subpathPrefix: "backup/db"
|
||||||
|
# -- Persistent volume claim subpath for the backups
|
||||||
|
# @default: <subpathPrefix/<release-name>
|
||||||
|
subpath:
|
||||||
|
image:
|
||||||
|
repository: postgres
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
tag: latest
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "10Mi"
|
||||||
|
cpu: "5m"
|
||||||
|
|
||||||
|
# Dissable Deployment and Service
|
||||||
|
controllerType: ""
|
||||||
|
service:
|
||||||
|
enabled: false
|
Loading…
Reference in New Issue
Block a user