← All insightsSecurity

Securing Kubernetes: least privilege and safe defaults

CodeWizard Engineering · 10 September 2026 · 3 min read · Advanced

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.

yaml
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.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult