Network isolation must allow required communication
Pod isolation
NetworkPolicy selects Pods and defines allowed incoming traffic, ingress, or outgoing traffic, egress. Permissions from applicable policies are combined. For an isolated direction, traffic must be allowed by at least one policy. This lesson uses one ingress policy.
The role of CNI
The presence of an API object does not prove that traffic is filtered. The network plugin must support NetworkPolicy. The model’s toggle represents this condition but does not install or configure a real CNI.
Keep the application accessible
Of 1000 requests, 800 are required by the application and 200 come from an unrelated namespace. Denying all traffic successfully isolates the Pods but breaks the service. Allow the required source and check legitimate and unrelated requests separately. A namespace defines a logical scope for cluster resources.
Networking and API permissions
NetworkPolicy restricts network traffic. Application user authentication and RBAC permissions for the Kubernetes API are configured separately. An application uses a ServiceAccount with minimal permissions to call that API. When restricting egress, also allow required dependencies, including DNS.
Task
1000 requests/s: 800 from the allowed application and 200 from an unrelated namespace. Restrict ingress to Pods while preserving useful traffic.
80% of ingress comes from an allowed source, 20% from an unrelated one. In the model, one ingress policy selects all application Pods. With a supporting CNI, it isolates the Pods and allows the specified namespace. Without CNI support, the object does not change access. Egress, DNS, RBAC, and authentication are not modeled.
- Add a policy supported by the CNI.
- Allow the application’s namespace.
- Verify legitimate traffic and the absence of unrelated access.