Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(prefect-worker): support extra initContainers #403

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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