Cheat notes · Module 03 · Platform foundation
Hand the fleet over to Git
A five-minute review for when you have done this module and want it back in your head. Open the full module for the steps and the lab, or the full text to print.
The idea
Terraform built the clusters; a root Application hands everything that runs on them to Git. Root points at applicationsets/, and an ApplicationSet turns the cluster list into one Application per cluster.
Remember
- Root Application:
root-app.yamlpoints Argo CD atapplicationsets/in your repo (app of apps). Terraform creates it once the file exists. - ApplicationSet: a template plus a generator. The git files generator reads
clusters/*.yamland creates one Application per cluster:dev-platform-namespaces,prod-platform-namespaces. - AppProject
fleet-platform: the project for platform-owned Applications. - After the handover Terraform only runs when clusters or the hub bootstrap change. Everything on the clusters goes through Git and Argo CD.
- Self-heal: a manual change survives only until the next comparison. Per-environment differences go in Kustomize overlays, reviewed.
Pitfalls
- Deleting a namespace Git declares with kubectl: it is back within seconds, with a new age. Make the change in the environment's overlay, by pull request.
- Putting logic in the root app. Keep it boring; it is what you need on the day you rebuild a hub.
Commands
kubectl --context kind-platform -n argocd get applications -w | Watch root create the fleet's Applications |
kubectl --context kind-dev get namespaces -l environment=dev | What Argo CD created on a spoke |
kubectl kustomize addons/namespaces/overlays/dev | Render an environment's overlay before you push |
git diff root-app.yaml | Check repoURL is your repo after set-repo-url.sh |
Remove one object in one environment
# addons/namespaces/overlays/dev/kustomization.yaml
patches:
- patch: |-
$patch: delete
apiVersion: v1
kind: Namespace
metadata:
name: platform-system
Test yourself
Answer in your head first, then open the answer.
What does root-app.yaml point at?
applicationsets/. The ApplicationSets generate everything else.
You delete a namespace that Git declares. What happens?
Argo CD recreates it (self-heal). Terraform is not involved after the handover.
When does Terraform run after this module?
Only when clusters or the hub bootstrap change.
Where module 03 leaves you: Git runs the fleet. Argo CD syncs dev-platform-namespaces and prod-platform-namespaces from your repo, and from now on Terraform only runs when clusters change.