π Understanding ArgoCD: Installation, Usage, and Troubleshooting
ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. It allows you to manage application deployments using Git repositories as the source of truth. With ArgoCD, you can automate application deployment, lifecycle management, and monitoring.
What is ArgoCD?
ArgoCD is a Kubernetes-native tool that follows the GitOps methodology. It continuously monitors Git repositories for changes and ensures that the desired state of your applications matches the state defined in Git.
Key Features:
- Declarative GitOps: Define your application state in Git.
- Continuous Monitoring: Automatically sync changes from Git to Kubernetes.
- Multi-Cluster Support: Manage applications across multiple Kubernetes clusters.
- Web UI and CLI: Provides both a web interface and CLI for managing applications.
Installation
Prerequisites:
- Kubernetes cluster (v1.20+ recommended)
kubectl
installed- Admin access to the cluster
Steps to Install ArgoCD:
- Install ArgoCD in Your Cluster:
Run the following command to install ArgoCD using the official manifests:
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
- Expose the ArgoCD Server:
By default, the ArgoCD server is not exposed externally. You can expose it using a LoadBalancer or port-forwarding:
kubectl port-forward svc/argocd-server -n argocd 8080:443
-
Access the Web UI: Open your browser and navigate to
https://localhost:8080
. - Login to ArgoCD:
Retrieve the initial admin password:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
Using ArgoCD
Add a Git Repository:
To connect a Git repository to ArgoCD, use the CLI:
argocd repo add https://github.com/your-repo.git --username <username> --password <password>
Create an Application:
Define an application that ArgoCD will manage:
argocd app create my-app \
--repo https://github.com/your-repo.git \
--path ./manifests \
--dest-server https://kubernetes.default.svc \
--dest-namespace default
Sync Applications:
Sync the application state from Git to Kubernetes:
argocd app sync my-app
Monitor Applications:
Check the status of your applications:
argocd app get my-app
Troubleshooting
Common Issues:
-
Application Out of Sync: Run
argocd app diff my-app
to see differences between Git and the cluster. -
Authentication Issues: Ensure the correct credentials are used for the Git repository.
-
Network Issues: Verify that the ArgoCD server can reach the Git repository and Kubernetes API.
Debugging Commands:
- Check ArgoCD logs:
kubectl logs -n argocd -l app.kubernetes.io/name=argocd-server
- Verify cluster connectivity:
argocd cluster list
CLI Commands
Login to ArgoCD:
argocd login <ARGOCD_SERVER>
List Applications:
argocd app list
Delete an Application:
argocd app delete my-app
Update an Application:
argocd app set my-app --repo https://github.com/new-repo.git
Conclusion
ArgoCD simplifies application deployment and management in Kubernetes by leveraging GitOps principles. With its powerful CLI and web UI, you can automate workflows, monitor application states, and troubleshoot issues effectively.
Whether youβre deploying a single application or managing multi-cluster environments, ArgoCD is a must-have tool for Kubernetes users.
Thanks for reading! π