kubernetes-network-policy-recipes
kubernetes-network-policy-recipes copied to clipboard
example for - allow egress only to public addresses
proposal to add an example for "allow egress only to public addresses".
In our use case, where we execute some user-configured rest calls, the service running those should not have access to internal Kubernetes endpoints. Took me a while of searching to end up with this policy, given that I'm not that knowledgeable about this topic. I think we can spare other people that, by including this as an example here (since this repo is linked in the official docs) And maybe someone notices a flaw in this.
spec:
podSelector: {}
policyTypes:
- Egress
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
Allows...
- DNS resolve requests
- All IPs except the IP ranges defined as private