Learn how GitOps manages infrastructure through code and automation by building on the success of DevOps practices.
The DevOps playbook has proven its value for many organizations by improving software development agility, efficiency, and speed.
DevOps enables developers to rapidly and frequently release new features and services by using continuous integration and continuous delivery (CI/CD), suites of collaboration tools, and version control practices, most often with the open source Git software at its core.
These methods improve the software development lifecycle (SDLC), but what if infrastructure deployment and management could also benefit? This method known as GitOps would also boost the speed and efficiency of practicing DevOps organizations.
What is GitOps?
GitOps is a specialized, prescriptive discipline of DevOps used to achieve similar goals of speed and efficiency. Building on the success of DevOps practices, GitOps is a relatively new way to manage infrastructure through code and automation, around a single Git repository (or a storage system for all the changes and files that relate to a given project).
Development teams use GitOps to specify their infrastructure requirements in code. Known as infrastructure as code (IaC), it can build out infrastructure automatically to scale. GitOps improves speed and scalability. Instead of manually setting up each configuration, the same environmental configuration is deployed and synced for each application deployment.
These practices can be a boon to infrastructure management, but GitOps presents challenges. The major challenge is ensuring that all participants are committed and accountable to the process while consistently documenting changes to production environments. GitOps also requires extensive approvals for any development.
Another challenge is the lack of expertise and lack of guidance. While GitOps can work without cloud, having Kubernetes knowledge helps to fully understand the function and impact of GitOps processes (teams can use GitOps outside of Kubernetes, but the practice is more commonly used with Kubernetes). Managing clusters through Git requires a broad and deep knowledge of Kubernetes to get the most from GitOps’ version control and verification advantages.
How does GitOps work?
At its most basic, GitOps uses Git repositories to store configuration files that define the desired state of your infrastructure, such as a Kubernetes cluster or any cloud-native application. Much like in software development, push-pull requests make changes to the files and merge them with the main file. Then, automation tools check the operation of those changes before deploying them to the Kubernetes cluster.
A key function of GitOps practices is verification. Since we can observe the state of the environment and view the specific Git repository, we can verify that the environment is in the new, desired state. The fluidity of this process is possible through automation tools compatible with Kubernetes.
What is a GitOps workflow?
In an example scenario, a team decides they need to change the Git repo to support the deployment of a new service. First, a developer creates a branch from the trunk, or main branch, of a Git repository. The developer then modifies the configuration files to include specifications for the new namespace and set of nodes into a configuration template. Then, a developer creates a pull request in Git. Another developer on the team can review the pull request before merging into the main branch. After merging, a CI/CD pipeline builds, tests, and deploys the application. Then a GitOps operator deploys the new configuration template. Kubernetes ends the workflow using a convergence mechanism that can detect differences in the current and desired configuration states. The mechanism eventually syncs the two with the new configuration changes applied. This new configuration state, as a template, can then be applied to hundreds of different application environments. It is scalable and reduces time needed to set up infrastructure.
Kubernetes, CI/CD, and GitOps
GitOps, when practiced successfully, empowers managing your Kubernetes clusters. Containers have become the standard way to deploy cloud-native services, and Kubernetes is the most widely-used container orchestration system. Managing Kubernetes can be challenging, especially if you depend on ad hoc scripts to make calls to the Kubernetes application programming interface and make changes to a cluster. If you’re new to Kubernetes, download the ebook The State of the Kubernetes Ecosystem to see how it can work across a host of environments.
While Kubernetes is a powerful platform, it depends on complex automation tasks that can make troubleshooting challenging. Developers can easily make a series of changes to a Kubernetes cluster using imperative kubectl commands that leave the cluster in an unexpected, unwanted state. Finding the source of the unwanted behavior or cluster states takes time that eats into other pressing infrastructure work.
Using declarative specifications and CI/CD pipelines helps avoid these kinds of problems. If there is a specification error, developers can use the same CI/CD pipelines to return to a previous working state.
Continuous integration processes prevent conflicting merges by utilizing automated management systems to properly organize and merge code. For GitOps, this means that changes to Kubernetes deployments won’t conflict. Conflicts would cause disruptions and require tedious troubleshooting sessions. Continuous delivery processes similarly streamline operations by breaking deployment changes into smaller chunks. This makes tracking and managing Kubernetes infrastructure more manageable and reduces deployment errors. Because the pipeline promotes controlled integration and delivery, rolling back infrastructure to a working state is faster and more efficient.
Using CI/CD with infrastructure unlocks the benefits of a modern software delivery life cycle. GitOps shores up infrastructure stability, and CI/CD pipelines are a crucial part of that function. With GitOps taking advantage of DevOps’ success, the result is greater automation and stability.
Dynatrace enables observability in GitOps
As more teams apply GitOps as an operational framework to automate the provisioning of infrastructure, Dynatrace’s monitoring platform facilitates observability through integrations with monitoring and configuration tools such as Prometheus, Jaeger, Ansible, and cloud-specific integrations. Dynatrace also supports monitoring as code and GitOps practices through Monaco. This supports automated syncing of environment configurations that can be scaled to all your applications to reduce onboarding time. GitOps practices can improve infrastructure management efficiency and stability. But without proper monitoring tools, it’s easy to get bogged down with the intricacies of Kubernetes deployments. With Dynatrace, you will gain deeper insights into the state of your infrastructure with end-to-end observability, distributed tracing, and cloud automation.