Security with Kubernetes is mostly correct, boring defaults applied consistently. Here is the short list that removes most of the risk.
Safe defaults
- Enforce least privilege with RBAC and disable the default ServiceAccount token mount
- Apply NetworkPolicies to default-deny east-west traffic
- Run Pod Security Admission in 'restricted' mode and scan workloads with Trivy
Wire it into the pipeline
Set the new image and wait for the rollout inside a pipeline.
deploy:
stage: deploy
script:
- kubectl set image deploy/web web=ghcr.io/acme/web:$CI_COMMIT_SHA
- kubectl rollout status deploy/web --timeout=120s
rules:
- if: '$CI_COMMIT_BRANCH == "main"'Reinforcing habits
- Set requests/limits and use the HorizontalPodAutoscaler for elastic workloads
- Separate config (ConfigMap) from secrets and mount them, don't bake them in
- Use readiness probes to gate traffic and PodDisruptionBudgets for safe drains
Want senior help putting Kubernetes to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.