I have a Backend service which is deployed to Kubernetes. Whenever I want to deploy I build my docker image, push it to the google docker registry with a tag (e.g. 1.1.0
) and update my deployment yaml.
However, updating this file and creating another commit is a PITA. Especially because I have a production and a staging environment (actually 2 namespaces) I recently found out about ConfigMaps in Kubernetes.
So I would like to know if it is possible to store a value in a ConfigMap with the image tag and use it? I haven't found a way so far.
Are there any good alternatives so I don't have to store the information about the current release in git? What's the best practice here? Using latest
tag I guess isn't.
I want to let my CI do the deployment whenever I push to master or development (I use gitlab CI), so any approach that is easy to do on the command line without a lot of sed
would be appreciated.
A straightforward solution is to trigger a rolling update of your deployment by using kubectl set image
:
kubectl set image deployment/foobar <container_name>=<new_image:new_tag>
and you can use your git commit id as image tag.