Argo CD : Continuous Deployment

Posted in Recipe on July 1, 2022 by Venkatesh S ‐ 2 min read


I have tried various options for CD, I liked an approach where the deployments are separately managed from the CI cycles. This gives me a lot of flexibility to manage deployments better.

I would like to introduce ArgoCD. As per the Argo CD docs, Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. Argo CD has now become my defacto standard for deploying applications on Kubernetes.

To deploy an application on Kubernetes using ArgoCD here are the steps to be followed.

  • Build your application, run your tests, containerize the same and push it to a container registry. This is ideally the typical CI cycle. This is what a developer would do.

  • Create a separate git repo for your deployment now. This would contain application definitions, configurations, and environments. Application deployment and lifecycle management will now become automated, auditable, and easy to understand if this repo is used to perform the deployments. Check the following git repo for an example project that you can use for deployment.

  • Setup Argo CD on Kubernetes with these commands.

# command to install ArgoCD in k8
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

# commands to access ArgoCD UI
kubectl get svc -n argocd
kubectl port-forward svc/argocd-server 8080:443 -n argocd

# login with admin user and below token (as in documentation):
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 --decode && echos
  • Access the ArgoCD UI at http://localhost:8080 and login using the user name as “admin” and password as retrieved above. homepage

  • Deploy your application using ArgoCD. The sample project has the following structure. It contains a dev folder that contains the Kubernetes Deployment and Service definitions. It also contains an application.yaml file that contains the Application definition for ArgoCD. We can now configure the application on ArgoCD using the following command. Note that this is the only apply we would do on Kubernetes and this command will deploy the application definition onto ArgoCD.

kubectl apply -n argocd -f application.yaml

home

app

  • Access your application. You should now be able to access your application. If your tried using the sample repo for deployment, execute the command below and access the application at http://localhost:3000
kubectl port-forward svc/redux-punch 3000:3000 -n redux-punch

punch

For more details on how to manage environments, what all options and features are possible, refer to ArgoCD documentation.