Can you tell k8s to deploy based on a git revision? What options are there

4/18/2018

Normally I would use ansible to deploy my code to a server.

Using k8s, what options are there?

Since everything is in a container, I guess the best practice is for immutable deployments as oppose to updating the code on a running instance?

Is it possible to just update the git revision # in your .yaml file and you can make it so it pulls from a specific version to deploy?

-- cool breeze
kubernetes

2 Answers

4/19/2018

Set up Jenkins to build Docker containers of every app from their Git repos. Make it tag the images with Git revisions or whatever (I like commit number). Make it push images to your Docker private registry.

Put all *.yaml of the cluster into a Git repository. Commit-push changes to these configs. On the cluster end - pull-apply.

-- Velkan
Source: StackOverflow

4/18/2018

https://helm.sh/ can help you.


Here are the steps you need to take:

  • Package your app(yaml with image tag as template parameter) as a Helm chart <your-helm-chart>.
  • Your chart's values.yaml (input to yaml template) will have one parameter git_commit_id: <some-id>
  • Your yaml template takes image tag parameter: image: your-app:{{ .Values.git_commit_id }}, this comes from values.yaml.
  • you will deploy your app as helm install <your-helm-chart>, this will give you a <release name>.
  • and then later when you need to update with new image tag: helm upgrade <release-name> <your-helm-chart> --set git_commit_id=NEWID
-- bits
Source: StackOverflow