Gitops

Git driven changes to Kubernetes clusters aka gitops are well described in gitops operations by pull request blog post.

One tool to implement gitops with Kubernetes is flux.
Flux get started is one example repository to apply git repository changes to Kubernetes clusters.

Flux offers quite some configuration options including:

I did apply these settings to my fork of flux: gh.com/lotharschulz/flux. Flux runs for me in a local Minikube Kubernetes cluster. Afterwards I did change PODINFO_UI_COLOR in my fork of flux get started. Colour settings did switch to green and back to white.

These changes happened in gh.com/lotharschulz/flux-get-started/workloads/podinfo-dep.yaml. Flux did pick up and applied those changes to the Kubernetes cluster. See the show case video below how this works out.

Showcase video

Best video view in full screen mode.

Video commands in detail

  1. check for minikube kubectl status:
    minikube status
    kubectl config current-context
    The 2 commands are defined in k8sdemo.sh.
  2. start tmux and split the pane.
  3. on the left hand side I watch the status of the podinfo deployment kubernetes resource:
    watch kubectl describe deployment podinfo --namespace=demo
  4. on the right hand side I do change a kubernetes manifest file and commit & push the changes:
    1. change podinfo-dep.yaml file – replace white with green:
      sed -i -e 's/value: white/value: green/g' ./workloads/podinfo-dep.yaml
    2. commit and push to remote git repository:
      git commit -am "PODINFO_UI_COLOR set to green"
      git push origin master

    These commands are defined in pod-info-change.sh

A couple of seconds after the changes are pushed to the git remote repository, flux fetches the changes and changes the state of the regarding kubernetes deployment resource.

Conclusion

Git is a great tool to version your source code changes. Gitops allows you to leverage config as code versions to manage your Kubernetes cluster status.

Source Code

Lothar Schulz

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.