diff --git a/charts/theia-cloud/templates/image-preloading.yaml b/charts/theia-cloud/templates/image-preloading.yaml index cc9bb25..fc02fb9 100644 --- a/charts/theia-cloud/templates/image-preloading.yaml +++ b/charts/theia-cloud/templates/image-preloading.yaml @@ -46,13 +46,47 @@ spec: # The pod can be killed instantly because it doesn't do any work requiring graceful shutdown terminationGracePeriodSeconds: 0 initContainers: - {{- range $index, $image := $images }} + {{- range $index, $entry := $images }} + {{- $imageRef := "" }} + {{- $isMap := kindIs "map" $entry }} + {{- if $isMap }} + {{- $imageRef = tpl ($entry.image | toString) $ }} + {{- else }} + {{- $imageRef = tpl ($entry | toString) $ }} + {{- end }} + {{- $useShell := true }} + {{- $customCmd := list }} + {{- $customArgs := list }} + {{- $hasArgsKey := false }} + {{- if $isMap }} + {{- if or $entry.command (hasKey $entry "args") }} + {{- $useShell = false }} + {{- end }} + {{- with $entry.command }} + {{- $customCmd = . }} + {{- end }} + {{- if hasKey $entry "args" }} + {{- $hasArgsKey = true }} + {{- $customArgs = $entry.args }} + {{- end }} + {{- end }} - name: image-preload-{{ $index }} - image: {{ $image }} + image: {{ $imageRef | quote }} imagePullPolicy: {{ $imagePullPolicy }} + {{- if $useShell }} command: ["/bin/sh", "-c"] args: - - "echo 'Loaded image {{ $image }}'; exit 0" + - {{ printf "echo 'Loaded image %s'; exit 0" $imageRef | quote }} + {{- else }} + {{- with $customCmd }} + command: + {{- toYaml . | nindent 10 }} + {{- end }} + {{- if $hasArgsKey }} + args: + {{- toYaml $customArgs | nindent 10 }} + {{- end }} + {{- end }} {{- end }} # Run the pause container to make the Pod go into the Running state without consuming resources containers: diff --git a/charts/theia-cloud/values.yaml b/charts/theia-cloud/values.yaml index 04273ee..4995e0c 100644 --- a/charts/theia-cloud/values.yaml +++ b/charts/theia-cloud/values.yaml @@ -444,9 +444,11 @@ monitor: preloading: # -- Is image preloading enabled. enable: true - # -- Images to preload. Images must support running /bin/sh. - # If the list is empty and demoApplication.install == true, - # demoApplication.name is automatically added. + # -- Images to preload. Each item is either an image reference string or a map: + # `{ image: "...", args: ["--version"] }` to use the image entrypoint (distroless-friendly), + # or `{ image: "...", command: [...], args: [...] }` for a full override. If only strings are used, + # the chart runs `/bin/sh -c 'echo …; exit 0'` (shell required in the image). + # If the list is empty and demoApplication.install == true, demoApplication.name is automatically added. images: [] # -- Optional: Override the imagePullPolicy for the image preloading containers. # If this is omitted or empty, the root at .Values.imagePullPolicy is used.