# Lab: Mastering the ArgoCD CLI This lab will guide you through managing your GitOps workflow using the `argocd` command-line interface, which is faster and often more scriptable than the UI. ## Prerequisites Ensure you have run `make setup` and your cluster is running. ## Step 1: Establish Connection 1. **Port Forward** (if not already running): Open a *separate terminal* and run: ```bash kubectl port-forward svc/argocd-server -n argocd 8080:443 ``` 2. **Get the Admin Password**: ```bash kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo ``` 3. **Login with CLI**: ```bash # Accept the self-signed certificate warning with 'y' argocd login localhost:8080 --username admin --password ``` ## Step 2: Inspecting Applications 1. **List all apps**: ```bash argocd app list ``` *Observe the `guestbook` app status (Synced/Healthy).* 2. **Get detailed info**: ```bash argocd app get guestbook ``` *This shows the "Service" and "Deployment" resources managed by this app.* 3. **Check Sync History**: ```bash argocd app history guestbook ``` ## Step 3: Triggering Actions 1. **Force a Refresh**: Sometimes ArgoCD doesn't pick up git changes immediately (default is 3m poll). Force it: ```bash argocd app get guestbook --refresh ``` 2. **Manual Sync**: If an app is "OutOfSync", you can trigger it manually: ```bash argocd app sync guestbook ``` ## Step 4: Imperative Deployment (The "Quick & Dirty" way) While we prefer declarative YAML (`application.yaml`), sometimes you need to test something quickly. 1. **Deploy the "Sock Shop" demo app**: ```bash argocd app create sock-shop \ --repo https://github.com/argoproj/argocd-example-apps.git \ --path sock-shop \ --dest-server https://kubernetes.default.svc \ --dest-namespace default ``` 2. **Sync it (Deploy it)**: Newly created apps are usually "OutOfSync" and "Missing" initially. ```bash argocd app sync sock-shop ``` 3. **Verify**: ```bash argocd app list kubectl get pods -n default ``` ## Step 5: Clean Up 1. **Delete the imperative app**: ```bash argocd app delete sock-shop --cascade ``` *Confirm with `y`. `--cascade` ensures k8s resources (deployments/services) are deleted too.*