quartz/content/Traffic to and from all pods in the same namespace.md
2024-03-30 08:10:09 +01:00

32 lines
713 B
Markdown

```yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: my-app-network-policy
namespace: default
spec:
podSelector: {} # select all pods in the same namespace
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector: {}
egress:
- to:
- podSelector: {}
```
If no other policies are applied, this is the only allowed traffic. Therefore, this policy will deny all other traffic.
We are targeting all pods within the same namespace with the first podSelector.
Then, under the from and to elements, we are only allowing pods in the same namespace because we use the podselctor for all pods
## Links:
**part of**:: [[Network Policies]]
[[CKS]]
202403251057