Table of Contents Show
In this article, we will delve into a comprehensive exploration of various GitOps deployment strategies (pull based vs push based ) .
What is GitOps?
GitOps uses Git repositories as a single source of truth to deliver infrastructure as code. Submitted code checks the CI process, while the CD process checks and applies requirements for things like security, infrastructure as code, or any other boundaries set for the application framework. All changes to code are tracked, making updates easy while also providing version control should a rollback be needed.
GitOps delivers:
- A standard workflow for application development
- Increased security for setting application requirements upfront
- Improved reliability with visibility and version control through Git
- Consistency across any cluster, any cloud, and any on-premise environment
Many other tools can be used together to build a GitOps framework. For example, git repositories, Kubernetes, continuous integration/continuous delivery (CI/CD) tools, and configuration management tools.
Why GitOps?
GitOps takes the philosophies and approaches promised to those investing in a DevOps culture and provides a framework to start realizing the results. Organizations who practice DevOps realize significant improvements to the rate of innovation in applications and code, as well as stability, according to the annual State of DevOps Report.
By using the same Git-based workflows that developers are familiar with, GitOps expands upon existing processes from application development to deployment, application life cycle management, and infrastructure configuration. Every change throughout the application life cycle is traced in the Git repository and is auditable. Making changes via Git means developers can finally do what they want: code at their own pace without waiting on resources to be assigned or approved by operations teams.
For ops teams, visibility to change means the ability to trace and reproduce issues quickly, improving overall security. With an up-to-date audit trail, organizations can reduce the risk of unwanted changes and correct them before they go into production.
These changes in code from development to production make organizations more agile in responding to changes in the business and competitive landscape.
How is GitOps different from DevOps?
GitOps and DevOps do share some of the same principles and goals. DevOps is about cultural change and providing a way for development teams and operations teams to work together collaboratively.
GitOps gives you tools and a framework to take DevOps practices, like collaboration, CI/CD, and version control, and apply them to infrastructure automation and application deployment. Developers can work in the code repositories they already know, while operations can put the other necessary pieces into place.
GitOps deployment strategies
There are two main types of GitOps deployment strategies: push-based and pull-based.
GitOps Push-based Deployments
Push-based deployment is a deployment strategy in which changes to the application code are pushed to the environment configuration repository by a CI/CD tool. The source code of the application and the Kubernetes YAMLs needed to deploy the app live in the application repository. When the application code is updated, the CI/CD tool triggers a build pipeline that builds the container images and updates the environment configuration repository with new deployment descriptors.
Here is a more detailed explanation of the push-based deployment strategy:
- The application code and Kubernetes YAMLs are stored in the application repository.
- When the application code is updated, the CI/CD tool triggers a CI (Build) pipeline.
- The build pipeline builds the container images and push it to Image Repository.
- The build pipeline updates the environment configuration repository with new deployment descriptors.
- The environment configuration (infra) repository is updated .
- The new deployment descriptors are applied to the Kubernetes cluster (Target env ).
The push-based deployment strategy is a simple and straightforward way to deploy applications. However, it can be error-prone, as it requires the CI/CD tool to correctly update the environment configuration repository.
Here are some of the benefits of push-based deployment:
- It is a simple and straightforward approach.
- It can be easily automated.
- It does not require any changes to the Kubernetes cluster.
Here are some of the drawbacks of push-based deployment:
- It can be error-prone.
- It can be difficult to track changes to the environment configuration repository.
- It can be difficult to roll back changes.
GitOps Pull-based Deployments
Pull-based deployment is a deployment strategy in which the Kubernetes cluster pulls changes from the environment configuration repository. The operator is a software agent that runs in the Kubernetes cluster and continuously compares the desired state in the environment repository with the actual state in the cluster. When the operator detects a difference, it updates the cluster to match the desired state.
Here is a more detailed explanation of the pull-based deployment strategy:
- The application code and Kubernetes YAMLs are stored in the environment configuration repository.
- When the application code is updated, the CI/CD tool triggers a CI (Build) pipeline.
- The build pipeline builds the container images and push it to Image Repository.
- The operator (for Example ArgoCD) runs in the Kubernetes cluster and continuously compares the desired state in the environment configuration repository with the actual state in the cluster.
- When the operator detects a difference, it updates the cluster to match the desired state.
- The operator can also be configured to monitor the image registry for new versions of images. When a new version of an image is found, the operator can automatically deploy the new image to the cluster.
The pull-based deployment strategy is a more secure and reliable way to deploy applications than push-based deployment. This is because the operator is always in sync with the environment configuration repository, so there is no risk of the cluster becoming out of sync with the desired state.
Here are some of the benefits of pull-based deployment:
- It is more secure and reliable than push-based deployment.
- It can be easily automated.
- It does not require any changes to the Kubernetes cluster.
Here are some of the drawbacks of pull-based deployment:
- It can be more complex to set up than push-based deployment.
- It can require more resources to run the operator.
Conclusion
The best deployment strategy for a particular organization will depend on its specific needs and requirements. However, GitOps is a proven methodology that can help organizations improve their infrastructure deployments.
Here are a few things to keep in mind when adopting GitOps:
- Choose the right tools and technologies.
- Get buy-in from all stakeholders.
- Start small and scale up.
In addition, GitOps supports two main deployment strategies: push-based and pull-based. Push-based deployment is the traditional approach, while pull-based deployment is the newer approach. Pull-based deployment is generally considered to be the more secure and reliable option.
Are you interested by Kubernetes certifications ? check our Study Guides for Kubernetes :