From a399acce253fc773db5b8d6f6b0e242d166c2345 Mon Sep 17 00:00:00 2001 From: Alice <31040183+alice-sawatzky@users.noreply.github.com> Date: Tue, 16 Jul 2019 03:25:23 -0500 Subject: [PATCH] [incubator/patroni] fix affinity type (#14797) * [incubator/patroni] make affinity a Map instead of a String This brings it in line with community standards for charts Signed-off-by: Alice Sawatzky * [incubator/patroni] minor version bump Signed-off-by: Alice Sawatzky * [incubator/patroni] fix default affinity value Signed-off-by: Alice Sawatzky * [incubator/patroni] add tests for different affinity values Signed-off-by: Alice Sawatzky * [incubator/patroni/ci/custom-affinity-values.yaml] fix spacing Signed-off-by: Alice Sawatzky * [incubator/patroni] simplify by adding affinityTemplate Signed-off-by: Alice Sawatzky --- incubator/patroni/Chart.yaml | 2 +- incubator/patroni/README.md | 5 +++-- incubator/patroni/templates/statefulset-patroni.yaml | 7 ++++++- incubator/patroni/values.yaml | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/incubator/patroni/Chart.yaml b/incubator/patroni/Chart.yaml index 8b4c585335..6aab82cbde 100644 --- a/incubator/patroni/Chart.yaml +++ b/incubator/patroni/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 name: patroni description: 'Highly available elephant herd: HA PostgreSQL cluster.' -version: 0.12.1 +version: 0.13.0 appVersion: 1.4-p16 home: https://github.com/zalando/patroni sources: diff --git a/incubator/patroni/README.md b/incubator/patroni/README.md index 5025b54b12..667433eef8 100644 --- a/incubator/patroni/README.md +++ b/incubator/patroni/README.md @@ -69,7 +69,7 @@ The following table lists the configurable parameters of the patroni chart and t | `credentials.admin` | Password of the admin | `cola` | | `credentials.standby` | Password of the replication user | `pinacolada` | | `kubernetes.dcs.enable` | Using Kubernetes as DCS | `true` | -| `kubernetes.configmaps.enable` | Using Kubernetes configmaps instead of endpoints | `false` | +| `kubernetes.configmaps.enable` | Using Kubernetes configmaps instead of endpoints | `false` | | `etcd.enable` | Using etcd as DCS | `false` | | `etcd.deployChart` | Deploy etcd chart | `false` | | `etcd.host` | Host name of etcd cluster | `nil` | @@ -88,7 +88,8 @@ The following table lists the configurable parameters of the patroni chart and t | `resources` | Any resources you wish to assign to the pod | `{}` | | `nodeSelector` | Node label to use for scheduling | `{}` | | `tolerations` | List of node taints to tolerate | `[]` | -| `affinity` | Affinity settings | Preferred on hostname | +| `affinityTemplate` | A template string to use to generate the affinity settings | Anti-affinity preferred on hostname | +| `affinity` | Affinity settings. Overrides `affinityTemplate` if set. | `{}` | | `persistentVolume.accessModes` | Persistent Volume access modes | `[ReadWriteOnce]` | | `persistentVolume.annotations` | Annotations for Persistent Volume Claim` | `{}` | | `persistentVolume.mountPath` | Persistent Volume mount root path | `/home/postgres/pgdata` | diff --git a/incubator/patroni/templates/statefulset-patroni.yaml b/incubator/patroni/templates/statefulset-patroni.yaml index 3cd611db3b..41f37c7e9f 100644 --- a/incubator/patroni/templates/statefulset-patroni.yaml +++ b/incubator/patroni/templates/statefulset-patroni.yaml @@ -141,8 +141,13 @@ spec: tolerations: {{ toYaml . | indent 8 }} {{- end }} + {{- if .Values.affinity }} affinity: -{{ tpl .Values.affinity . | indent 8 }} +{{ .Values.affinity | toYaml | indent 8 }} + {{- else if .Values.affinityTemplate }} + affinity: +{{ tpl .Values.affinityTemplate . | indent 8 }} + {{- end }} volumes: - name: patroni-config secret: diff --git a/incubator/patroni/values.yaml b/incubator/patroni/values.yaml index e6f4f04c29..149e3f315b 100644 --- a/incubator/patroni/values.yaml +++ b/incubator/patroni/values.yaml @@ -90,7 +90,7 @@ nodeSelector: {} tolerations: [] # https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity -affinity: | +affinityTemplate: | podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 @@ -100,6 +100,7 @@ affinity: | matchLabels: app: {{ template "patroni.name" . }} release: {{ .Release.Name | quote }} +affinity: {} rbac: # Specifies whether RBAC resources should be created