From fc3cce57ab9f7201fce663769159379cb7a1da65 Mon Sep 17 00:00:00 2001
From: ggwpp
Date: Sun, 21 Jul 2019 16:48:53 +0700
Subject: [PATCH] [incubator/Patroni]Patroni add consul (#13710)
* [incubator/patroni] add consul for dcs, extra env
Signed-off-by: ggwpp
* bumped verion
Signed-off-by: ggwpp
* correct value
Signed-off-by: ggwpp
* Bump chart version
Signed-off-by: ggwpp
---
incubator/patroni/Chart.yaml | 2 +-
incubator/patroni/README.md | 4 ++++
incubator/patroni/requirements.lock | 7 +++++--
incubator/patroni/requirements.yaml | 4 ++++
.../patroni/templates/statefulset-patroni.yaml | 16 +++++++++++++++-
incubator/patroni/values.yaml | 8 ++++++++
6 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/incubator/patroni/Chart.yaml b/incubator/patroni/Chart.yaml
index 6aab82cbde..3b60d04a23 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.13.0
+version: 0.13.1
appVersion: 1.4-p16
home: https://github.com/zalando/patroni
sources:
diff --git a/incubator/patroni/README.md b/incubator/patroni/README.md
index 667433eef8..2cf8872dc7 100644
--- a/incubator/patroni/README.md
+++ b/incubator/patroni/README.md
@@ -77,6 +77,10 @@ The following table lists the configurable parameters of the patroni chart and t
| `zookeeper.enable` | Using ZooKeeper as DCS | `false` |
| `zookeeper.deployChart` | Deploy ZooKeeper chart | `false` |
| `zookeeper.hosts` | List of ZooKeeper cluster members | `host1:port1,host2:port,etc...` |
+| `consul.enable` | Using Consul as DCS | `false` |
+| `consul.deployChart` | Deploy Consul chart | `false` |
+| `consul.host` | Host name of consul cluster | `nil` |
+| `env` | Extra custom environment variables | `{}` |
| `walE.enable` | Use of Wal-E tool for base backup/restore | `false` |
| `walE.scheduleCronJob` | Schedule of Wal-E backups | `00 01 * * *` |
| `walE.retainBackups` | Number of base backups to retain | `2` |
diff --git a/incubator/patroni/requirements.lock b/incubator/patroni/requirements.lock
index bbcd925378..33d434dec2 100644
--- a/incubator/patroni/requirements.lock
+++ b/incubator/patroni/requirements.lock
@@ -5,5 +5,8 @@ dependencies:
- name: zookeeper
repository: https://kubernetes-charts-incubator.storage.googleapis.com/
version: 1.0.0
-digest: sha256:b65cce5b82c3c9971b7551e923e03a9253bcb9771386086a4e75992a9682ca03
-generated: 2019-01-26T09:48:28.627975698-06:00
+- name: consul
+ repository: https://kubernetes-charts.storage.googleapis.com/
+ version: 3.6.1
+digest: sha256:65ce2049b946b29c3705df1c6b3df323bbaccd571b51cb3b2c4964608a1f0e37
+generated: 2019-05-13T14:05:58.771774+07:00
diff --git a/incubator/patroni/requirements.yaml b/incubator/patroni/requirements.yaml
index 72555f2605..ec4875f554 100644
--- a/incubator/patroni/requirements.yaml
+++ b/incubator/patroni/requirements.yaml
@@ -7,3 +7,7 @@ dependencies:
version: 1.0.0
repository: https://kubernetes-charts-incubator.storage.googleapis.com/
condition: zookeeper.deployChart
+- name: consul
+ version: 3.6.1
+ repository: https://kubernetes-charts.storage.googleapis.com/
+ condition: consul.deployChart
diff --git a/incubator/patroni/templates/statefulset-patroni.yaml b/incubator/patroni/templates/statefulset-patroni.yaml
index 41f37c7e9f..74658a25ab 100644
--- a/incubator/patroni/templates/statefulset-patroni.yaml
+++ b/incubator/patroni/templates/statefulset-patroni.yaml
@@ -49,11 +49,11 @@ spec:
value: {{ (printf "{ \"app\": \"%s\", \"release\": \"%s\" }" (include "patroni.fullname" .) .Release.Name) | quote }}
- name: KUBERNETES_SCOPE_LABEL
value: "app"
- {{- end }}
{{- if .Values.kubernetes.configmaps.enable }}
- name: KUBERNETES_USE_CONFIGMAPS
value: "true"
{{- end }}
+ {{- end }}
{{- if .Values.etcd.enable }}
{{- if .Values.etcd.deployChart }}
- name: ETCD_DISCOVERY_DOMAIN
@@ -70,6 +70,14 @@ spec:
- name: ZOOKEEPER_HOSTS
value: {{ .Values.zookeeper.hosts | quote }}
{{- end }}
+ {{- else if .Values.consul.enable }}
+ {{- if .Values.consul.deployChart }}
+ - name: PATRONI_CONSUL_HOST
+ value: {{(printf "'%s-consul'" .Release.Name | trunc 63)}}
+ {{- else }}
+ - name: PATRONI_CONSUL_HOST
+ value: {{ .Values.consul.host | quote }}
+ {{- end }}
{{- end }}
- name: SCOPE
value: {{ template "patroni.fullname" . }}
@@ -114,6 +122,12 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
+ {{- if .Values.env }}
+ {{- range $key, $val := .Values.env }}
+ - name: {{ $key | quote | upper }}
+ value: {{ $val | quote }}
+ {{- end }}
+ {{- end }}
ports:
- containerPort: 8008
- containerPort: 5432
diff --git a/incubator/patroni/values.yaml b/incubator/patroni/values.yaml
index 149e3f315b..d895cf6836 100644
--- a/incubator/patroni/values.yaml
+++ b/incubator/patroni/values.yaml
@@ -36,6 +36,14 @@ zookeeper:
# If not deploying etcd chart, fill-in list of ZooKeeper members in format:
# 'host1:port1','host2:port2','etc...'
hosts:
+consul:
+ enable: false
+ deployChart: false
+ # Leave blank to use vendored consul chart
+ hosts:
+
+# Extra custom environment variables.
+env: {}
walE:
# Specifies whether Wal-E should be enabled