Closed
Description
For IPv6 clusters, all IPv4 egress traffic cannot filtered with policies (and likely vice versa for IPv4 clusters with IPv6 link-local addresses).
Example (on a clean IPv6 EKS cluster):
Using this policy to deny all egress traffic (except DNS):
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-egress
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
Using this pod to test with:
apiVersion: v1
kind: Pod
metadata:
labels:
app: netshoot
name: netshoot
spec:
containers:
- name: netshoot
image: nicolaka/netshoot
command: ["/bin/bash"]
args: ["-c", "sleep inf"]
All IPv6 traffic is blocked from accessing external resources, but IPv4 is not:
$ kubectl exec -it netshoot -- curl --max-time 3 -I -v example.com
* Trying [2606:2800:220:1:248:1893:25c8:1946]:80...
* Trying 93.184.216.34:80...
* Connected to example.com (93.184.216.34) port 80 (#0)
> HEAD / HTTP/1.1
> Host: example.com
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Age: 192079
Age: 192079
< Cache-Control: max-age=604800
Cache-Control: max-age=604800
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Date: Fri, 08 Sep 2023 15:18:21 GMT
Date: Fri, 08 Sep 2023 15:18:21 GMT
< Etag: "3147526947"
Etag: "3147526947"
< Expires: Fri, 15 Sep 2023 15:18:21 GMT
Expires: Fri, 15 Sep 2023 15:18:21 GMT
< Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
< Server: ECS (nyb/1D06)
Server: ECS (nyb/1D06)
< X-Cache: HIT
X-Cache: HIT
< Content-Length: 1256
Content-Length: 1256
<
* Connection #0 to host example.com left intact
Metadata
Metadata
Assignees
Labels
No labels