This article was written by a guest author.
Not long ago, if we wanted to put our code into production, we needed to manually configure a server, our infrastructure, that would host our app or database. This manual process is not only time-consuming, but also prone to errors. That is why at present, developers chose to create “scripts” that are in charge of configuring the infrastructure These “scripts” are known as Infrastructure as Code (IaC).
As our applications evolved, our Infrastructure as Code did too. A simple Bash script or Python script was no longer enough; that’s why tools like Terraform, Ansible, Chef, or Puppet came to the rescue. All of these tools allow us to easily indicate the instructions our infrastructure needs to execute to be ready to host our code.
That’s why today, IaC is the standard. It made our lives easier, but what happens when…
- We have this awesome Infrastructure as Code that automates so many things but we still run them manually in our cloud provider (GCP, AWS, Azure, etc)?
- We made changes on it and just threw them to run without code review or test?
As you can imagine, this is slow and many things can go wrong in the process.
The best thing we can do for our IaC is review it, test it and automate the deployment process. In a few words, use GitOps to achieve beautiful Infrastructure as Code ❤️.
What is GitOps?
GitOps is a modern methodology to deliver our IaC. In this methodology, we use Git to track the evolution of the code, we review the changes, we approve them, and then we deploy those changes, just as we would with application code.
The GitOps flow it’s not complicated, so there is no excuse to not use it.
The flow of GitOps looks like this:
Here you can see the GitKraken Git GUI in the stage and commit phase because it will allow us to stage and commit our changes. In addition, GitKraken will allow us to open a pull request, GitHub, GitLab, and Bitbucket.
GitKraken plays a crucial role in the GitOps flow, and enables a seamless transition between other stages in the production pipeline.
For code developers, this flow sounds familiar, right? But the flow does not end there; we need to put our IaC in our server cluster. We have two options to make this happen:
- Push Model
- Pull Model ⭐️
Push Model
This is when our CI/CD Server executes a command on the cluster to guess… push the new code to the deployment environment. 🥳
Pull Model
In this other model, we have an agent (like Argo CD or Flux CD) installed in our cluster. This agent is the one in charge to pull the changes from our repository. 🥳🥳
Tools for GitOps
Probably you are thinking: What tools are able to make the GitOps Flow happen?
Well, I already (randomly) mentioned some of them, but I will list some standards in the industry.
Of course, Git is the cornerstone for this flow. Remember, that GitOps it’s about delivering quality code. Git will allow us to track and observe the evolution of our code.
When you finish your changes to your IaC, you can effortlessly review them with the GitKraken Git GUI before you commit them.
In addition, GitKraken allows you to easily check the history of changes in a file. Displayed below is the GitKraken Diff view, which uses colors to show added and removed lines, so you can quickly understand what you’re viewing.
After committing you can open a Git pull request from GitKraken, no matter if you use GitHub, GitLab, or Bitbucket. Also from GitKraken, you are able to review your pull requests created by members on your team.
💡 No browser need: From GitKraken, you can approve or make comments on GitHub pull requests. This saves a lot of time.
For the Push Model, we can use: Jenkins is an open source automation server that enables developers around the world to reliably build, test, and deploy their software.
For the Pull Model, we can use: ArgoCD is a continuous deployment tool that only implements the monitoring of the repositories by performing Pulling.
With the power of GitKraken at your side, no change will escape you in the code review! You can download GitKraken from here.
Ready to dive into GitOps?
Remember, if your IaC is not as good as your Application Code, your infrastructure will most likely fail. And without Infrastructure, your application cannot be used by anyone. So it’s better to keep our IaC safe by only pulling in our tested, reviewed code.
Implementing a GitOps flow in your projects is not very complicated and there are tools that make it much easier, even if you have never used Git before, such as GitKraken. Using GitOps brings many other advantages such as:
- Quality code
- Automated Process
- Transparency to all the team
- Fast Deploy and Rollback
On the other hand you may be already applying GitOps to your project, but if you are not using GitOps yet, it’s definitely time to start. 🚀
You can read this post in Spanish on the author’s personal website: ¿Qué es GitOps?
Succeeding at GitOps is far easier if you equip yourself with the right tools. GitKraken will help fulfill multiple stages of the GitOps flow, including staging, committing, pull requests, and code review.