1+ {{- if .Values.settings.pgpool.enabled }}
2+ apiVersion : v1
3+ kind : ServiceAccount
4+ metadata :
5+ name : {{ include "appscode.serviceAccountName" . }}-pgpool-wait
6+ namespace : {{ .Release.Namespace }}
7+ labels :
8+ {{- include "ace.labels" . | nindent 4 }}
9+ annotations :
10+ " helm.sh/hook " : post-install,post-upgrade
11+ " helm.sh/hook-weight " : " 0"
12+ " helm.sh/hook-delete-policy " : before-hook-creation,hook-succeeded
13+ ---
14+ apiVersion : rbac.authorization.k8s.io/v1
15+ kind : Role
16+ metadata :
17+ name : {{ include "ace.fullname" . }}-pgpool-wait
18+ namespace : {{ .Release.Namespace }}
19+ labels :
20+ {{- include "ace.labels" . | nindent 4 }}
21+ annotations :
22+ " helm.sh/hook " : post-install,post-upgrade
23+ " helm.sh/hook-weight " : " 0"
24+ " helm.sh/hook-delete-policy " : before-hook-creation,hook-succeeded
25+ rules :
26+ # wait for the Postgres database to become Ready before creating the Pgpool
27+ - apiGroups :
28+ - kubedb.com
29+ resources :
30+ - postgreses
31+ verbs : ["get", "list", "watch"]
32+ ---
33+ apiVersion : rbac.authorization.k8s.io/v1
34+ kind : RoleBinding
35+ metadata :
36+ name : {{ include "ace.fullname" . }}-pgpool-wait
37+ namespace : {{ .Release.Namespace }}
38+ labels :
39+ {{- include "ace.labels" . | nindent 4 }}
40+ annotations :
41+ " helm.sh/hook " : post-install,post-upgrade
42+ " helm.sh/hook-weight " : " 0"
43+ " helm.sh/hook-delete-policy " : before-hook-creation,hook-succeeded
44+ roleRef :
45+ apiGroup : rbac.authorization.k8s.io
46+ kind : Role
47+ name : {{ include "ace.fullname" . }}-pgpool-wait
48+ subjects :
49+ - kind : ServiceAccount
50+ name : {{ include "appscode.serviceAccountName" . }}-pgpool-wait
51+ namespace : {{ .Release.Namespace }}
52+ ---
53+ apiVersion : batch/v1
54+ kind : Job
55+ metadata :
56+ name : {{ include "ace.fullname" . }}-pgpool-wait
57+ namespace : {{ .Release.Namespace }}
58+ labels :
59+ {{- include "ace.labels" . | nindent 4 }}
60+ annotations :
61+ " helm.sh/hook " : post-install,post-upgrade
62+ " helm.sh/hook-weight " : " 1"
63+ " helm.sh/hook-delete-policy " : before-hook-creation,hook-succeeded
64+ spec :
65+ activeDeadlineSeconds : 21600
66+ backoffLimit : 3
67+ template :
68+ spec :
69+ {{- include "appscode.imagePullSecrets" . | nindent 6 }}
70+ serviceAccountName : {{ include "appscode.serviceAccountName" . }}-pgpool-wait
71+ automountServiceAccountToken : true
72+ {{- if eq "true" ( include "distro.openshift" . ) }}
73+ securityContext :
74+ {{- toYaml (omit .Values.podSecurityContext "runAsUser" "runAsGroup" "fsGroup" "supplementalGroups") | nindent 8 }}
75+ {{- else }}
76+ securityContext :
77+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
78+ {{- end }}
79+ containers :
80+ - name : kubectl
81+ {{- if eq "true" ( include "distro.openshift" . ) }}
82+ securityContext :
83+ {{- toYaml (omit .Values.securityContext "runAsUser" "runAsGroup" "fsGroup" "supplementalGroups") | nindent 12 }}
84+ {{- else }}
85+ securityContext :
86+ {{- toYaml .Values.securityContext | nindent 12 }}
87+ {{- end }}
88+ image : " {{ include " kubectl.registry" . }}/{{ .Values.kubectl.repository }}:{{ .Values.kubectl.tag | default .Chart.AppVersion }}"
89+ imagePullPolicy : {{ .Values.kubectl.pullPolicy }}
90+ command :
91+ - /bin/sh
92+ - -c
93+ - |
94+ echo "Waiting for Postgres {{ include "ace.fullname" . }}-db to become Ready..."
95+ until [ "$(kubectl get pg {{ include "ace.fullname" . }}-db -n {{ .Release.Namespace }} -o jsonpath='{.status.phase}' 2>/dev/null)" = "Ready" ]; do
96+ echo "Postgres {{ include "ace.fullname" . }}-db is not Ready yet. Retrying in 10s..."
97+ sleep 10
98+ done
99+ echo "Postgres {{ include "ace.fullname" . }}-db is Ready. Proceeding to create Pgpool."
100+ resources :
101+ {{- toYaml .Values.resources | nindent 12 }}
102+ {{- with .Values.nodeSelector }}
103+ nodeSelector :
104+ {{- toYaml . | nindent 8 }}
105+ {{- end }}
106+ {{- with .Values.affinity }}
107+ affinity :
108+ {{- toYaml . | nindent 8 }}
109+ {{- end }}
110+ {{- with .Values.tolerations }}
111+ tolerations :
112+ {{- toYaml . | nindent 8 }}
113+ {{- end }}
114+ restartPolicy : Never
115+ {{- end }}
0 commit comments