The software development industry is, for better or worse, fertile ground for buzzwords, acronyms, and new terms. It’s often overwhelming to keep up with so many new concepts. Also, it’s not easy to distinguish between those buzzwords that are only passing fads from permanent fixtures of the tech scene. Today’s post is about one instance of the latter type of buzzword since we’ll answer the question: what is GitOps?
By the end of the post, you’ll understand what it is, why it exists, and how software teams can benefit from it. Let’s dig in.
What Is GitOps?
Just by its name, it’s easy to see that GitOps has something to do with Git and operations. But what exactly?
We can describe GitOps as an approach or set of practices. Its goal is to create a continuous deployment approach to help teams manage cloud-native or clustered applications, borrowing concepts from CI/CD and DevOps.
GitOps aims to create an approach that revolves around the developer. It accomplishes that by making Git the single source of truth of the organization’s infrastructure and CI/CD approach. In other words, the idea is to have the desired state of the organization’s infrastructure in a declarative format so that it can be versioned inside a Git repository.
That way, developers can continue using the tools and workflows they are familiar with. But now, instead of just using them for managing application code, developers can also leverage them for infrastructure provisioning and management.
The main principles of GitOps are
- Infrastructure as code. Everything about the system’s infrastructure, down to machine and network settings, is declared as versionable files.
- Git as the single source of truth. In GitOps, teams can use the Git version control tool to manage how the infrastructure evolves, usually by adopting a pull-request-based workflow.
- Automation. CI/CD pipelines are used to manage not only application source code but infrastructure and operations.
- Developer-centric approach. GitOps leverages tools and techniques developers are already comfortable with, such as Git and CI/CD workflows.
Why Should You Care About GitOps?
Why would you want to have your infrastructure’s configuration stored as declarative instructions in a Git repository? What’s the benefit of that?
It all boils down to accountability and automation.
Versioning the state of the system makes all changes to it traceable. It’s just a matter of looking at the repository’s Git log. But GitOps isn’t only about tracking; it’s also about enforcing. By using GitOps software, it’s possible to detect divergences between the configuration of a given cluster and the canonical current state as described by the repository. Divergences will set alerts, and the software agents can even roll back the divergent cluster to the previous state.
The other important point is automation. Under GitOps, as soon as changes to the infrastructure are approved, they must be applied automatically to the system, and this is possible without additional processes or workflows for deployment.
The Benefits of GitOps
Let’s take a look at some of the main benefits of adopting GitOps.
All Changes to the Environment Are Completely Traceable
In GitOps, every deployment is self-documenting. Since everything has to happen via the Git repository, all changes to the system are completely accessible via the Git log. It’s easy to see who made the change, when, and exactly what changed from one version to another.
You Can Recover From Errors Faster
If your environment is down due to the last deployment, you can simply use Git to revert to the previous version. With GitOps, rolling a bad deployment back is as easy as it can get.
It’s Easy to Share Knowledge Across the Team
Having a Git repository as the single source of truth for the infrastructure makes it very easy to share information across the team. If you want to learn how the infrastructure evolved over time, it’s just a matter of cloning the repository and reading through the past commits.
What Should Your Next Step Be on Your GitOps Journey?
In this post, we’ve given you a brief introduction to the concept of GitOps. It is, in short, a way to apply DevOps practices to native cloud applications. Better yet, GitOps accomplishes that while employing tools and workflows developers already know and love.
As its name makes it clear — and this post made even clearer — Git is central in GitOps. That means that mastering Git isn’t optional when it comes to implementing GitOps. If you feel your team isn’t as up to speed with Git as they should be, you might take a look at Cprime’s Git and GitHub Bootcamp.