Blog

Kubernetes Security: The Complete Guide

A complete guide to Kubernetes security: the 4C's model, attack surface, RBAC, pods, network policies, secrets, supply chain, and shift-left practices.

Bruno Baldo·Sep 14, 2026·13 min read·Reviewed by Rainforest Technologies

Kubernetes has become the default way to run containerized applications at scale, and with that ubiquity comes a security problem that is easy to underestimate. Kubernetes security is the practice of protecting your clusters, the workloads they run, and the software supply chain that feeds them, across the entire lifecycle from a developer's first commit to a pod serving live traffic. It is not a single control you switch on. It is a discipline that touches infrastructure, application code, networking, identity, and process.

If you are a platform or security engineer, you have probably felt the gap between how quickly teams can ship on Kubernetes and how hard it is to know whether what they shipped is safe. This guide is the cornerstone of our Kubernetes security cluster. It walks through the model, the reasons securing Kubernetes clusters is genuinely difficult, the attack surface you are defending, and the core practice areas, each of which has a dedicated deep-dive. The goal is a clear, practical map of Kubernetes security best practices you can actually work through with your team.

A quick note on scope before we begin. Kubernetes security is often discussed as though it were purely an operations concern, something the platform team configures once and forgets. In practice the strongest programs treat it as a shared discipline: developers influence it through the images and manifests they write, platform teams through cluster configuration and guardrails, and security teams through policy and verification. This guide is written with all three audiences in mind, because the failures that matter usually happen in the seams between them.

What is Kubernetes security?

Kubernetes security is the set of controls, configurations, and processes that keep a Kubernetes environment and its workloads trustworthy. That includes who can talk to the cluster and what they can do, how workloads are isolated from one another, how sensitive data is stored and accessed, where container images come from, and how you detect and respond when something goes wrong.

A useful way to frame container orchestration security is the shared-responsibility model. If you run a managed Kubernetes service, your cloud provider secures the underlying hardware and, depending on the offering, parts of the control plane. Everything above that line, your cluster configuration, your workloads, and your code, is yours to secure. Misreading that line is one of the most common sources of exposure.

The 4C's of cloud native security

The community has settled on a layered model, the 4C's, that describes defense in depth from the outside in:

  • Cloud (or the corporate datacenter/infrastructure): the environment the cluster runs in. Weaknesses here, an over-permissive cloud IAM role, an exposed management port, undermine everything above.
  • Cluster: the Kubernetes components themselves, the API server, etcd, controllers, and the policies that govern access and workload behavior.
  • Container: the images and runtimes for individual workloads, including what is inside the image and how the container is allowed to run.
  • Code: your own application code and its dependencies, where injection flaws, insecure logic, and vulnerable libraries live.

Each layer sits inside the next. You cannot secure the container layer if the cluster layer is wide open, and hardening the cluster does little if your code ships a critical remote-code-execution vulnerability. Effective Kubernetes security works on all four at once.

Why Kubernetes security is hard

Kubernetes is powerful precisely because it is dynamic, distributed, and highly configurable. Those same properties make it hard to secure.

It is dynamic. Pods are created and destroyed constantly. An IP address that belonged to a payments service one minute might belong to something else the next. Traditional perimeter and host-based controls, which assume relatively stable assets, struggle in an environment where the average workload lifetime is measured in hours or minutes.

It is distributed. A cluster is a collection of cooperating components, control plane and worker nodes, spread across machines and often across availability zones. There are many moving parts and many trust relationships. A weakness in one component, say a kubelet exposed without proper authentication, can become a foothold into the rest.

It is insecure by default in ways that surprise people. Out of the box, Kubernetes optimizes for getting workloads running, not for locking them down. By default, any pod can talk to any other pod across the cluster because there is no network segmentation until you add network policies. Containers often run as root unless you explicitly prevent it. Service accounts can be granted far more access than a workload needs. Secrets are stored in etcd base64-encoded, which is encoding, not encryption. None of these defaults is malicious; they simply mean that a cluster you have not deliberately hardened is a cluster with real gaps.

