July 10, 2024

What is GitOps? Examples, Use Cases, and More

DevOps

This blog will be the first in a two-part blog series where we explore the benefits of the GitOps practice and how to get the most from GitOps. Here is an overview of the series:

  • Part 1: What is GitOps? Examples, Use Cases, and More — The start of our series and introduction to the concept and inner working of GitOps. 
  • Part 2: Gain Efficiency with a GitOps Workflow — Once you’ve implemented the Four Principles of GitOps, here's how to build a standardized workflow that adds consistency and efficiency to your plan. 

Let’s start at the very beginning — what is GitOps? If you want to start to build a single source of truth for both your code and your infrastructure, if you want to ensure your deployments are automated and reliable, you’ll want to know GitOps.

Table of Contents: 

What is GitOps? 

GitOps is an operational framework that uses tried-and-true Git concepts to manage your infrastructure and applications. It takes the core principles of DevOps – collaboration, automation, and version control – and applies them to everything from code deployment to infrastructure provisioning. 

To break this down further, Git is a tool that tracks changes to files over time — essentially a version control system for your code. It's like a “rewind” button for your project, letting you see past versions or revert to an earlier state as needed. 

And Ops? This broad word includes all tasks that keep things running smoothly, like managing servers, deploying applications, and ensuring system uptime. 

What is the Origin of GitOps? 

In 2017, the CEO of Weaveworks, Alexis Richardson, first coined the term “GitOps.” But Gartner Research was one of the earliest places where the term was defined and tracked across industries. They produced several reports like the “Top 4 Uses Cases for GitOps” since then, helping spread the word about this operational framework and broaden use.

How Does GitOps Differ from DevOps? 

DevOps broadly emphasizes collaboration and automation throughout the software development lifecycle. It encourages breaking down silos between development and operations teams. GitOps, on the other hand, is a specific practice within DevOps that leverages Git for infrastructure and application configuration. DevOps is the philosophy and GitOps as a specific toolset that embodies those principles. 

OpenGitOps narrows down this philosophy by breaking it into four principles. These principles were developed from best practices for the operation and management of software systems. 

The Four Principles of GitOps 

Within each of these GitOps principles, you have the idea of the “Desired State.” When you describe the Desired State of your system using version-controlled data that can't be changed directly, you continuously guide the actual configuration of your running system, ensuring it always matches your desired state. 

  1. The Principle of Declarative Desired State 

    Instead of telling a system how to achieve something, GitOps lets you describe what you want the result to be (i.e., it’s declarative). You write this desired state as data, making it easy for both humans and machines to work with. 

  2. The Principle of Immutable Desired State 

    Versions Changes to your desired state are tracked in versions, just like code. This lets you see history, rollback if needed, and ensures each configuration is unique and traceable. 

  3. The Principle of Continuous State Reconciliation 

    GitOps constantly checks the actual state of your system (running applications, server settings) against the desired state you defined. If there's a mismatch, it automatically fixes it. 

  4. The Principle of Operations Through Declaration 

    Forget manual configuration changes — with GitOps, everything you do to manage the system (deployments, scaling, updates, etc.) happens by declaring the desired state, which simplifies operations and reduces errors. 

With these four principles, the developer community can understand exactly what GitOps is and what it is not, starting from the beginning of the development workflow all the way to deployment. 

In short GitOps is developer-friendly Infrastructure that: 

  • Leverages familiar Git for app configuration and infrastructure. 
  • Stores everything in Git repositories for version control. 
  • Automates deployment and keeps infrastructure in sync. 

How Are Teams Using GitOps? 

How exactly are teams using GitOps to streamline their workflows and achieve greater agility? 

Common Use Cases Continuous 

Delivery: Automate infrastructure deployments alongside application updates, enabling faster releases. 

Multi-Cluster Management: Simplify the management of complex deployments across multiple Kubernetes clusters. 

Disaster Recovery: Quickly restore infrastructure from a known good state stored in Git, minimizing downtime. 

You may have heard that GitOps is ideal for cloud-native Kubernetes deployments. And while GitOps does excel with Kubernetes, its benefits extend to broader infrastructure management. 

Teams can leverage GitOps principles for cloud deployments, virtual machines, and even bare-metal setups. The key lies in treating configurations as code and leveraging Git for version control and automation. 

Decluttering Your Infrastructure with Code 

Traditionally, infrastructure configurations were scattered across manual processes and cryptic scripts. GitOps throws that chaos out the window. By treating infrastructure as code (IaC), GitOps stores configurations in version-controlled Git repositories – the same familiar tools developers use for application code. This brings several benefits: 

  • Version Control: Track changes, rollback if needed, and ensure consistent infrastructure across environments. 
  • Collaboration: Developers and operations teams work together in a central location, fostering better communication. 
  • Automation: GitOps tools automate the deployment process based on changes in the Git repository, reducing manual errors. 

By embracing GitOps, teams are experiencing a paradigm shift in infrastructure management. Version control, improved collaboration, and automated deployments are just a few of the advantages this approach offers. As cloud adoption continues to rise, GitOps is poised to become an essential tool for building and maintaining robust, scalable infrastructure. 

Getting Started with GitOps 

So, you’ve gotten buy-in from your team and you are ready to implement GitOps principles and simplify workflows, improve reliability, and enhance collaboration. At its most basic, here is how you get started with GitOps: 

  1. Choose Your Tools: Several GitOps tools exist, each with their own pros and cons. As we’ll explore in the next section, Puppet manages and enforces your desired state with infrastructure as code and is a solid addition to your GitOps tooling plans. 
  2. Define Your Configuration: Start by codifying your infrastructure and application configurations in YAML or JSON files. 
  3. Set Up Your Git Repository: Create a dedicated Git repository to store your configuration files. 
  4. Implement GitOps Tools: Integrate your chosen GitOps tool with your Git repository and target deployment environment. You can then start enforcing your desired state using infrastructure as code. 

How Puppet Supports GitOps 

Puppet Enterprise excels at infrastructure and policy as code — which covers the very first Principle of Declarative Desired State for GitOps. This allows you to define your desired state in code files, which can be easily stored in a Git repository. 

GitOps and Puppet are a perfect match for: 

  • Improved Collaboration: Teams work together on infrastructure changes through pull requests and code reviews. 
  • Auditable History: Git tracks all changes, allowing you to see who made what modification and when. 
  • Reduced Errors: Human intervention in infrastructure management is minimized, leading to less errors. 
  • Disaster Recovery: Rollback to previous configurations is simplified with Git's version control. 

Puppet's capabilities and mature tooling make it the perfect fit to support your GitOps strategy. 

Puppet's capabilities and mature tooling make it the perfect fit to support your GitOps strategy. 

Summary 

GitOps is an operational framework that was popularized by Gartner and leverages Git for infrastructure and application management. GitOps streamlines workflows, improves reliability, and enhances collaboration by:

  1. Treating infrastructure as code (IaC): Configurations are stored in version-controlled Git repositories, enabling version control, collaboration, and automation. 
  2. Using a declarative approach: Your desired state is defined rather than specific commands for achieving it. 
  3. Employing continuous reconciliation: The system automatically ensures the actual state matches the desired state.

Common use cases include continuous delivery, multi-cluster management, and disaster recovery. GitOps is well-suited for cloud-native deployments but can also be applied to broader infrastructure management. 

Don’t miss the rest of our two-part series on GitOps best practices, including how to develop and maintain a mature GitOps strategy with tips you can use: 

If you want to see how Puppet Enterprise can support GitOps yourself, request a free demo at:

TRY PUPPET FOR GITOPS