Mount a Secret, audit who can read it, rotate it

  • 12 min
  • 7 steps
  • Config, storage and state

Steps

0 of 7 done

Give a Deployment the Secret it mounts, find the RBAC path that reads it without any rule on secrets, and rotate the value in place.

  1. Step 1 of 7

    The ledger pods in payments never get past ContainerCreating. Find the event that names what they are waiting for.

    Checked against what your commands print.

  2. Step 2, not started: Create the generic Secret ledger-api in payments with one key, api-token, set to tok-7f3a9c. Wait for both pods to become ready.

  3. Step 3, not started: Read the token the way the application does: as a file under the volume's mount path inside a running ledger pod.

  4. Step 4, not started: The team is moving ledger to a private registry. Create a Secret ghcr-pull in payments of the type the kubelet reads for registry credentials, for server ghcr.io, user ledger-ci and password example-token.

  5. Step 5, not started: The ci-deployer service account's Role has no rule on secrets. Ask the API server whether that service account can do the thing that lets it read ledger-api anyway.

  6. Step 6, not started: Rotate the token in place: set api-token in ledger-api to tok-81d2e4 without deleting the Secret.

  7. Step 7, not started: Confirm that the running pods see the rotated token in the mounted file, with no restart. On a real cluster this can take a minute or more after the patch.

Lab terminal

Cluster time 50 seconds
kind cluster kx, Kubernetes 1.37.
Each step is checked as you work.
​
Tab completes. Up and Down recall.
Type help for more.
Terminal keys

Enter runs the command. Tab completes, and the arrow keys recall earlier commands. Control C stops a watch. On an empty line, or after Escape, Tab moves focus out of the terminal.