Add the pace of change, new nodes, new workloads, new dependencies every day, and it becomes clear why point-in-time audits do not keep up. Kubernetes security has to be continuous.

The Kubernetes attack surface and threat model

To defend a cluster, it helps to think like an attacker and enumerate the ways in. The Kubernetes attack surface is broad, but the recurring targets cluster into a handful of areas.

The control plane. The API server is the front door to everything; if an attacker can reach it with sufficient privileges, they effectively own the cluster. etcd stores all cluster state, including secrets, so read access to etcd is catastrophic. An improperly secured or internet-exposed API server or etcd endpoint is one of the highest-severity findings you can have.

The nodes and kubelet. Each worker node runs a kubelet that manages pods on that node. An exposed or weakly authenticated kubelet can let an attacker execute commands inside containers or on the node itself. Compromise of a single node can lead to compromise of the workloads scheduled there.

Workloads and lateral movement. Once an attacker has a foothold in one pod, whether through a vulnerable application, a poisoned dependency, or a leaked credential, they look to move. Over-permissive RBAC, mounted service-account tokens, flat pod networking, and containers running with excess privileges all make lateral movement and privilege escalation easier.

The supply chain. Increasingly, the way into a cluster is not a live exploit but a compromised image or dependency that you deployed yourself. A base image with a known critical vulnerability, a typosquatted package, or a build pipeline that pulls unverified artifacts are all supply-chain risks that land malicious or vulnerable code inside your trust boundary.

Configuration drift and human error. Many of the most damaging incidents trace back not to a novel exploit but to a misconfiguration: a dashboard exposed without authentication, a secret committed to a repository, a role bound too broadly. Directionally, misconfiguration and credential exposure account for a large share of real-world Kubernetes incidents, which is why so much of good practice is about defaults and guardrails rather than exotic defenses.

It also helps to think in terms of the phases an attacker moves through: initial access (a vulnerable app, a leaked credential, an exposed endpoint), execution and persistence inside a workload, privilege escalation from container to node to cluster, and finally impact, exfiltrating data, mining cryptocurrency on your nodes, or tampering with workloads. Each of the pillars later in this guide interrupts one or more of those phases. Least-privilege RBAC and hardened pods raise the cost of the first foothold and of escalation; network policies choke off lateral movement; secrets protection limits what a compromised workload can reach; and supply-chain controls reduce the chance the attacker was invited in via an image you built.

Mapping these to a threat model gives you the priorities that drive the rest of this guide: control access tightly, constrain what workloads can do, segment the network, protect secrets, and trust only the images and dependencies you have verified.

The core Kubernetes security pillars

The practice areas below are the heart of a Kubernetes security program. Each one is a deep subject in its own right, so each has a dedicated satellite guide. Use this section as the map, and follow the links when you are ready to implement.

RBAC and access control

Role-based access control governs who and what can perform which actions against the API server. This is your first and most important line of defense, and also one of the easiest to get wrong: cluster-admin bindings handed out for convenience, service accounts with far more access than their workloads need, and no periodic review. The goal is least privilege, scoped roles bound to specific subjects in specific namespaces, and disciplined handling of service-account tokens. See the deep dive on Kubernetes RBAC and access control.

Pod security

Pods can be configured to give away the farm, running as root, mounting the host filesystem, sharing host namespaces, or requesting privileged mode. Pod-level hardening uses security contexts and Pod Security Admission (the built-in successor to the removed PodSecurityPolicy) to enforce baseline and restricted standards, so that a compromised container cannot easily escalate to the node. Full details in the Kubernetes pod security guide.

Network policies

By default the cluster network is flat: every pod can reach every other pod. Network policies let you define which workloads may communicate, implementing microsegmentation and a default-deny posture that dramatically limits lateral movement after a compromise. Learn how to design and roll these out in the Kubernetes network policies guide.

