Secure controller manager and scheduler
Summary of best practices:- Isolate the controller manager and scheduler on a dedicated node
- Apply RBAC to limit what each component can do
- Secure all inter-component communication with TLS
- Enable audit logging and monitor with Prometheus and Grafana
- Use secure default configurations and protect configuration files
- Run the latest Kubernetes version
- Regularly scan for vulnerabilities
Secure kubelet
Summary of best practices:- Set the authorization mode to
Webhook - Disable anonymous access and enable supported authentication mechanisms
| Port | Description |
|---|---|
| 10250 | Serves the kubelet API with full access |
| 10255 | Serves a read-only, unauthenticated kubelet API (deprecated in recent versions) |
Set authorization mode to Webhook
By default, the kubelet allows all requests without authorization. Set the authorization mode toWebhook so the kubelet forwards authorization decisions to the kube-apiserver.
/var/lib/kubelet/config.yaml
Disable anonymous access and enable authentication
By default, the kubelet allows requests from anonymous users (system:anonymous, group system:unauthenticated). Disable this and require certificate-based authentication.
/var/lib/kubelet/config.yaml
- Certificate-based
- API bearer token-based
Secure container runtime
Notable CVEs in container runtimes:| CVE ID | Description |
|---|---|
| CVE-2019-5736 | Allows overwriting the host runc binary, gaining root execution on the host |
| CVE-2020-15257 | Allows access to containerd API without proper authentication |
| CVE-2021-30465 | Allows container escape and arbitrary code execution on the host |
| CVE-2021-32760 | Allows denial-of-service via malformed containerd API requests |
| CVE-2022-23648 | Allows unauthorized access to containerd API |
| CVE-2022-0811 | Allows privilege escalation in CRI-O |
- Regularly update the container runtime to the latest version.
-
Run containers with least privilege and avoid running as root:
-
Set a read-only root filesystem to prevent writes:
-
Limit resource consumption (CPU, Memory) to prevent denial-of-service:
-
Apply security profiles like AppArmor or SELinux:
- SELinux
- AppArmor
SELinux enforces mandatory access control policies at the kernel level:sample.yaml - Transition to supported runtimes like containerd or CRI-O. Docker is deprecated in Kubernetes.
- Enable monitoring and logging (Prometheus, Grafana) and audit logging to detect suspicious activity.
Secure kube-proxy
Summary of best practices:- Set configuration file permissions to 644 or stricter, owned by
root:root - Secure communication with TLS between kube-proxy and kube-apiserver
- Set kube-proxy with least privilege
- Apply network policies to restrict access to the kube-proxy service
- Enable audit logging and monitoring
- Regularly scan and update for vulnerabilities
644 allows the owner to read and modify the file, while the group and others can only read it (r=4, w=2, x=1)./var/lib/kube-proxy/kubeconfig.conf
audit.yaml
Secure ETCD
Summary of best practices:- Encrypt data at rest (etcd and persistent volumes)
- Perform regular backups
- Secure all communication with TLS
Secure container networking
By default, Kubernetes networking is flat and open — all pods can communicate with each other without restriction. Best practices:- Implement network policies to restrict ingress and egress traffic between pods.
- Use a service mesh like Istio for mutual TLS, encrypted and authenticated pod communication, traffic management, and observability.
- Encrypt network traffic between pods using IPSec or WireGuard.
- Isolate sensitive workloads using namespaces and apply namespace-level network policies to reduce the impact of a compromised workload.
Secure storage
Storage security risks in Kubernetes:- Misconfigured storage access — allows attackers to access sensitive data
- Lack of encryption — can lead to data leakage
- Insufficient backup — can result in data loss from failures or attacks
- Encrypt data at rest using your cloud provider’s encryption options (e.g., AWS EBS, Azure Disk Storage).
- Use RBAC to limit storage access to authorized users only.
-
Use StorageClass to enforce encryption, performance limits, and backup policies:
sample-storage-class.yamlIOPS (Input/Output Operations Per Second) defines the read/write throughput of the volume. Higher IOPS means better performance.
- Regularly back up data and prepare a disaster recovery plan. Tools: Velero, Heptio Ark, Kasten.
- Monitor and audit storage metrics to detect suspicious activity and enable audit logging.