What Is GitOps?
Glossary

What Is GitOps?

May 03, 2023
In this article

While the software development cycle has been automated through DevOps practices, infrastructure has lagged behind. Infrastructure management has remained largely manual and requires specialized teams and workflows to operate. This just isn’t feasible anymore with the growing use of cloud-first technologies and development practices. Infrastructure automation has become a critical process when keeping up with today’s pace of development and the complex, dynamic nature of the cloud resources involved. That’s where GitOps comes in. 

 

What is GitOps?

GitOps is an infrastructure automation methodology that uses Git as the single source of truth for declarative infrastructure and application deployment. As an operational framework, it employs DevOps best practices like version control, collaboration, and CI/CD among others and applies them to infrastructure automation.

In GitOps, all infrastructure and application configuration is defined in code that is version-controlled and stored in Git. All changes to the configuration are made via Git pull requests that trigger an automated pipeline for making changes to the live environment. The pipeline tests, builds, and deploys the changes while ensuring that the live environment is always in sync with the Git repository. GitOps makes it possible to have a consistent, automated, and auditable approach to infrastructure deployment and management whether for Kubernetes or other cloud-native technologies. 

 

What are the core principles of GitOps?

In short, the core principles of GitOps are: 

Infrastructure as Code (IaC): All infrastructure, from configuration to deployment scripts, are managed as code and version in a Git repo. 

Declarative configuration: Changes should be made in a declarative format that specifies the desired state of the infrastructure — think Kubernetes. 

One Git, one truth: Git should be the canonical repository for all configuration, deployment scripts, and any other infrastructure-related files. 

CI/CD: Automated pipelines that use Git as the control plane are used to continuously integrate and deliver changes to the target environment. 

Observability: The system should provide real-time feedback on state of infrastructure and applications for clear observability. 

Security and Compliance: Security and compliance requirements must be met with appropriate access control, log auditing, and other security best practices. 

 

What is the difference between GitOps and DevOps?

Although seemingly very similar there are distinct differences between GitOps and DevOps. GitOps is actually a subset of DevOps and focuses on using Git as a single source of truth for infrastructure and application development while DevOps is a broader concept focused on integrating development and operations teams with application and server configuration files at the center. More specifically, GitOps and DevOps are different in: 

Practice Focus: While DevOps is focused on development and operations team practices for the sake of faster software delivery, GitOps is focused on using Git as the canonical source for infrastructure and application delivery specifically. Moreover, GitOps works with containerization technologies like Kubernetes and DevOps can be used with any application. 

Control: In GitOps, infrastructure and application delivery is managed through version-controlled Git repos that provides greater visibility and control over the entire tech stack. DevOps emphasizes collaboration and communication across teams. 

Automation: GitOps is all about automation with Git triggering automated deployment and management of infrastructure and applications. DevOps also focuses on automation but has a broader scope, including automating testing, deployment, and monitoring. 

 

How should teams conduct effective GitOps? 

GitOps can be different from team to team depending on needs and goals. But there are some general things to keep in mind when getting started with GitOps, including using a dedicated GitOps repo that holds all configurations and code for all team members, automating code changes, and setting up alerts for when changes occur. 

This can all be made possible with three things in mind: Infrastructure as code (IaC), merger requests (MRs), and continuous integration and continuous delivery (CI/CD). IaC makes it possible to define and control all changes to infrastructure in a repeatable, scalable, and predictable manner. With MRs as the change mechanism, teams can collaborate through reviews and comments. Plus, it serves as an audit log as merges commit to the main branch. CI/CD enacts changes in the environment automatically as code is merged simplifying the speed and frequency of deployments. Moreover, if any errors are introduced via manual changes or errors, they’re automatically overwritten so the environment always matches the desired state as defined in the Git.  

Other things to note include declarative configuration, progressive delivery, and observability. It’s important to use declarative configuration files that define the desired state versus the steps required to reach it. This is how configuration drift can be avoided. Progressive delivery techniques like canary releases and feature flags are also key for gradually rolling out changes into production, reducing the risk of issues and making it easy to roll back things if necessary. Observability is integral in GitOps as much as it is in DevOps at large, so teams should build it into their system and workflows.

 

What are common GitOps challenges?

Much like DevOps, GitOps is tricky due to its collaborative nature. For instance, where once engineers could make quick, manual changes, they now have to make the changes, create a merge request, get it approved, and then it’s deployed under GitOps best practices. More specifically, GitOps can be challenging due to: 

Managing secrets: Security is always top of mind but not easy. Managing secrets means securing sensitive data from API keys to certificates to passwords, while still making them accessible to the pipeline. All members of a team should have access to what they need without encroaching on other secrets to prevent access to sensitive data.  

Version control: GitOps needs careful version control so all changes are tracked and audited. Challenges in this process may arise when dealing with dependencies and maintaining backward compatibility with legacy systems. 

Monitoring and alerting: Although GitOps pipelines are designed to be automated, they still require oversight. If not designed to be observable, issues can go unnoticed and can become hard to remediate when they happen. 

Rollbacks and disaster recovery: GitOps offers rollback capabilities that allows teams to restore a previous version of a system, but this can be complicated when there are too many changes or dependencies between services. Disaster recovery plans may be necessary as a result. 

System complexity: Modern systems are only getting more complex. This complexity is exacerbated when legacy systems are involved. If so, there may still be manual or a hybrid approach to managing it, adding complexity to GitOps pipelines. 

 

What are the benefits of GitOps?

GitOps makes it so organizations can manage their entire infrastructure and application development cycle in a unified way. It improves efficiency, security, and reduces cost. This happens because GitOps ensures that the desired state of the system is always maintained, making it easier to detect configuration drift —  improving reliability and consistency. There are also faster feedback loops since changes are made automatically, allowing teams to iterate and go to market faster. There is also improved collaboration, as both development and operations teams have access to a transparent deployment process. The same transparency makes it easier to be compliant and secure, providing a complete audit trail of changes. Finally, and not to be overlooked, GitOps reduces infrastructure costs. By reducing the need for manual intervention and streamlining the deployment process, efficiencies can greatly reduce overall cost. 

What is the future of GitOps and observability?

The future of GitOps is bright as it aligns with the surge in cloud-native technologies being adopted and the growth of Kubernetes as the de facto standard for container orchestration. What can we expect from GitOps in the time to come? 

Increased GitOps adoption in enterprise: GitOps is already widespread in the cloud-native community. It will continue to gain traction in the enterprise as more organizations move towards cloud-native architectures. 

More integrations: Expect GitOps to become even more integrated with existing tools and platforms like CI/CD platforms including Jenkins, CircleCI, or Travis CI, as well as Kubernetes-native tools. 

More focus on observability: Real-time monitoring will be crucial in such an automated process. Making systems observable and employing tools that can see into the GitOps pipeline, show cause and effect, and point to easy remediation will be integral to all future monitoring and troubleshooting.