The Essentials of Gitops: The Need For A New Operational Model
The Essentials of Gitops: The Need For A New Operational Model
The Essentials
CONTENTS
∙ Infrastructure Automation
of GitOps
for Modern Applications
∙ GitOps Benefits
∙ Conclusion
ISAAC MOSQUERA
CHIEF TECHNOLOGY OFFICER, ARMORY
THE NEED FOR A NEW code (IaC), merge requests (MRs) as the request for change and system
With increasing user demand for always-on applications, available GitOps = IaC + MRs + CI/CD
on any device, the complexity and sophistication of software
development and delivery amplify. Traditional, monolithic apps CORE PRACTICE: INFRASTRUCTURE-AS-CODE
are being decomposed into cloud services that are built and run Infrastructure-as-Code (IaC) is the practice of keeping all infrastructure
by a distributed workforce, collaborating from around the globe. configurations stored as code. GitOps uses a Git repository as the single
Operations teams need a new paradigm to support the upsurge of source of truth for the definition of your infrastructure environments.
deployment frequency across multiplying services and in multiple By shifting your environment definitions from manual configuration
regions, all while reducing risk, increasing uptime, and staying secure. to configuration by code, you gain access to an array of benefits such
as version control, code collaboration, and auditability.
GitOps is an operational framework that takes DevOps best
practices used for application development, such as version You also unlock Git as the user interface for your infrastructure,
control, collaboration, compliance, and CI/CD, and applies them to allowing you to leverage all of the developer tooling, training, and
infrastructure automation. While GitOps practices work well within knowledge associated with Git for your infrastructure operations.
any software environment, Kubernetes is particularly well suited
due to its use of declarative infrastructure definitions kept alongside
application code in a Git repository.
Keeping your system definition in Git means your engineers can use
familiar, Git-based tooling and workflows to manage both application
and infrastructure changes. With the entire state of your cluster kept
under source control, you gain the ability to automate changes for
less risk, recreate historical states, review a robust audit log, manage
compliance, and more.
INFRASTRUCTURE AUTOMATION
FOR MODERN APPLICATIONS
GitOps practices aren’t dependent on any specific technology. While
logically GitOps is simply managing operations by Git, there are three
core practices that make up a mature GitOps practice: Infrastructure-as-
1
armory.io
Continuous delivery
at enterprise scale
Although IaC is a popular and well-known practice, GitOps isn’t that environment. Changes are proposed on a feature branch, and a
relegated to simply infrastructure. Any operations that can be defined PR is made to merge the changes into the main branch. This PR allows
as code (e.g., network, policy, security) are benefits of GitOps too. In for collaboration between operations engineers for peer review, along
some cases, the term “X-as-Code” (XaC) can be used to encompass with the development teams, security teams, and other stakeholders.
operations beyond infrastructure. This Refcard uses the more This powerful model for collaboration permits anyone to propose a
established term “IaC” with the understanding that we're including the change, while also allowing you to maintain compliance by limiting
entirety of the operational environment, not simply the infrastructure. the number of people who can merge the changes.
It’s the difference between saying, “I have three servers but want six, This type of automation serves as a powerful protection against
so I need to write a script to create three more services,” and simply configuration drift. There are many reasons configurations can fall out
telling the system, “There should be six servers. If there comes a of sync. Whether due to a component failure or inadvertent manual
point when there are too few or too many, change the state of the change, each time the automation runs, it overwrites the existing state
environment until we have the correct number.” Using declarative with Git source of truth.
patterns can be very powerful within a GitOps operational model,
but they aren't a strict requirement. You can still benefit from GitOps AGENT VS. AGENTLESS GITOPS
practices if your environments are imperatively defined. A couple of different models for GitOps automation have emerged,
namely Agent-based and Agentless, each with its own pros and cons.
CORE PRACTICE: USING PULL REQUESTS Agentless GitOps is a traditional model, also known as push-based
FOR CHANGES GitOps, in which your CI/CD tool reads from your Git repository and
It may be surprising to learn that the underlying Git version control pushes changes into your environment.
system used to power tools such as Bitbucket, GitHub, and GitLab • Pro – It’s simpler and more flexible as it can be used with
doesn’t include a way to request your branch be merged back into the any type of infrastructure, from physical servers and VMs to
branch it was created or forked from. This was a later advancement Kubernetes clusters.
introduced by Git management tools. GitHub and Bitbucket use the
• Con – You must give your CI/CD tool access to make writes
term pull request (PR) while GitLab uses the term merge request
to your environment. Requiring your environment to be
(MR), but functionally, they perform as a central point of developer
open to writes from the external internet can cause security
collaboration for code review and change orchestration.
and compliance issues.
Without a proper version control and branching strategy, collaboration
Figure 1: Agentless GitOps model
on new changes is a frustrating endeavor. When anyone can modify a
file without a way to track who made which change, it can be almost
impossible to ensure the correct version is being used. A common
application development workflow uses a main branch as a centralized
collaboration point. Feature branches are created from the main
branch, where new work is developed, and merged back into the main
branch using a pull request. Leveraging this best practice for all of your
infrastructure code nets you the same benefits that developers enjoy.
Agent-based GitOps, also known as pull-based GitOps, makes use of an INCREASED DEPLOYMENT FREQUENCY
agent that runs inside of your infrastructure. This agent pulls changes With automated application deployment and environment
in from an external Git repository when it detects that the state of the provisioning, you can do many small, frequent deployments rather
environment is out of sync with the source of truth. than occasional large, risk-prone deployments. Smaller changes are
easier to reason about when troubleshooting and easier to roll back.
• Pro – CD agents can allow you to operate in a more secure
Additionally, deploying features to your users sooner leads to happier
and compliant way without the need to open inbound ports
users, more actionable feedback, and ultimately improved software.
in your firewall.
• Con – Agents must be custom-designed to the type of REDUCED MEAN TIME TO RECOVERY
infrastructure you want to use. A core benefit of keeping environment state in version control is that
rolling back to the last known good configuration when you experience
Figure 2: Agent-based GitOps model
problems is straightforward. This can dramatically reduce your mean
time to recovery (MTTR) because you can fix issues quickly during
an incident by rolling back, and then after your system is operating
normally, you can troubleshoot.
With manual tools, auditing is highly painful. Pulling data from multiple
places and trying to normalize it is extremely time-consuming. Having
all operations in Git gives you a one-stop shop for audit logs of every
GitOps best practices are far-reaching and can provide the following
ENHANCED SECURITY
benefits.
Leveraging Git’s robust permission model makes it simple to grant,
TIGHTER COLLABORATION revoke, and track permissions for each environment. Beyond read/
Using the pull requests as a central point of collaboration enables write access, the Git merge request workflow unlocks an additional
teams across the organization to work together in a fast, automated, ability to grant proposal access. Many users can be granted the ability
and asynchronous way. Best practices from one team can be easily to propose changes, while simultaneously keeping the pool of people
shared and consumed across the organization because they are who can enact those changes small.
documented as code.
GITOPS TOOLING AND TECHNOLOGIES 8. The code is iterated on until it meets the standards to be
As a methodology, GitOps doesn’t require any specific technology to merged. This typically means all automated checks have
implement. The following table lists examples of the types of tooling passed, all comments are resolved, and any needed
that you’ll generally want to implement when adopting GitOps, along approvals have been added.
with some examples of each. 9. The Git merge to the main branch triggers the CI/CD
deployment pipeline, where an additional set of
Table 1: Examples of GitOps tooling
automated tests can be run.
TOOLING TYPE EXAMPLE
10. The infrastructure pipeline configures and provisions
Git code repository Git
the environment, while the product pipeline deploys
Git management tool Bitbucket, GitHub, GitLab the application code.
Workflows can vary depending on the size of the team, the repository
setup, and if you are using Agent or Agentless tooling. The workflow WRITTEN BY ISAAC MOSQUERA,
above can be adapted and extended to meet the specific requirements CHIEF TECHNOLOGY OFFICER & CO-FOUNDER, ARMORY