Install Argo CD on a Kubernetes cluster to synchronize changes made to Manifests in a Git repository

kubernetes

Argo CD is a CD tool for Kubernetes.

Install CRDs, Controllers, and other components.

$ kubectl create namespace argocd
$ kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
customresourcedefinition.apiextensions.k8s.io/applications.argoproj.io created
customresourcedefinition.apiextensions.k8s.io/applicationsets.argoproj.io created
customresourcedefinition.apiextensions.k8s.io/appprojects.argoproj.io created
serviceaccount/argocd-application-controller created
...
service/argocd-server-metrics created
deployment.apps/argocd-applicationset-controller created
deployment.apps/argocd-dex-server created
deployment.apps/argocd-notifications-controller created
deployment.apps/argocd-redis created
deployment.apps/argocd-repo-server created
deployment.apps/argocd-server created
statefulset.apps/argocd-application-controller created
...

Install the CLI, retrieve the admin password, and log in.

$ brew install argocd
$ ADMIN_PASSWORD=$(argocd admin initial-password -n argocd)
$ echo $ADMIN_PASSWORD

$ argocd login localhost:8080 --username admin --password $ADMIN_PASSWORD --insecure

Create a sample application.

$ argocd app create guestbook \
  --repo https://github.com/argoproj/argocd-example-apps.git \
  --path guestbook --dest-server https://kubernetes.default.svc \
  --dest-namespace default
application 'guestbook' created

$ kubectl get -n argocd application
NAME        SYNC STATUS   HEALTH STATUS
guestbook   OutOfSync     Missing

It can also be confirmed on the UI.

$ kubectl port-forward svc/argocd-server -n argocd 8080:443

Since it hasn’t been synced yet, the manifest to be applied is displayed as a diff.

When synced, a Pod starts up.

Next, create an application with Auto sync enabled using Application resource.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-guestbook
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/sambaiz/argocd-example-apps.git
    targetRevision: HEAD
    path: guestbook
  destination:
    server: https://kubernetes.default.svc
    namespace: default
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

When a manifest is added and pushed to the repository, sync runs automatically. Order can be controlled using argocd.argoproj.io/sync-wave annotation. Manifests deleted from the repository are deleted from the cluster due to pruning, and changes made manually to the cluster are reverted by selfHeal.

Storing tokens or other credentials in the argocd-notifications-secret Secret, and configuring notification in argocd-notifications-cm ConfigMap or adding notifications.argoproj.io/subscribe.(trigger).(service): (recipients) annotation to Application, notifications will be sent when a trigger is fired.

metadata:
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my-channel1;my-channel2