Skip to main content
Kubernetes Security Best Practices (2026)

Kubernetes Security Best Practices (2026)

KU
· Founder & Chief Editor
• 8 min read•Updated •58 views

A practical, layer-by-layer checklist for securing Kubernetes clusters, workloads, networking, secrets, and the software supply chain.

Key takeaways

  • Start with four controls that shrink blast radius most.
  • Remove standing cluster-admin and wildcard RBAC grants, label every namespace with Pod Security enforce restricted, apply a default-deny NetworkPolicy per namespace, and fail CI on critical image vulnerabilities.
  • Then add encryption at rest for Secrets, signed-image admission policy, and runtime detection.

The four Kubernetes security controls that matter most are: least-privilege RBAC with no standing cluster-admin, Pod Security Admission at restricted on every namespace, a default-deny NetworkPolicy per namespace, and image scanning that fails CI on criticals. Do those this week. Encryption at rest, signed images and runtime detection come next.

Verified against

Kubernetes 1.37 (1.37.1), against the kubernetes.io Pod Security Standards, security checklist, RBAC good practices and Network Policies pages. Checked October 2026.

A fresh cluster will happily run a container as root, let any pod reach any other pod, and mount a service account token the workload never needed. Securing it is less about one magic setting than closing gaps at every layer. As of October 2026 the project maintains 1.37, 1.36 and 1.35; 1.34 reached end of life on 2026-10-27, so anything older is running without upstream patches.

Cluster and API server

If someone owns the API server or etcd, they own the cluster.

RBAC least privilege is the highest-impact control you have. Nobody should hold cluster-admin unless a human is actively breaking glass. Scope roles to namespaces, avoid wildcard verbs and resources, and watch service accounts: a pod that can create pods or read Secrets cluster-wide is a lateral-movement engine. Audit what exists:

code
$ kubectl get clusterrolebindings -o json \
    | jq -r '.items[] | select(.roleRef.name=="cluster-admin")
             | .metadata.name + " -> " + ([.subjects[]? | .kind + ":" + .name] | join(", "))'
cluster-admin -> Group:system:masters
ci-deployer -> ServiceAccount:ci-deployer

$ kubectl auth can-i --list --as=system:serviceaccount:payments:default -n payments
$ kubectl auth can-i get secrets --all-namespaces --as=system:serviceaccount:payments:api
no

Any binding besides the built-in system:masters one deserves a ticket. Answering yes to the last command for an application service account is a finding.

