From b1c0e2b41c26054630a664da6a4e3d994df7d1cd Mon Sep 17 00:00:00 2001 From: Nikhil Jiju Date: Tue, 1 Oct 2024 11:56:17 -0400 Subject: [PATCH 1/2] Adding option for defining extra Init Containers Signed-off-by: Nikhil Jiju --- charts/prefect-worker/templates/deployment.yaml | 7 ++++++- charts/prefect-worker/values.schema.json | 8 ++++++++ charts/prefect-worker/values.yaml | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/charts/prefect-worker/templates/deployment.yaml b/charts/prefect-worker/templates/deployment.yaml index cf93e08c..5543b1b5 100644 --- a/charts/prefect-worker/templates/deployment.yaml +++ b/charts/prefect-worker/templates/deployment.yaml @@ -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 }} @@ -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 diff --git a/charts/prefect-worker/values.schema.json b/charts/prefect-worker/values.schema.json index 698fa0ad..de3daf91 100644 --- a/charts/prefect-worker/values.schema.json +++ b/charts/prefect-worker/values.schema.json @@ -172,6 +172,14 @@ } } } + }, + "extraContainers": { + "type": "array", + "title": "Extra Containers", + "description": "additional init containers", + "items": { + "type": "object" + } } } }, diff --git a/charts/prefect-worker/values.yaml b/charts/prefect-worker/values.yaml index 9c29f752..0f87e875 100644 --- a/charts/prefect-worker/values.yaml +++ b/charts/prefect-worker/values.yaml @@ -52,6 +52,9 @@ worker: allowPrivilegeEscalation: false # -- set init container's security context capabilities capabilities: {} + + # -- additional sidecar containers + extraContainers: [] image: # -- worker image repository From 08d90c4a32bd7c28a4d168d924d70ecc5db26213 Mon Sep 17 00:00:00 2001 From: Nikhil Jiju Date: Tue, 22 Oct 2024 15:35:56 -0400 Subject: [PATCH 2/2] fixing trailing space and adding test case Signed-off-by: Nikhil Jiju --- charts/prefect-worker/tests/worker_test.yaml | 17 +++++++++++++++++ charts/prefect-worker/values.yaml | 1 - 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/charts/prefect-worker/tests/worker_test.yaml b/charts/prefect-worker/tests/worker_test.yaml index 08914117..619f19b6 100644 --- a/charts/prefect-worker/tests/worker_test.yaml +++ b/charts/prefect-worker/tests/worker_test.yaml @@ -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 diff --git a/charts/prefect-worker/values.yaml b/charts/prefect-worker/values.yaml index 0f87e875..2d614474 100644 --- a/charts/prefect-worker/values.yaml +++ b/charts/prefect-worker/values.yaml @@ -52,7 +52,6 @@ worker: allowPrivilegeEscalation: false # -- set init container's security context capabilities capabilities: {} - # -- additional sidecar containers extraContainers: []