logo

Kubernetes Security Best Practices for Enterprise Deployments

YR
Yasir Raza · Senior Solutions Architect
3 min read · January 15, 2024

Securing Kubernetes takes planning at several levels at once. The more of your workloads run in containers, the more your applications and data depend on how well the cluster is locked down.

Understanding the Kubernetes security model

Kubernetes security works on four layers:

  1. Cluster security: the cluster infrastructure itself
  2. Workload security: the individual applications
  3. Network security: which traffic is allowed to flow
  4. Data security: sensitive information such as credentials

RBAC (role-based access control)

Role-based access control decides who can reach which resources and what they can do with them. It is usually the first control to get right.

Creating secure RBAC policies

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: production
  name: pod-reader
rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get", "watch", "list"]

Good RBAC practice:

  • Follow the principle of least privilege
  • Use namespace-specific roles when possible
  • Audit and review permissions regularly
  • Avoid cluster-admin unless there is no other way

Network policies

Network policies control which pods can talk to each other, much like internal firewalls for your applications.

Example network policy

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-all-ingress
  namespace: secure-namespace
spec:
  podSelector: {}
  policyTypes:
  - Ingress

Pod security standards

Kubernetes Pod Security Standards let you define security policies for your workloads.

Security context best practices

apiVersion: v1
kind: Pod
metadata:
  name: secure-pod
spec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 1000
    fsGroup: 2000
  containers:
  - name: app
    image: myapp:latest
    securityContext:
      allowPrivilegeEscalation: false
      readOnlyRootFilesystem: true
      capabilities:
        drop:
        - ALL

Image security

Container images are a common way in for attackers. To reduce that risk:

  1. Use trusted base images from reputable sources.
  2. Scan images for vulnerabilities with tools like Trivy or Clair.
  3. Sign images with a tool like Cosign.
  4. Use admission controllers to enforce image policies.

Secrets management

Never store sensitive data in plain text in your Kubernetes manifests:

apiVersion: v1
kind: Secret
metadata:
  name: app-secret
type: Opaque
data:
  database-password: <base64-encoded-password>

External secret managers

For sensitive data, consider an external secret manager such as:

  • HashiCorp Vault
  • AWS Secrets Manager
  • Azure Key Vault
  • External Secrets Operator

Monitoring and auditing

Log and monitor these areas:

  1. Audit logging of every API server request
  2. Runtime security monitoring of container behaviour
  3. Regular compliance scans and security assessments
  4. Alerting and response when something suspicious happens

Cluster hardening

Control plane

  • Enable audit logging
  • Restrict access to the API server
  • Use TLS everywhere
  • Apply security updates regularly

Nodes

  • Keep the attack surface small
  • Use read-only root filesystems
  • Run runtime security tooling
  • Patch the operating system regularly

Compliance and governance

Enterprise deployments usually have to meet one or more of these frameworks:

  • CIS Kubernetes Benchmark
  • NIST Cybersecurity Framework
  • SOC 2 Type II
  • PCI DSS (for payment processing)

Implementation checklist

  • RBAC policies implemented and reviewed
  • Network policies defined for all namespaces
  • Pod Security Standards enforced
  • Image scanning integrated into CI/CD
  • Secrets management solution deployed
  • Monitoring and alerting configured
  • Regular security assessments scheduled

Conclusion

Kubernetes security needs regular reviews, updates and monitoring after the initial setup. Start with RBAC, network policies and pod security, then add the other tools on top.

Developers and operators share responsibility for security with the security team, so build these practices into your development process.

Additional resources


Questions about putting these practices in place? Talk to our engineers.

YR
Written by
Yasir Raza
Co-founder · Senior Solutions Architect

Yasir designs the platforms our clients run on: Kubernetes, cloud and on-premises infrastructure, security baselines and the automation that keeps them consistent. He leads architecture and security reviews on our projects.

Want a second opinion on your setup?
Talk to the engineers who wrote this. 30 minutes, no sales pitch.
Book a call

Keep reading

Observability
Datadog Bill Too High? How to Cut It, and When to Move to Open Source
Where Datadog costs come from, the fixes that cut the bill inside Datadog, and when a hybrid or full move to Prometheus, Grafana and OpenTelemetry pays off.
Read article →
Nextcloud
The November 2026 Outlook Outage: How to Keep Working When Microsoft 365 Goes Down
What happened in the 12–14 November Outlook and Microsoft 365 outage, and how a Nextcloud setup you control keeps teams working and data private.
Read article →
Observability
Building an On-Prem Observability Stack with Prometheus, Grafana, Loki and OpenTelemetry
How to build a unified, open-source observability stack on your own servers: OpenTelemetry, Prometheus, Loki, Tempo and Grafana, with sizing and alerting.
Read article →

Next step

Talk to an engineer about Kubernetes

Send a few details, and pick up to 3 times if you would like a call. We reply within one business day.

You talk to the expert who would do the work

Written scope and price after the call

No obligation

info@opensource.consulting
+1 514 577 8599