Skip to the page

Kubernetes in production · senior

RBAC and secrets

RBAC should give a pipeline only what it needs in one namespace. Secrets in Git as base64 are not protected; use encrypted Git or an external secret store.

The notes

What you must know

  • A ClusterRoleBinding with a wildcard rule gives full admin over the whole cluster: every resource and verb in every namespace, including reading all Secrets.
  • Fix: a Role in the target namespace (or a ClusterRole bound only by a RoleBinding in that namespace) with just the resources and verbs a deploy needs. No secrets unless required, no pods/exec, no wildcards.
  • Put the service account in its own namespace, not default. Pods that do not call the API should set automountServiceAccountToken to false.
  • Test with kubectl auth can-i --as=system:serviceaccount:<ns>:<name>.
  • base64 is encoding, not encryption. Anyone with repo access can read the password, and anyone allowed to get secrets in the namespace can read them in the cluster.
  • etcd stores Secrets unencrypted unless encryption at rest is configured. That protects disks and backups, not API access.
  • Sealed Secrets encrypt with the controller's public key so only the cluster can decrypt. SOPS encrypts values in files with age or KMS. External Secrets sync from a store such as AWS Secrets Manager and make rotation and audit easier.
  • Choose by team size and needs: Sealed Secrets or SOPS for a simple GitOps fit, External Secrets when a central store and rotation matter. Never commit plain secrets, and rotate any that were committed.

The red pen

Common traps: mistake → fix

  • Mistake: Base64 hides a secret

    Fix: it is only encoding.

  • Mistake: A namespace gives isolation by itself

    Fix: RBAC and network policy are needed too.

  • Mistake: cluster-admin for CI is simpler and fine

    Fix: a leaked token owns the cluster.

Easy to hard

Questions interviewers ask, easy to hard

  1. What does this RBAC for a CI pipeline really allow?
  2. How would you fix it?
  3. What is wrong with base64 secrets in Git?
  4. Sealed Secrets, SOPS or External Secrets?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview