Using kubectl set image to update image of initContainer

The documentation seems to suggests that only containers are concerned.

Maybe you could switch to kubectl patch ?

(I know it's more tedious...)

kubectl patch deployment/deployment_name --patch "{\"spec\": {\"template\": {\"spec\": {\"initContainers\": [{\"name\": \"container_name\",\"image\": \"url_to_container\"}]}}}}"

Since the accepted answer, the team developed the ability to set image for Kubernetes init containers. Using the same command, simply use the init container name for the container part of the command you supplied.

kubectl set image deployment/deployment_name myInitContainer=url_to_container

In case you want to update both container images in a single command, use:

kubectl set image deployment/deployment_name myInitContainer=url_to_container container=url_to_container

Tags:

Kubernetes