How do you roll out default-deny NetworkPolicies in a running production cluster?
IntermediateProductionKubernetes Security Posture
Answer
- Make sure the CNI enforces policies (Cilium, Calico, or VPC CNI with network policy enabled).
- Observe real traffic first: Cilium Hubble, VPC Flow Logs, or a mesh's telemetry.
- Write allow policies per app (ingress from its callers, egress to its dependencies and DNS).
- 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.
More on Kubernetes Security Posture
What is your security baseline for a new production EKS cluster?IntermediateDraw the layered security controls for workloads on Kubernetes.BeginnerHow do you assign Pod Security Admission levels across namespaces in production?BeginnerKyverno, OPA Gatekeeper or ValidatingAdmissionPolicy: how do you choose?IntermediateShow a ValidatingAdmissionPolicy that blocks containers without resource limits.AdvancedFalco or Tetragon for runtime security: how do you choose and run it?Advanced