Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes image configuration in ConfigMap

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.

like image 808
Bantak Avatar asked Nov 01 '25 23:11

Bantak


1 Answers

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.

like image 158
Sebastien Goasguen Avatar answered Nov 04 '25 21:11

Sebastien Goasguen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!