Explain Kubernetes network policies and how you would isolate a production namespace.
By default, all pods in a Kubernetes cluster can communicate with each other freely. NetworkPolicies are namespace-scoped firewall rules that control which pods can talk to which.
To enforce full isolation on a namespace, start by denying all ingress and egress, then selectively allow only what’s needed:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
namespace: production
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
Then add specific allow rules for your database, monitoring agents, and DNS (port 53).