Skip to content

Commit

Permalink
add support for defining registry for wait for mongo init container
Browse files Browse the repository at this point in the history
  • Loading branch information
dejanzele committed Aug 13, 2024
1 parent f68d886 commit d025177
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
20 changes: 20 additions & 0 deletions charts/testkube-cloud-api/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,23 @@ Define API image
{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $tag -}}
{{- end -}}
{{- end -}}

{{/*
Define Mongo init image
TODO: Implement this using dict and reuse the same for each image
*/}}
{{- define "testkube-cloud-api.init-mongo-image" -}}
{{- $registryName := default "docker.io" .Values.init.mongo.image.registry -}}
{{- if .Values.global.imageRegistry -}}
{{- $registryName = .Values.global.imageRegistry -}}
{{- end -}}
{{- $repositoryName := .Values.init.mongo.image.repository -}}
{{- $tag := default .Chart.AppVersion .Values.init.mongo.image.tag | toString -}}
{{- $separator := ":" -}}
{{- if .Values.init.mongo.image.digest -}}
{{- $separator = "@" -}}
{{- $tag = .Values.init.mongo.image.digest | toString -}}
{{- end -}}

{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $tag -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/testkube-cloud-api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
{{- if .Values.init.enabled }}
initContainers:
- name: wait-for-mongo
image: {{ .Values.init.mongo.image.repository }}:{{ .Values.init.mongo.image.tag }}
image: {{ include "testkube-cloud-api.init-mongo-image" . }}
imagePullPolicy: {{ .Values.init.mongo.image.pullPolicy }}
command: ["/bin/sh", "-c"]
args:
Expand Down
4 changes: 3 additions & 1 deletion charts/testkube-cloud-api/templates/migrations-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ spec:
serviceAccountName: {{ include "testkube-cloud-api.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.init.enabled }}
initContainers:
- name: wait-for-mongo
image: alpine/mongosh:2.0.2
image: {{ include "testkube-cloud-api.init-mongo-image" . }}
command: ["/bin/sh", "-c"]
args:
- |
Expand All @@ -55,6 +56,7 @@ spec:
{{- else }}
value: {{ .Values.global.mongo.dsn | default .Values.api.mongo.dsn }}
{{- end }}
{{- end }}
containers:
- name: migrations
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand Down
4 changes: 4 additions & 0 deletions charts/testkube-cloud-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ init:
enabled: false
mongo:
image:
# -- MongoSH image registry
registry: "docker.io"
# -- MongoSH image repository
repository: alpine/mongosh
# -- MongoSH image tag
tag: 2.0.2
# -- MongoSH image pull policy
pullPolicy: IfNotPresent
# -- MongoSH image digest
digest: ""
analytics:
segmentio:
# -- Toggle whether to enable Segment.io analytics
Expand Down

0 comments on commit d025177

Please sign in to comment.