Kubernetes Security Essentials

CNPA Domain: Platform Observability, Security, and Conformance (20%) Topic: Kubernetes Security Essentials

Overview

Kubernetes is a powerful platform, but its defaults are not production-secure. Platform engineering teams are responsible for hardening Kubernetes clusters and ensuring that every workload runs with the minimum necessary privileges. This article covers the essential Kubernetes security primitives: RBAC, Pod Security Standards, Secrets management, and admission webhooks.


The 4Cs of Cloud Native Security

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Code (application vulnerabilities)                    β”‚
β”‚                                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Container (image vulnerabilities, base images)  β”‚  β”‚
β”‚  β”‚                                                  β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚  Cluster (RBAC, PSS, network policies)     β”‚  β”‚  β”‚
β”‚  β”‚  β”‚                                            β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  β”‚  Cloud (IAM, VPC, node security)     β”‚  β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Platform engineers own the Cluster layer and influence the Container and Code layers.


Role-Based Access Control (RBAC)

RBAC controls who can do what in a Kubernetes cluster.

Core RBAC Objects

Object
Scope
Purpose

Role

Namespace

Set of allowed API operations in one namespace

ClusterRole

Cluster

Set of allowed API operations cluster-wide

RoleBinding

Namespace

Grants a Role to a user/group/service account

ClusterRoleBinding

Cluster

Grants a ClusterRole cluster-wide

Least Privilege Example

Service Account Security

Every pod runs as a ServiceAccount. Restrict service accounts to minimum required permissions:


Pod Security Standards (PSS)

Pod Security Standards replace the deprecated PodSecurityPolicy and define three security profiles:

Profile
Use Case
Key Restrictions

Privileged

System-level workloads (node agents)

No restrictions

Baseline

General workloads

Blocks known privilege escalation

Restricted

High-security workloads

Enforces security best practices

Enforcing PSS via Namespace Labels

What restricted Profile Requires


Secrets Management

Kubernetes Secrets are base64-encoded (not encrypted) by default. Platform teams must ensure secrets are protected:

Encryption at Rest

Enable etcd encryption for Secret resources:

External Secrets Operator

The best practice is to not store secrets in Kubernetes at all β€” reference them from an external secrets manager:


Admission Webhooks for Security

Admission webhooks (covered in Policy Engines) enforce security policies at the API layer. Key security-focused policies:


Node Security

Platform teams also harden the nodes themselves:

Control
Implementation

Node IAM

Use IRSA (AWS) / Workload Identity (GCP) instead of node instance roles

Node hardening

CIS Kubernetes Benchmark, minimal OS (Bottlerocket, Flatcar)

Node isolation

Taints and node selectors for sensitive workloads

Container runtime

Use gVisor or Kata Containers for strong isolation


Security Scanning

Tool
Scans
Notes

Trivy

Container images, Helm charts, IaC

CNCF project

Kubescape

Cluster configuration against NSA/MITRE/CIS

Platform assessment

Falco

Runtime threat detection (syscall-level)

CNCF graduated

Checkov

IaC files (Terraform, Helm, Kubernetes YAML)

CI integration


Key Takeaways

  • RBAC controls who can access what β€” always enforce least privilege via Role/RoleBinding, not ClusterRoleBinding

  • Pod Security Standards (restricted profile) prevent privilege escalation, require non-root containers, and enforce security contexts

  • Secrets should be encrypted at rest in etcd and ideally managed by an external secrets manager (Vault, AWS Secrets Manager)

  • Admission webhooks (Kyverno/Gatekeeper) enforce security policies at the API layer before resources are created

  • Use Trivy and Kubescape for continuous security scanning of images and cluster config


Further Reading

Last updated