Skip to content

Commit

Permalink
feat(prefect-worker): support extra initContainers (#403)
Browse files Browse the repository at this point in the history
* Adding option for defining extra Init Containers

Signed-off-by: Nikhil Jiju <[email protected]>

* fixing trailing space and adding test case

Signed-off-by: Nikhil Jiju <[email protected]>

---------

Signed-off-by: Nikhil Jiju <[email protected]>
  • Loading branch information
NiJuFirenzia authored Oct 25, 2024
1 parent 3a4c96a commit fe70769
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion charts/prefect-worker/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ spec:
{{- if .Values.worker.priorityClassName }}
priorityClassName: {{ .Values.worker.priorityClassName }}
{{- end }}
{{- if include "worker.baseJobTemplateName" . }}
{{- if or (include "worker.baseJobTemplateName" .) (.Values.worker.initContainer.extraContainers) }}
initContainers:
{{- if include "worker.baseJobTemplateName" . }}
- name: sync-base-job-template
image: "{{ .Values.worker.image.repository }}:{{ .Values.worker.image.prefectTag }}"
imagePullPolicy: {{ .Values.worker.image.pullPolicy }}
Expand Down Expand Up @@ -125,6 +126,10 @@ spec:
{{- with .Values.worker.initContainer.containerSecurityContext }}
securityContext: {{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.worker.initContainer.extraContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.worker.initContainer.extraContainers "context" $) | nindent 8 }}
{{- end }}
{{- end }}
containers:
- name: prefect-worker
Expand Down
17 changes: 17 additions & 0 deletions charts/prefect-worker/tests/worker_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ values:
- ./required_values.yaml

tests:
- it: Should set extra init containers
set:
worker:
initContainer:
extraContainers:
- name: code-init
image: custom/prefect-init:v2.0.0
asserts:
- template: deployment.yaml
equal:
path: .spec.template.spec.initContainers[0].name
value: code-init
- template: deployment.yaml
equal:
path: .spec.template.spec.initContainers[0].image
value: custom/prefect-init:v2.0.0

- it: Should set the correct image and tag
asserts:
- template: deployment.yaml
Expand Down
8 changes: 8 additions & 0 deletions charts/prefect-worker/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@
}
}
}
},
"extraContainers": {
"type": "array",
"title": "Extra Containers",
"description": "additional init containers",
"items": {
"type": "object"
}
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions charts/prefect-worker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ worker:
allowPrivilegeEscalation: false
# -- set init container's security context capabilities
capabilities: {}
# -- additional sidecar containers
extraContainers: []

image:
# -- worker image repository
Expand Down

0 comments on commit fe70769

Please sign in to comment.