Kubernetes Security & Hardening›20 · Knowledge check: Kubernetes security

Lesson 20 of 20 · Practice: Vault, egress and tenant labs

Knowledge check: Kubernetes security

30 questions across this course and its labs: identity, authorization, tenant isolation, supply chain, detection and response, Vault and egress. Answer each in a sentence or two, then open the answer; every answer links to the lesson that explains it.

All levels
Key wordsknowledge checkself-testidentityRBACtenant isolationPod SecurityNetworkPolicysupply chainauditVaultegress

How to use this page

Answer each question in your head or on paper first, in a sentence or two. Then open it to compare. Every answer links to the lesson that explains it, so a wrong answer tells you exactly what to reread.

Scoring: 1 point for a full answer, ½ for a partial one. 24 or more: you know this well. 16–23: reread the lessons behind the ones you missed. Under 16: do Lab: attack your own tenant setup and try again.

Like checking your homework against the answer key: the point isn't the score, it's finding the exact page you need to read again.

1 · Identity

1. Where are Kubernetes users stored?

Nowhere inside Kubernetes: there's no User object. The authenticator decides who you are, from a client certificate's CN and O, an OIDC token's claims, or a ServiceAccount token. → Authentication methods

2. What's the difference between a 401 and a 403 from the API server?

401: it doesn't know who you are (missing, bad or expired credential). 403: it knows who you are, and authorization said no. → Authentication methods

3. In the CSR flow, which file never leaves the user's machine, and which never leaves the control plane?

The user's private key stays on their machine; only the public key travels inside the CSR. The cluster CA's private key stays on the control plane: whoever has it can create any identity offline. → Lab: a developer's own kubeconfig, Cluster PKI & certificates

4. Why is approving a CSR a sensitive action?

You grant whatever names the request claims. A CSR with O=system:masters becomes a full admin that RBAC can't restrict. → Lab: a developer's own kubeconfig

5. Which of these renew themselves: control-plane certificates, the kubelet client certificate, a pod's ServiceAccount token, a person's client certificate?

Control-plane certificates: renewed by kubeadm (kubeadm certs renew, and on every upgrade). Kubelet client certificate: rotates itself. Pod ServiceAccount token: refreshed by the kubelet. A person's client certificate: never; they repeat the CSR flow. → Cluster PKI & certificates

6. Why should people log in with OIDC rather than client certificates?

Certificates can't be revoked, their groups are fixed until expiry, and nothing renews them. OIDC tokens are short-lived, groups come from the identity provider, and disabling someone there ends their access. → OIDC login for kubectl

2 · Authorization

7. Which RBAC combinations exist, and which gives shared rules in only one namespace?

