How do I version control a kubernetes application?

11/24/2016

I've checked out helm.sh of course, but at first glance the entire setup seems a little complicated (helm-client & tiller-server). It seems to me like I can get away by just having a helm-client in most cases.

This is what I currently do

Let's say I have a project composed of 3 services viz. postgres, express, nginx.

I create a directory called product-release that is as follows:

product-release/
    .git/
    k8s/
        postgres/
            Deployment.yaml
            Service.yaml
            Secret.mustache.yaml   # Needs to be rendered by the dev before use
        express/
            Deployment.yaml
            Service.yaml
        nginx/
            Deployment.yaml
            Service.yaml
    updates/
        0.1__0.2/
            Job.yaml    # postgres schema migration
            update.sh   # k8s API server scritps to patch/replace existing k8s objects, and runs the state change job

The usual git stuff can apply now. Everytime I make a change, I make changes to the spec files, test them, write the update scripts to help move from the last version to this current version and then commit it and tag it.

Questions:

  1. This works for me so far, but is this "the right way"?
  2. Why does helm have the tiller server? Isn't it simpler to do the templating on the client-side? Of course, if you want to separate the activity of the deployment from the knowledge of the application (like secrets) the templating would have to happen on the server, but otherwise why?
-- iamnat
kubernetes
kubernetes-helm
microservices

3 Answers

11/29/2019

Notice: Tiller has been removed in Helm v3. Checkout this answer to see details on why it needs tiller in Helm v2 and why it's removed in Helm v3: https://v3.helm.sh/docs/faq/#removal-of-tiller

According to the idea of GitOps, what you did is a right way (to perform release from a git repo). However, if you want to push it further to make it more common, you can plan more goals including:

  • Choose a configuration management system beyond k8s app declarative definition only. E.g., Helm (like above answer https://stackoverflow.com/a/42053983/914967), Kustomize. They're pure client-side only.
  • avoid custom release process by altering update.sh with popular tools like kubectl apply or helm install.
  • drive change delivery from git tags/branches by using a CI/CD engine like argocd, Travis CI or GitHub Actions.
  • Uses branching strategy so that you can try changes on test/staging/production/ environment before delivering it directly.
-- shawmzhu
Source: StackOverflow

2/5/2017

We are using kubernetes/helm (the latest/incubated version) and a central repository for Helm charts (with references container images built for our component releases).

In other words, the Helm package definitions and its dependencies are separate from the source code and image definitions that make up the several components of our web applications.

-- Vincent De Smet
Source: StackOverflow

11/24/2016

Seems that https://redspread.com/ (open source) addresses this particular issue, but needs more development before it'll be production ready - at least from my team quick glance at it.

We'll stick with keeping yaml files in git together with the deployed application for now I guess.

-- Jakub GÅ‚azik
Source: StackOverflow