Skip to content

Commit

Permalink
Switch to wait4x to wait for db
Browse files Browse the repository at this point in the history
There is a bug related to nslookup in busybox
(docker-library/busybox#48). nslookup doesn't
return 0 when one of the hostname+domain suffix failed to resolve. The
suffix are listed in /etc/resolve.conf. e.g.
default.svc.cluster.local svc.cluster.local cluster.local

Also checking DNS doesn't mean service is up. wait4x will try
to make connection and valid the servie is up and running.
  • Loading branch information
xcompass committed Dec 13, 2022
1 parent 90f0b38 commit 54058f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compair/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords:
- peer learning
- education
name: compair
version: 0.9.0
version: 0.9.1
appVersion: 1.2.13
home: http://ubc.github.io/compair/
sources:
Expand Down
18 changes: 16 additions & 2 deletions compair/templates/compair-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,23 @@ spec:
{{- end }}
initContainers:
- name: wait-for-db-service
image: busybox
command: ["sh", "-c", "until nslookup {{ template "fullname" . }}-db; do echo waiting for {{ template "fullname" . }}-db; sleep 2; done;"]
image: atkrad/wait4x
command: ["sh", "-c", "wait4x", "mysql", "${DB_USERNAME}:${DB_PASSWORD}@tcp(${DB_HOST}:${DB_PORT})/${DB_NAME}"]
imagePullPolicy: {{ .Values.app.image.pullPolicy }}
env:
- name: DB_HOST
value: "{{ template "fullname" . }}-db"
- name: DB_PORT
value: {{ .Values.dbPort | quote }}
- name: DB_USERNAME
value: {{ .Values.dbUsername | quote }}
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "fullname" . }}
key: mysql_password
- name: DB_NAME
value: {{ .Values.dbName | quote }}
- name: init-db
image: "{{ .Values.app.image.repository }}:{{ .Values.app.image.tag }}"
command: ["sh", "-c", "python manage.py database create {{ if .Values.demoInstance }}--sample_data{{ end }}"]
Expand Down

0 comments on commit 54058f0

Please sign in to comment.