Install Argo CD in Kubernetes
Argo CD is a powerful continuous delivery tool for managing Kubernetes resources through a GitOps approach. With Argo CD, your Git repository is the single source of truth for your application’s desired state, ensuring consistency and reliability across your deployments.
Why Argo CD?
Argo CD offers several advantages:
- GitOps Workflow: Use Git repositories as the source of truth for deployment configurations
- Declarative Setup: Manage applications declaratively with versioning and auditing
- Real-time Monitoring: Continuous monitoring of applications to ensure the live state matches the desired state
- Automated Rollbacks: Automatic rollback to a previous healthy state if a deployment fails
- Multi-cluster Support: Manage deployments across multiple clusters from a single Argo CD instance
Argo CD Architectural Overview
The architecture of Argo CD allows efficient management and deployment of applications.
In this guide, we'll walk through the process of installing Argo CD on a Kubernetes cluster running on Docker Desktop on MacOS.
Create Self-Signed Certificate
Pre-requisite: openssl must be installed in MacOS
openssl req -x509 -nodes -days 365 \
-subj "/C=DE/ST=Berlin/L=Berlin/O=appdev24/OU=dev/CN=argo-cd.local" \
-newkey rsa:4096 -keyout selfsigned.key \
-out selfsigned.crt
-subj switch option:
- Country Name (2 letter code): DE
- State or Province Name (full name): Berlin
- Locality Name (city): Berlin
- Organization Name (company): appdev24
- Organizational Unit Name (department): dev
- Common Name (server FQDN): argo-cd.local
Update hosts file
Add an entry for Argo CD API Server
sudo vi /etc/hosts
# Append the server entry
127.0.0.1 argo-cd.local
Create Kubernetes Namespace
Create a dedicated namespace for Argo CD in your Kubernetes cluster.
kubectl create namespace argo-cd
Create Kubernetes Secret
Store the self-signed TLS certificate as a Kubernetes secret.
kubectl create secret tls argocd-server-tls --namespace argo-cd --cert=selfsigned.crt --key=selfsigned.key
Install Argo CD
Install Argo CD using the Helm chart and expose the Argo CD API server using the Nginx Ingress Controller with SSL termination.
helm upgrade --install argo-cd argo-cd \
--repo https://argoproj.github.io/argo-helm \
--namespace argo-cd \
--set global.domain=argo-cd.local \
--set configs.params."server\.insecure"=true \
--set server.ingress.enabled=true \
--set server.ingress.ingressClassName=nginx \
--set server.ingress.annotations."nginx\.ingress\.kubernetes\.io/force-ssl-redirect"="true" \
--set server.ingress.annotations."nginx\.ingress\.kubernetes\.io/backend-protocol"="HTTP" \
--set server.ingress.tls=true
Generate Password
Retrieve the initial password for the Argo CD admin user.
kubectl -n argo-cd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
# I-yHGc0tlC3lOwrG
Login to API Server
Now you can login to the Agro CD API Server at https://argo-cd.local. Use the retrieved password to log in as the admin user.
Optionally you can download the self signed certificate from
Chrome > Developer Tools > Security Tab > View Certificate
and import into MacOS System Keychain to Always Trust the self signed certificate and avoid the certificate warning.
Optional: Register Cluster to Deploy Apps
If you want to deploy applications to an external cluster, you need to register that cluster's credentials with Argo CD. For internal deployments (to the same cluster where Argo CD is running), use https://kubernetes.default.svc as the application's Kubernetes API server address.
argocd cluster add <CONTEXTNAME>
Create an Application
Argo CD allows you to create applications directly from your Git repositories. Configure your application to sync and deploy the resources defined in your Git repository to Kubernetes cluster.
- Application Name: backend-api
- Project Name: default
- Sync Policy: Manual
- Source Repository URL: https://github.com/sarubhai/demo_cd.git
- Source Revision: main
- Source Path: kubernetes
- Destination Cluster URL: https://kubernetes.default.svc
- Destination Namespace: default
Sync the Application
Once your application is created, you can sync it to deploy the defined resources to your Kubernetes cluster.
Click on Synchronize.
Verify Deployment
The application has been deployed successfully in the Kubernetes cluster.
Click on the application to view the details.
Finally verify the application deployment at https://python-api.local/api/products
By following these steps, you'll have a fully functional Argo CD setup on your local Kubernetes cluster running on Docker Desktop. This setup allows you to manage your Kubernetes resources declaratively and leverage the benefits of a GitOps workflow.