In this slide, we introduce the concept of the GitOps and compare it with the common CI/CD pipeline we used so far. we also demonstrate two open-source projects, ArgoCD and Flux to show what are them and how they implemented GitOps.
2. About Me
HungWei Chiu(Hwchiu)
MTS @ Open Networking Foundation (ONF)
Kubernetes/Container/Linux/Network...etc
Online courses in Hiskio platform
Blog: https://hwchiu.com
3. Users Groups
CNTUG (Cloud Native Taiwan User Group)
Facebook: https://fb.cloudnative.tw
Telegram: https://t.me/cntug
Meetup: https://www.meetup.com/CloudNative-Taiwan/
8. Common Issues
Reinventing the wheel when you switch to different pipeline
system.
Jenkins/Drone/Cloud Tools...others
Security Concern of kubeconfig
Private Kubernetes Cluster (without WAN access)
Running state is uncontrollable.
9. GitOps
By Weaveworks in 2017
GitOps is a way of implementing CD for cloud native
applications.
By using Git and Continuous Deployment tools.
10. Core Idea
Singe source of truth: Git Repository
Contains declarative manifest.
An automated process to make the environment match the described state in the Git
repository.
Running State(In K8S) == Debited State (In Git)
Deploy/Update:
Update manifest in Git repository, an automated process will deal with the rest of
things.
11. An Automated Process Kuberentes
Git Repo
Developer
Commit
Push
Trigger
GitOps
1. Prepare Kubeconfig
2. Deploy to Kubernetes
Deploying steps
Polling
12. An Automated Process Kuberentes
Git Repo
Developer
Commit
Push
Trigger
GitOps
1. Prepare Kubeconfig
2. Deploy to Kubernetes
Deploying steps
Polling
13. How GitOps Works
Environment Configurations as Git repository.
Two repositories:
Application code / Environment manifests.
Push-based/Pull-based deployment.
https://www.gitops.tech/
15. Push-based Deployment
Deployment pipeline only is triggered when the environment
repo changes.
Deployment pipeline still needs environment credential
Deployment pipeline can't aware any change of the environment
repo automatically.
If someone modify the running state (via kubectl patch/edit).
17. Pull-based Deployment
I called the automated process, operator.
Operator is triggered by different events.
Environment repo changes.
Container image change. (Optional)
Operator update the Environment Repo if someone change the running state.
Ensures all changes are traceable in the Git log.
Operator live in the environment, no need any access credentials.
18. Summary
GitOps is concept, not implementations
Not all open source projects implemented all above features.
Can I use GitOps in other environment but Kubernetes.
Yes if you can find any open source project implemented it :)
20. ArgoCD
A declarative, GitOps continuous delivery tool for Kubernetes.
Kubernetes manifests can be specified in several ways
Helm
Kustomize
Plain Yaml/Json
24. Demo
Demo Application:
Simple bash container with sleep
Change the number of replicas
Demo Process
Init Git Repo
Deploy application
Modify it by Kubectl
Rollback from ArgoCD portal
Update in Git and then upgrade app by ArgoCD
26. Flux Limitation
Flux can only deal with one such repo at a time
Flux will ignore directories which looks like Helm Charts, to avoid
applying templated YAML manifests.
Use HelmRelease instead.
Flux watches the annotation for plain yaml
30. Demo Process
Install flux and check application yaml
List workloads and deployed applications.
Update in Git (change the number of replica)
List workloads and deployed applications.
Update docker image (SemVer)
List workloads and deployed applications.
Check GitCommit
31. HelmRelease
CRD object describe how to deploy the Helm Chart.
Specify the helm location, helm values and flux related
annotations.
35. Demo Process
Install CRD and helm-operator
Check HelmRelease yaml
List workloads and deployed applications.
Update in Git (change the number of replica)
List workloads and deployed applications.
Update docker image (SemVer)
List workloads and deployed applications.
Check GitCommit
36. Summary
GitOps -> Concept
Use git repo as the single source of truth of your application
manifest
Implementation -> Up to you
Pull/Push