Kubernetes gives you powerful security controls, but very few of them are switched on by default. These are the basics we put in place on every production cluster, ordered by impact.
1. Handle secrets properly
Kubernetes Secret objects are only base64-encoded, not encrypted, so anyone who can read them in the API or in Git can read your passwords.
- Never commit raw secrets to Git. Use Sealed Secrets or SOPS to commit only encrypted versions, or the External Secrets Operator to sync from a vault (AWS Secrets Manager, GCP Secret Manager, Azure Key Vault, HashiCorp Vault).
- Enable encryption at rest for Secrets in etcd. Most managed services offer this, sometimes with your own key.
- Rotate credentials regularly, and immediately when someone leaves the team.
2. Least-privilege RBAC
- Give people and CI pipelines namespace-scoped Roles, not cluster-wide
cluster-admin. - Separate read-only access for developers in production from deploy access for the pipeline.
- Give each workload its own ServiceAccount, and disable token auto-mounting for pods that don't call the Kubernetes API.
- Review bindings regularly. Permissions only ever seem to grow.
3. Scan and trust your images
- Scan images for known vulnerabilities in CI with tools such as Trivy or Grype, or use your registry's built-in scanner (Harbor includes one).
- Fail the build on critical vulnerabilities that have a fix available.
- Use small base images (slim or distroless) with fewer packages, so there's less to patch.
- Pull only from trusted registries, and consider signing images (for example with Sigstore cosign) and verifying signatures at admission.
4. Lock down pods
Apply the built-in Pod Security Standards (aim for restricted where possible) and set a sensible securityContext:
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
Running as non-root with a read-only filesystem blocks a large class of container-escape and persistence attacks.
5. Restrict network traffic
By default, every pod can talk to every other pod. NetworkPolicies fix that:
- start with a default-deny policy per namespace,
- explicitly allow only the flows you need (ingress controller to web, web to database, and so on),
- limit egress so a compromised pod can't freely reach the internet.
Make sure your network plugin (Calico, Cilium and similar) actually enforces policies.
6. Protect the control plane
- Restrict API server access to known networks, a VPN or a private endpoint.
- Keep Kubernetes and node images up to date. Managed services make upgrades much easier.
- Never expose dashboards or admin tools publicly without strong authentication.
7. Log and audit
Enable Kubernetes audit logs and ship them, along with application logs, to a central place with retention. Runtime security tools like Falco can alert on suspicious behaviour, such as a shell opening inside a production container.
A quick self-check
- Are any secrets in Git in plain text?
- How many people have
cluster-admin? - Do any containers run as root?
- Can a pod in one namespace reach the database of another?
- When was the cluster last upgraded?
If any answer makes you uncomfortable, our DevOps team can run a security review and help you fix it step by step.