GitOps with Kubernetes: Managing Application using GitLab and Argo CD

Evolution to GitOps

Traditional Ops

DevOps

  1. Better collaboration between development and operations
    2. Improved product quality
    3. More frequently releases
    4. Reducing time for new features.

GitOps

Quick Intro: Kubernetes

  1. A Cluster for running application
  2. An Orchestration of cloud-native microservice applications

Masters & Nodes

Masters (Control Plane)

  1. API Server
  2. Cluster Store
  3. The Controller Manager
  4. The Scheduler
  5. The Cloud Control Manager

API Server

The Cluster Store(etcd)

The Controller Manager

The Scheduler

The Cloud Control Manager

Nodes

Kubelet

Kube-proxy

Pod & Containers

Deployment

Services

Installing Kubernetes (MiniKube) on Machine

kubectl cluster-info
kubectl get nodes

Installing Argo CD

minikube addons enable ingress
kubectl create ns argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
minikube tunnel
kubectl patch svc argocd-server -n argocd -p ‘{“spec”: {“type”: “LoadBalancer”}}’
kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d’/’ -f 2
argocd login <IP>:<PORT>argocd account update-password
minikube service argocd-server -n argocd --url
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

GitLab Project SetUp

  • CI_PUSH_TOKEN — the token
  • CI_USERNAME — the username of the token owner

Argo CD Application Setup

  • name — the name of our Argo CD application
  • namespace — must be the same as the Argo CD instance
  • project — project name where the application will be configured (this is the way to organize your applications in Argo CD)
  • repo URL — URL of our source code repository
  • target revision — the git branch you want to use
  • path — The path where Kubernetes manifests are stored inside the repository
  • destination — Kubernetes destination-related things (in this case the cluster is the same where Argo CD is hosted)
kubectl apply -f argocd.yml
argocd app list
-> kubectl get application -n argocd
NAME AGE
web-app-dev 40m
web-app-prod 41m

GitLab CI Pipeline

How Everything is Working?

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store