From 3eeefd3a23d97563cfbe7b86873227d688717f35 Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Wed, 5 Jul 2017 23:07:31 +0200 Subject: [PATCH] [incubator/patroni] Make nodeSelector and storage-class configurable (#880) * Make StatefulSet nodeSelector configurable * Make storage-class configurable * Add NodeSelector, StorageClass to README * Use persistentVolume pattern * Add commented-out `NodeSelector` example * update chart.yaml and requirements.lock * [incubator/patroni] add appVersion and github ids --- incubator/patroni/Chart.yaml | 7 +-- incubator/patroni/README.md | 8 +++- incubator/patroni/requirements.lock | 5 ++- .../templates/statefulset-patroni.yaml | 43 ++++++++++++++----- incubator/patroni/values.yaml | 15 ++++++- 5 files changed, 60 insertions(+), 18 deletions(-) diff --git a/incubator/patroni/Chart.yaml b/incubator/patroni/Chart.yaml index eeada4f792..caf2fc3c09 100644 --- a/incubator/patroni/Chart.yaml +++ b/incubator/patroni/Chart.yaml @@ -1,12 +1,13 @@ name: patroni description: "Highly available elephant herd: HA PostgreSQL cluster." -version: 0.2.0 +version: 0.2.1 +appVersion: 1.0-p5 home: https://github.com/zalando/patroni sources: - https://github.com/zalando/patroni - https://github.com/zalando/spilo maintainers: - - name: Team ACID @ Zalando SE + - name: alexeyklyukin email: team-acid@zalando.de - - name: Team Teapot @ Zalando SE + - name: linki email: team-teapot@zalando.de diff --git a/incubator/patroni/README.md b/incubator/patroni/README.md index 32514b57e6..20fa31e923 100644 --- a/incubator/patroni/README.md +++ b/incubator/patroni/README.md @@ -57,15 +57,21 @@ The following tables lists the configurable parameters of the patroni chart and | `Spilo.Version` | Container image tag | `1.0-p5` | | `ImagePullPolicy` | Container pull policy | `IfNotPresent` | | `Replicas` | k8s statefulset replicas | `5` | +| `NodeSelector` | nodeSelector map | Empty | | `Component` | k8s selector key | `patroni` | | `Resources.Cpu` | container requested cpu | `100m` | | `Resources.Memory` | container requested memory | `512Mi` | -| `Resources.Storage` | Persistent volume size | `1Gi` | | `Credentials.Superuser` | password for the superuser | `tea` | | `Credentials.Admin` | password for the admin user | `cola` | | `Credentials.Standby` | password for the replication user | `pinacolada` | | `Etcd.Host` | host name of etcd cluster | not used (Etcd.Discovery is used instead) | | `Etcd.Discovery` | domain name of etcd cluster | `-etcd..svc.cluster.local` | +| `persistentVolume.accessModes` | Persistent Volume access modes | `[ReadWriteOnce]` | +| `persistentVolume.annotations` | Annotations for Persistent Volume Claim` | `{}` | +| `persistentVolume.mountPath` | Persistent Volume mount root path | `/home/postgres/pgdata` | +| `persistentVolume.size` | Persistent Volume size | `2Gi` | +| `persistentVolume.storageClass` | Persistent Volume Storage Class | `volume.alpha.kubernetes.io/storage-class: default` | +| `persistentVolume.subPath` | Subdirectory of Persistent Volume to mount | `""` | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. diff --git a/incubator/patroni/requirements.lock b/incubator/patroni/requirements.lock index 62491ae92d..a8433054b6 100644 --- a/incubator/patroni/requirements.lock +++ b/incubator/patroni/requirements.lock @@ -1,9 +1,10 @@ dependencies: - condition: "" enabled: false + import-values: null name: etcd repository: https://kubernetes-charts-incubator.storage.googleapis.com/ tags: null version: 0.2.0 -digest: sha256:252c24b9a22eb235857447e235fbfa89ea9e13ebffedede26c087540315a88c5 -generated: 2017-03-24T16:20:33.196803732Z +digest: sha256:ed1ddf10ed804801e6b01afd2533dcf3ef4b0c6000513110ff78c1430934c2a1 +generated: 2017-06-08T12:51:07.354627568+02:00 diff --git a/incubator/patroni/templates/statefulset-patroni.yaml b/incubator/patroni/templates/statefulset-patroni.yaml index 2adbe7be67..96d2be1339 100644 --- a/incubator/patroni/templates/statefulset-patroni.yaml +++ b/incubator/patroni/templates/statefulset-patroni.yaml @@ -19,6 +19,12 @@ spec: chart: "{{.Chart.Name}}-{{.Chart.Version}}" component: "{{.Release.Name}}-{{.Values.Component}}" spec: + {{if .Values.NodeSelector }} + nodeSelector: + {{range $key, $value := .Values.NodeSelector}} + {{ $key }}: {{ $value | quote }} + {{end}} + {{end}} containers: - name: spilo image: "{{ .Values.Spilo.Image }}:{{ .Values.Spilo.Version }}" @@ -64,8 +70,9 @@ spec: cpu: "{{.Values.Resources.Cpu}}" memory: "{{.Values.Resources.Memory}}" volumeMounts: - - name: pgdata - mountPath: /home/postgres/pgdata + - name: storage-volume + mountPath: "{{ .Values.persistentVolume.mountPath }}" + subPath: "{{ .Values.persistentVolume.subPath }}" - mountPath: /etc/patroni name: patroni-config readOnly: true @@ -73,13 +80,27 @@ spec: - name: patroni-config secret: secretName: {{ template "fullname" . }} + volumeClaimTemplates: - - metadata: - name: pgdata - annotations: - volume.alpha.kubernetes.io/storage-class: default - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: "{{.Values.Resources.Storage}}" + - metadata: + name: storage-volume + annotations: + {{- if .Values.persistentVolume.storageClass }} + volume.beta.kubernetes.io/storage-class: "{{ .Values.persistentVolume.storageClass }}" + {{- else }} + volume.alpha.kubernetes.io/storage-class: default + {{- end }} + {{- if .Values.persistentVolume.annotations }} +{{ toYaml .Values.persistentVolume.annotations | indent 8 }} + {{- end }} + labels: + heritage: {{.Release.Service | quote }} + release: {{.Release.Name | quote }} + chart: "{{.Chart.Name}}-{{.Chart.Version}}" + component: "{{.Release.Name}}-{{.Values.Component}}" + spec: + accessModes: +{{ toYaml .Values.persistentVolume.accessModes | indent 8 }} + resources: + requests: + storage: "{{ .Values.persistentVolume.size }}" diff --git a/incubator/patroni/values.yaml b/incubator/patroni/values.yaml index 2eafa3ae82..63cca2d8e6 100644 --- a/incubator/patroni/values.yaml +++ b/incubator/patroni/values.yaml @@ -16,7 +16,10 @@ Replicas: 5 Resources: Cpu: 100m Memory: 512Mi - Storage: 1Gi + +# Node selector for Patroni pods +#NodeSelector: +# cloud.google.com/gke-nodepool: highmem-pool # Credentials used by Patroni # * more information: https://github.com/zalando/patroni/blob/master/docs/SETTINGS.rst#postgresql @@ -29,3 +32,13 @@ Credentials: Etcd: Host: # fill-in value for etcd host (etcd.default.svc.cluster.local), leave blank to use the discovery parameter Discovery: # leave blank to use vendored etcd chart + +persistentVolume: + size: 1G + storageClass: "" + subPath: "" + mountPath: "/home/postgres/data" + annotations: {} + + accessModes: + - ReadWriteOnce