Kubernetes Image Configuration in ConfigMap

I have a Backend service that deploys to Kubernetes. Whenever I want to deploy, I build a docker image, drag it to the google docker registry with a tag (for example 1.1.0

) and update the yaml for deployment.

However, updating that file and making another commit is a PITA. Especially since I have a production and staging environment (actually 2 namespaces) I recently learned about ConfigMaps in Kubernetes.

So, I would like to know if it is possible to store the value in ConfigMap with an image tag and use it? I haven't found a way yet.

Are there any good alternatives so I don't need to store the current version information in git? What's the best practice here? Using the tag latest

, I think it is not.

I want my CI to do deployment whenever I hit wizard or develop (I'm using gitlab CI), so any approach that's easy to do on the command line without a lot sed

would be appreciated.

+3


source to share


1 answer


A simple solution is to run a rolling update of your deployment with 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.

+2


source







All Articles