Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using kubectl set image to update image of initContainer

Tags:

kubernetes

Currently, to update a k8s deployment image, we use the kubectl set image command like this:

kubectl set image deployment/deployment_name container=url_to_container

While this command updates the URL used for the main container in the deployment, it does not update the URL for the initContainer also set within the deployment.

Is there a similar kubectl command I can use to update the initContainer to the same URL?

like image 395
Max Woolf Avatar asked Mar 21 '18 14:03

Max Woolf


1 Answers

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
like image 82
Yonatan Wilkof Avatar answered Sep 30 '22 16:09

Yonatan Wilkof