Skip to main content

ArgoCD Introduction

Argo CD is a GitOps controller for Kubernetes. It watches a Git repository, compares the desired state with the current cluster state, and helps keep them in sync. It is commonly used to deploy applications and manage cluster configuration declaratively.

One of the main ideas in GitOps is simple: store the desired state in Git.

Screenshot 2022-11-29 at 11 44 57 PM

Installation

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Default credentials:

  • Username: admin
  • Password: You can get it by running the following command
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

Sync Policy - Features

Screenshot 2022-11-30 at 4 56 41 PM

  • Auto Sync - Argo CD automatically syncs the application with the Git repository.

  • Self Healing - If someone changes resources directly in the cluster, Argo CD can revert them so the live state matches Git again.

  • Auto Pruning - Argo CD can automatically remove resources that are no longer defined in Git.

Progressive Delivery

Progressive Delivery is the practice of deploying an application in a gradual manner allowing for minimum downtime and easy rollbacks. There are several forms of progressive delivery such as blue/green, canary, a/b and feature flags.

  • Blue/Green - Deploy the new version of the application to a new environment and then switch the traffic to the new environment. This is the most common form of progressive delivery. It is also the most complex to implement. It requires a lot of infrastructure and a lot of testing.

  • Canary - Deploy the new version of the application to a small subset of users. If the new version is working fine, then deploy it to the rest of the users. This is the most common form of progressive delivery. It is also the most complex to implement. It requires a lot of infrastructure and a lot of testing.

  • To keep the whole setup declarative, we can define Argo CD applications just like any other Kubernetes resource and store them in Git as well.

Docs for reference.

Sample YAML:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: nginx-app # This is the name of the application
namespace: argocd
spec:
destination:
namespace: argocd # This is the namespace where the application will be deployed
server: https://kubernetes.default.svc # This is the default server
project: default
source:
path: ./manifest # This is the path where the manifest is present
repoURL: https://github.com/sarafpradumna/argo-test # This is the repo where the manifest is present
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
allowEmpty: false #By default it is false
syncOptions:
- CreateNamespace=true # This will create namespace if not present

What's next?