Role + RoleBinding, ClusterRole + RoleBinding, ClusterRole + ClusterRoleBinding (a Role can't be used by a ClusterRoleBinding). ClusterRole + RoleBinding reuses one set of rules inside one namespace. → RBAC & ServiceAccounts

8. How do you take one permission away from a user?

There's no "deny" in RBAC: access is the union of all bindings. Remove or narrow the binding (or role) that grants it. → RBAC & ServiceAccounts

9. A tenant admin tries to bind cluster-admin inside their namespace. What stops them?

Escalation prevention: you can only bind a role whose permissions you already hold, unless you have the bind verb on it. → Lab: attack your own tenant setup

10. A developer has no access to Secrets but can create pods. Are the Secrets safe?

No. A pod can mount any Secret and run as any ServiceAccount in its namespace. → Lab: attack your own tenant setup

11. Name three permissions that are admin-level even though their names don't say so.

Any three of: create pods, list secrets, impersonate, bind/escalate, create serviceaccounts/token, approving CSRs, nodes/proxy, pods/exec, writing webhook configurations. → RBAC design at scale

12. What does 'kubectl auth can-i ... --as=bob' test if you leave out --as-group?

User bob with no groups. Bindings to his groups aren't counted, so you often get a wrong "no". → Lab: attack your own tenant setup

13. Can resourceNames limit which objects someone may list?

No. RBAC never filters a list. With resourceNames, a plain list is refused; list/watch work only when the client asks for that one exact name (--field-selector metadata.name=<name>). create can't be limited by name at all. → RBAC design at scale

14. Name three ways to make ServiceAccounts safer.

Any three of: one ServiceAccount per app; no roles on default; automountServiceAccountToken: false when the app doesn't call the API; short-lived bound tokens instead of Secret tokens; workload identity for cloud access; least-privilege roles. → RBAC & ServiceAccounts

15. How do you give a support team read-only access through a cluster web console?

They log in as themselves through SSO in front of the console, and their group gets the built-in view role through RoleBindings in the namespaces they support. view excludes Secrets, and the audit log shows their own names. Never give the console's own ServiceAccount broad rights. → RBAC design at scale

3 · Tenant isolation

16. Why does a ResourceQuota on requests.cpu usually need a LimitRange?

Once the quota limits requests.cpu, every pod must declare CPU requests or it's rejected. A LimitRange with defaultRequest fills them in. → Teams on a shared Kubernetes cluster

17. You lower a namespace's quota below current use. What happens to running pods?

Nothing. Quota is checked when objects are created; new pods are refused until usage drops. → Lab: attack your own tenant setup

18. A Deployment shows 0/3 ready and the pods have no events. Where do you look?

One level up: the ReplicaSet's FailedCreate events. The pods were never created, because of quota, LimitRange, Pod Security or a webhook. → Lab: attack your own tenant setup

19. Why can't a tenant admin remove the Pod Security labels from their namespace?

The Namespace is cluster-scoped. Their admin rights come from a RoleBinding inside the namespace, which grants nothing on the Namespace object itself. → Lab: attack your own tenant setup

20. With Pod Security 'enforce: restricted', you apply a Deployment with a privileged container. What happens?

The Deployment is accepted (with a warning if warn is set); its ReplicaSet then fails to create pods with FailedCreate ... violates PodSecurity. Enforce checks pods only. → Pod Security & admission control

21. You applied a default-deny NetworkPolicy and traffic still flows. Give two possible reasons.

Any two of: the CNI doesn't enforce NetworkPolicy; the podSelector doesn't match (label typo); policyTypes leaves out that direction; another policy allows the traffic; it's host-network traffic. → Network policies & mTLS

22. An operator's CRD is installed. How does the API server know about the operator's pods?

It doesn't. The CRD only adds a type and an endpoint. The operator is an ordinary client that watches that endpoint with its ServiceAccount, and RBAC decides what it may touch. The API server only calls out to it if you register a webhook or an APIService. → RBAC design at scale

4 · Supply chain and data

23. Why deploy images by digest instead of by tag?

A tag can be moved to different content; a digest (@sha256:...) always means exactly the same bytes. → Supply chain security

24. What does an image signature not prove?

That the image is free of vulnerabilities, or that it was built from reviewed code. It proves only that the image is unchanged since a trusted identity signed it. → Supply chain security

25. Is a Kubernetes Secret encrypted?

Not by default: it's base64, which anyone can decode. Turn on encryption at rest (ideally with a KMS), restrict get/list on secrets, and keep the source of truth in a secret manager. → Secrets management

5 · Detect and respond

26. Which audit level would you use for Secrets, and why?

Metadata: it records who touched which Secret and when, without writing the value into the log. → Audit logging & runtime detection

27. Why isolate a compromised pod before deleting it?

Deleting it destroys the evidence of how the attacker got in, and doesn't stop credentials they already copied. Isolate it (labels + deny-all NetworkPolicy), remove its ServiceAccount's bindings, collect evidence, then delete. → Responding to a compromised workload

28. A new policy would block 40 existing workloads. How do you roll it out?

Audit mode first; share the report with the owning teams with a deadline; allow time-boxed exceptions with an owner; then enforce step by step. → Compliance as code

6 · Vault and egress

29. Which Vault delivery pattern puts the secret into etcd, and what must you then turn on?

The Vault Secrets Operator, because it syncs into normal Kubernetes Secrets. Encryption at rest becomes mandatory. The Agent Injector and the CSI provider keep secrets out of etcd. → Vault on Kubernetes

30. Why can't a normal NetworkPolicy block internet access for every pod in the cluster?

It applies only inside its own namespace and has no deny, so a team can always add an allow next to it. Use the CNI's cluster-wide policy (Cilium CiliumClusterwideNetworkPolicy or a Calico GlobalNetworkPolicy in its own tier) with a deny that beats namespace allows. → Blocking internet egress by pod label

Recap

This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.