Skip to content

Commit 34c7a51

Browse files
committed
Use helm hook to get kubedb ready
Signed-off-by: notTabassum <oyshee@appscode.com>
1 parent 1a88c8d commit 34c7a51

6 files changed

Lines changed: 396 additions & 272 deletions

File tree

charts/ace-installer-certified-crds/README.md

Lines changed: 134 additions & 134 deletions
Large diffs are not rendered by default.

charts/ace-installer-certified-crds/values.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ helm:
9090
enabled: true
9191
version: "v2026.6.19"
9292
values: # +doc-gen:break
93-
featureGates:
94-
Pgpool: true
93+
global:
94+
featureGates:
95+
Pgpool: true
9596
kubedb-provisioner:
9697
enabled: true
9798
kubedb-catalog:

charts/ace-installer-certified/README.md

Lines changed: 134 additions & 134 deletions
Large diffs are not rendered by default.

charts/ace-installer-certified/values.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ helm:
9090
enabled: true
9191
version: "v2026.6.19"
9292
values: # +doc-gen:break
93-
featureGates:
94-
Pgpool: true
93+
global:
94+
featureGates:
95+
Pgpool: true
9596
kubedb-provisioner:
9697
enabled: true
9798
kubedb-catalog:
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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 }}

charts/ace/templates/db/pgpool.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ metadata:
66
namespace: {{ .Release.Namespace }}
77
labels:
88
{{- include "ace.labels" . | nindent 4 }}
9+
annotations:
10+
# Create the Pgpool only after the referenced Postgres is Ready. The
11+
# pgpool-wait hook (weight 1) blocks until the DB reports phase=Ready, so
12+
# this higher-weighted hook runs afterwards.
13+
"helm.sh/hook": post-install,post-upgrade
14+
"helm.sh/hook-weight": "2"
15+
"helm.sh/hook-delete-policy": before-hook-creation
916
spec:
1017
version: "4.6.0"
1118
replicas: {{ .Values.settings.pgpool.replicas }}

0 commit comments

Comments
 (0)