Recently I learned about GitOps which is a way to manage your Kubernetes clusters and the applications you run on top using Git. The idea is that you can declaratively describe the desired state of your systems in Git and roll out changes as soon as merges occur.
You can immediately see the main benefits of such an approach: Your Git repositories become the single source of truth for both your infrastructure and application code, allowing the teams to increase productivity and stability (you get the Git log to audit changes).
To implement GitOps you can use and configure Flux following some simple steps:
1. Download the helm template
1helm fetch ` 2 --repo https://fluxcd.github.io/flux ` 3 --untar ` 4 --untardir .\.charts ` 5 --version 0.10.2 ` 6 flux
2. Bake the template with your repo (I don’t use Tiller)
1helm template flux ` 2 --set git.url="email@example.com:cmendible/kubernetes.samples" ` 3 --set git.path="19.flux" ` 4 --set git.pollInterval="5s" ` 5 --namespace flux ` 6 --output-dir .\.baked .\.charts\fluxcd
3. Deploy the configuration to your cluster
1kubectl apply -f .\.baked\flux\templates\
4. Get the fluxctl CLI
Download the fluxctl CLI
5. Use fluxctl to get the public key
1fluxctl identity --k8s-fwd-ns flux
This key is needed to sync your cluster state with the Git repository (GitHub): Copy the key you obtained and use it to create a deploy key with write access on your GitHub repository (Settings > Deploy keys > Add deploy key > check Allow write access > paste the Flux public key > click Add key)
You are all set. If everything runs smooth you’ll find a new deployment in your cluster with the dni-function name.
To learn more about GitOps check: Weaveworks
Click here to learn more about Flux
Hope it helps!