How do you control which external domains pods can reach?
AdvancedScenarioKubernetes Security
Answer
Situation read → Standard NetworkPolicy works on IPs, not domains. Egress control by domain needs more tooling.
What I'd do →
- Cilium
CiliumNetworkPolicywithtoFQDNsrules (for examplematchName: api.stripe.com) plus DNS visibility. - Or an egress gateway or proxy (Istio egress gateway, Squid) that pods must use, with an allowlist.
- At the VPC level, AWS Network Firewall domain lists or a NAT with filtering.
- Start in log-only mode to build the allowlist from real traffic.
Why → Egress control blocks data exfiltration and command-and-control callbacks.
Interview tip → Say you learn real traffic first, then enforce, to avoid breaking apps.
More on Kubernetes Security
What are the 4Cs of cloud native security?BeginnerWhat happens to a request between `kubectl apply` and etcd from a security point of view?IntermediateExplain Role, ClusterRole, RoleBinding and ClusterRoleBinding.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?Intermediate