Lab 02: First Application
Uses the guestbook app from argoproj/argocd-example-apps. Needs lab 01 (logged in with the CLI, port-forward up).
Look at the source
git clone https://github.com/argoproj/argocd-example-apps.git
ls argocd-example-apps/guestbook
guestbook-ui-deployment.yamlandguestbook-ui-svc.yaml, plain manifests (imagegcr.io/google-samples/gb-frontend, port 80)- To push changes fork it and use your fork as
--repo
Create the app
argocd app create guestbook \
--repo https://github.com/argoproj/argocd-example-apps.git \
--path guestbook \
--dest-server https://kubernetes.default.svc \
--dest-namespace default
argocd app list
argocd app get guestbook
--pathis the dir in the repo,--dest-serveris the target cluster API (this one = in-cluster)- Starts as
OutOfSync/Missing: Git has the resources, the cluster doesn’t - Same as a declarative
Application:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: guestbook
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/argoproj/argocd-example-apps.git
targetRevision: HEAD
path: guestbook
destination:
server: https://kubernetes.default.svc
namespace: default
Sync
argocd app manifests guestbook
argocd app diff guestbook
argocd app sync guestbook
argocd app wait guestbook --timeout 300
kubectl get all -n default -l app.kubernetes.io/instance=guestbook
kubectl port-forward svc/guestbook-ui 8081:80
diffis the live vs. desired state (everything is a diff before the first sync)- Sync status:
Synced/OutOfSync. Health:Healthy/Progressing/Degraded/Missing - Resource tree in the UI shows the same thing
Drift vs. Git change
Drift in the cluster:
kubectl scale deployment guestbook-ui --replicas=2
argocd app get guestbook --refresh
argocd app diff guestbook
- Live changes are seen almost immediately (the controller watches the cluster)
- A plain
argocd app sync guestbookputs replicas back to what Git says
Change in Git (fork):
- Edit
replicasinguestbook-ui-deployment.yaml, push
argocd app set guestbook --repo https://github.com/<user>/argocd-example-apps.git
argocd app get guestbook --refresh
argocd app sync guestbook
- Git polling is every 3 minutes by default,
--refreshor a webhook skips the wait
History and rollback
argocd app history guestbook
argocd app rollback guestbook <ID>
- Rollback only works with auto-sync off, it would just be synced forward again otherwise
- Rollback deploys a previous revision but Git still points at the new one, so the app shows
OutOfSync - Better rollback is
git revert
Sync options:
argocd app sync guestbook --dry-run
argocd app sync guestbook --prune
argocd app sync guestbook --resource apps:Deployment:guestbook-ui
--prunedeletes resources that are no longer in Git--resourceisGROUP:KIND:NAME
Cleanup
argocd app delete guestbook --yes
kubectl get all -n default -l app.kubernetes.io/instance=guestbook
- Delete cascades to the resources by default (finalizer),
--cascade=falseleaves them behind - ctrl-c the port-forward