What is GitOps

Simply put: GitOps is a way of managing infrastructure, configuration, permissions, etc... in an explicit and repeatable way by simply pushing changes to git and allowing an associated pipeline to make the changes come to life.
Let's dig a little deeper.

What GitOps Isn't

GitOps is not meant to replace DevOps. It's not a way to deploy code, and it doesn't even have to be associated with changes that affect our code or environment in any way.

When to use GitOps

If your task doesn't require a build, but it can be automated, it's likely a candidate for GitOps. Some examples of when to use GitOps are when you want to:

  • Manage infrastructure changes with Terraform
  • Manage user permissions
  • Manage configuration independent of infrastructure or applications

A quick example

To get started with GitOps, you simply need to find a place where you can manage something via code. Let's consider a scenario where you want to manage users in your GitHub Organization. This is an example of changing something that doesn't affect code nor environments. Here's a block with Terraform that can do just that:

# Add a user to the organization
resource "github_membership" "membership_for_some_user" {
  username = "SomeUser"
  role     = "member"

This is just a simple example of something you can manage, but there are few limits to the things you can do with GitOps. The above would allow us to explicitly define a user and their role in our organization. What's better is that if someone manually alters their permission, we will know the next time we run the GitOps pipeline, because Terraform would tell us. And even better, their permissions will be reset to the role that we explicitly set with this declarative block.