Secrets management

Kubernetes Secrets are, by default, only base64-encoded in etcd, not encrypted, and are readily readable by anyone with the right API access. Protecting them means enabling encryption at rest, tightening access with RBAC, avoiding secrets in manifests and environment variables where practical, and often integrating an external secrets manager. The Kubernetes secrets management guide covers the patterns.

Image and supply-chain security

Everything you run starts as an image built from a base and a set of dependencies. Minimizing base images, scanning for known vulnerabilities, pinning and verifying provenance, and generating a software bill of materials all reduce the chance that you deploy something exploitable. This is where container security meets software composition analysis. See Kubernetes image and supply-chain security.

Admission control and runtime security

Two cross-cutting layers tie the pillars together. Admission control, via validating and mutating admission webhooks and policy engines, lets you enforce rules at deploy time: reject a pod that runs as root, require signed images, block a workload that lacks resource limits. It is how you turn best practices into guardrails that cannot be bypassed by a hurried kubectl apply.

Runtime security assumes that some risk will always slip through and watches the cluster while it runs, detecting anomalous process activity, unexpected network connections, or attempts at container escape, and giving you the signal to respond. Admission control keeps bad configurations out; runtime security catches what gets in anyway. Together with the pillars above, they form defense in depth.

Kubernetes security across the SDLC: shift left

The single most effective change most teams can make is to move security earlier, to shift left, so that problems are caught when they are cheap to fix rather than after they are running in production. Kubernetes makes this practical because so much of what you deploy is declared as code.

Author and scan manifests and IaC. Your Kubernetes manifests, Helm charts, and infrastructure-as-code templates are where misconfigurations are born. Scanning them in the repository and in pull requests catches the container-running-as-root, the missing network policy, or the over-broad role before it is ever applied. This is the same discipline described in our broader look at what application security is, applied to infrastructure.

Scan images in CI. Build pipelines are the right place to scan container images for known vulnerabilities and to check dependencies with software composition analysis. Failing a build on a critical, fixable vulnerability is far cheaper than patching a fleet of running pods. Pin base images, verify provenance, and keep images minimal.

Enforce at admission. Use admission control as the gate between "declared" and "running." Policies that require signed images, forbid privileged pods, or mandate resource limits ensure that the standards you agreed on are actually met at deploy time.

Monitor at runtime. Finally, watch what is actually happening in the cluster, both for threats and for drift from the secure baseline you established earlier. A workload that suddenly spawns a shell, reaches for the cloud metadata endpoint, or opens a connection it has never made before is worth investigating, and runtime signals are also how you learn that a control you thought was in place has quietly stopped working.

The payoff of this ordering is economic. A misconfiguration caught in a pull request costs a developer a few minutes; the same issue caught in a running production cluster can mean an incident, a rollout, and an audit. Shifting left does not mean doing less security later, it means the later stages have far less to catch. Just as important, feedback delivered in the tools developers already use, the repository, the pull request, the CI pipeline, is feedback teams will act on, whereas a report that lands in a separate console days later tends to be ignored.

This lifecycle view is the essence of moving from DevOps to DevSecOps: security becomes a property of the pipeline, owned by the teams building and running the software, rather than a gate bolted on at the end.

Kubernetes security best practices

The practices below distill the pillars into a working checklist. Treat it as a starting point and follow the satellite guides for depth. A fuller, prioritized list lives in the dedicated Kubernetes security best practices guide.

  • Apply least privilege everywhere: scoped RBAC roles, minimal service-account permissions, and no default cluster-admin bindings.
  • Lock down the control plane: restrict and authenticate access to the API server and etcd, enable audit logging, and encrypt etcd at rest.
  • Harden pods with security contexts and Pod Security Admission: no root, no privileged mode, read-only root filesystems where feasible, and dropped Linux capabilities.
  • Segment the network with default-deny network policies, opening only the connections workloads genuinely need.
  • Protect secrets: enable encryption at rest, restrict access, keep secrets out of images and source control, and consider an external secrets manager.
  • Secure the supply chain: use minimal, trusted base images, scan images and dependencies, verify provenance, and keep a software bill of materials.
  • Enforce standards with admission control so guardrails cannot be skipped under deadline pressure.
  • Monitor at runtime and keep everything, Kubernetes, nodes, and images, patched and current.
  • Make it continuous: scan manifests, IaC, and images on every change rather than in periodic audits.

