GitOps is a paradigm designed around Kubernetes that allows developers and IT operations teams to use Git for cluster management and application delivery. Applying a Git workflow to operations and development teams allows developers to use Git pull requests to manage infrastructure provisioning and software deployment.
Git is an open source distributed code management and version control system. Git is used to track changes in source code throughout software development and is also used for configuration and content management. A portion of Git, related to GitOps, includes pull requests. A pull request lets users tell others what changes they've pushed to a new branch in a repository through GitHub. When a user opens a pull request, they can review, discuss or follow up on commits before any changes are merged into a base branch.
GitOps was developed by WeaveWorks, with the goal to create a "single source of truth" related to infrastructure and applications. To accomplish this, WeaveWorks placed Git at the center of their delivery pipeline so that developers can make use of pull requests to simplify operations and software deployment in Kubernetes.
GitOps uses Git wherever possible, from development to deployment. This means that GitOps can be used to code and write applications, build pipelines -- typically using YAML --, provision a Kubernetes cluster and deploy work on Kubernetes clusters, servers or container registries.
GitOps can be used by teams that often work with Kubernetes and want to start moving towards continuous models such as continuous integration (CI), deployment or testing.
How GitOps works
GitOps is based around pull requests. Once a pull request is initialized, the user should be able to see an overview of changes in each branch in a repository base. The user can then add a summary of proposed changes, review changes, add labels and mention other contributors. After the pull request is created, a commit from a topic branch can be added to the pull request -- where contributors can then view any proposed changes themselves. Once everyone approves of the request, the changes can be merged with the pull request.
Possible changes to an application or cluster could include updates to container images, fixes to errors in the environment or updates to specifications. Troubleshooting with GitOps tends to be fast since users can fix any issues that appear with a pull request rather than in the underlying system.
GitOps can also make use of other tools for Git pushes, development and continuous integration. GitOps will work with any CI and Git server. Other tools, such as Jenkins X, will also work with GitOps. Jenkins X is an open source tool which can provide continuous integration and continuous delivery, as well as other automated testing tools designed for cloud-native applications -- specifically in a Kubernetes environment. Other tools such as GitHub, Bitbucket or AWS CodeDeploy can be used in GitOps too. Bitbucket is a repository tool similar to GitHub; however, Bitbucket hosts Mercurial repositories as opposed to the Git repositories that GitHub uses. AWS CodeDeploy can be used to automate code deployments.
Uses of GitOps
GitOps can be used for a number of reasons, for example, to enable continuous deployment for Kubernetes. Besides enabling an organization to push applications out more quickly, continuous deployment removes the need for any individual deployment management systems.
GitOps can also be used to implement continuous delivery for Kubernetes. Continuous delivery typically enables development teams to build, test and deploy software at a fast pace through incremental updates. Continuous delivery for Kubernetes also enables a continuous integration and runtime pipeline -- which should be able to read and write files to Git, update container repositories and load container images.
GitOps also allows an organization to use a single tool for controlling infrastructure, enabling version control for changes in configuration as well as the ability to constantly monitor for changes and give alerts.
Advantages of implementing GitOps include:
- Increased productivity through the enablement of continuous delivery and deployment;
- Reliability through revert/rollback and fork features;
- Standardized workflows centered around Git;
- Enables an organization to use a single set of tools;
- Reduces the number of potential variables in infrastructure management;
- Provides additional visibility; and
- Smaller potential attack surfaces.
Some disadvantages of GitOps, however, include:
- Users must look out for broken YAML manifests, in which syntax or object references may be broken.
- By approaching development through a pull approach, users are limited to using only tools that execute pulls.
- There is potential for API throttling, since GitOps will consistently poll Git repo.
GitOps vs. DevOps
GitOps and DevOps are very similar sounding portmanteaus, which have equally important similarities and differences.
DevOps is a combination of the words "development" and "operations." It's a collaborative approach to tasks performed by an organization's application development and IT operations teams. Some of the main goals in DevOps are to promote collaboration between development and operations teams and to adopt programmable software development, automation and infrastructure deployment practices.
GitOps is a subset or extension of DevOps that specifically leverages the tool Git. One of the main goals of GitOps is to automate the development process and speed up release cadences, which is a shared goal of DevOps. However, GitOps is a paradigm or technique, whereas DevOps is more of a culture or philosophy. GitOps is tied to the use of Git and Kubernetes, whereas DevOps is not tied to the use of a single tool.
Future of GitOps
Some believe GitOps may be the future of DevOps -- this is because GitOps is both a declarative and a cloud-native approach to configuration management. GitOps is certainly useful in instances where using version control to manage infrastructure and application deployment would be difficult otherwise.
However, the future of GitOps may not be the right fit for everyone, as not every organization will view having a reliance on a single tool or even just using Git pull requests as the most optimal workflow for their infrastructures.