
Testing Connectivity in the QA Namespace
Start by verifying that permitted connections in the “qa-test” namespace work correctly. First, list all services across namespaces:Investigating and Refining QA Namespace Policies
Examine the network policies in the “qa-test” namespace:Controlling API-to-Frontend Traffic
The “frontend-api-np” network policy is designed to permit only frontend pods to connect to API pods. Below is its YAML configuration:Troubleshooting the Staging Namespace
In the staging namespace, both frontend and API pods are unable to connect as required. Additionally, pods from the QA namespace are mistakenly able to access the staging database if they use the unqualified service name (e.g., “db-svc” resolves within the QA namespace). To avoid this, the fully qualified domain name (FQDN) must be used. First, list the network policies in the staging namespace:Recap
Key takeaways from this troubleshooting exercise include:| Topic | Explanation | Example Configuration |
|---|---|---|
| AND vs OR in Network Policies | Using a single ingress rule with combined selectors applies an AND condition. Separating the selectors into multiple rules applies an OR condition. | Combined rule: See YAML snippet under “Investigating and Refining QA Namespace Policies” |
| Network Policies are Additive | Specific allow rules can override default-deny policies. When creating a default deny for ingress or egress, ensure the desired allow rules are still in place. | Default-deny policy YAML snippet above |
| Default Behavior | Without explicit deny rules, Kubernetes allows traffic by default. Enforcing explicit default-deny policies helps secure your network traffic. | Example default-deny policy |
