In this lab, you will implement ArgoCD to automate Kubernetes application deployments using GitOps principles. You’ll install ArgoCD via Helm, configure it to manage your Python app, and simulate production-like workflows.
6 Points:
-
Install ArgoCD via Helm
-
Add the ArgoCD Helm repository:
helm repo add argo https://argoproj.github.io/argo-helm
-
Install ArgoCD:
helm install argo argo/argo-cd --namespace argocd --create-namespace
-
Verify installation:
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=argocd-server -n argocd --timeout=90s
-
-
Install ArgoCD CLI
-
Install the ArgoCD CLI tool (required for command-line interactions):
# For macOS (Homebrew): brew install argocd # For Debian/Ubuntu: sudo apt-get install -y argocd # For other OS/architectures: curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 chmod +x argocd sudo mv argocd /usr/local/bin/
-
Verify CLI installation:
argocd version
-
-
Access the ArgoCD UI
-
Forward the ArgoCD server port:
kubectl port-forward svc/argocd-server -n argocd 8080:443 &
-
Log in using the initial admin password:
# Retrieve the password: kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 --decode # Log in via CLI: argocd login localhost:8080 --insecure argocd account login
-
-
Configure Python App Sync
-
Create an ArgoCD folder: Add an
ArgoCD
folder in yourk8s
directory for ArgoCD manifests. -
Define the ArgoCD Application: Create
argocd-python-app.yaml
in theArgoCD
folder:apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: python-app namespace: argocd spec: project: default source: repoURL: https://github.com/<your-repo>/S25-core-course-labs.git targetRevision: lab13 path: <k8s/app-python> helm: valueFiles: - values.yaml destination: server: https://kubernetes.default.svc namespace: default syncPolicy: automated: {}
-
Apply the configuration:
kubectl apply -f ArgoCD/argocd-python-app.yaml
-
Verify sync:
argocd app sync python-app argocd app status python-app
-
-
Test Sync Workflow
-
Modify
values.yaml
(e.g., updatereplicaCount
). -
Commit and push changes to the target branch from the config.
-
Observe ArgoCD auto-sync the update:
argocd app status python-app
-
4 Points:
-
Set Up Multi-Environment Configurations
- Extend your Python app’s Helm chart to support
dev
andprod
environments. - Create environment-specific values files (
values-dev.yaml
,values-prod.yaml
).
- Extend your Python app’s Helm chart to support
-
Create Namespaces
kubectl create namespace dev kubectl create namespace prod
-
Deploy Multi-Environment via ArgoCD
- Define two ArgoCD applications with auto-sync:
argocd-python-dev.yaml
andargocd-python-prod.yaml
(as before).
- Define two ArgoCD applications with auto-sync:
-
Enable Auto-Sync
- Test auto-sync by updating
values-prod.yaml
and pushing to Git.
- Test auto-sync by updating
-
Self-Heal Testing
-
Test 1: Manual Override of Replica Count
-
Modify the deployment’s replica count manually:
kubectl patch deployment python-app-prod -n prod --patch '{"spec":{"replicas": 3}}'
-
Observe ArgoCD auto-revert the change (due to
syncPolicy.automated
):argocd app sync python-app-prod argocd app status python-app-prod
-
-
Test 2: Delete a Pod (Replica)
-
Delete a pod in the
prod
namespace:kubectl delete pod -n prod -l <app.kubernetes.io/name=python-app>
-
Verify Kubernetes recreates the pod to match the deployment’s
replicaCount
:kubectl get pods -n prod -w
-
Confirm ArgoCD shows no drift (since pod deletions don’t affect the desired state):
argocd app diff python-app-prod
-
-
-
Documentation
- In
13.md
, include:- Output of
kubectl get pods -n prod
before and after pod deletion. - Screenshots of ArgoCD UI showing sync status and the dashboard after both tests.
- Explanation of how ArgoCD handles configuration drift vs. runtime events.
- Output of
- In
2.5 Points:
- Configure ArgoCD for Bonus App
-
Create an
argocd-<bonus>-app.yaml
similar to Task 1, pointing to your bonus app’s helm chart folder. -
Sync and validate deployment with:
kubectl get pods -n <namespace>
-
- Follow the ArgoCD docs for advanced configurations.
- Use consistent naming conventions (e.g.,
lab13
branch for Git commits). - Document all steps in
13.md
(include diffs, outputs, and UI screenshots). - For your repository PR, ensure it's from the
lab14
branch to the main branch.
Note: This lab emphasizes GitOps workflows, environment isolation, and automation. Mastery of ArgoCD will streamline your CI/CD pipelines in real-world scenarios.