Lesson 15 of 18 · Playbooks, challenges & practice
The flow: laptop → cluster → kubeconfig → app
Follow the whole path, end to end: how an engineer's laptop authenticates and gets a kubeconfig, how access entries decide what they can do, and how changes reach the cluster the CI/CD way: infra through Terraform pipelines, apps through image builds, a GitOps repo and Argo CD.
Two kinds of traffic to the cluster
- People looking and debugging (and, rarely, fixing).
- Changes: infrastructure and applications.
In a mature setup, the first is mostly read-only, and the second always goes through Git and pipelines.
A museum: visitors get a day ticket (short-lived credentials) that lets them look at the exhibits (read-only kubectl). Only the museum staff (pipelines) move exhibits, and every move is written in the logbook (Git). If there's a fire, a guard has the emergency key (break-glass).
Path 1: laptop → cluster
$ aws sso login --profile prod-readonly
$ aws eks update-kubeconfig --name prod --region eu-west-1 --alias prod --profile prod-readonly
$ kubectl config view --minify | grep -A8 'exec:'
exec:
apiVersion: client.authentication.k8s.io/v1beta1
command: aws
args: [ --region, eu-west-1, eks, get-token, --cluster-name, prod, --output, json ]
env: [ { name: AWS_PROFILE, value: prod-readonly } ]
$ kubectl auth whoami
$ kubectl get pods -n payments
What happens:
- Your SSO session gives temporary IAM credentials for a role.
kubectlrunsaws eks get-token, which creates a short-lived token from those credentials.- EKS checks the IAM role against its access entries and applies the associated access policies (or RBAC groups): view in
payments, nothing inkube-system, for example. - If the endpoint is private, you need network access to the VPC (VPN, bastion, or SSM port forwarding).
Path 2: infrastructure changes
- Engineer opens a PR in the infra repo → pipeline assumes a read-only plan role via OIDC → posts
terraform plan. - Merge to
main→ pipeline assumes the apply role (only for the approved environment) → applies the saved plan. - Details: lesson 10.
Path 3: application changes
- App repo CI (OIDC to AWS) builds the image and pushes it to ECR, recording the digest.
- CI commits the new digest to the GitOps repo (Kustomize/Helm values).
- Argo CD inside the cluster notices and syncs; pods pull from ECR (the node role / credential provider handles auth).
- Health and SLO checks confirm the rollout; rollback is a
git revertin the GitOps repo.
(Same pattern as Hands-on Projects, project 02; Argo CD details in GitOps with Argo CD.)
Break-glass
A tightly controlled admin role with its own access entry, used only in emergencies, alerting on every use, and followed by a review. Test it every quarter.
Try it: trace every hop
- Configure two AWS profiles (read-only and admin) and generate kubeconfig entries for each (
--alias prod-ro,--alias prod-admin). - Run
kubectl auth whoamiandkubectl auth can-i --list -n paymentswith each. - Look at CloudTrail for the
AssumeRoleWithWebIdentityevent from a pipeline run. - Change an image digest in the GitOps repo and follow it: commit → Argo CD sync → new pods.
- Use the break-glass role once in a sandbox and check that the alert fired.
Command summary
aws sso login --profile prod-readonly
aws eks update-kubeconfig --name prod --region eu-west-1 --alias prod --profile prod-readonly
kubectl config view --minify ; kubectl auth whoami ; kubectl auth can-i --list -n payments
# pipelines: OIDC → terraform plan/apply (infra) ; docker build/push to ECR (apps) ; commit digest to GitOps repo
argocd app get <app> ; git revert <sha> # GitOps rollback
Recap
- Laptop: SSO → temporary credentials → update-kubeconfig → exec token → access entries.
- Changes: infra via Terraform pipelines (OIDC), apps via ECR + GitOps + Argo CD.
- Humans read, pipelines write; a tested break-glass role for emergencies.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.