How do you implement network segmentation for a microservices application?
Network segmentation limits the blast radius of a compromise. In a microservices context:
- AWS: Security Groups + VPC design: Place services in private subnets. Use security groups to only allow traffic between services that need to communicate (e.g., allow port 5432 only from the API service to the database SG).
- Kubernetes: NetworkPolicies: Default-deny all inter-pod traffic. Explicitly allow only required paths.
- Service Mesh (Istio/Linkerd): Mutual TLS (mTLS) between all services — all communication is encrypted and authenticated at the network level. Zero-trust networking.