GitOps is an operational approach for platform engineers and software developers where every aspect of a project’s infrastructure, including infrastructure as code files, configuration files, and application code files, are stored in git repositories. When a git commit is pushed to source control, it triggers a change that updates the cloud infrastructure or application. GitOps relies on Git as the single source of truth, meaning that only changes in git can trigger builds and deployments of infrastructure and applications. Organizations that have Kubernetes as their container orchestration platform often use GitOps.
A platform engineering team builds a DigitalOcean Managed Kubernetes Cluster using Terraform. The cluster and all associated resources are defined in Terraform files stored in a Git repository. When `terraform plan` is run, the Terraform state file is stored in a DigitalOcean Spaces Bucket. Once the Kubernetes cluster is up and running, the platform engineering team installs FluxCD and Helm in the cluster. Whenever a platform engineer makes a change to the Kubernetes cluster, or any other DigitalOcean resources, they make changes to a Terraform file and commit the change via Git. FluxCD monitors changes made to the Git repo, and when it notices the new commit, it applies the changes to the infrastructure.
Now the deployment platform is ready for the application development team. The dev team builds their application, uses Docker to create an image of their containerized application, and stores the image in the DigitalOcean Container Registry. Once they have the image of their application in the container registry, the application development team prepares to deploy the application inside the Kubernetes cluster by creating Helm manifests to set up the application in the cluster. These manifests are stored in a Git repository and added to the list of repositories that Flux monitors. Now, whenever the development team makes a change to their Helm manifests, Flux knows to roll out the update in the Kubernetes cluster.
Here is a diagram of this Gitops story.
DevOps is a way of thinking that aims to increase collaboration and eliminate silos within organizations by encouraging a culture shift, training, and the use of many different tools. GitOps is a subset of DevOps, which uses software tools to ensure that Git repositories are the single source of truth for a company’s digital infrastructure. Some popular GitOps tools include Flux, ArgoCD, and Jenkins X.
It provides the opportunity for continuous delivery
Implementing GitOps enables developers to take advantage of continuous delivery. Continuous delivery allows developers to send changes of all kinds into production faster, safer, and more sustainably. The system is automated so that when someone makes a change to an application or infrastructure, the system makes updates in a staging environment, verifies whether or not the changes are safe, and then deploys the changes to production as quickly as possible. This allows developers to get updates, changes, and fixes to the customer faster.
It’s public and verifiable
GitOps requires engineers to manage their systems using a declarative approach, meaning that configuration is guaranteed by code in a file instead of commands from an individual’s terminal. Having configuration code stored in a file and updated via git allows for each change to be tracked within the system. Every change made in the system is viewable, and all changes must be verified and approved before going to production. The transparency provided by GitOps means that no one person or team houses the entirety of the knowledge of the application or infrastructure, making the system more resilient in large organizations.
It’s easier to audit
Because all changes are tracked in the system, it’s relatively easy to audit and revert if something goes wrong. This means that teams can move faster, test more often, and be more agile.
Using GitOps to manage containerized workloads is increasingly popular. Kubernetes is another tool that can be operated declaratively, which means it can be version-controlled through Git. Check out this tech talk to learn what a production-ready, GitOps-enabled Kubernetes cluster looks like.
Take a look at this tutorial to learn how to set up a GitOps workflow using ArgoCD and Kubernetes.
Many organizations use DigitalOcean as they experience rapid growth. From Droplet virtual machines to App Platform, our Platform as a Service offering, and Managed Kubernetes, we provide the tools you need to build and grow your applications. To sign up for a DigitalOcean account, click here.