What is GitOps?
GitOps is an operational framework that takes DevOps best practices used for application development such as version control, collaboration, compliance, and CI/CD, and applies them to infrastructure automation.
GitOps is an operational framework that applies DevOps practices like version control, collaboration, and CI/CD to infrastructure automation, ensuring consistent, repeatable deployments.
While much of the software development lifecycle has been automated, infrastructure has remained a largely manual process that requires specialized teams. With the demands made on today’s infrastructure, it has become increasingly crucial to implement infrastructure automation. Modern infrastructure needs to be elastic so that it can effectively manage cloud resources that are needed for continuous deployments.
Modern and cloud native applications are developed with speed and scale in mind. Organizations with a mature DevOps culture can deploy code to production hundreds of times per day. DevOps teams can accomplish this through development best practices such as version control, code review, and CI/CD pipelines that automate testing and deployments.
GitOps is used to automate the process of provisioning infrastructure, especially modern cloud infrastructure. Similar to how teams use application source code, operations teams that adopt GitOps use configuration files stored as code (infrastructure as code). GitOps configuration files generate the same infrastructure environment every time it’s deployed, just as application source code generates the same application binaries every time it’s built.
Teams put GitOps into practice by using Git repositories as the single source of truth, automating deployments, and enforcing changes through merge requests or pull requests.
GitOps is not a single product, plugin, or platform. There is no one-size-fits-all answer to this question, as the best way for teams to put GitOps into practice will vary depending on the specific needs and goals of the team. However, some tips on how to get started with GitOps include using a dedicated GitOps repository for all team members to share configurations and code, automating the deployment of code changes, and setting up alerts to notify the team when changes occur.
GitOps requires three core components:
Infrastructure as code (IaC):
GitOps uses a Git repository as the single source of truth for infrastructure definitions. Git is an open source version control system that tracks code management changes, and a Git repository is a .git folder in a project that tracks all changes made to files in a project over time. Infrastructure as code (IaC) is the practice of keeping all infrastructure configuration stored as code. The actual desired state may or may not be not stored as code (e.g., number of replicas or pods).
Merge requests (MRs):
GitOps uses merge requests (MRs) or pull requests (PRs) as the change mechanism for all infrastructure updates. The MR or PR is where teams can collaborate via reviews and comments and where formal approvals take place. A merge commits to your main (or trunk) branch and serves as an audit log or audit trail.
Continuous integration and development (CI/CD):
GitOps automates infrastructure updates using a Git workflow with continuous integration and continuous delivery (CI/CD). When new code is merged, the CI/CD pipeline enacts the change in the environment. Any configuration drift, such as manual changes or errors, is overwritten by GitOps automation so the environment converges on the desired state defined in Git. GitLab uses CI/CD pipelines to manage and implement GitOps automation, but other forms of automation, such as definitions operators, can be used as well.
With any collaborative effort, change can be tricky and GitOps is no exception. GitOps is a process change that will require discipline from all participants and a commitment to doing things in a new way. It is vital for teams to write everything down.
GitOps allows for greater collaboration, but that is not necessarily something that comes naturally for some individuals or organizations. A GitOps approval process means that developers make changes to the code, create a merge request, an approver merges these changes, and the change is deployed. This sequence introduces a “change by committee” element to infrastructure, which can seem tedious and time-consuming to engineers used to making quick, manual changes.
It is important for everyone on the team to record what’s going on in merge requests and issues. The temptation to edit something directly in production or change something manually is going to be difficult to suppress, but the less “cowboy engineering” there is, the better GitOps will work.
There are many benefits of GitOps, including improved efficiency and security, a better developer experience, reduced costs, and faster deployments.
With GitOps, organizations can manage their entire infrastructure and application development lifecycle using a single, unified tool. This allows for greater collaboration and coordination between teams and results in fewer errors and faster problem resolution.
In addition, GitOps can help organizations take advantage of containers and microservices and maintain consistency across all their infrastructure — from Kubernetes cluster configurations and Docker images to cloud instances and anything on-prem.
GitOps is a modern implementation of DevOps that uses Git repositories as the single source of truth for both infrastructure and application deployments.
While DevOps is a broader cultural and technical movement focused on collaboration, automation, and continuous delivery across all types of applications, GitOps applies these principles specifically through Git-based workflows.
GitOps is most commonly used with containerization technologies like Kubernetes, since declarative infrastructure aligns well with version-controlled workflows, while DevOps practices can be applied to any type of environment.
The key difference is that GitOps requires Git to be the definitive source of truth for deployment state, whereas DevOps does not mandate a specific source of truth and can use a variety of tools and approaches.
The four key components of a GitOps workflow are a Git repository, a continuous delivery pipeline, an application deployment tool, and a monitoring system.
A GitOps workflow refers to a systematic and version-controlled approach to infrastructure and application management. Imagine it as treating your system operations with the same rigor you expect from your codebase. In GitOps, Git repositories serve as the single source of truth for system and infrastructure configurations.
Changes to configurations are made through pull requests, ensuring peer reviews and audit trails for updates. Automated tools implement these changes, allowing for consistent and reproducible deployments. This methodology enables high velocity, empowers collaboration among team members, and heightens operational efficiencies through clear documentation and traceability.
Key components of a GitOps workflow
A GitOps workflow is built around four fundamental components, each playing a vital role in streamlining the deployment and management of applications.
1. Git Repository: This serves as the foundational element, acting as the central source of truth for both the application's code and its configuration. By storing all critical information in the Git repository, teams ensure consistency and transparency across the development lifecycle.
2. Continuous Delivery (CD) Pipeline: The CD pipeline automates the processes of building, testing, and deploying the application. It bridges the gap between code development and deployment, facilitating a smooth transition from development to production environments while ensuring that the application meets quality standards.
3. Application Deployment Tool: This tool takes charge of deploying the application into the desired environment. It handles the orchestration and management of application resources, ensuring that the application is deployed correctly and efficiently according to the configurations defined in the Git repository.
4. Monitoring System: Essential for maintaining application health, the monitoring system keeps a vigilant eye on application performance. It gathers data and provides the development team with actionable insights and feedback, enabling them to make informed decisions and quickly address any issues that may arise.
Together, these components create a cohesive GitOps workflow that not only enhances the efficiency and reliability of application deployments but also aligns with modern DevOps practices by emphasizing automation, monitoring, and continuous improvement.
What makes GitOps work?
As with any emerging technology term, GitOps isn’t strictly defined the same way by everyone across the industry. GitOps principles can be applied to all types of infrastructure automation including VMs and containers, and can be very effective for teams looking to manage Kubernetes-based infrastructure. While many tools and methodologies promise faster deployment and seamless management between code and infrastructure, GitOps differs by focusing on a developer-centric experience. Infrastructure management through GitOps happens in the same version control system as the application development, enabling teams to collaborate more in a central location while benefiting from Git’s built-in features.
Frequently Asked Questions
Frequently Asked Questions
GitOps is an operational framework that applies DevOps best practices like version control, collaboration, compliance, and CI/CD to infrastructure automation. Unlike manual infrastructure processes requiring specialized teams, GitOps uses configuration files stored as code to generate consistent infrastructure environments.
GitOps requires Infrastructure as Code using Git repositories as a single source of truth for infrastructure definitions, merge requests or pull requests as change mechanisms for all infrastructure updates with formal approvals, and CI/CD automation that enacts changes when new code is merged.
GitOps automation overwrites any configuration drift, manual changes, or errors so the environment converges on the desired state defined in Git. When new code is merged, the CI/CD pipeline automatically enacts changes, ensuring consistency and eliminating unauthorized modifications.
A GitOps workflow includes Git repository as the central source of truth for application code and configuration, continuous delivery pipeline for automated building and testing, application deployment tool for orchestrating resources, and monitoring system for tracking application performance and providing feedback.
GitOps requires discipline from all participants and commitment to new processes. The approval process introduces "change by committee" elements that can seem tedious to engineers used to quick manual changes. Teams must suppress the temptation to edit production directly and reduce "cowboy engineering" practices.
Related Resources
50%+ of the Fortune 100 trust GitLab
Start shipping better software faster
See what your team can do with the intelligent
DevSecOps platform.