Kubernetes Security
Kubernetes security protects the cluster control plane, workloads, and data from unauthorized access and compromise. It covers RBAC, network policies, pod security standards, secrets management, image trust, runtime monitoring, and supply chain integrity.
itCloud native tools and technologies | OpenSkills.info
Recommended first:kubernetes-fundamentals
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic — Kubernetes Security
Here is the sentence a colleague would give you at the coffee machine: a fresh Kubernetes cluster is not locked down, and it was never going to be. It ships mechanisms with the switches in the off position, and the work is deciding which to turn on. This is less alarming than it sounds and more work than anyone budgets for.
The reason it looks like sprawl is that the pieces live in unrelated APIs. Identity, admission, workload hardening, secrets, network rules, and audit logs are six separate conversations wearing one topic's name. The organizing frame the ecosystem uses is the 4C's — Cloud, Cluster, Container, Code — four nested layers where each one depends on everything outside it. Perfect application code inside a container that can reach the host kernel is not protected code, in the same way that an excellent lock on an open door is still an excellent lock.
Two ideas carry most of the weight. The first is that every interaction with a cluster goes through one component, the API server, and every request crosses three gates in a fixed order: authentication (which identity is this), authorization (is that identity allowed this action, in practice via RBAC, the role-based permission model), and admission (should this object be permitted or altered before it is stored). One front door, three checks, and almost all access control work happens at one of them.
The second is that hardening a workload means restricting what a container may be, not what it may talk to. A container is an ordinary process on a shared machine kernel, and the securityContext — the block of settings on a Pod that governs privilege — decides how much of that kernel it can touch. Because auditing every workload individually is nobody's idea of a career, the Pod Security Standards bundle these settings into three named profiles, and a label on a namespace applies one.
Now the surprise, and it is a good one. A Secret, the object built for sensitive values, is not encrypted. It is base64-encoded, which is a formatting choice, not a security one, and the cluster's datastore holds it in the clear until someone configures encryption at rest. The vocabulary is lying to you slightly. It is worth knowing on day one rather than during an incident review.
Where to go from here. The Cheatsheet is the compressed map — profiles, verbs, and a hardening order to work through. The Practice Reference has the commands, including the ones that ask the cluster what an identity can actually do. Field Notes covers the parts that surprise people who already know the mechanisms. The Exercise builds a throwaway cluster and breaks it on purpose, which is the fastest way to believe any of this.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://kubernetes.io/docs/concepts/security/
Supports
- Security mechanism taxonomy — control plane protection, secrets, workload protection, admission, auditing, policies
- TLS for control plane traffic; encryption at rest as separate opt-in
- Pod security standards and RuntimeClass for custom isolation
- https://kubernetes.io/docs/concepts/security/cloud-native-security/
Supports
- The 4C's layered model (Cloud, Cluster, Container, Code) and layer interdependence
- https://kubernetes.io/docs/concepts/security/controlling-access/
Supports
- Request pipeline — TLS, authentication, authorization, admission control
- No built-in human user database; certificate/token/OIDC authentication options
- https://kubernetes.io/docs/reference/access-authn-authz/rbac/
Supports
- Role/ClusterRole and RoleBinding/ClusterRoleBinding semantics and scoping
- Additive-only permissions, deny-by-default
- Privilege escalation prevention (bind/escalate), least-privilege guidance
- https://kubernetes.io/docs/concepts/security/service-accounts/
Supports
- ServiceAccounts as Pod identity; projected short-lived tokens; opting out of token automounting
- https://kubernetes.io/docs/concepts/security/pod-security-standards/
Supports
- Privileged/Baseline/Restricted profile definitions and cumulative relationship
- https://kubernetes.io/docs/concepts/security/pod-security-admission/
Supports
- Built-in admission enforcement via namespace labels; enforce/audit/warn modes; staged rollout
- https://kubernetes.io/docs/concepts/security/pod-security-policy/
Supports
- PodSecurityPolicy removal in v1.25 and replacement by Pod Security Admission
- https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
Supports
- securityContext controls — runAsNonRoot, capabilities, allowPrivilegeEscalation, readOnlyRootFilesystem, seccomp
- https://kubernetes.io/docs/concepts/configuration/secret/
Supports
- Secrets as base64-encoded API objects, stored unencrypted in etcd by default
- Risk notes — anyone authorized to read/create Pods can access Secrets; mitigation guidance
- https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/
Supports
- Encryption-at-rest configuration for Secrets (EncryptionConfiguration, KMS providers)
- https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/
Supports
- Admission controllers intercepting API requests to validate or mutate
- https://kubernetes.io/docs/concepts/services-networking/network-policies/
Supports
- NetworkPolicy as the traffic segmentation mechanism; namespaces alone do not isolate traffic
- https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/
Supports
- Audit logging of API requests — actors, actions, timing; audit policy stages
- https://kubernetes.io/docs/concepts/containers/runtime-class/
Supports
- RuntimeClass for selecting alternative/sandboxed container runtimes per workload
- https://kubernetes.io/docs/concepts/security/rbac-good-practices/
Supports
- Permission to create workloads in a namespace implicitly grants access to Secrets, ConfigMaps and PersistentVolumes that can be mounted in Pods
- list and watch access on Secrets returns their contents, so listing is equivalent to reading every Secret in scope
- Permission to create arbitrary PersistentVolumes includes hostPath volumes, granting access to the underlying node filesystem
- Access to the nodes/proxy subresource grants kubelet API rights, allowing command execution on Pods and bypassing audit logging and admission control
- https://kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-namespace-labels/
Supports
- Pod Security Standards are applied through pod-security.kubernetes.io/<enforce|audit|warn> namespace labels with optional -version pins
- https://kind.sigs.k8s.io/docs/user/quick-start/
Supports
- kind create cluster --name and kind delete cluster --name manage a local single-node Kubernetes cluster in containers
- https://kubernetes.io/blog/2017/04/rbac-support-in-kubernetes/
Supports
- The RBAC authorizer moved to beta in Kubernetes 1.6 and provided a transition path from ABAC
- https://kubernetes.io/blog/2017/10/using-rbac-generally-available-18/
Supports
- RBAC was promoted to generally available in Kubernetes 1.8
- https://kubernetes.io/blog/2017/09/kubernetes-18-security-workloads-and/
Supports
- Kubernetes 1.8 graduated RBAC to stable, announced September 2017
- https://github.com/kubernetes/kubernetes/issues/71411
Supports
- CVE-2018-1002105: proxy request handling in kube-apiserver could leave a connection that allowed arbitrary requests to a backend using the API server's TLS credentials, rated CVSS 9.8
- https://www.cncf.io/blog/2019/08/06/open-sourcing-the-kubernetes-security-audit/
Supports
- The 2019 CNCF third-party security audit by Trail of Bits and Atredis Partners covered eight core components and was published in August 2019
- https://kubernetes.io/blog/2022/10/05/current-state-2019-third-party-audit/
Supports
- The 2019 audit assessed Kubernetes 1.13.4 and produced 37 findings alongside a whitepaper and threat guide
- https://kubernetes.io/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/
Supports
- PodSecurityPolicy was deprecated in Kubernetes 1.21 with removal planned for 1.25, because of usability problems that could not be fixed without breaking changes
- https://www.cisa.gov/news-events/alerts/2021/08/02/cisa-and-nsa-release-kubernetes-hardening-guidance
Supports
- NSA and CISA released Kubernetes Hardening Guidance in August 2021
- https://kubernetes.io/blog/2021/10/05/nsa-cisa-kubernetes-hardening-guidance/
Supports
- The Kubernetes project reviewed the NSA and CISA hardening guidance and its recommendations
- https://kubernetes.io/blog/2021/12/09/pod-security-admission-beta/
Supports
- Pod Security Admission graduated to beta in Kubernetes 1.23 as the built-in replacement for PodSecurityPolicy
- https://kubernetes.io/blog/2022/08/25/pod-security-admission-stable/
Supports
- Pod Security Admission graduated to stable and PodSecurityPolicy was removed in Kubernetes 1.25
- https://kubernetes.io/blog/2022/05/03/kubernetes-1-24-release-announcement/
Supports
- Kubernetes 1.24 was released on 3 May 2022
- https://www.cncf.io/blog/2023/04/19/new-kubernetes-security-audit-complete-and-open-sourced/
Supports
- A further CNCF Kubernetes security audit was completed and open sourced in April 2023
- https://kubernetes.io/blog/2023/05/16/kms-v2-moves-to-beta/
Supports
- KMS v2 moved to beta in Kubernetes 1.27 with improvements to key rotation, health checks, performance and observability
- https://kubernetes.io/docs/tasks/administer-cluster/kms-provider/
Supports
- KMS v2 is stable as of Kubernetes 1.29; KMS v1 is deprecated since 1.28 and disabled by default since 1.29
- https://kubernetes.io/blog/2023/12/13/kubernetes-v1-29-release/
Supports
- Kubernetes 1.29 was released on 13 December 2023
- https://kubernetes.io/blog/2024/04/24/validating-admission-policy-ga/
Supports
- ValidatingAdmissionPolicy became generally available in Kubernetes 1.30, providing in-process CEL validation as an alternative to validating admission webhooks
