Skip to content

Commit

Permalink
feat: init container to wait for patroni to be available (#41)
Browse files Browse the repository at this point in the history
* feat: create init container to wait for db pods

* feat: update init container script

* feat: fix pre-commit
  • Loading branch information
NithinKuruba authored Jan 30, 2024
1 parent a24e8b2 commit 96a36b6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/keycloak/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: sso-keycloak
version: 1.15.0
version: 1.15.1
appVersion: 7.6.39-build.1
description: Open Source Identity and Access Management For Modern Applications and Services
dependencies:
Expand Down
28 changes: 28 additions & 0 deletions charts/keycloak/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ spec:
{{- end }}
labels: {{ include "sso-keycloak.labels" . | nindent 8 }}
spec:
initContainers:
- name: {{ .Chart.Name }}-init
image: openshift/origin-cli:latest
command:
- "/bin/sh"
- "-c"
- |
namespace="{{ .Release.Namespace }}"
name={{ .Values.patroni.nameOverride }}
echo "Current Namespace: $namespace"
echo "Patroni Statefulset: $name"
check_rollout_status(){
replicas_desired={{ .Values.patroni.replicaCount }}
replicas_current=$(oc get -n $namespace statefulset $name -o jsonpath='{.status.currentReplicas}')
# Set replicas_current to zero if it is not available
replicas_current="${replicas_current:-0}"
echo "Replicas desired: ${replicas_desired}, Replicas current: ${replicas_current}"
if [ "${replicas_current}" -eq "${replicas_desired}" ]; then
return 0 # Rollout is complete
else
return 1 # Rollout is not complete
fi
}
while ! check_rollout_status; do
echo "Waiting for StatefulSet {{ .Values.patroni.nameOverride }} rollout to complete..."
sleep 5
done
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down

0 comments on commit 96a36b6

Please sign in to comment.