Over the years, software development methodologies have changed from the waterfall model, to agile, to what we call DevOps today. Even though these methodologies focus mostly on cultural aspects, they are all backed by powerful tools and technologies that make the work more straightforward than before. Just as Docker and Kubernetes boosted DevOps adoption by making containerization easier for organizations, we are now witnessing GitOps gain traction but with Git at the center of the approach.
This article will explore GitOps: Why is it used? How does it work?
Today, many enterprises are embracing this new method of versioning their infrastructure and apps. GitOps helps engineering teams respond to issues faster and make fixes quicker, leading to more agile deployments. A significant benefit is that all changes can be tracked through history, making debugging and rolling back easier. It also allows you to make changes more quickly and improves collaboration by letting others know what you are doing during the deployment process. In addition, the deployments are easy to reverse if something goes wrong.
With GitOps, if you are unsure or something doesn’t work, you don’t have to debug the issue by going through complex logs; you can simply go to your commit history to see everything clearly and also roll back to the previously known stable release.
GitOps reduces some complexity by leveraging Git at the center of the delivery pipelines. Instead of learning a new shiny tool, developers can leverage their knowledge of Git commands.
How Does It Work?
Many organizations struggle to release new features because of complex release processes that increase downtime and affect developer morale. Deploying hundreds of features that take many hours to deploy overnight doesn’t help either – GitOps is a way to manage such deployments by automating the heavy lifting required without mishaps.
The central idea of GitOps is to keep your project code in a Git repo (application code, the files, dependencies, manifests, etc.) and sync the state of the repo with the state of the Kubernetes cluster. For this to succeed, an agent keeps track of the manifest file changes or whenever a developer pushes new code. The agent can see what changed and sync it to match the expected/desired state.
GitOps works on two models – push and pull. The push-based approach is where your CI/CD tool will push the changes to the production environment. The pull-based method requires an agent to be installed in every cluster. It keeps track of the changes and pulls them in whenever there is a mismatch from the required configuration. FluxCD, Argo CD, and JenkinsX are the three major platforms that pioneered the GitOps space.
Let’s assume that you have a Git repository with all your application code and a properly configured CI pipeline. When a developer pushes new code to GitHub, it gets verified, and a CI server checks and builds the code by running the specified tests to see if everything is good. Next, a container image is created and pushed to an image registry. The new change gets pulled/picked by the Git operator and scans it to see if the current and desired state match. If the current and desired state doesn’t match, then it gets provisioned to maintain the desired state. Finally, the deployment happens.
GitOps vs DevOps: What’s the Difference?
Both DevOps and GitOps promote the ease of deploying software at their core, but they differ in how they operate. Let us see how they compare with each other.
- GitOps fits under the automation principle of DevOps. It helps companies incrementally deploy software often and with speed.
- While DevOps focuses on breaking the silos between Dev and Ops, GitOps focuses on intelligent and automated Ops.
- DevOps promotes CI/CD automation with a push-based approach, whereas GitOps predominantly promotes Continuous Delivery with the pull-based approach.
- DevOps involves both declarative and imperative approaches for deployment, whereas GitOps enables declarative IaC.
- GitOps centralizes its focus on Git as the prominent tool. In contrast, DevOps doesn’t focus on tools. Instead, it focuses on the cultural aspect to boost collaboration between Dev and Ops.
- GitOps tends to be more developer-centric as it makes deploying easy by involving tools such as Git and Kubernetes. In contrast, DevOps can’t be described with any particular tool as it is a methodology across the organization.
- The scope of DevOps is not limited just to CI/CD and the correctness of software delivery. In contrast, the primary focus of GitOps is on continuously delivering software the right way.
When looking at GitOps, it is evident that it has numerous advantages. It helps developers and DevOps engineers automate the software delivery process. It does this by moving software from development to testing, staging, and finally to production. Developers already love this approach, and it seems like GitOps will continue to grow in popularity in the cloud-native space.
One concerning point of GitOps today is it lacks a full-blown end-to-end tool/platform so organizations can use it as a standard approach. Hence, to make it a new reality, Harness recently introduced Harness GitOps, which incorporates highly sophisticated CI and CD capabilities.