Interview Prep/DevSecOps/Kubernetes Security

A pentest shows any pod can reach any other pod, including the database. What do you implement?

BeginnerScenarioKubernetes Security
Answer

Situation read → Kubernetes networking is flat by default. NetworkPolicies need a CNI that enforces them (Calico, Cilium, or VPC CNI with network policy enabled).

What I'd do →

  1. Confirm enforcement support in the CNI.
  2. Apply default deny in each namespace:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: default-deny, namespace: orders }
spec:
  podSelector: {}
  policyTypes: [Ingress, Egress]
  1. Add allow rules: ingress controller to frontend, frontend to API, API to DB on 5432, and DNS egress to kube-dns on 53.
  2. Test with a temporary pod and nc -zv.

Why → Default deny turns lateral movement from trivial into hard.

Interview tip → Forgetting DNS egress is the classic mistake; mention it.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security