Setting Up Your Environment for Argo CD
Setting up your environment for Argo CD involves a few essential steps that will allow you to manage your Kubernetes applications effectively. This guide will lead you through the prerequisites and installation steps so that you can hit the ground running with Argo CD.
Prerequisites
Before diving into the installation steps for Argo CD, ensure that you have the following prerequisites in place:
1. Kubernetes Cluster
Argo CD is designed to work with Kubernetes, so you need to have access to a Kubernetes cluster. You can set up a local cluster using tools like:
- Minikube: Provides a local Kubernetes cluster on your machine.
- kind (Kubernetes IN Docker): Runs Kubernetes clusters in Docker containers.
- K3s: A lightweight Kubernetes distribution that packs all Kubernetes components into a small installable binary.
For this guide, we will assume you are using Minikube.
Install Minikube:
-
Install a compatible version of Minikube.
# For macOS with Homebrew brew install minikube # For Windows choco install minikube # Ensure you have Chocolatey installed. # For Linux curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube
2. kubectl
You also need the Kubernetes CLI tool, kubectl, to interact with your Kubernetes cluster.
Install kubectl:
-
You can follow the official instructions to install
kubectlbased on your operating system. Here are quick steps:# For macOS brew install kubectl # For Windows choco install kubernetes-cli # For Linux curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" sudo install kubectl /usr/local/bin/
3. Helm (optional but recommended)
While not a requirement for Argo CD itself, Helm can be a helpful addition as it is widely used for managing Kubernetes applications.
Install Helm:
Follow the instructions on the Helm website relevant to your operating system.
4. Git
Argo CD relies on Git repositories for deploying applications. Make sure you have Git installed:
# For macOS
brew install git
# For Windows
choco install git
# For Linux
sudo apt-get install git
Installation Steps
Once you've satisfied the prerequisites, it's time to install Argo CD:
Step 1: Start Your Minikube Cluster
If you opted for Minikube, start your cluster by running:
minikube start
This starts a single-node Kubernetes cluster on your local machine.
Step 2: Install Argo CD
You can install Argo CD using the following commands. An easy way to do this is with kubectl.
# Create the namespace for Argo CD
kubectl create namespace argocd
# Apply the Argo CD install manifests
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
This will set up Argo CD and all of its dependencies inside the argocd namespace of your Kubernetes cluster.
Step 3: Access Argo CD API Server
To access the Argo CD API server, you need to port-forward its service to your local machine:
kubectl port-forward svc/argocd-server -n argocd 8080:443
This command forwards the Argo CD server to localhost:8080. You can now access the Argo CD UI at https://localhost:8080.
Step 4: Retrieve the Initial Admin Password
The default admin credential for Argo CD is the name of the server pod. You can retrieve it with:
kubectl get pods -n argocd
Find the pod starting with argocd-server. Then run this command to obtain the password:
kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath='{.data.password}' | base64 -d
Use this password along with admin as the username to log in.
Step 5: Additional CLI Installation (Optional)
For a command-line experience with Argo CD, you might want to install the Argo CD CLI tool.
Here's how to install it:
For macOS:
brew install argocd
For Windows (via Chocolatey):
choco install argocd
For Linux, download the latest release from the Argo CD GitHub releases page, then install:
curl -sSL https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 -o argocd
chmod +x argocd
sudo mv argocd /usr/local/bin/
Step 6: Configure a Git Repository
Argo CD needs a Git repository where your application's Kubernetes manifests are stored. Here's a basic guide to connect your Git repository:
-
Log in via the Argo CD CLI:
argocd login localhost:8080 -
Add your Git repository:
argocd repo add <git-repo-url> --username <git-username> --password <git-password>
Replace <git-repo-url>, <git-username>, and <git-password> with your repository details.
Step 7: Deploy Your First Application
Now that you have everything set up, it’s time to deploy your first application. Use the following Argo CD CLI command:
argocd app create <app-name> --repo <git-repo-url> --path <path-to-manifests> --dest-server https://kubernetes.default.svc --dest-namespace default
Replace placeholders with appropriate values based on your setup.
Step 8: Sync Application
Finally, get your application into sync:
argocd app sync <app-name>
And there you go! With these steps, you’ve successfully set up your Argo CD environment, connected it to a Git repository, and deployed your first application.
Conclusion
Setting up your environment for Argo CD might seem daunting at first, but by following these steps, you’ve laid a strong foundation to manage your Kubernetes applications seamlessly. Enjoy the benefits of continuous delivery and keep exploring Argo CD’s powerful features to elevate your DevOps practices!