Skip to main content

Initial setup

Argo CD applies the GitOps methodology to Kubernetes. It uses Git as a source of truth for your cluster's desired state. You can use Argo CD to deploy applications, monitor their health, and sync them with the desired state. Kubernetes manifests can be specified in several ways:

  • Kustomize applications
  • Helm charts
  • Jsonnet files
  • Plain directories of Kubernetes YAML files

In this lab exercise, we will deploy an applications specified in Kustomize using Argo CD. We will use the ui application from EKS Workshop repository.

The Git repository in AWS CodeCommit has already been created for you.

info

If you want to use your own GitHub private repository you could re define

export GITOPS_REPO_URL_ARGOCD=https://github.com/username/reponame

and use those instructions to create an Argo CD secret to give access to the Git repository from Argo CD

Let's clone the Git repository.

~$git clone $GITOPS_REPO_URL_ARGOCD ~/environment/argocd
~$git -C ~/environment/argocd checkout -b main
Switched to a new branch 'main'
~$mkdir ~/environment/argocd/apps && touch ~/environment/argocd/apps/.gitkeep
~$git -C ~/environment/argocd add .
~$git -C ~/environment/argocd commit -am "Initial commit"
~$git -C ~/environment/argocd push --set-upstream origin main

Create an Argo CD secret to give access to the Git repository from Argo CD:

~$argocd repo add $GITOPS_REPO_URL_ARGOCD --ssh-private-key-path ${HOME}/.ssh/gitops_ssh.pem --insecure-ignore-host-key --upsert --name git-repo
Repository 'ssh://...' added

Argo CD application is a CRD Kubernetes resource object representing a deployed application instance in an environment. It defines key information about the application, such as the application name, the Git repository, and the path to the Kubernetes manifests. The application resource also defines the desired state of the application, such as the target revision, the sync policy, and the health check policy.

As the next step let's create an Argo CD Application which Sync with desired state in the Git repository:

~$argocd app create apps --repo $GITOPS_REPO_URL_ARGOCD \
--path apps --dest-server https://kubernetes.default.svc
application 'apps' created

Verify that the application has been created:

~$argocd app list
NAME         CLUSTER                         NAMESPACE  PROJECT  STATUS  HEALTH   SYNCPOLICY  CONDITIONS
argocd/apps  https://kubernetes.default.svc             default  Synced  Healthy  <none>      <none>

We can also see this Application in the ArgoCD UI now:

Application in the ArgoCD UI

Alternatively, you can also interact with Argo CD objects in the cluster using the kubectl command:

~$kubectl get applications.argoproj.io -n argocd
NAME   SYNC STATUS   HEALTH STATUS
apps   Synced        Healthy