From 10b1d082c3bf8bb040691b096aa6bd51420f2ca1 Mon Sep 17 00:00:00 2001 From: Andrey Voronkov Date: Sat, 26 Jan 2019 19:11:06 +0300 Subject: [PATCH] Enable Kubernetes API for DCS. (#8112) * Ability to use Kubernetes for DCS. Update spilo image. Signed-off-by: Andrey Voronkov * Update README and image version. Signed-off-by: Andrey Voronkov * Turn on K8s based DCS on by default. Turn off etcd. Signed-off-by: Andrey Voronkov * Update README Signed-off-by: Andrey Voronkov * fix pvc claim for patronic and make it optional Signed-off-by: Paul Czarkowski --- incubator/patroni/Chart.yaml | 4 +-- incubator/patroni/README.md | 11 +++--- incubator/patroni/requirements.lock | 6 ++-- incubator/patroni/requirements.yaml | 2 +- incubator/patroni/templates/role-patroni.yaml | 34 +++++++++++++++++-- .../templates/statefulset-patroni.yaml | 18 ++++++++++ incubator/patroni/values.yaml | 14 +++++--- 7 files changed, 71 insertions(+), 18 deletions(-) diff --git a/incubator/patroni/Chart.yaml b/incubator/patroni/Chart.yaml index 1a1d69f45a..586c9aab68 100644 --- a/incubator/patroni/Chart.yaml +++ b/incubator/patroni/Chart.yaml @@ -1,7 +1,7 @@ name: patroni description: 'Highly available elephant herd: HA PostgreSQL cluster.' -version: 0.10.0 -appVersion: 1.4-p7 +version: 0.11.0 +appVersion: 1.4-p16 home: https://github.com/zalando/patroni sources: - https://github.com/zalando/patroni diff --git a/incubator/patroni/README.md b/incubator/patroni/README.md index 309f0432b8..5025b54b12 100644 --- a/incubator/patroni/README.md +++ b/incubator/patroni/README.md @@ -14,7 +14,6 @@ This directory contains a Kubernetes chart to deploy a five node [Patroni](https ## Todo * Make namespace configurable -* K8S native DCS ## Chart Details This chart will do the following: @@ -63,14 +62,16 @@ The following table lists the configurable parameters of the patroni chart and t | `nameOverride` | Override the name of the chart | `nil` | | `fullnameOverride` | Override the fullname of the chart | `nil` | | `replicaCount` | Amount of pods to spawn | `5` | -| `image.repository` | The image to pull | `registry.opensource.zalan.do/acid/spilo-10` | -| `image.tag` | The version of the image to pull | `1.4-p6` | +| `image.repository` | The image to pull | `registry.opensource.zalan.do/acid/spilo-10` | +| `image.tag` | The version of the image to pull | `1.4-p16` | | `image.pullPolicy` | The pull policy | `IfNotPresent` | | `credentials.superuser` | Password of the superuser | `tea` | | `credentials.admin` | Password of the admin | `cola` | | `credentials.standby` | Password of the replication user | `pinacolada` | -| `etcd.enable` | Using etcd as DCS | `true` | -| `etcd.deployChart` | Deploy etcd chart | `true` | +| `kubernetes.dcs.enable` | Using Kubernetes as DCS | `true` | +| `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` | | `etcd.discovery` | Domain name of etcd cluster | `nil` | | `zookeeper.enable` | Using ZooKeeper as DCS | `false` | diff --git a/incubator/patroni/requirements.lock b/incubator/patroni/requirements.lock index 77b5ba2ef2..bbcd925378 100644 --- a/incubator/patroni/requirements.lock +++ b/incubator/patroni/requirements.lock @@ -1,9 +1,9 @@ dependencies: - name: etcd repository: https://kubernetes-charts-incubator.storage.googleapis.com/ - version: 0.3.9 + version: 0.6.2 - name: zookeeper repository: https://kubernetes-charts-incubator.storage.googleapis.com/ version: 1.0.0 -digest: sha256:2cba87a0a23df25d78a0908f4ce9ae27acb0530a5aac430f19a2dbc0778aa4b2 -generated: 2018-05-14T14:49:09.901956221+02:00 +digest: sha256:b65cce5b82c3c9971b7551e923e03a9253bcb9771386086a4e75992a9682ca03 +generated: 2019-01-26T09:48:28.627975698-06:00 diff --git a/incubator/patroni/requirements.yaml b/incubator/patroni/requirements.yaml index 4f2db1b56d..72555f2605 100644 --- a/incubator/patroni/requirements.yaml +++ b/incubator/patroni/requirements.yaml @@ -1,6 +1,6 @@ dependencies: - name: etcd - version: 0.3.9 + version: 0.6.2 repository: https://kubernetes-charts-incubator.storage.googleapis.com/ condition: etcd.deployChart - name: zookeeper diff --git a/incubator/patroni/templates/role-patroni.yaml b/incubator/patroni/templates/role-patroni.yaml index 2a289bf181..3341826b1b 100644 --- a/incubator/patroni/templates/role-patroni.yaml +++ b/incubator/patroni/templates/role-patroni.yaml @@ -9,7 +9,35 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} rules: - - apiGroups: [""] - resources: ["endpoints", "pods"] - verbs: ["patch"] +- apiGroups: [""] + resources: ["configmaps"] + verbs: + - create + - get + - list + - patch + - update + - watch + # delete is required only for 'patronictl remove' + - delete +- apiGroups: [""] + resources: ["endpoints"] + verbs: + - create + - get + - patch + - update + # the following three privileges are necessary only when using endpoints + - list + - watch + # delete is required only for for 'patronictl remove' + - delete +- apiGroups: [""] + resources: ["pods"] + verbs: + - get + - list + - patch + - update + - watch {{- end }} diff --git a/incubator/patroni/templates/statefulset-patroni.yaml b/incubator/patroni/templates/statefulset-patroni.yaml index 0f0f914bbc..76c129102d 100644 --- a/incubator/patroni/templates/statefulset-patroni.yaml +++ b/incubator/patroni/templates/statefulset-patroni.yaml @@ -42,6 +42,18 @@ spec: secretKeyRef: name: {{ template "patroni.fullname" . }} key: password-standby + {{- if .Values.kubernetes.dcs.enable }} + - name: DCS_ENABLE_KUBERNETES_API + value: "true" + - name: KUBERNETES_LABELS + value: {{ (printf "{ \"app\": \"%s\", \"release\": \"%s\" }" (include "patroni.name" .) .Release.Name) | quote }} + - name: KUBERNETES_SCOPE_LABEL + value: "app" + {{- end }} + {{- if .Values.kubernetes.configmaps.enable }} + - name: KUBERNETES_USE_CONFIGMAPS + value: "true" + {{- end }} {{- if .Values.etcd.enable }} {{- if .Values.etcd.deployChart }} - name: ETCD_DISCOVERY_DOMAIN @@ -142,6 +154,11 @@ spec: secretName: {{ .Values.walE.kubernetesSecret }} {{- end }} {{- end }} + {{- if not .Values.persistentVolume.enabled }} + - name: storage-volume + emptyDir: {} + {{- end }} + {{- if .Values.persistentVolume.enabled }} volumeClaimTemplates: - metadata: name: storage-volume @@ -166,3 +183,4 @@ spec: storageClassName: "{{ .Values.persistentVolume.storageClass }}" {{- end }} {{- end }} + {{- end }} diff --git a/incubator/patroni/values.yaml b/incubator/patroni/values.yaml index 8de23e67e1..e6f4f04c29 100644 --- a/incubator/patroni/values.yaml +++ b/incubator/patroni/values.yaml @@ -4,7 +4,7 @@ image: # Image was built from # https://github.com/zalando/spilo/tree/master/postgres-appliance repository: registry.opensource.zalan.do/acid/spilo-10 - tag: 1.4-p7 + tag: 1.4-p16 pullPolicy: IfNotPresent # Credentials used by Patroni @@ -17,9 +17,14 @@ credentials: # Distribution Configuration stores # Please note that only one of the following stores should be enabled. +kubernetes: + dcs: + enable: true + configmaps: + enable: false etcd: - enable: true - deployChart: true + enable: false + deployChart: false # If not deploying etcd chart, fill-in value for etcd service # ..svc.cluster.local host: @@ -52,6 +57,7 @@ walE: backupThresholdPercentage: 30 persistentVolume: + enabled: true size: 1G ## database data Persistent Volume Storage Class ## If defined, storageClassName: @@ -60,7 +66,7 @@ persistentVolume: ## set, choosing the default provisioner. (gp2 on AWS, standard on ## GKE, AWS & OpenStack) ## - storageClass: "-" + # storageClass: "-" subPath: "" mountPath: "/home/postgres/pgdata" annotations: {}