DEV Community

Cover image for How to Update an Kubernetes Image Imperatively.
Thodoris Velmachos
Thodoris Velmachos

Posted on

How to Update an Kubernetes Image Imperatively.

In the rare case you need to update the Container Images Manually instead of managing the Deployment the GitOps Way via FluxCD or ArgoCD. Then see the commands bellow.

With FluxCD you can do the following:

Ask FluxCD to stop managing the Deployment / Statefulset.

flux suspend kustomization <kustomization-name>
Enter fullscreen mode Exit fullscreen mode

Update the image with the following commands.

kubectl set image statefulsets.apps/<statefulset-name> <container-name>=<image-name>
OR
kubectl patch statefulsets.apps/<statefulset-name> -p '{"spec":{"containers":[{"name":"<container-name>","image":"<image-name>"}]}}'
Enter fullscreen mode Exit fullscreen mode

Ensure the Image has been updated.

kubectl get statefulsets.apps/<statefulset-name>-o=jsonpath='{$.spec.template.spec.containers[:1].image}'
Enter fullscreen mode Exit fullscreen mode

I hope you like the tutorial, if you do give a thumps up! and follow me in Twitter, also you can subscribe to my Newsletter in order to avoid missing any of the upcoming tutorials.

Media Attribution

I would like to thank Clark Tibbs for designing the awesome photo I am using in my posts.

Top comments (0)