How Rainforest helps

Much of Kubernetes security comes down to trusting what you deploy and knowing where the risk is, across images, infrastructure code, and dependencies. Rainforest is an application security testing platform that covers exactly those surfaces, so that the checks described throughout this guide happen automatically as part of how your teams build.

  • Container image security scans the images you ship for known vulnerabilities and insecure configurations, so a critical flaw in a base image is caught in CI rather than in production. Learn more on the container security page.
  • Infrastructure-as-code scanning analyzes your Kubernetes manifests, Helm charts, and IaC templates for misconfigurations, the over-broad role, the missing network policy, the privileged pod, before they are applied. See IaC scanning.
  • Software composition analysis identifies vulnerable and risky dependencies in your code and images, addressing the supply-chain layer of the 4C's model. See software composition analysis.
  • Unified findings bring image, IaC, and dependency results into a single, prioritized view, so your teams fix root causes once instead of triaging duplicate alerts across disconnected tools. Explore the full application security testing platform.

If you want to see how this looks against your own clusters and pipelines, book a demo and we will walk through it with your stack.

Frequently asked questions

What is Kubernetes security?

Kubernetes security is the practice of protecting Kubernetes clusters, the workloads they run, and the software supply chain that feeds them, across the whole lifecycle. It spans access control, workload isolation, network segmentation, secrets protection, image and dependency integrity, and runtime detection, framed by the shared-responsibility and 4C's models.

What are the 4 C's of cloud native security?

The 4C's are Cloud, Cluster, Container, and Code. They describe layered defense in depth from the outside in: the cloud or datacenter the cluster runs in, the Kubernetes cluster components themselves, the individual containers and their runtimes, and finally your own application code and dependencies. Each layer sits inside the next, so a weakness in an outer layer undermines the ones within it.

What are the biggest Kubernetes security risks?

The most common and damaging risks are misconfigurations and over-permissive access (broad RBAC, exposed API server or dashboards), insecure defaults (flat pod networking, containers running as root, unencrypted secrets), and supply-chain exposure from vulnerable base images and dependencies. Directionally, misconfiguration and credential exposure drive a large share of real-world incidents.

How do you secure a Kubernetes cluster?

Start with least-privilege RBAC and a locked-down control plane, then harden pods with security contexts and Pod Security Admission, segment the network with default-deny network policies, protect secrets with encryption at rest and restricted access, and secure the supply chain by scanning images and dependencies. Enforce these with admission control and back them with runtime monitoring, scanning manifests, IaC, and images continuously rather than in periodic audits.

What is Pod Security Admission?

Pod Security Admission is Kubernetes' built-in admission controller for enforcing the Pod Security Standards (privileged, baseline, and restricted) at the namespace level. It replaced the removed PodSecurityPolicy and lets you prevent pods that violate a chosen standard, for example those running as root or in privileged mode, from being admitted to the cluster.

Does Kubernetes encrypt secrets by default?

No. By default, Kubernetes Secrets are only base64-encoded and stored in etcd, which is encoding, not encryption, and anyone with sufficient API or etcd access can read them. You need to enable encryption at rest for etcd, restrict access with RBAC, and often integrate an external secrets manager to protect them properly.

Bruno Baldo

Written by

Bruno Baldo

CMO

Um pouco de marketing e um pouco de curiosidade e temos a receita pra criar um apaixonado por cyber!

Keep reading