- Published on
A Quick Overview of GitOps
- Authors
- Name
- Joseph Goksu
- @josephgoksu
Overview
Hello everyone,
Recently, I've been hearing a lot about GitOps. I'd like to share some of my own experiences with it.
Let's start with a simple question.
What is GitOps?
It's an operational framework that takes DevOps best practices and applies them to infrastructure automation.
It focuses on a developer-centric experience when operating infrastructure, including Git and Continuous Deployment tools. The main idea is to make it easier for developers to work with infrastructure, and to make it easier for teams to work together.
I've been using Jenkins for quite some time, and I really enjoy utilising "Jenkinsfile" to automate the CI/CD process. I can use the same Jenkinsfile to execute builds for multiple branches in multibranch projects.
My primary flow is as follows:
Develop -> PR request -> Merge -> Build -> Test -> Deploy.
Everything is defined in the Jenkinsfile, and it handles the rest. I may use the same Jenkinsfile for other projects as well. It simplifies my life as well as DevOps pipeline management.
Here is an example Jenkinsfile for creating your project and use codedeploy to deploy it to AWS ECS. It is not entirely correct. It is merely a workflow depiction.
#!/usr/bin/env groovy
pipeline {
agent any
tools {nodejs "latest"}
stages {
stage('preflight') {
steps {
echo sh(returnStdout: true, script: 'env')
sh 'node -v'
sh 'npm --version'
sh 'git log --reverse -1'
}
}
stage('build') {
steps {
sh 'npm install'
sh 'npm run build'
}
}
stage('deploy') {
steps {
sh 'docker build . ${git repo name}'
sh 'aws codedeploy ...'
}
}
}
}
Principles
- Declaratively described: Define the workflow in the Jenkinsfile (or whatevery you have/want)
- Single source of truth: All the code is in one place, and all the changes are in one place.
- Approved changes for direct application to the system: The changes are approved by the team before they are applied to the system.
Difference between DevOps and GitOps
DevOps is the combination of cultural philosophies, practices and tools that are used to automate the process of building, deploying and maintaining software. GitOps is a technique to implement Continuous Delivery. If you already employing DevOps techniques, shared principles between them certainly make it easier to adopt a GitOps workflow.
I want to share definitions and my experience with GitOps. Hopefully, it will be useful for you.
Thanks for reading! Reach out to me on Twitter if you have any questions or comments.
References
- https://www.gitops.tech/