In this article, we are going to dive into a central term in the application development and management mix: GitOps. We’ll cover what GitOps is, how it affects an organization and how it aligns with Kubernetes.
What is GitOps?
GitOps is a process that leverages Git for operations and management of cloud-native applications. When working according to the GitOps principles, Git represents the single source of truth concerning the condition of the system. Naturally, this brings up the question: What is the system? With GitOps it is actually possible to use Git for provisioning of the entire application infrastructure, and not just the application itself. This means by using so-called declarative infrastructure or "infrastructure as code" you can use Git as single source of truth for the entire application environment.
GitOps and CI/CD: What’s the connection?
GitOps and CI/CD (continuous integration/continuous delivery or deployment) belongs together. As a refresher, CI/CD lets developers continuously develop and deploy applications. Often the takes place through a Git repository (although there can be other repositories). During the deployment/delivery phase, the built container-based application is “pushed” to Kubernetes for deployment. The operation of GitOps enhances the CI/CD model by using a controller in Kubernetes to keep an eye on the desired state (Git) and compare it to the actual state (Kubernetes). If the two are inconsistent, a pull-method is applied to bring the Kubernetes cluster to the desired state.
But what happens if someone changes something running within the Kubernetes cluster? Well, our goal is to use Git as the primary source of truth as a declarative deployment tool and leverage additional tools to alert us when there is divergence. By leveraging tools that can identify differences between the running and declared state, Kubernetes remediates to the known/declared operating state.
Note: Continuous integration and continuous development are complementary but separate processes. Since CI and CD processes occur in different groups, the process may vary from one organization to another.
Why GitOps?
First and foremost, GitOps is the way to go for organisations that wish to automate the entire application environment - including network, virtual environments and the application itself. Depending on what your company's CI/CD pipeline looks like, large parts of it might still be "hand-held". With GitOps it is possible to automate both the integration and deployment while ensuring full control of the version management.
In addition, Git comes with a nice audit-log which provides great advantages concerning revision and debugging.
More inspiration
The concept GitOps was invented by Alexis Richardson from Weavework a few years back. His main idea was that everything that is required to re-establish a setup, including infrastructure, platform and applications, should be in Git, hence the terminology GitOps.
Netic's business partners from Rancher Labs have written a blog post about GitOps, where they go in depth with Flux - the tool used in Kubernetes to enable GitOps. Flux is open source and managed within the framework of CNCF.
https://rancher.com/blog/2020/gitops-kubernetes-connection.
The tool Flux can be found at Github here https://github.com/fluxcd/flux.
Please reach out to us, if you wish to know more about GitOps and how your company can use GitOps for automation of your CI/CD pipeline.