Lock down the API surface. The checklist says the Kubernetes API, kubelet API and etcd should not be exposed publicly on the Internet. Restrict anonymous access, require authentication and authorization on the kubelet (the docs warn the kubelet's defaults without a --config file are "overly permissive"), and use mTLS for etcd with a CA unique to etcd.

Turn on audit logging and ship it somewhere queryable; when something goes wrong, it is often the only record of who did what. Encrypt Secrets at rest with an EncryptionConfiguration on the API server, ideally backed by a KMS provider. On managed services most of this is the provider's job, which is one reason we steer teams toward managed Kubernetes.

Workloads

Assume application code will be exploited, and make a breakout useless. Enforce Pod Security Admission at restricted, but audit first so you know what breaks:

code
$ kubectl label --dry-run=server --overwrite ns payments \
    pod-security.kubernetes.io/enforce=restricted
Warning: existing pods in namespace "payments" violate the new PodSecurity enforce level "restricted:latest"
Warning: api-7d9f: allowPrivilegeEscalation != false, unrestricted capabilities, runAsNonRoot != true, seccompProfile
namespace/payments labeled (server dry run)

Fix the warnings, then apply it for real:

YAML
# namespaces/payments.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: payments
  labels:
    pod-security.kubernetes.io/enforce: restricted
    pod-security.kubernetes.io/enforce-version: v1.37
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/audit: restricted

Pinning enforce-version stops a cluster upgrade from tightening the policy under you. Per the Pod Security Standards, restricted requires runAsNonRoot: true, allowPrivilegeEscalation: false, a capability drop list that includes ALL (only NET_BIND_SERVICE may be added back), a seccompProfile of RuntimeDefault or Localhost, and only safe volume types (no hostPath). A compliant container spec:

YAML
# deploy/api.yaml (container securityContext excerpt)
securityContext:
  runAsNonRoot: true
  runAsUser: 10001
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop: ["ALL"]
  seccompProfile:
    type: RuntimeDefault

readOnlyRootFilesystem and resource limits are not part of restricted; we set them anyway. A read-only root stops an attacker writing tools into the container, and CPU and memory limits stop one workload starving a node. Set automountServiceAccountToken: false on pods that never call the API.

Networking

By default every pod can reach every other pod. Apply default-deny per namespace, then open only the paths you need:

YAML
# netpol/default-deny.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny
  namespace: payments
spec:
  podSelector: {}
  policyTypes: ["Ingress", "Egress"]

That blocks DNS too, so the first allow rule is usually egress to kube-dns on port 53. NetworkPolicy is only enforced if your CNI plugin supports it; on a plugin that doesn't, these objects are accepted and silently ignored. Kubernetes network policies in practice covers the allow rules in depth. The checklist also calls for filtering workload access to the cloud metadata API and restricting LoadBalancer and ExternalIPs. Add mTLS between services (a service mesh does this without code changes), and limit egress so exfiltration and command-and-control have nowhere to go.

Supply chain, secrets and runtime

Supply chain. Scan images in CI and block criticals, as described in container vulnerability scanning. Sign images and verify signatures at admission with Kyverno or OPA Gatekeeper: no unsigned images, no latest tags, no untrusted registries. Generate an SBOM and provenance for every build so "is this CVE in production" takes minutes, which we cover in supply-chain security with SBOMs.

Secrets. The checklist says ConfigMaps must not hold confidential data, encryption at rest must be configured for the Secret API, and pods should get secrets through mounted volumes. Keep the source of truth outside the cluster with an external secrets operator or Vault, and never bake secrets into images.

Runtime. Prevention is never complete. Deploy runtime detection such as Falco for shells spawned in containers, unexpected syscalls and odd outbound connections, plus drift detection for containers that no longer match their image.

Failure modes when you turn this on

  • pods "api-..." is forbidden: violates PodSecurity "restricted:v1.37": allowPrivilegeEscalation != false ...: the controller rejected the pod. Usually the Deployment applies but its ReplicaSet can't create pods, so check kubectl get events -n payments. Add the missing securityContext fields.
  • Error: container has runAsNonRoot and image will run as root: the image's USER is root. Set runAsUser to a non-zero UID or rebuild with a non-root USER.
  • container has runAsNonRoot and image has non-numeric user (nginx), cannot verify user is non-root: set a numeric runAsUser.
  • Read-only file system in app logs: the app writes to /tmp or a cache dir. Mount an emptyDir there.
  • Everything times out after default-deny: you blocked DNS egress. Allow UDP and TCP 53 to kube-dns.

Where this breaks

Some workloads cannot run under restricted: CNI agents, CSI drivers, log shippers and node exporters need host access. Put them in dedicated namespaces at privileged or baseline, keep those namespaces small, and restrict who can deploy there. Pod Security is also namespace-scoped and coarse; per-image or per-registry rules need an admission policy engine. And none of this helps if a CI credential with cluster-admin leaks, which is exactly the path in the STORM-3068 Kubernetes credential theft campaign.

Questions people ask

What are the most important Kubernetes security best practices?

Start with four: remove standing cluster-admin and wildcard RBAC grants, enforce Pod Security Admission at restricted on application namespaces, apply a default-deny NetworkPolicy per namespace, and scan images in CI so criticals fail the build. They shrink the blast radius of a compromised pod the most. Then add encryption at rest, signed-image admission and runtime detection.

What does the Pod Security restricted profile require?

It includes everything in baseline plus: runAsNonRoot: true, no runAsUser: 0, allowPrivilegeEscalation: false, capabilities dropping ALL with only NET_BIND_SERVICE addable, a seccomp profile of RuntimeDefault or Localhost, and only safe volume types such as configMap, secret, emptyDir, projected and persistentVolumeClaim. It does not require a read-only root filesystem or resource limits.

Are Kubernetes Secrets encrypted by default?

No. Secrets are base64-encoded, not encrypted, and stored in etcd as-is unless the API server is configured with encryption at rest, preferably through a KMS provider. Many managed services enable encryption for you, but check. Also restrict who can get or list Secrets in RBAC, because API access bypasses at-rest encryption entirely.

The call we'd make

Treat the cluster as hostile from the inside. Get the blast-radius controls solid first: least-privilege RBAC, restricted Pod Security with a pinned version, default-deny networking, and scanned, signed images. Then layer in secrets management, admission policy and runtime detection. Kubernetes security is one slice of a broader program, so fit it into your application security best practices rather than treating it as a separate island.

Sources

React
Share this post
Cite this article
Plain text

Kiril Urbonas (2026). Kubernetes Security Best Practices (2026). DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/kubernetes-security-best-practices

Markdown

[Kubernetes Security Best Practices (2026)](https://www.devopsness.com/blog/kubernetes-security-best-practices) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)

KU

Kiril Urbonas

Founder & Chief Editor

586 articles
View all articles by Kiril Urbonas

You might have missed

Evergreen posts worth revisiting.