Interview Prep/DevSecOps/Kubernetes Security Posture

How do you roll out default-deny NetworkPolicies in a running production cluster?

IntermediateProductionKubernetes Security Posture
Answer
  1. Make sure the CNI enforces policies (Cilium, Calico, or VPC CNI with network policy enabled).
  2. Observe real traffic first: Cilium Hubble, VPC Flow Logs, or a mesh's telemetry.
  3. Write allow policies per app (ingress from its callers, egress to its dependencies and DNS).
  4. Apply default-deny per namespace, starting with non-critical ones:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: default-deny, namespace: payments}
spec:
  podSelector: {}
  policyTypes: [Ingress, Egress]

Always add an explicit DNS egress rule to kube-system port 53, or every app breaks. With Cilium, use L7 and FQDN policies for egress to external APIs.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security Posture