Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pod can't access clusterip service for another pod with endpoint on the same node #1702

Closed
oe-hbk opened this issue Jan 3, 2023 · 40 comments

Comments

@oe-hbk
Copy link

oe-hbk commented Jan 3, 2023

With latest flannel 0.20.2 using vxlan (with and without DirectRouting enabled) and firewalld disabled on identical nodes with latest CentOS 7.
When node1 is running pod1 and pod2, and there is a clusterip service around pod2, pod1 cannot route traffic to the clusterip, but it can route to the pod2 ip.

If pod2 moves to node2, and pod1 remains on node1, pod1 is now able to route traffic to both pod2 ip and the clusterip.

Expected Behavior

Expect traffic flow from pod to clusterip when clusterip's endpoint hits a pod on the same node as original pod.

Current Behavior

Traffic from pod1 does not properly flow to pod2 when pod2 is an endpoint for a clusterip service and pod1 tries to communicate to this clusterip. This is only broken if pod1 and pod2 are on the same node. Pod1 is able to contact pod2 directly by pod2's IP.

Possible Solution

Steps to Reproduce (for bugs)

  1. Install 3 node kubeadm cluster ( serviceSubnet: 10.233.0.0/18 , podSubnet: 10.233.64.0/18)
  2. Install flannel 0.20.2 via manifest ("Network": "10.233.64.0/18", Type,vxlan, VNI: 1, Port, 8472, DirectRouting true/or/false/doesn't matter)
  3. Create nginx pod on node1, create service around this pod. Get IP of pod and service
  4. Create busybox pod (named samenode-pod) on node1, with command: ["sleep", "3600"]
  5. Create busybox pod (named othernode-pod) on node2, with command: ["sleep", "3600"]
  6. kubectl exec -it othernode-pod -- wget -O - pod_ip_of_nginx
  7. kubectl exec -it othernode-pod -- wget -O - service_ip_of_nginx < this will work>
  8. kubectl exec -it samenode-pod -- wget -O - pod_ip_of_nginx < this will work>
  9. kubectl exec -it samenode-pod -- wget -O - service_ip_of_nginx < this will NOT work>

Context

Your Environment

  • Flannel version: 0.20.2
  • Backend used (e.g. vxlan or udp): vxlan
  • Etcd version: 3.5.5-0
  • Kubernetes version (if used): 1.24.8
  • Operating System and version: CentOS 7.9 (kernel 3.10.0-1160.80.1.el7.x86_64)
  • Link to your project (optional):
@oe-hbk
Copy link
Author

oe-hbk commented Jan 3, 2023

To reproduce, after creating a 3 node kubeadm cluster (1.24.8 in case that matters), with flannel 0.20.2

$ cat bugtest.yaml

apiVersion: v1
kind: Namespace
metadata:
  name: bugtest
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  namespace: bugtest
  labels:
    app: nginx-pod
spec:
  nodeName: node1
  containers:
  - name: nginx
    image: nginx:latest
    ports:
    - containerPort: 80
---
apiVersion: v1
kind: Pod
metadata:
  name: samenode-pod
  namespace: bugtest
  labels:
    app: samenode-pod
spec:
  nodeName: node1
  containers:
  - name: busybox
    image: busybox:latest
    command: ["sleep", "3600"]
---
apiVersion: v1
kind: Pod
metadata:
  name: othernode-pod
  namespace: bugtest
  labels:
    app: othernode-pod
spec:
  nodeName: node2
  containers:
  - name: busybox
    image: busybox:latest
    command: ["sleep", "3600"]
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: bugtest
spec:
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx-pod
  sessionAffinity: None
  type: ClusterIP
$ kubectl apply -f bugtest.yaml
namespace/bugtest created 
pod/nginx-pod created
pod/samenode-pod created
pod/othernode-pod created
service/nginx-service created
kubectl get pods,services,endpoints -n bugtest -o wide --show-labels
NAME                READY   STATUS    RESTARTS   AGE   IP              NODE    NOMINATED NODE   READINESS GATES   LABELS
pod/nginx-pod       1/1     Running   0          16m   10.233.64.103   node1    <none>           <none>            app=nginx-pod
pod/othernode-pod   1/1     Running   0          15m   10.233.65.42    node2    <none>           <none>            app=othernode-pod
pod/samenode-pod    1/1     Running   0          15m   10.233.64.104   node1    <none>           <none>            app=samenode-pod

NAME                    TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE   SELECTOR        LABELS
service/nginx-service   ClusterIP   10.233.63.155   <none>        80/TCP    15m   app=nginx-pod   <none>

NAME                      ENDPOINTS          AGE   LABELS
endpoints/nginx-service   10.233.64.103:80   15m   <none>

This works (node2 pod to podip)

$ kubectl exec -it -n bugtest othernode-pod -- wget -O - 10.233.64.103
Connecting to 10.233.64.103 (10.233.64.103:80)
writing to stdout
<!DOCTYPE html>
<html>

This works (node2 pod to clusterip)

$ kubectl exec -it -n bugtest othernode-pod -- wget -O - 10.233.63.155
Connecting to 10.233.63.155 (10.233.63.155:80)
writing to stdout
<!DOCTYPE html>
<html>

This works (node1 to podip)

$ kubectl exec -it -n bugtest samenode-pod -- wget -O - 10.233.64.103
Connecting to 10.233.64.103 (10.233.64.103:80)
writing to stdout
<!DOCTYPE html>
<html>

But this does not (node1 to clusterip). It just hangs.

$ kubectl exec -it -n bugtest samenode-pod -- wget -O - 10.233.63.155
Connecting to 10.233.63.155 (10.233.63.155:80)

@rbrtbnfgl
Copy link
Contributor

rbrtbnfgl commented Jan 4, 2023

This could be a bug maybe related to #1703 or it could be centos related I'll try your setup.

@rbrtbnfgl
Copy link
Contributor

Could you try to do iptables-save on the node where the nginx pod is running?

@oe-hbk
Copy link
Author

oe-hbk commented Jan 4, 2023

Thanks @rbrtbnfgl,

With a clean setup before the above pods/service are created.

# Generated by iptables-save v1.4.21 on Wed Jan  4 08:49:06 2023
*mangle
:PREROUTING ACCEPT [948261765:1968292282959]
:INPUT ACCEPT [840091992:1895453826471]
:FORWARD ACCEPT [108169772:72838456428]
:OUTPUT ACCEPT [695724218:2687620842519]
:POSTROUTING ACCEPT [803893946:2760459294940]
:KUBE-IPTABLES-HINT - [0:0]
:KUBE-KUBELET-CANARY - [0:0]
:KUBE-PROXY-CANARY - [0:0]
COMMIT
# Completed on Wed Jan  4 08:49:06 2023
# Generated by iptables-save v1.4.21 on Wed Jan  4 08:49:06 2023
*filter
:INPUT ACCEPT [22119:45912065]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [22108:30876563]
:FLANNEL-FWD - [0:0]
:KUBE-EXTERNAL-SERVICES - [0:0]
:KUBE-FIREWALL - [0:0]
:KUBE-FORWARD - [0:0]
:KUBE-KUBELET-CANARY - [0:0]
:KUBE-NODEPORTS - [0:0]
:KUBE-PROXY-CANARY - [0:0]
:KUBE-SERVICES - [0:0]
-A INPUT -m comment --comment "kubernetes health check service ports" -j KUBE-NODEPORTS
-A INPUT -m conntrack --ctstate NEW -m comment --comment "kubernetes externally-visible service portals" -j KUBE-EXTERNAL-SERVICES
-A INPUT -j KUBE-FIREWALL
-A FORWARD -m comment --comment "flanneld forward" -j FLANNEL-FWD
-A FORWARD -m comment --comment "kubernetes forwarding rules" -j KUBE-FORWARD
-A FORWARD -m conntrack --ctstate NEW -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A FORWARD -m conntrack --ctstate NEW -m comment --comment "kubernetes externally-visible service portals" -j KUBE-EXTERNAL-SERVICES
-A OUTPUT -m conntrack --ctstate NEW -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A OUTPUT -j KUBE-FIREWALL
-A FLANNEL-FWD -s 10.233.64.0/18 -m comment --comment "flanneld forward" -j ACCEPT
-A FLANNEL-FWD -d 10.233.64.0/18 -m comment --comment "flanneld forward" -j ACCEPT
-A KUBE-FIREWALL -m comment --comment "kubernetes firewall for dropping marked packets" -m mark --mark 0x8000/0x8000 -j DROP
-A KUBE-FIREWALL ! -s 127.0.0.0/8 -d 127.0.0.0/8 -m comment --comment "block incoming localnet connections" -m conntrack ! --ctstate RELATED,ESTABLISHED,DNAT -j DROP
-A KUBE-FORWARD -m conntrack --ctstate INVALID -j DROP
-A KUBE-FORWARD -m comment --comment "kubernetes forwarding rules" -m mark --mark 0x4000/0x4000 -j ACCEPT
-A KUBE-FORWARD -m comment --comment "kubernetes forwarding conntrack rule" -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Wed Jan  4 08:49:06 2023
# Generated by iptables-save v1.4.21 on Wed Jan  4 08:49:06 2023
*nat
:PREROUTING ACCEPT [22:1300]
:INPUT ACCEPT [22:1300]
:OUTPUT ACCEPT [364:28482]
:POSTROUTING ACCEPT [364:28482]
:CNI-DN-bf882a7c6b6d62bc1131a - [0:0]
:CNI-HOSTPORT-DNAT - [0:0]
:CNI-HOSTPORT-MASQ - [0:0]
:CNI-HOSTPORT-SETMARK - [0:0]
:FLANNEL-POSTRTG - [0:0]
:KUBE-KUBELET-CANARY - [0:0]
:KUBE-MARK-DROP - [0:0]
:KUBE-MARK-MASQ - [0:0]
:KUBE-NODEPORTS - [0:0]
:KUBE-POSTROUTING - [0:0]
:KUBE-PROXY-CANARY - [0:0]
:KUBE-SEP-2CGKZLTJ3FLW3FSU - [0:0]
:KUBE-SEP-47DFFSOXHPCJZCQX - [0:0]
:KUBE-SEP-4AFLHXUZERIRGFQ5 - [0:0]
:KUBE-SEP-4M6LEU24GIGGAHXT - [0:0]
:KUBE-SEP-5AJZOHQUMTI3L7PQ - [0:0]
:KUBE-SEP-7CJOWH5QVJ5VSNDT - [0:0]
:KUBE-SEP-AWEBZGUO5K4R67AN - [0:0]
:KUBE-SEP-BSEE6OPNLZSR4VQA - [0:0]
:KUBE-SEP-DFYUFVNLE3RYJESR - [0:0]
:KUBE-SEP-E4BCXHIBYCGLIWKZ - [0:0]
:KUBE-SEP-EK3Z7KR3JJPQNZPM - [0:0]
:KUBE-SEP-EO2UPE7MX2YEKJSE - [0:0]
:KUBE-SEP-GO53PN4PHNUZXEHS - [0:0]
:KUBE-SEP-HJRMCMEBH7MIF5C4 - [0:0]
:KUBE-SEP-HTZLFWWCDJFZJFG5 - [0:0]
:KUBE-SEP-LGIAERUE4BLI6LZK - [0:0]
:KUBE-SEP-Q3SAJ7UTJWHTZ3D4 - [0:0]
:KUBE-SEP-Q63REDBBL4J65CU6 - [0:0]
:KUBE-SEP-RITVHJDUYJCR2JY7 - [0:0]
:KUBE-SEP-UVUPKPN3MFOEKGFB - [0:0]
:KUBE-SEP-V6AKX6JIXITU6DRY - [0:0]
:KUBE-SEP-VYHL4Z7L73QGQ6X2 - [0:0]
:KUBE-SEP-WGW3XGAKK54B56HJ - [0:0]
:KUBE-SEP-Y2P4PTKOTRZBDDBR - [0:0]
:KUBE-SEP-YB4HHCFFBWW42YR3 - [0:0]
:KUBE-SEP-ZJHHB4UIZEYDBUZZ - [0:0]
:KUBE-SERVICES - [0:0]
:KUBE-SVC-5UPLZIDSZ45WUZX3 - [0:0]
:KUBE-SVC-BMJHC2PLFK2DBPFL - [0:0]
:KUBE-SVC-BOJCKSINR77JVVPB - [0:0]
:KUBE-SVC-CG5I4G2RS3ZVWGLK - [0:0]
:KUBE-SVC-DKVZ4CBQHUTBLZJ6 - [0:0]
:KUBE-SVC-EDNDUDH2C75GIR6O - [0:0]
:KUBE-SVC-ERIFXISQEP7F7OF4 - [0:0]
:KUBE-SVC-ES6IOJC4EK5DV77J - [0:0]
:KUBE-SVC-EZYNCFY2F7N6OQA2 - [0:0]
:KUBE-SVC-JD5MR3NA4I4DYORP - [0:0]
:KUBE-SVC-JTNE6R4VUKUHTUHZ - [0:0]
:KUBE-SVC-NPX46M4PTMTKRN6Y - [0:0]
:KUBE-SVC-TCOU7JCQXEZGVUNU - [0:0]
:KUBE-SVC-VOOBF6UTRBMKQJOO - [0:0]
-A PREROUTING -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A PREROUTING -m addrtype --dst-type LOCAL -j CNI-HOSTPORT-DNAT
-A OUTPUT -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A OUTPUT -m addrtype --dst-type LOCAL -j CNI-HOSTPORT-DNAT
-A POSTROUTING -m comment --comment "flanneld masq" -j FLANNEL-POSTRTG
-A POSTROUTING -m comment --comment "CNI portfwd requiring masquerade" -j CNI-HOSTPORT-MASQ
-A POSTROUTING -m comment --comment "kubernetes postrouting rules" -j KUBE-POSTROUTING
-A CNI-DN-bf882a7c6b6d62bc1131a -s 10.233.64.0/24 -p tcp -m tcp --dport 80 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-bf882a7c6b6d62bc1131a -s 127.0.0.1/32 -p tcp -m tcp --dport 80 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-bf882a7c6b6d62bc1131a -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.233.64.93:80
-A CNI-DN-bf882a7c6b6d62bc1131a -s 10.233.64.0/24 -p tcp -m tcp --dport 443 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-bf882a7c6b6d62bc1131a -s 127.0.0.1/32 -p tcp -m tcp --dport 443 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-bf882a7c6b6d62bc1131a -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.233.64.93:443
-A CNI-HOSTPORT-DNAT -p tcp -m comment --comment "dnat name: \"cbr0\" id: \"be884d182a6ed5c10e7a6a8b60cb52c2bf230306ddd6767ac67b9e6e87fe4686\"" -m multiport --dports 80,443 -j CNI-DN-bf882a7c6b6d62bc1131a
-A CNI-HOSTPORT-MASQ -m mark --mark 0x2000/0x2000 -j MASQUERADE
-A CNI-HOSTPORT-SETMARK -m comment --comment "CNI portfwd masquerade mark" -j MARK --set-xmark 0x2000/0x2000
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -j RETURN
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE
-A KUBE-MARK-DROP -j MARK --set-xmark 0x8000/0x8000
-A KUBE-MARK-MASQ -j MARK --set-xmark 0x4000/0x4000
-A KUBE-POSTROUTING -m mark ! --mark 0x4000/0x4000 -j RETURN
-A KUBE-POSTROUTING -j MARK --set-xmark 0x4000/0x0
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -j MASQUERADE
-A KUBE-SEP-2CGKZLTJ3FLW3FSU -s 10.233.66.58/32 -m comment --comment "cattle-system/rancher-webhook:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-2CGKZLTJ3FLW3FSU -p tcp -m comment --comment "cattle-system/rancher-webhook:https" -m tcp -j DNAT --to-destination 10.233.66.58:9443
-A KUBE-SEP-47DFFSOXHPCJZCQX -s 10.233.65.48/32 -m comment --comment "kube-system/kube-dns:metrics" -j KUBE-MARK-MASQ
-A KUBE-SEP-47DFFSOXHPCJZCQX -p tcp -m comment --comment "kube-system/kube-dns:metrics" -m tcp -j DNAT --to-destination 10.233.65.48:9153
-A KUBE-SEP-4AFLHXUZERIRGFQ5 -s 10.233.64.93/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -j KUBE-MARK-MASQ
-A KUBE-SEP-4AFLHXUZERIRGFQ5 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -m tcp -j DNAT --to-destination 10.233.64.93:8443
-A KUBE-SEP-4M6LEU24GIGGAHXT -s 10.105.10.145/32 -m comment --comment "default/kubernetes:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-4M6LEU24GIGGAHXT -p tcp -m comment --comment "default/kubernetes:https" -m tcp -j DNAT --to-destination 10.105.10.145:6443
-A KUBE-SEP-5AJZOHQUMTI3L7PQ -s 10.233.66.56/32 -m comment --comment "cattle-system/rancher:https-internal" -j KUBE-MARK-MASQ
-A KUBE-SEP-5AJZOHQUMTI3L7PQ -p tcp -m comment --comment "cattle-system/rancher:https-internal" -m tcp -j DNAT --to-destination 10.233.66.56:444
-A KUBE-SEP-7CJOWH5QVJ5VSNDT -s 10.233.65.35/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -j KUBE-MARK-MASQ
-A KUBE-SEP-7CJOWH5QVJ5VSNDT -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -m tcp -j DNAT --to-destination 10.233.65.35:10254
-A KUBE-SEP-AWEBZGUO5K4R67AN -s 10.233.66.50/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-AWEBZGUO5K4R67AN -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -m tcp -j DNAT --to-destination 10.233.66.50:80
-A KUBE-SEP-BSEE6OPNLZSR4VQA -s 10.233.66.56/32 -m comment --comment "cattle-system/rancher:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-BSEE6OPNLZSR4VQA -p tcp -m comment --comment "cattle-system/rancher:http" -m tcp -j DNAT --to-destination 10.233.66.56:80
-A KUBE-SEP-DFYUFVNLE3RYJESR -s 10.233.65.48/32 -m comment --comment "kube-system/kube-dns:dns" -j KUBE-MARK-MASQ
-A KUBE-SEP-DFYUFVNLE3RYJESR -p udp -m comment --comment "kube-system/kube-dns:dns" -m udp -j DNAT --to-destination 10.233.65.48:53
-A KUBE-SEP-E4BCXHIBYCGLIWKZ -s 10.122.88.50/32 -m comment --comment "default/kubernetes:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-E4BCXHIBYCGLIWKZ -p tcp -m comment --comment "default/kubernetes:https" -m tcp -j DNAT --to-destination 10.122.88.50:6443
-A KUBE-SEP-EK3Z7KR3JJPQNZPM -s 10.233.65.35/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-EK3Z7KR3JJPQNZPM -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -m tcp -j DNAT --to-destination 10.233.65.35:443
-A KUBE-SEP-EO2UPE7MX2YEKJSE -s 10.233.66.58/32 -m comment --comment "cattle-system/webhook-service:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-EO2UPE7MX2YEKJSE -p tcp -m comment --comment "cattle-system/webhook-service:https" -m tcp -j DNAT --to-destination 10.233.66.58:8777
-A KUBE-SEP-GO53PN4PHNUZXEHS -s 10.233.66.49/32 -m comment --comment "cattle-fleet-system/gitjob:http-80" -j KUBE-MARK-MASQ
-A KUBE-SEP-GO53PN4PHNUZXEHS -p tcp -m comment --comment "cattle-fleet-system/gitjob:http-80" -m tcp -j DNAT --to-destination 10.233.66.49:8080
-A KUBE-SEP-HJRMCMEBH7MIF5C4 -s 10.233.66.50/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -j KUBE-MARK-MASQ
-A KUBE-SEP-HJRMCMEBH7MIF5C4 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -m tcp -j DNAT --to-destination 10.233.66.50:10254
-A KUBE-SEP-HTZLFWWCDJFZJFG5 -s 10.233.64.93/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-HTZLFWWCDJFZJFG5 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -m tcp -j DNAT --to-destination 10.233.64.93:443
-A KUBE-SEP-LGIAERUE4BLI6LZK -s 10.233.65.35/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-LGIAERUE4BLI6LZK -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -m tcp -j DNAT --to-destination 10.233.65.35:80
-A KUBE-SEP-Q3SAJ7UTJWHTZ3D4 -s 10.233.65.46/32 -m comment --comment "kube-system/sealed-secrets-controller" -j KUBE-MARK-MASQ
-A KUBE-SEP-Q3SAJ7UTJWHTZ3D4 -p tcp -m comment --comment "kube-system/sealed-secrets-controller" -m tcp -j DNAT --to-destination 10.233.65.46:8080
-A KUBE-SEP-Q63REDBBL4J65CU6 -s 10.233.66.50/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-Q63REDBBL4J65CU6 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -m tcp -j DNAT --to-destination 10.233.66.50:443
-A KUBE-SEP-RITVHJDUYJCR2JY7 -s 10.233.64.93/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -j KUBE-MARK-MASQ
-A KUBE-SEP-RITVHJDUYJCR2JY7 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -m tcp -j DNAT --to-destination 10.233.64.93:10254
-A KUBE-SEP-UVUPKPN3MFOEKGFB -s 10.233.65.35/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -j KUBE-MARK-MASQ
-A KUBE-SEP-UVUPKPN3MFOEKGFB -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -m tcp -j DNAT --to-destination 10.233.65.35:8443
-A KUBE-SEP-V6AKX6JIXITU6DRY -s 10.233.65.48/32 -m comment --comment "kube-system/kube-dns:dns-tcp" -j KUBE-MARK-MASQ
-A KUBE-SEP-V6AKX6JIXITU6DRY -p tcp -m comment --comment "kube-system/kube-dns:dns-tcp" -m tcp -j DNAT --to-destination 10.233.65.48:53
-A KUBE-SEP-VYHL4Z7L73QGQ6X2 -s 10.233.64.93/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-VYHL4Z7L73QGQ6X2 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -m tcp -j DNAT --to-destination 10.233.64.93:80
-A KUBE-SEP-WGW3XGAKK54B56HJ -s 10.233.65.43/32 -m comment --comment "cattle-system/rancher:https-internal" -j KUBE-MARK-MASQ
-A KUBE-SEP-WGW3XGAKK54B56HJ -p tcp -m comment --comment "cattle-system/rancher:https-internal" -m tcp -j DNAT --to-destination 10.233.65.43:444
-A KUBE-SEP-Y2P4PTKOTRZBDDBR -s 10.233.65.43/32 -m comment --comment "cattle-system/rancher:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-Y2P4PTKOTRZBDDBR -p tcp -m comment --comment "cattle-system/rancher:http" -m tcp -j DNAT --to-destination 10.233.65.43:80
-A KUBE-SEP-YB4HHCFFBWW42YR3 -s 10.132.70.246/32 -m comment --comment "default/kubernetes:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-YB4HHCFFBWW42YR3 -p tcp -m comment --comment "default/kubernetes:https" -m tcp -j DNAT --to-destination 10.132.70.246:6443
-A KUBE-SEP-ZJHHB4UIZEYDBUZZ -s 10.233.66.50/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -j KUBE-MARK-MASQ
-A KUBE-SEP-ZJHHB4UIZEYDBUZZ -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -m tcp -j DNAT --to-destination 10.233.66.50:8443
-A KUBE-SERVICES -d 10.233.13.83/32 -p tcp -m comment --comment "cattle-system/rancher-webhook:https cluster IP" -m tcp --dport 443 -j KUBE-SVC-BOJCKSINR77JVVPB
-A KUBE-SERVICES -d 10.233.0.1/32 -p tcp -m comment --comment "default/kubernetes:https cluster IP" -m tcp --dport 443 -j KUBE-SVC-NPX46M4PTMTKRN6Y
-A KUBE-SERVICES -d 10.233.62.33/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http cluster IP" -m tcp --dport 80 -j KUBE-SVC-CG5I4G2RS3ZVWGLK
-A KUBE-SERVICES -d 10.233.62.98/32 -p tcp -m comment --comment "cattle-fleet-system/gitjob:http-80 cluster IP" -m tcp --dport 80 -j KUBE-SVC-5UPLZIDSZ45WUZX3
-A KUBE-SERVICES -d 10.233.0.10/32 -p tcp -m comment --comment "kube-system/kube-dns:dns-tcp cluster IP" -m tcp --dport 53 -j KUBE-SVC-ERIFXISQEP7F7OF4
-A KUBE-SERVICES -d 10.233.27.16/32 -p tcp -m comment --comment "cattle-system/rancher:https-internal cluster IP" -m tcp --dport 443 -j KUBE-SVC-BMJHC2PLFK2DBPFL
-A KUBE-SERVICES -d 10.233.39.60/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics cluster IP" -m tcp --dport 10254 -j KUBE-SVC-VOOBF6UTRBMKQJOO
-A KUBE-SERVICES -d 10.233.62.33/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https cluster IP" -m tcp --dport 443 -j KUBE-SVC-EDNDUDH2C75GIR6O
-A KUBE-SERVICES -d 10.233.49.128/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook cluster IP" -m tcp --dport 443 -j KUBE-SVC-EZYNCFY2F7N6OQA2
-A KUBE-SERVICES -d 10.233.0.10/32 -p tcp -m comment --comment "kube-system/kube-dns:metrics cluster IP" -m tcp --dport 9153 -j KUBE-SVC-JD5MR3NA4I4DYORP
-A KUBE-SERVICES -d 10.233.26.49/32 -p tcp -m comment --comment "cattle-system/webhook-service:https cluster IP" -m tcp --dport 443 -j KUBE-SVC-DKVZ4CBQHUTBLZJ6
-A KUBE-SERVICES -d 10.233.27.16/32 -p tcp -m comment --comment "cattle-system/rancher:http cluster IP" -m tcp --dport 80 -j KUBE-SVC-ES6IOJC4EK5DV77J
-A KUBE-SERVICES -d 10.233.4.158/32 -p tcp -m comment --comment "kube-system/sealed-secrets-controller cluster IP" -m tcp --dport 8080 -j KUBE-SVC-JTNE6R4VUKUHTUHZ
-A KUBE-SERVICES -d 10.233.0.10/32 -p udp -m comment --comment "kube-system/kube-dns:dns cluster IP" -m udp --dport 53 -j KUBE-SVC-TCOU7JCQXEZGVUNU
-A KUBE-SERVICES -m comment --comment "kubernetes service nodeports; NOTE: this must be the last rule in this chain" -m addrtype --dst-type LOCAL -j KUBE-NODEPORTS
-A KUBE-SVC-5UPLZIDSZ45WUZX3 ! -s 10.233.64.0/18 -d 10.233.62.98/32 -p tcp -m comment --comment "cattle-fleet-system/gitjob:http-80 cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SVC-5UPLZIDSZ45WUZX3 -m comment --comment "cattle-fleet-system/gitjob:http-80 -> 10.233.66.49:8080" -j KUBE-SEP-GO53PN4PHNUZXEHS
-A KUBE-SVC-BMJHC2PLFK2DBPFL ! -s 10.233.64.0/18 -d 10.233.27.16/32 -p tcp -m comment --comment "cattle-system/rancher:https-internal cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-BMJHC2PLFK2DBPFL -m comment --comment "cattle-system/rancher:https-internal -> 10.233.65.43:444" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-WGW3XGAKK54B56HJ
-A KUBE-SVC-BMJHC2PLFK2DBPFL -m comment --comment "cattle-system/rancher:https-internal -> 10.233.66.56:444" -j KUBE-SEP-5AJZOHQUMTI3L7PQ
-A KUBE-SVC-BOJCKSINR77JVVPB ! -s 10.233.64.0/18 -d 10.233.13.83/32 -p tcp -m comment --comment "cattle-system/rancher-webhook:https cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-BOJCKSINR77JVVPB -m comment --comment "cattle-system/rancher-webhook:https -> 10.233.66.58:9443" -j KUBE-SEP-2CGKZLTJ3FLW3FSU
-A KUBE-SVC-CG5I4G2RS3ZVWGLK ! -s 10.233.64.0/18 -d 10.233.62.33/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SVC-CG5I4G2RS3ZVWGLK -m comment --comment "ingress-nginx/ingress-nginx-controller:http -> 10.233.64.93:80" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-VYHL4Z7L73QGQ6X2
-A KUBE-SVC-CG5I4G2RS3ZVWGLK -m comment --comment "ingress-nginx/ingress-nginx-controller:http -> 10.233.65.35:80" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-LGIAERUE4BLI6LZK
-A KUBE-SVC-CG5I4G2RS3ZVWGLK -m comment --comment "ingress-nginx/ingress-nginx-controller:http -> 10.233.66.50:80" -j KUBE-SEP-AWEBZGUO5K4R67AN
-A KUBE-SVC-DKVZ4CBQHUTBLZJ6 ! -s 10.233.64.0/18 -d 10.233.26.49/32 -p tcp -m comment --comment "cattle-system/webhook-service:https cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-DKVZ4CBQHUTBLZJ6 -m comment --comment "cattle-system/webhook-service:https -> 10.233.66.58:8777" -j KUBE-SEP-EO2UPE7MX2YEKJSE
-A KUBE-SVC-EDNDUDH2C75GIR6O ! -s 10.233.64.0/18 -d 10.233.62.33/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-EDNDUDH2C75GIR6O -m comment --comment "ingress-nginx/ingress-nginx-controller:https -> 10.233.64.93:443" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-HTZLFWWCDJFZJFG5
-A KUBE-SVC-EDNDUDH2C75GIR6O -m comment --comment "ingress-nginx/ingress-nginx-controller:https -> 10.233.65.35:443" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-EK3Z7KR3JJPQNZPM
-A KUBE-SVC-EDNDUDH2C75GIR6O -m comment --comment "ingress-nginx/ingress-nginx-controller:https -> 10.233.66.50:443" -j KUBE-SEP-Q63REDBBL4J65CU6
-A KUBE-SVC-ERIFXISQEP7F7OF4 ! -s 10.233.64.0/18 -d 10.233.0.10/32 -p tcp -m comment --comment "kube-system/kube-dns:dns-tcp cluster IP" -m tcp --dport 53 -j KUBE-MARK-MASQ
-A KUBE-SVC-ERIFXISQEP7F7OF4 -m comment --comment "kube-system/kube-dns:dns-tcp -> 10.233.65.48:53" -j KUBE-SEP-V6AKX6JIXITU6DRY
-A KUBE-SVC-ES6IOJC4EK5DV77J ! -s 10.233.64.0/18 -d 10.233.27.16/32 -p tcp -m comment --comment "cattle-system/rancher:http cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SVC-ES6IOJC4EK5DV77J -m comment --comment "cattle-system/rancher:http -> 10.233.65.43:80" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-Y2P4PTKOTRZBDDBR
-A KUBE-SVC-ES6IOJC4EK5DV77J -m comment --comment "cattle-system/rancher:http -> 10.233.66.56:80" -j KUBE-SEP-BSEE6OPNLZSR4VQA
-A KUBE-SVC-EZYNCFY2F7N6OQA2 ! -s 10.233.64.0/18 -d 10.233.49.128/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-EZYNCFY2F7N6OQA2 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook -> 10.233.64.93:8443" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-4AFLHXUZERIRGFQ5
-A KUBE-SVC-EZYNCFY2F7N6OQA2 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook -> 10.233.65.35:8443" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-UVUPKPN3MFOEKGFB
-A KUBE-SVC-EZYNCFY2F7N6OQA2 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook -> 10.233.66.50:8443" -j KUBE-SEP-ZJHHB4UIZEYDBUZZ
-A KUBE-SVC-JD5MR3NA4I4DYORP ! -s 10.233.64.0/18 -d 10.233.0.10/32 -p tcp -m comment --comment "kube-system/kube-dns:metrics cluster IP" -m tcp --dport 9153 -j KUBE-MARK-MASQ
-A KUBE-SVC-JD5MR3NA4I4DYORP -m comment --comment "kube-system/kube-dns:metrics -> 10.233.65.48:9153" -j KUBE-SEP-47DFFSOXHPCJZCQX
-A KUBE-SVC-JTNE6R4VUKUHTUHZ ! -s 10.233.64.0/18 -d 10.233.4.158/32 -p tcp -m comment --comment "kube-system/sealed-secrets-controller cluster IP" -m tcp --dport 8080 -j KUBE-MARK-MASQ
-A KUBE-SVC-JTNE6R4VUKUHTUHZ -m comment --comment "kube-system/sealed-secrets-controller -> 10.233.65.46:8080" -j KUBE-SEP-Q3SAJ7UTJWHTZ3D4
-A KUBE-SVC-NPX46M4PTMTKRN6Y ! -s 10.233.64.0/18 -d 10.233.0.1/32 -p tcp -m comment --comment "default/kubernetes:https cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-NPX46M4PTMTKRN6Y -m comment --comment "default/kubernetes:https -> 10.105.10.145:6443" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-4M6LEU24GIGGAHXT
-A KUBE-SVC-NPX46M4PTMTKRN6Y -m comment --comment "default/kubernetes:https -> 10.122.88.50:6443" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-E4BCXHIBYCGLIWKZ
-A KUBE-SVC-NPX46M4PTMTKRN6Y -m comment --comment "default/kubernetes:https -> 10.132.70.246:6443" -j KUBE-SEP-YB4HHCFFBWW42YR3
-A KUBE-SVC-TCOU7JCQXEZGVUNU ! -s 10.233.64.0/18 -d 10.233.0.10/32 -p udp -m comment --comment "kube-system/kube-dns:dns cluster IP" -m udp --dport 53 -j KUBE-MARK-MASQ
-A KUBE-SVC-TCOU7JCQXEZGVUNU -m comment --comment "kube-system/kube-dns:dns -> 10.233.65.48:53" -j KUBE-SEP-DFYUFVNLE3RYJESR
-A KUBE-SVC-VOOBF6UTRBMKQJOO ! -s 10.233.64.0/18 -d 10.233.39.60/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics cluster IP" -m tcp --dport 10254 -j KUBE-MARK-MASQ
-A KUBE-SVC-VOOBF6UTRBMKQJOO -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics -> 10.233.64.93:10254" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-RITVHJDUYJCR2JY7
-A KUBE-SVC-VOOBF6UTRBMKQJOO -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics -> 10.233.65.35:10254" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-7CJOWH5QVJ5VSNDT
-A KUBE-SVC-VOOBF6UTRBMKQJOO -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics -> 10.233.66.50:10254" -j KUBE-SEP-HJRMCMEBH7MIF5C4
COMMIT
# Completed on Wed Jan  4 08:49:06 2023

Then creating the pods/service as per my steps:

kubectl get pods,services,endpoints -n bugtest -o wide --show-labels
NAME                READY   STATUS    RESTARTS   AGE     IP              NODE    NOMINATED NODE   READINESS GATES   LABELS
pod/nginx-pod       1/1     Running   0          2m18s   10.233.64.112   node1    <none>           <none>            app=nginx-pod
pod/othernode-pod   1/1     Running   0          2m18s   10.233.65.49    node2    <none>           <none>            app=othernode-pod
pod/samenode-pod    1/1     Running   0          2m18s   10.233.64.111   node1    <none>           <none>            app=samenode-pod

NAME                    TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE     SELECTOR        LABELS
service/nginx-service   ClusterIP   10.233.25.242   <none>        80/TCP    2m18s   app=nginx-pod   <none>

NAME                      ENDPOINTS          AGE     LABELS
endpoints/nginx-service   10.233.64.112:80   2m18s   <none>

And here's the iptables-save after reproducing it:

# Generated by iptables-save v1.4.21 on Wed Jan  4 08:50:22 2023
*mangle
:PREROUTING ACCEPT [948316441:1968377607163]
:INPUT ACCEPT [840146666:1895539150555]
:FORWARD ACCEPT [108169774:72838456548]
:OUTPUT ACCEPT [695774257:2687715300972]
:POSTROUTING ACCEPT [803943985:2760553753337]
:KUBE-IPTABLES-HINT - [0:0]
:KUBE-KUBELET-CANARY - [0:0]
:KUBE-PROXY-CANARY - [0:0]
COMMIT
# Completed on Wed Jan  4 08:50:22 2023
# Generated by iptables-save v1.4.21 on Wed Jan  4 08:50:22 2023
*filter
:INPUT ACCEPT [40226:56959106]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [35569:74595303]
:FLANNEL-FWD - [0:0]
:KUBE-EXTERNAL-SERVICES - [0:0]
:KUBE-FIREWALL - [0:0]
:KUBE-FORWARD - [0:0]
:KUBE-KUBELET-CANARY - [0:0]
:KUBE-NODEPORTS - [0:0]
:KUBE-PROXY-CANARY - [0:0]
:KUBE-SERVICES - [0:0]
-A INPUT -m comment --comment "kubernetes health check service ports" -j KUBE-NODEPORTS
-A INPUT -m conntrack --ctstate NEW -m comment --comment "kubernetes externally-visible service portals" -j KUBE-EXTERNAL-SERVICES
-A INPUT -j KUBE-FIREWALL
-A FORWARD -m comment --comment "flanneld forward" -j FLANNEL-FWD
-A FORWARD -m comment --comment "kubernetes forwarding rules" -j KUBE-FORWARD
-A FORWARD -m conntrack --ctstate NEW -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A FORWARD -m conntrack --ctstate NEW -m comment --comment "kubernetes externally-visible service portals" -j KUBE-EXTERNAL-SERVICES
-A OUTPUT -m conntrack --ctstate NEW -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A OUTPUT -j KUBE-FIREWALL
-A FLANNEL-FWD -s 10.233.64.0/18 -m comment --comment "flanneld forward" -j ACCEPT
-A FLANNEL-FWD -d 10.233.64.0/18 -m comment --comment "flanneld forward" -j ACCEPT
-A KUBE-FIREWALL -m comment --comment "kubernetes firewall for dropping marked packets" -m mark --mark 0x8000/0x8000 -j DROP
-A KUBE-FIREWALL ! -s 127.0.0.0/8 -d 127.0.0.0/8 -m comment --comment "block incoming localnet connections" -m conntrack ! --ctstate RELATED,ESTABLISHED,DNAT -j DROP
-A KUBE-FORWARD -m conntrack --ctstate INVALID -j DROP
-A KUBE-FORWARD -m comment --comment "kubernetes forwarding rules" -m mark --mark 0x4000/0x4000 -j ACCEPT
-A KUBE-FORWARD -m comment --comment "kubernetes forwarding conntrack rule" -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Wed Jan  4 08:50:22 2023
# Generated by iptables-save v1.4.21 on Wed Jan  4 08:50:22 2023
*nat
:PREROUTING ACCEPT [32:1880]
:INPUT ACCEPT [32:1880]
:OUTPUT ACCEPT [531:41235]
:POSTROUTING ACCEPT [532:41295]
:CNI-DN-bf882a7c6b6d62bc1131a - [0:0]
:CNI-HOSTPORT-DNAT - [0:0]
:CNI-HOSTPORT-MASQ - [0:0]
:CNI-HOSTPORT-SETMARK - [0:0]
:FLANNEL-POSTRTG - [0:0]
:KUBE-KUBELET-CANARY - [0:0]
:KUBE-MARK-DROP - [0:0]
:KUBE-MARK-MASQ - [0:0]
:KUBE-NODEPORTS - [0:0]
:KUBE-POSTROUTING - [0:0]
:KUBE-PROXY-CANARY - [0:0]
:KUBE-SEP-2CGKZLTJ3FLW3FSU - [0:0]
:KUBE-SEP-47DFFSOXHPCJZCQX - [0:0]
:KUBE-SEP-4AFLHXUZERIRGFQ5 - [0:0]
:KUBE-SEP-4M6LEU24GIGGAHXT - [0:0]
:KUBE-SEP-5AJZOHQUMTI3L7PQ - [0:0]
:KUBE-SEP-7CJOWH5QVJ5VSNDT - [0:0]
:KUBE-SEP-AWEBZGUO5K4R67AN - [0:0]
:KUBE-SEP-BSEE6OPNLZSR4VQA - [0:0]
:KUBE-SEP-DFYUFVNLE3RYJESR - [0:0]
:KUBE-SEP-E4BCXHIBYCGLIWKZ - [0:0]
:KUBE-SEP-EK3Z7KR3JJPQNZPM - [0:0]
:KUBE-SEP-EO2UPE7MX2YEKJSE - [0:0]
:KUBE-SEP-GO53PN4PHNUZXEHS - [0:0]
:KUBE-SEP-HJRMCMEBH7MIF5C4 - [0:0]
:KUBE-SEP-HTZLFWWCDJFZJFG5 - [0:0]
:KUBE-SEP-LGIAERUE4BLI6LZK - [0:0]
:KUBE-SEP-Q3SAJ7UTJWHTZ3D4 - [0:0]
:KUBE-SEP-Q63REDBBL4J65CU6 - [0:0]
:KUBE-SEP-RITVHJDUYJCR2JY7 - [0:0]
:KUBE-SEP-UVUPKPN3MFOEKGFB - [0:0]
:KUBE-SEP-V6AKX6JIXITU6DRY - [0:0]
:KUBE-SEP-VYHL4Z7L73QGQ6X2 - [0:0]
:KUBE-SEP-WGW3XGAKK54B56HJ - [0:0]
:KUBE-SEP-Y2P4PTKOTRZBDDBR - [0:0]
:KUBE-SEP-YB4HHCFFBWW42YR3 - [0:0]
:KUBE-SEP-ZJHHB4UIZEYDBUZZ - [0:0]
:KUBE-SEP-ZQPXH23K73HW2IJD - [0:0]
:KUBE-SERVICES - [0:0]
:KUBE-SVC-5UPLZIDSZ45WUZX3 - [0:0]
:KUBE-SVC-BMJHC2PLFK2DBPFL - [0:0]
:KUBE-SVC-BOJCKSINR77JVVPB - [0:0]
:KUBE-SVC-CG5I4G2RS3ZVWGLK - [0:0]
:KUBE-SVC-DKVZ4CBQHUTBLZJ6 - [0:0]
:KUBE-SVC-EDNDUDH2C75GIR6O - [0:0]
:KUBE-SVC-ERIFXISQEP7F7OF4 - [0:0]
:KUBE-SVC-ES6IOJC4EK5DV77J - [0:0]
:KUBE-SVC-EZYNCFY2F7N6OQA2 - [0:0]
:KUBE-SVC-JD5MR3NA4I4DYORP - [0:0]
:KUBE-SVC-JTNE6R4VUKUHTUHZ - [0:0]
:KUBE-SVC-NPX46M4PTMTKRN6Y - [0:0]
:KUBE-SVC-SZFARUNKF6CO24AA - [0:0]
:KUBE-SVC-TCOU7JCQXEZGVUNU - [0:0]
:KUBE-SVC-VOOBF6UTRBMKQJOO - [0:0]
-A PREROUTING -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A PREROUTING -m addrtype --dst-type LOCAL -j CNI-HOSTPORT-DNAT
-A OUTPUT -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A OUTPUT -m addrtype --dst-type LOCAL -j CNI-HOSTPORT-DNAT
-A POSTROUTING -m comment --comment "flanneld masq" -j FLANNEL-POSTRTG
-A POSTROUTING -m comment --comment "CNI portfwd requiring masquerade" -j CNI-HOSTPORT-MASQ
-A POSTROUTING -m comment --comment "kubernetes postrouting rules" -j KUBE-POSTROUTING
-A CNI-DN-bf882a7c6b6d62bc1131a -s 10.233.64.0/24 -p tcp -m tcp --dport 80 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-bf882a7c6b6d62bc1131a -s 127.0.0.1/32 -p tcp -m tcp --dport 80 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-bf882a7c6b6d62bc1131a -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.233.64.93:80
-A CNI-DN-bf882a7c6b6d62bc1131a -s 10.233.64.0/24 -p tcp -m tcp --dport 443 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-bf882a7c6b6d62bc1131a -s 127.0.0.1/32 -p tcp -m tcp --dport 443 -j CNI-HOSTPORT-SETMARK
-A CNI-DN-bf882a7c6b6d62bc1131a -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.233.64.93:443
-A CNI-HOSTPORT-DNAT -p tcp -m comment --comment "dnat name: \"cbr0\" id: \"be884d182a6ed5c10e7a6a8b60cb52c2bf230306ddd6767ac67b9e6e87fe4686\"" -m multiport --dports 80,443 -j CNI-DN-bf882a7c6b6d62bc1131a
-A CNI-HOSTPORT-MASQ -m mark --mark 0x2000/0x2000 -j MASQUERADE
-A CNI-HOSTPORT-SETMARK -m comment --comment "CNI portfwd masquerade mark" -j MARK --set-xmark 0x2000/0x2000
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -j RETURN
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE
-A KUBE-MARK-DROP -j MARK --set-xmark 0x8000/0x8000
-A KUBE-MARK-MASQ -j MARK --set-xmark 0x4000/0x4000
-A KUBE-POSTROUTING -m mark ! --mark 0x4000/0x4000 -j RETURN
-A KUBE-POSTROUTING -j MARK --set-xmark 0x4000/0x0
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -j MASQUERADE
-A KUBE-SEP-2CGKZLTJ3FLW3FSU -s 10.233.66.58/32 -m comment --comment "cattle-system/rancher-webhook:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-2CGKZLTJ3FLW3FSU -p tcp -m comment --comment "cattle-system/rancher-webhook:https" -m tcp -j DNAT --to-destination 10.233.66.58:9443
-A KUBE-SEP-47DFFSOXHPCJZCQX -s 10.233.65.48/32 -m comment --comment "kube-system/kube-dns:metrics" -j KUBE-MARK-MASQ
-A KUBE-SEP-47DFFSOXHPCJZCQX -p tcp -m comment --comment "kube-system/kube-dns:metrics" -m tcp -j DNAT --to-destination 10.233.65.48:9153
-A KUBE-SEP-4AFLHXUZERIRGFQ5 -s 10.233.64.93/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -j KUBE-MARK-MASQ
-A KUBE-SEP-4AFLHXUZERIRGFQ5 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -m tcp -j DNAT --to-destination 10.233.64.93:8443
-A KUBE-SEP-4M6LEU24GIGGAHXT -s 10.105.10.145/32 -m comment --comment "default/kubernetes:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-4M6LEU24GIGGAHXT -p tcp -m comment --comment "default/kubernetes:https" -m tcp -j DNAT --to-destination 10.105.10.145:6443
-A KUBE-SEP-5AJZOHQUMTI3L7PQ -s 10.233.66.56/32 -m comment --comment "cattle-system/rancher:https-internal" -j KUBE-MARK-MASQ
-A KUBE-SEP-5AJZOHQUMTI3L7PQ -p tcp -m comment --comment "cattle-system/rancher:https-internal" -m tcp -j DNAT --to-destination 10.233.66.56:444
-A KUBE-SEP-7CJOWH5QVJ5VSNDT -s 10.233.65.35/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -j KUBE-MARK-MASQ
-A KUBE-SEP-7CJOWH5QVJ5VSNDT -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -m tcp -j DNAT --to-destination 10.233.65.35:10254
-A KUBE-SEP-AWEBZGUO5K4R67AN -s 10.233.66.50/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-AWEBZGUO5K4R67AN -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -m tcp -j DNAT --to-destination 10.233.66.50:80
-A KUBE-SEP-BSEE6OPNLZSR4VQA -s 10.233.66.56/32 -m comment --comment "cattle-system/rancher:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-BSEE6OPNLZSR4VQA -p tcp -m comment --comment "cattle-system/rancher:http" -m tcp -j DNAT --to-destination 10.233.66.56:80
-A KUBE-SEP-DFYUFVNLE3RYJESR -s 10.233.65.48/32 -m comment --comment "kube-system/kube-dns:dns" -j KUBE-MARK-MASQ
-A KUBE-SEP-DFYUFVNLE3RYJESR -p udp -m comment --comment "kube-system/kube-dns:dns" -m udp -j DNAT --to-destination 10.233.65.48:53
-A KUBE-SEP-E4BCXHIBYCGLIWKZ -s 10.122.88.50/32 -m comment --comment "default/kubernetes:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-E4BCXHIBYCGLIWKZ -p tcp -m comment --comment "default/kubernetes:https" -m tcp -j DNAT --to-destination 10.122.88.50:6443
-A KUBE-SEP-EK3Z7KR3JJPQNZPM -s 10.233.65.35/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-EK3Z7KR3JJPQNZPM -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -m tcp -j DNAT --to-destination 10.233.65.35:443
-A KUBE-SEP-EO2UPE7MX2YEKJSE -s 10.233.66.58/32 -m comment --comment "cattle-system/webhook-service:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-EO2UPE7MX2YEKJSE -p tcp -m comment --comment "cattle-system/webhook-service:https" -m tcp -j DNAT --to-destination 10.233.66.58:8777
-A KUBE-SEP-GO53PN4PHNUZXEHS -s 10.233.66.49/32 -m comment --comment "cattle-fleet-system/gitjob:http-80" -j KUBE-MARK-MASQ
-A KUBE-SEP-GO53PN4PHNUZXEHS -p tcp -m comment --comment "cattle-fleet-system/gitjob:http-80" -m tcp -j DNAT --to-destination 10.233.66.49:8080
-A KUBE-SEP-HJRMCMEBH7MIF5C4 -s 10.233.66.50/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -j KUBE-MARK-MASQ
-A KUBE-SEP-HJRMCMEBH7MIF5C4 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -m tcp -j DNAT --to-destination 10.233.66.50:10254
-A KUBE-SEP-HTZLFWWCDJFZJFG5 -s 10.233.64.93/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-HTZLFWWCDJFZJFG5 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -m tcp -j DNAT --to-destination 10.233.64.93:443
-A KUBE-SEP-LGIAERUE4BLI6LZK -s 10.233.65.35/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-LGIAERUE4BLI6LZK -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -m tcp -j DNAT --to-destination 10.233.65.35:80
-A KUBE-SEP-Q3SAJ7UTJWHTZ3D4 -s 10.233.65.46/32 -m comment --comment "kube-system/sealed-secrets-controller" -j KUBE-MARK-MASQ
-A KUBE-SEP-Q3SAJ7UTJWHTZ3D4 -p tcp -m comment --comment "kube-system/sealed-secrets-controller" -m tcp -j DNAT --to-destination 10.233.65.46:8080
-A KUBE-SEP-Q63REDBBL4J65CU6 -s 10.233.66.50/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-Q63REDBBL4J65CU6 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https" -m tcp -j DNAT --to-destination 10.233.66.50:443
-A KUBE-SEP-RITVHJDUYJCR2JY7 -s 10.233.64.93/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -j KUBE-MARK-MASQ
-A KUBE-SEP-RITVHJDUYJCR2JY7 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics" -m tcp -j DNAT --to-destination 10.233.64.93:10254
-A KUBE-SEP-UVUPKPN3MFOEKGFB -s 10.233.65.35/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -j KUBE-MARK-MASQ
-A KUBE-SEP-UVUPKPN3MFOEKGFB -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -m tcp -j DNAT --to-destination 10.233.65.35:8443
-A KUBE-SEP-V6AKX6JIXITU6DRY -s 10.233.65.48/32 -m comment --comment "kube-system/kube-dns:dns-tcp" -j KUBE-MARK-MASQ
-A KUBE-SEP-V6AKX6JIXITU6DRY -p tcp -m comment --comment "kube-system/kube-dns:dns-tcp" -m tcp -j DNAT --to-destination 10.233.65.48:53
-A KUBE-SEP-VYHL4Z7L73QGQ6X2 -s 10.233.64.93/32 -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-VYHL4Z7L73QGQ6X2 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http" -m tcp -j DNAT --to-destination 10.233.64.93:80
-A KUBE-SEP-WGW3XGAKK54B56HJ -s 10.233.65.43/32 -m comment --comment "cattle-system/rancher:https-internal" -j KUBE-MARK-MASQ
-A KUBE-SEP-WGW3XGAKK54B56HJ -p tcp -m comment --comment "cattle-system/rancher:https-internal" -m tcp -j DNAT --to-destination 10.233.65.43:444
-A KUBE-SEP-Y2P4PTKOTRZBDDBR -s 10.233.65.43/32 -m comment --comment "cattle-system/rancher:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-Y2P4PTKOTRZBDDBR -p tcp -m comment --comment "cattle-system/rancher:http" -m tcp -j DNAT --to-destination 10.233.65.43:80
-A KUBE-SEP-YB4HHCFFBWW42YR3 -s 10.132.70.246/32 -m comment --comment "default/kubernetes:https" -j KUBE-MARK-MASQ
-A KUBE-SEP-YB4HHCFFBWW42YR3 -p tcp -m comment --comment "default/kubernetes:https" -m tcp -j DNAT --to-destination 10.132.70.246:6443
-A KUBE-SEP-ZJHHB4UIZEYDBUZZ -s 10.233.66.50/32 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -j KUBE-MARK-MASQ
-A KUBE-SEP-ZJHHB4UIZEYDBUZZ -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook" -m tcp -j DNAT --to-destination 10.233.66.50:8443
-A KUBE-SEP-ZQPXH23K73HW2IJD -s 10.233.64.112/32 -m comment --comment "bugtest/nginx-service:http" -j KUBE-MARK-MASQ
-A KUBE-SEP-ZQPXH23K73HW2IJD -p tcp -m comment --comment "bugtest/nginx-service:http" -m tcp -j DNAT --to-destination 10.233.64.112:80
-A KUBE-SERVICES -d 10.233.0.10/32 -p udp -m comment --comment "kube-system/kube-dns:dns cluster IP" -m udp --dport 53 -j KUBE-SVC-TCOU7JCQXEZGVUNU
-A KUBE-SERVICES -d 10.233.27.16/32 -p tcp -m comment --comment "cattle-system/rancher:https-internal cluster IP" -m tcp --dport 443 -j KUBE-SVC-BMJHC2PLFK2DBPFL
-A KUBE-SERVICES -d 10.233.13.83/32 -p tcp -m comment --comment "cattle-system/rancher-webhook:https cluster IP" -m tcp --dport 443 -j KUBE-SVC-BOJCKSINR77JVVPB
-A KUBE-SERVICES -d 10.233.0.1/32 -p tcp -m comment --comment "default/kubernetes:https cluster IP" -m tcp --dport 443 -j KUBE-SVC-NPX46M4PTMTKRN6Y
-A KUBE-SERVICES -d 10.233.62.33/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http cluster IP" -m tcp --dport 80 -j KUBE-SVC-CG5I4G2RS3ZVWGLK
-A KUBE-SERVICES -d 10.233.62.98/32 -p tcp -m comment --comment "cattle-fleet-system/gitjob:http-80 cluster IP" -m tcp --dport 80 -j KUBE-SVC-5UPLZIDSZ45WUZX3
-A KUBE-SERVICES -d 10.233.25.242/32 -p tcp -m comment --comment "bugtest/nginx-service:http cluster IP" -m tcp --dport 80 -j KUBE-SVC-SZFARUNKF6CO24AA
-A KUBE-SERVICES -d 10.233.0.10/32 -p tcp -m comment --comment "kube-system/kube-dns:dns-tcp cluster IP" -m tcp --dport 53 -j KUBE-SVC-ERIFXISQEP7F7OF4
-A KUBE-SERVICES -d 10.233.0.10/32 -p tcp -m comment --comment "kube-system/kube-dns:metrics cluster IP" -m tcp --dport 9153 -j KUBE-SVC-JD5MR3NA4I4DYORP
-A KUBE-SERVICES -d 10.233.39.60/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics cluster IP" -m tcp --dport 10254 -j KUBE-SVC-VOOBF6UTRBMKQJOO
-A KUBE-SERVICES -d 10.233.62.33/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https cluster IP" -m tcp --dport 443 -j KUBE-SVC-EDNDUDH2C75GIR6O
-A KUBE-SERVICES -d 10.233.49.128/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook cluster IP" -m tcp --dport 443 -j KUBE-SVC-EZYNCFY2F7N6OQA2
-A KUBE-SERVICES -d 10.233.4.158/32 -p tcp -m comment --comment "kube-system/sealed-secrets-controller cluster IP" -m tcp --dport 8080 -j KUBE-SVC-JTNE6R4VUKUHTUHZ
-A KUBE-SERVICES -d 10.233.26.49/32 -p tcp -m comment --comment "cattle-system/webhook-service:https cluster IP" -m tcp --dport 443 -j KUBE-SVC-DKVZ4CBQHUTBLZJ6
-A KUBE-SERVICES -d 10.233.27.16/32 -p tcp -m comment --comment "cattle-system/rancher:http cluster IP" -m tcp --dport 80 -j KUBE-SVC-ES6IOJC4EK5DV77J
-A KUBE-SERVICES -m comment --comment "kubernetes service nodeports; NOTE: this must be the last rule in this chain" -m addrtype --dst-type LOCAL -j KUBE-NODEPORTS
-A KUBE-SVC-5UPLZIDSZ45WUZX3 ! -s 10.233.64.0/18 -d 10.233.62.98/32 -p tcp -m comment --comment "cattle-fleet-system/gitjob:http-80 cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SVC-5UPLZIDSZ45WUZX3 -m comment --comment "cattle-fleet-system/gitjob:http-80 -> 10.233.66.49:8080" -j KUBE-SEP-GO53PN4PHNUZXEHS
-A KUBE-SVC-BMJHC2PLFK2DBPFL ! -s 10.233.64.0/18 -d 10.233.27.16/32 -p tcp -m comment --comment "cattle-system/rancher:https-internal cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-BMJHC2PLFK2DBPFL -m comment --comment "cattle-system/rancher:https-internal -> 10.233.65.43:444" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-WGW3XGAKK54B56HJ
-A KUBE-SVC-BMJHC2PLFK2DBPFL -m comment --comment "cattle-system/rancher:https-internal -> 10.233.66.56:444" -j KUBE-SEP-5AJZOHQUMTI3L7PQ
-A KUBE-SVC-BOJCKSINR77JVVPB ! -s 10.233.64.0/18 -d 10.233.13.83/32 -p tcp -m comment --comment "cattle-system/rancher-webhook:https cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-BOJCKSINR77JVVPB -m comment --comment "cattle-system/rancher-webhook:https -> 10.233.66.58:9443" -j KUBE-SEP-2CGKZLTJ3FLW3FSU
-A KUBE-SVC-CG5I4G2RS3ZVWGLK ! -s 10.233.64.0/18 -d 10.233.62.33/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:http cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SVC-CG5I4G2RS3ZVWGLK -m comment --comment "ingress-nginx/ingress-nginx-controller:http -> 10.233.64.93:80" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-VYHL4Z7L73QGQ6X2
-A KUBE-SVC-CG5I4G2RS3ZVWGLK -m comment --comment "ingress-nginx/ingress-nginx-controller:http -> 10.233.65.35:80" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-LGIAERUE4BLI6LZK
-A KUBE-SVC-CG5I4G2RS3ZVWGLK -m comment --comment "ingress-nginx/ingress-nginx-controller:http -> 10.233.66.50:80" -j KUBE-SEP-AWEBZGUO5K4R67AN
-A KUBE-SVC-DKVZ4CBQHUTBLZJ6 ! -s 10.233.64.0/18 -d 10.233.26.49/32 -p tcp -m comment --comment "cattle-system/webhook-service:https cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-DKVZ4CBQHUTBLZJ6 -m comment --comment "cattle-system/webhook-service:https -> 10.233.66.58:8777" -j KUBE-SEP-EO2UPE7MX2YEKJSE
-A KUBE-SVC-EDNDUDH2C75GIR6O ! -s 10.233.64.0/18 -d 10.233.62.33/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller:https cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-EDNDUDH2C75GIR6O -m comment --comment "ingress-nginx/ingress-nginx-controller:https -> 10.233.64.93:443" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-HTZLFWWCDJFZJFG5
-A KUBE-SVC-EDNDUDH2C75GIR6O -m comment --comment "ingress-nginx/ingress-nginx-controller:https -> 10.233.65.35:443" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-EK3Z7KR3JJPQNZPM
-A KUBE-SVC-EDNDUDH2C75GIR6O -m comment --comment "ingress-nginx/ingress-nginx-controller:https -> 10.233.66.50:443" -j KUBE-SEP-Q63REDBBL4J65CU6
-A KUBE-SVC-ERIFXISQEP7F7OF4 ! -s 10.233.64.0/18 -d 10.233.0.10/32 -p tcp -m comment --comment "kube-system/kube-dns:dns-tcp cluster IP" -m tcp --dport 53 -j KUBE-MARK-MASQ
-A KUBE-SVC-ERIFXISQEP7F7OF4 -m comment --comment "kube-system/kube-dns:dns-tcp -> 10.233.65.48:53" -j KUBE-SEP-V6AKX6JIXITU6DRY
-A KUBE-SVC-ES6IOJC4EK5DV77J ! -s 10.233.64.0/18 -d 10.233.27.16/32 -p tcp -m comment --comment "cattle-system/rancher:http cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SVC-ES6IOJC4EK5DV77J -m comment --comment "cattle-system/rancher:http -> 10.233.65.43:80" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-Y2P4PTKOTRZBDDBR
-A KUBE-SVC-ES6IOJC4EK5DV77J -m comment --comment "cattle-system/rancher:http -> 10.233.66.56:80" -j KUBE-SEP-BSEE6OPNLZSR4VQA
-A KUBE-SVC-EZYNCFY2F7N6OQA2 ! -s 10.233.64.0/18 -d 10.233.49.128/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-EZYNCFY2F7N6OQA2 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook -> 10.233.64.93:8443" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-4AFLHXUZERIRGFQ5
-A KUBE-SVC-EZYNCFY2F7N6OQA2 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook -> 10.233.65.35:8443" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-UVUPKPN3MFOEKGFB
-A KUBE-SVC-EZYNCFY2F7N6OQA2 -m comment --comment "ingress-nginx/ingress-nginx-controller-admission:https-webhook -> 10.233.66.50:8443" -j KUBE-SEP-ZJHHB4UIZEYDBUZZ
-A KUBE-SVC-JD5MR3NA4I4DYORP ! -s 10.233.64.0/18 -d 10.233.0.10/32 -p tcp -m comment --comment "kube-system/kube-dns:metrics cluster IP" -m tcp --dport 9153 -j KUBE-MARK-MASQ
-A KUBE-SVC-JD5MR3NA4I4DYORP -m comment --comment "kube-system/kube-dns:metrics -> 10.233.65.48:9153" -j KUBE-SEP-47DFFSOXHPCJZCQX
-A KUBE-SVC-JTNE6R4VUKUHTUHZ ! -s 10.233.64.0/18 -d 10.233.4.158/32 -p tcp -m comment --comment "kube-system/sealed-secrets-controller cluster IP" -m tcp --dport 8080 -j KUBE-MARK-MASQ
-A KUBE-SVC-JTNE6R4VUKUHTUHZ -m comment --comment "kube-system/sealed-secrets-controller -> 10.233.65.46:8080" -j KUBE-SEP-Q3SAJ7UTJWHTZ3D4
-A KUBE-SVC-NPX46M4PTMTKRN6Y ! -s 10.233.64.0/18 -d 10.233.0.1/32 -p tcp -m comment --comment "default/kubernetes:https cluster IP" -m tcp --dport 443 -j KUBE-MARK-MASQ
-A KUBE-SVC-NPX46M4PTMTKRN6Y -m comment --comment "default/kubernetes:https -> 10.105.10.145:6443" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-4M6LEU24GIGGAHXT
-A KUBE-SVC-NPX46M4PTMTKRN6Y -m comment --comment "default/kubernetes:https -> 10.122.88.50:6443" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-E4BCXHIBYCGLIWKZ
-A KUBE-SVC-NPX46M4PTMTKRN6Y -m comment --comment "default/kubernetes:https -> 10.132.70.246:6443" -j KUBE-SEP-YB4HHCFFBWW42YR3
-A KUBE-SVC-SZFARUNKF6CO24AA ! -s 10.233.64.0/18 -d 10.233.25.242/32 -p tcp -m comment --comment "bugtest/nginx-service:http cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SVC-SZFARUNKF6CO24AA -m comment --comment "bugtest/nginx-service:http -> 10.233.64.112:80" -j KUBE-SEP-ZQPXH23K73HW2IJD
-A KUBE-SVC-TCOU7JCQXEZGVUNU ! -s 10.233.64.0/18 -d 10.233.0.10/32 -p udp -m comment --comment "kube-system/kube-dns:dns cluster IP" -m udp --dport 53 -j KUBE-MARK-MASQ
-A KUBE-SVC-TCOU7JCQXEZGVUNU -m comment --comment "kube-system/kube-dns:dns -> 10.233.65.48:53" -j KUBE-SEP-DFYUFVNLE3RYJESR
-A KUBE-SVC-VOOBF6UTRBMKQJOO ! -s 10.233.64.0/18 -d 10.233.39.60/32 -p tcp -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics cluster IP" -m tcp --dport 10254 -j KUBE-MARK-MASQ
-A KUBE-SVC-VOOBF6UTRBMKQJOO -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics -> 10.233.64.93:10254" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-RITVHJDUYJCR2JY7
-A KUBE-SVC-VOOBF6UTRBMKQJOO -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics -> 10.233.65.35:10254" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-7CJOWH5QVJ5VSNDT
-A KUBE-SVC-VOOBF6UTRBMKQJOO -m comment --comment "ingress-nginx/ingress-nginx-controller-metrics:metrics -> 10.233.66.50:10254" -j KUBE-SEP-HJRMCMEBH7MIF5C4
COMMIT
# Completed on Wed Jan  4 08:50:22 2023

@oe-hbk
Copy link
Author

oe-hbk commented Jan 4, 2023

please ignore the extra

-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -j RETURN

In the nat table, I had added that while troubleshooting, as per another incident I saw on the issues page, but realized later that the issue was fixed in 0.20.2. The behavior is the same without that entry as well

@oe-hbk
Copy link
Author

oe-hbk commented Jan 4, 2023

I have a couple of other clusters running older versions of k8s (1.21.x) and flannel (0.12, and 0.17) which don't exhibit this issue. When I use the older versions of flannel (0.12, and 0.17) against this 1.24.8 cluster, the issue remains. So perhaps this isn't flannel related, but maybe kube-proxy?

@rbrtbnfgl
Copy link
Contributor

rbrtbnfgl commented Jan 5, 2023

It can be related to kube-proxy and centos, because I tested your env with ubuntu and it worked.
You could check the traffic with tcpdump from the pod that is generating interface and the traffic from the nginx pod interface.

@jan-lucansky
Copy link

jan-lucansky commented Jan 11, 2023

I am hitting this issue for UDP datagrams only when sending traffic from Node1 to pod on Node2 via ClusterIP service.

My Environment

  • Flannel version: 0.20.1 (latest version used in kubespray)
  • Backend used (e.g. vxlan or udp): vxlan
  • Etcd version: 3.5.6
  • Kubernetes version (if used): 1.23.9, 1.24.6, 1.25.5
  • Operating System and version: Ubuntu 20.04.4 (kernel 5.13.0-1031-aws x86_64) - AWS community AMI ami-02b38bc5d81cd5945
  • Cloud platform AWS

I am running Kubespray installation in AWS, which uses flannel:

  • flannel_version: "v0.20.1"
  • flannel_cni_version: "v1.2.0"
  • cni_version: "v1.1.1"

Traffic description:

Node1 --> ClusterIP (for pod on Node2)

Node1 is sending traffic to ClusterIP covering a pod on Node2, TCP works fine, UDP datagrams get dropped. I was able to trace the datagram to Node2, it arrives there fine with proper IP addresses and port (vxlan 8472). The first header has a destination IP set to ClusterIP of the service, the inside header has destination IP of the pod (expected scenario). After stripping the first header, the packet/datagram disappers in kernel. I made sure there are no rules dropping this in iptables (couple of people verified this).

  • I ran the same test scenario on the same node OS (the same AMI, same Kubespray release) with an older version of flannel (v0.15.1 -> quay.io/coreos/flannel:v0.15.1) and it works fine.
  • Also tried older version of k8s (1.23.9, same AMI and Kubespray release) with the new Flannel (v0.20.1 -> docker.io/flannelcni/flannel:v0.20.1) and it failed.

I have the setup automated in case more details are needed and also have a tcpdump trace of the packet but I am reluctant to share that without permission. I have tried several suggestions mentioned in similar bugs either mentioned here, on Kubespray page or on AWS page (like disabling source/destination address checking), none of them worked.

@rbrtbnfgl
Copy link
Contributor

if you test this

sudo ethtool -K flannel.1 tx-checksum-ip-generic off

Does it fix it?

@jan-lucansky
Copy link

jan-lucansky commented Jan 11, 2023

Yes, it does!

Please, feel free to educate me and/or send the links for the reason behind this, I would like to understand it more in order to avoid it in the future. Or if there is another ticket where this was already discussed, I will look there. Thank you in advance.

EDIT: I guess this is the issue where it is discussed more in depth, right? #1279

@rbrtbnfgl
Copy link
Contributor

Flannel v0.20.2 should fix this bug.
The reason is related to a bug on some kernel version with the check of the UDP checksum in case of the masqueraded packet forwarded through the VXLAN tunnel.

@jan-lucansky
Copy link

One last question - v.0.20.2 will have a "general" fix that will work regardless of the kernel version?

@rbrtbnfgl
Copy link
Contributor

yes

@oe-hbk
Copy link
Author

oe-hbk commented Jan 11, 2023

My issue, which I was able to consistently reproduce no longer does after I rebuilt the entire cluster. If this happens again, I'll report it again, but for the time being, I think this was just my environment.

@rbrtbnfgl
Copy link
Contributor

Thanks for reporting.
I'll close this.

@oe-hbk
Copy link
Author

oe-hbk commented Jan 17, 2023

@rbrtbnfgl This issue came back unfortunately. After rebooting all nodes in the cluster, was able to see the same problem again. Rebuilt the cluster once more, and things went back to working, rebooted all the nodes, and back to broken state.

@rbrtbnfgl
Copy link
Contributor

Are you using flannel v.0.20.2 or only the fix with ethtool?
That command is loss on system reboot you have to run it again.

@oe-hbk
Copy link
Author

oe-hbk commented Jan 17, 2023

I'm on 0.20.2 and had checked the ethtool fix as well in case, but no difference.

@oe-hbk
Copy link
Author

oe-hbk commented Jan 17, 2023

Now that I can reproduce again by rebooting a node after cluster rebuild, I did some iptable-save s before (when it works) and after reboot (when it doesn't work) and found some differences.

Better yet, confirmed that after a rebuild, and after any number of reboots, I can get back to working state with a simple
iptables-save | iptables-restore

which is really odd.
I saved the before and after, and there are differences.
when it doesn't work, nat table has:

-A PREROUTING -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A OUTPUT -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A POSTROUTING -m comment --comment "flanneld masq" -j FLANNEL-POSTRTG
-A POSTROUTING -m comment --comment "kubernetes postrouting rules" -j KUBE-POSTROUTING
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE
-A KUBE-MARK-DROP -j MARK --set-xmark 0x8000/0x8000
-A KUBE-MARK-MASQ -j MARK --set-xmark 0x4000/0x4000
-A KUBE-POSTROUTING -m mark ! --mark 0x4000/0x4000 -j RETURN
-A KUBE-POSTROUTING -j MARK --set-xmark 0x4000/0x0
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -j MASQUERADE

Just with an iptables-save | iptables-restore (again I don't know why this happens, but perhaps a race-condition when flannel first starts up, vs. when it detects and corrects stuff)

The new nat table has two additional entries

-A PREROUTING -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A OUTPUT -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
-A POSTROUTING -m comment --comment "flanneld masq" -j FLANNEL-POSTRTG
-A POSTROUTING -m comment --comment "kubernetes postrouting rules" -j KUBE-POSTROUTING
-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE
-A KUBE-MARK-DROP -j MARK --set-xmark 0x8000/0x8000
-A KUBE-MARK-MASQ -j MARK --set-xmark 0x4000/0x4000
-A KUBE-POSTROUTING -m mark ! --mark 0x4000/0x4000 -j RETURN
-A KUBE-POSTROUTING -j MARK --set-xmark 0x4000/0x0
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -j MASQUERADE

Specifically:

-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE

@oe-hbk
Copy link
Author

oe-hbk commented Jan 18, 2023

@rbrtbnfgl could you please re-open this issue. I don't see a way to do it myself.

Some new developments.
All my machines have

iptables --version
iptables v1.4.21

And according to https://github.com/coreos/go-iptables/blob/d2b8608923d15b0800af7d9f4bb6dea90e03b7d5/iptables/iptables.go#L661 it should not support --random-fully and I've confirmed that it doesn't by trying to create a rule with that option.

Unfortunately flannel seems to want to use this flag when it's trying to reset/restore rules, which is why I think I get the higher ordered MASQUERADE rules, because I think it's not properly deleting those before adding. I'll post some verbose logs when I have a better understanding of what's going on.

I went and changed the code so that it always took the NOT has_random_fully code path, and also changed:

     // This rule ensure that the flannel iptables rules are executed before other rules on the node
        {"nat", "-I", "POSTROUTING", []string{"-m", "comment", "--comment", "flanneld masq", "-j", "FLANNEL-POSTRTG"}},
        // This rule will not masquerade traffic marked by the kube-proxy to avoid double NAT bug on some kernel version
        {"nat", "-A", "FLANNEL-POSTRTG", []string{"-m", "mark", "--mark", kubeProxyMark, "-m", "comment", "--comment", "flanneld masq", "-j", "RETURN"}},
        // This rule makes sure we don't NAT traffic within overlay network (e.g. coming out of docker0)
        {"nat", "-A", "FLANNEL-POSTRTG", []string{"-s", n, "-d", n, "-m", "comment", "--comment", "flanneld masq", "-j", "RETURN"}},
        // NAT if it's not multicast traffic
        {"nat", "-A", "FLANNEL-POSTRTG", []string{"-s", n, "!", "-d", "224.0.0.0/4", "-m", "comment", "--comment", "flanneld masq", "-j", "MASQUERADE", "--random-fully"}},
        // Prevent performing Masquerade on external traffic which arrives from a Node that owns the container/pod IP address
        {"nat", "-A", "FLANNEL-POSTRTG", []string{"!", "-s", n, "-d", sn, "-m", "comment", "--comment", "flanneld masq", "-j", "RETURN"}},
        // Masquerade anything headed towards flannel from the host
        {"nat", "-A", "FLANNEL-POSTRTG", []string{"!", "-s", n, "-d", n, "-m", "comment", "--comment", "flanneld masq", "-j", "MASQUERADE", "--random-fully"}},


to

   return []IPTablesRule{
      // This rule ensure that the flannel iptables rules are executed before other rules on the node
      {"nat", "-I", "POSTROUTING", []string{"-m", "comment", "--comment", "flanneld masq", "-j", "FLANNEL-POSTRTG"}},
      // NAT if it's not multicast traffic
      {"nat", "-A", "FLANNEL-POSTRTG", []string{"-s", n, "!", "-d", "224.0.0.0/4", "-m", "comment", "--comment", "flanneld masq", "-j", "MASQUERADE"}},
      // Masquerade anything headed towards flannel from the host
      {"nat", "-A", "FLANNEL-POSTRTG", []string{"!", "-s", n, "-d", n, "-m", "comment", "--comment", "flanneld masq", "-j", "MASQUERADE"}},
      // This rule will not masquerade traffic marked by the kube-proxy to avoid double NAT bug on some kernel version
      {"nat", "-A", "FLANNEL-POSTRTG", []string{"-m", "mark", "--mark", kubeProxyMark, "-m", "comment", "--comment", "flanneld masq", "-j", "RETURN"}},
      // This rule makes sure we don't NAT traffic within overlay network (e.g. coming out of docker0)
      {"nat", "-A", "FLANNEL-POSTRTG", []string{"-s", n, "-d", n, "-m", "comment", "--comment", "flanneld masq", "-j", "RETURN"}},
      // Prevent performing Masquerade on external traffic which arrives from a Node that owns the container/pod IP address
      {"nat", "-A", "FLANNEL-POSTRTG", []string{"!", "-s", n, "-d", sn, "-m", "comment", "--comment", "flanneld masq", "-j", "RETURN"}},
    }

and now on a reboot, the pod->service on same node works correctly.

iptables -L FLANNEL-POSTRTG -t nat -n
Chain FLANNEL-POSTRTG (1 references)
target     prot opt source               destination
MASQUERADE  all  --  10.233.64.0/18      !224.0.0.0/4          /* flanneld masq */
MASQUERADE  all  -- !10.233.64.0/18       10.233.64.0/18       /* flanneld masq */
RETURN     all  --  0.0.0.0/0            0.0.0.0/0            mark match 0x4000/0x4000 /* flanneld masq */
RETURN     all  --  10.233.64.0/18       10.233.64.0/18       /* flanneld masq */
RETURN     all  -- !10.233.64.0/18       10.233.64.0/24       /* flanneld masq */

I haven't wrapped my head around all these rules, so there's a high chance I broke something else as a result, but I wanted to provide that detail. I should have more logs and details tomorrow, but if you see something obvious, please let me know.

Thank you

@rbrtbnfgl rbrtbnfgl reopened this Jan 18, 2023
@rbrtbnfgl
Copy link
Contributor

Thanks @oe-hbk for finding this. I'll check it and I'll make a PR to fix this.

@oe-hbk
Copy link
Author

oe-hbk commented Jan 18, 2023

Thanks @rbrtbnfgl , I have a question. For the --random-fully option, the iptables version detection is happening inside the flannel container, and that version in the standard flannel image is
iptables v1.8.8 (nf_tables)

While my hosts have
iptables v1.4.21

which doesn't support --random-fully

How does this work? Can the iptables client in the container do what it needs to do on a kernel at the host that might not support it?

@rbrtbnfgl
Copy link
Contributor

I'll check this too. That's a strange behaviour.

@oe-hbk
Copy link
Author

oe-hbk commented Jan 18, 2023

I think I have an explanation for why things work right after cluster build, but not after a reboot.

After cluster install, because the cni-plugin in kube-flannel.yaml enables the portmap plugin, the POSTROUTING chain has

-A POSTROUTING -m comment --comment "flanneld masq" -j FLANNEL-POSTRTG
-A POSTROUTING -m comment --comment "CNI portfwd requiring masquerade" -j CNI-HOSTPORT-MASQ
-A POSTROUTING -m comment --comment "kubernetes postrouting rules" -j KUBE-POSTROUTING
-A CNI-HOSTPORT-MASQ -m mark --mark 0x2000/0x2000 -j MASQUERADE
-A CNI-HOSTPORT-SETMARK -m comment --comment "CNI portfwd masquerade mark" -j MARK --set-xmark 0x2000/0x2000
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE
-A KUBE-MARK-DROP -j MARK --set-xmark 0x8000/0x8000
-A KUBE-MARK-MASQ -j MARK --set-xmark 0x4000/0x4000
-A KUBE-POSTROUTING -m mark ! --mark 0x4000/0x4000 -j RETURN
-A KUBE-POSTROUTING -j MARK --set-xmark 0x4000/0x0
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -j MASQUERADE

After a reboot however, the CNI portmap plugin created chain is no longer there.

-A POSTROUTING -m comment --comment "flanneld masq" -j FLANNEL-POSTRTG
-A POSTROUTING -m comment --comment "kubernetes postrouting rules" -j KUBE-POSTROUTING
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE
-A KUBE-MARK-DROP -j MARK --set-xmark 0x8000/0x8000
-A KUBE-MARK-MASQ -j MARK --set-xmark 0x4000/0x4000
-A KUBE-POSTROUTING -m mark ! --mark 0x4000/0x4000 -j RETURN
-A KUBE-POSTROUTING -j MARK --set-xmark 0x4000/0x0
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -j MASQUERADE

I am not sure why the CNI portmap plugin created rules aren't surviving a reboot. Without them, the FLANNEL-POSTRTG rules are not in the correct order, the mark rule has to happen after the first two listed.

@rbrtbnfgl
Copy link
Contributor

rbrtbnfgl commented Jan 19, 2023

All the iptables rules are deleted on reboot. I don't think the ordering is related to portmap. Flannel is always checking that every rules are created and when something is missing it should delete all the Flannel related rules and create them on the same order.

@oe-hbk
Copy link
Author

oe-hbk commented Jan 19, 2023

I get that iptables aren't saved (unless you run a save/restore as it used to be the case) but I still don't know how the CNI portmap created ones are supposed to persist, but they do seem to play a role at least in my env. for flannel to work correctly after cluster is initialized, and when they're gone with the reboot, the issue is experienced. Anyway, thank you so much for looking into this. Please let me know if I can help test in any way.

@rbrtbnfgl
Copy link
Contributor

So it could be related on the two missing rules:

-A CNI-HOSTPORT-MASQ -m mark --mark 0x2000/0x2000 -j MASQUERADE
-A CNI-HOSTPORT-SETMARK -m comment --comment "CNI portfwd masquerade mark" -j MARK --set-xmark 0x2000/0x2000

Somehow they should be responsible of the cluster-ip FWD. Could you also provide the flannel pod logs?

@oe-hbk
Copy link
Author

oe-hbk commented Jan 20, 2023

Here are 3 pod logs.

After cluster create, before adding the bugtest.yaml

I0120 22:24:31.849323       1 main.go:204] CLI flags config: {etcdEndpoints:http://127.0.0.1:4001,http://127.0.0.1:2379 etcdPrefix:/coreos.com/network etcdKeyfile: etcdCertfile: etcdCAFile: etcdUsername: etcdPassword: version:false kubeSubnetMgr:true kubeApiUrl: kubeAnnotationPrefix:flannel.alpha.coreos.com kubeConfigFile: iface:[] ifaceRegex:[] ipMasq:true ifaceCanReach: subnetFile:/run/flannel/subnet.env publicIP: publicIPv6: subnetLeaseRenewMargin:60 healthzIP:0.0.0.0 healthzPort:0 iptablesResyncSeconds:5 iptablesForwardRules:true netConfPath:/etc/kube-flannel/net-conf.json setNodeNetworkUnavailable:true}
W0120 22:24:31.849562       1 client_config.go:617] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
I0120 22:24:32.072292       1 kube.go:126] Waiting 10m0s for node controller to sync
I0120 22:24:32.142474       1 kube.go:431] Starting kube subnet manager
I0120 22:24:33.144667       1 kube.go:133] Node controller sync successful
I0120 22:24:33.144726       1 main.go:224] Created subnet manager: Kubernetes Subnet Manager - dalqaifxranch1
I0120 22:24:33.144739       1 main.go:227] Installing signal handlers
I0120 22:24:33.146582       1 main.go:467] Found network config - Backend type: vxlan
I0120 22:24:33.146903       1 match.go:206] Determining IP address of default interface
I0120 22:24:33.147639       1 match.go:259] Using interface with name ens192 and address 10.105.10.145
I0120 22:24:33.147687       1 match.go:281] Defaulting external address to interface address (10.105.10.145)
I0120 22:24:33.147830       1 vxlan.go:138] VXLAN config: VNI=1 Port=8472 GBP=false Learning=false DirectRouting=true
I0120 22:24:33.243907       1 main.go:416] Current network or subnet (10.233.64.0/18, 10.233.64.0/24) is not equal to previous one (0.0.0.0/0, 0.0.0.0/0), trying to recycle old iptables rules
I0120 22:24:33.244251       1 kube.go:452] Creating the node lease for IPv4. This is the n.Spec.PodCIDRs: [10.233.64.0/24]
I0120 22:24:35.143934       1 iptables_restore.go:86] trying to run with payload
I0120 22:24:35.149420       1 main.go:342] Setting up masking rules
I0120 22:24:35.351635       1 main.go:364] Changing default FORWARD chain policy to ACCEPT
I0120 22:24:35.548989       1 main.go:379] Wrote subnet file to /run/flannel/subnet.env
I0120 22:24:35.549023       1 main.go:383] Running backend.
I0120 22:24:35.550470       1 vxlan_network.go:61] watching for new subnet leases
I0120 22:24:35.654947       1 main.go:404] Waiting for all goroutines to exit
I0120 22:24:36.845125       1 iptables.go:263] trying to run iptables-restore < map[filter:[[-I FORWARD -m comment --comment flanneld forward -j FLANNEL-FWD] [-A FLANNEL-FWD -s 10.233.64.0/18 -m comment --comment flanneld forward -j ACCEPT] [-A FLANNEL-FWD -d 10.233.64.0/18 -m comment --comment flanneld forward -j ACCEPT]]]
I0120 22:24:36.845226       1 iptables_restore.go:86] trying to run with payload *filter
-I FORWARD -m comment --comment "flanneld forward" -j FLANNEL-FWD
-A FLANNEL-FWD -s 10.233.64.0/18 -m comment --comment "flanneld forward" -j ACCEPT
-A FLANNEL-FWD -d 10.233.64.0/18 -m comment --comment "flanneld forward" -j ACCEPT
COMMIT
I0120 22:24:36.962429       1 iptables.go:270] bootstrap done
I0120 22:24:37.254425       1 iptables.go:263] trying to run iptables-restore < map[nat:[[-I POSTROUTING -m comment --comment flanneld masq -j FLANNEL-POSTRTG] [-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment flanneld masq -j RETURN] [-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment flanneld masq -j RETURN] [-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment flanneld masq -j MASQUERADE --random-fully] [-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment flanneld masq -j RETURN] [-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment flanneld masq -j MASQUERADE --random-fully]]]
I0120 22:24:37.254554       1 iptables_restore.go:86] trying to run with payload *nat
-I POSTROUTING -m comment --comment "flanneld masq" -j FLANNEL-POSTRTG
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE --random-fully
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE --random-fully
COMMIT
I0120 22:24:37.364103       1 iptables.go:270] bootstrap done
I0120 22:25:39.034170       1 kube.go:452] Creating the node lease for IPv4. This is the n.Spec.PodCIDRs: [10.233.65.0/24]
I0120 22:25:39.034855       1 vxlan_network.go:178] adding subnet: 10.233.65.0/24 PublicIP: 10.132.70.246 VtepMAC: e2:e0:9f:75:3e:24
I0120 22:25:39.034937       1 device.go:203] calling AddARP: 10.233.65.0, e2:e0:9f:75:3e:24
I0120 22:25:39.035070       1 device.go:157] calling AddFDB: 10.132.70.246, e2:e0:9f:75:3e:24
I0120 22:26:08.607526       1 kube.go:452] Creating the node lease for IPv4. This is the n.Spec.PodCIDRs: [10.233.66.0/24]
I0120 22:26:08.607784       1 vxlan_network.go:178] adding subnet: 10.233.66.0/24 PublicIP: 10.122.88.50 VtepMAC: 56:50:e6:2f:53:12
I0120 22:26:08.607811       1 device.go:203] calling AddARP: 10.233.66.0, 56:50:e6:2f:53:12
I0120 22:26:08.607895       1 device.go:157] calling AddFDB: 10.122.88.50, 56:50:e6:2f:53:12

After applying bugtest.yaml (things work at this point because we haven't rebooted yet).. Nothing new gets added to the pod log.

Now after a reboot, at this point bug is triggered:

I0120 22:32:32.107280       1 main.go:204] CLI flags config: {etcdEndpoints:http://127.0.0.1:4001,http://127.0.0.1:2379 etcdPrefix:/coreos.com/network etcdKeyfile: etcdCertfile: etcdCAFile: etcdUsername: etcdPassword: version:false kubeSubnetMgr:true kubeApiUrl: kubeAnnotationPrefix:flannel.alpha.coreos.com kubeConfigFile: iface:[] ifaceRegex:[] ipMasq:true ifaceCanReach: subnetFile:/run/flannel/subnet.env publicIP: publicIPv6: subnetLeaseRenewMargin:60 healthzIP:0.0.0.0 healthzPort:0 iptablesResyncSeconds:5 iptablesForwardRules:true netConfPath:/etc/kube-flannel/net-conf.json setNodeNetworkUnavailable:true}
W0120 22:32:32.107503       1 client_config.go:617] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
I0120 22:32:32.403557       1 kube.go:126] Waiting 10m0s for node controller to sync
I0120 22:32:32.403650       1 kube.go:431] Starting kube subnet manager
I0120 22:32:32.502058       1 kube.go:452] Creating the node lease for IPv4. This is the n.Spec.PodCIDRs: [10.233.65.0/24]
I0120 22:32:32.502127       1 kube.go:452] Creating the node lease for IPv4. This is the n.Spec.PodCIDRs: [10.233.66.0/24]
I0120 22:32:32.502146       1 kube.go:452] Creating the node lease for IPv4. This is the n.Spec.PodCIDRs: [10.233.64.0/24]
I0120 22:32:33.403923       1 kube.go:133] Node controller sync successful
I0120 22:32:33.403970       1 main.go:224] Created subnet manager: Kubernetes Subnet Manager - dalqaifxranch1
I0120 22:32:33.403991       1 main.go:227] Installing signal handlers
I0120 22:32:33.404238       1 main.go:467] Found network config - Backend type: vxlan
I0120 22:32:33.404305       1 match.go:206] Determining IP address of default interface
I0120 22:32:33.405044       1 match.go:259] Using interface with name ens192 and address 10.105.10.145
I0120 22:32:33.405097       1 match.go:281] Defaulting external address to interface address (10.105.10.145)
I0120 22:32:33.405256       1 vxlan.go:138] VXLAN config: VNI=1 Port=8472 GBP=false Learning=false DirectRouting=true
I0120 22:32:33.559221       1 kube.go:452] Creating the node lease for IPv4. This is the n.Spec.PodCIDRs: [10.233.64.0/24]
I0120 22:32:33.602450       1 main.go:416] Current network or subnet (10.233.64.0/18, 10.233.64.0/24) is not equal to previous one (0.0.0.0/0, 0.0.0.0/0), trying to recycle old iptables rules
I0120 22:32:35.706414       1 iptables_restore.go:86] trying to run with payload
I0120 22:32:35.807388       1 main.go:342] Setting up masking rules
I0120 22:32:36.003024       1 main.go:364] Changing default FORWARD chain policy to ACCEPT
I0120 22:32:36.203116       1 main.go:379] Wrote subnet file to /run/flannel/subnet.env
I0120 22:32:36.203150       1 main.go:383] Running backend.
I0120 22:32:36.203582       1 vxlan_network.go:61] watching for new subnet leases
I0120 22:32:36.207305       1 vxlan_network.go:178] adding subnet: 10.233.65.0/24 PublicIP: 10.132.70.246 VtepMAC: e2:e0:9f:75:3e:24
I0120 22:32:36.207346       1 device.go:203] calling AddARP: 10.233.65.0, e2:e0:9f:75:3e:24
I0120 22:32:36.207476       1 device.go:157] calling AddFDB: 10.132.70.246, e2:e0:9f:75:3e:24
I0120 22:32:36.207795       1 vxlan_network.go:178] adding subnet: 10.233.66.0/24 PublicIP: 10.122.88.50 VtepMAC: 56:50:e6:2f:53:12
I0120 22:32:36.207816       1 device.go:203] calling AddARP: 10.233.66.0, 56:50:e6:2f:53:12
I0120 22:32:36.208141       1 device.go:157] calling AddFDB: 10.122.88.50, 56:50:e6:2f:53:12
I0120 22:32:36.403410       1 main.go:404] Waiting for all goroutines to exit
I0120 22:32:37.306362       1 iptables.go:263] trying to run iptables-restore < map[filter:[[-I FORWARD -m comment --comment flanneld forward -j FLANNEL-FWD] [-A FLANNEL-FWD -s 10.233.64.0/18 -m comment --comment flanneld forward -j ACCEPT] [-A FLANNEL-FWD -d 10.233.64.0/18 -m comment --comment flanneld forward -j ACCEPT]]]
I0120 22:32:37.306473       1 iptables_restore.go:86] trying to run with payload *filter
-I FORWARD -m comment --comment "flanneld forward" -j FLANNEL-FWD
-A FLANNEL-FWD -s 10.233.64.0/18 -m comment --comment "flanneld forward" -j ACCEPT
-A FLANNEL-FWD -d 10.233.64.0/18 -m comment --comment "flanneld forward" -j ACCEPT
COMMIT
I0120 22:32:37.504652       1 iptables.go:270] bootstrap done
I0120 22:32:38.002602       1 iptables.go:263] trying to run iptables-restore < map[nat:[[-I POSTROUTING -m comment --comment flanneld masq -j FLANNEL-POSTRTG] [-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment flanneld masq -j RETURN] [-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment flanneld masq -j RETURN] [-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment flanneld masq -j MASQUERADE --random-fully] [-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment flanneld masq -j RETURN] [-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment flanneld masq -j MASQUERADE --random-fully]]]
I0120 22:32:38.002723       1 iptables_restore.go:86] trying to run with payload *nat
-I POSTROUTING -m comment --comment "flanneld masq" -j FLANNEL-POSTRTG
-A FLANNEL-POSTRTG -m mark --mark 0x4000/0x4000 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG -s 10.233.64.0/18 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE --random-fully
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/24 -m comment --comment "flanneld masq" -j RETURN
-A FLANNEL-POSTRTG ! -s 10.233.64.0/18 -d 10.233.64.0/18 -m comment --comment "flanneld masq" -j MASQUERADE --random-fully
COMMIT
I0120 22:32:38.108204       1 iptables.go:270] bootstrap done

@rbrtbnfgl
Copy link
Contributor

rbrtbnfgl commented Jan 23, 2023

The logs on flannel side seem rights. I'm checking if it could be an issue related to portmap.

@rbrtbnfgl
Copy link
Contributor

Are you using containerd? And which version?

@oe-hbk
Copy link
Author

oe-hbk commented Jan 23, 2023

Yes I am.

containerd containerd.io 1.6.9 1c90a442489720eec95342e1789ee8a5e1b9536f

@rbrtbnfgl
Copy link
Contributor

It could be containerd related containerd/containerd#7843
1.6.14 version should fix it.

@oe-hbk
Copy link
Author

oe-hbk commented Jan 23, 2023

upgraded to 1.6.15 (latest) and rebuilt the cluster, but no luck once again after reboot

@oe-hbk
Copy link
Author

oe-hbk commented Jan 23, 2023

I will also try upgrading k8s to 1.24.10

@oe-hbk
Copy link
Author

oe-hbk commented Jan 24, 2023

same thing with 1.24.10

@rbrtbnfgl
Copy link
Contributor

could you check kubelet logs too? Maybe we can find something there.

@oe-hbk
Copy link
Author

oe-hbk commented Jan 25, 2023

Nothing in the kubelet logs.

Should this pod to service (to pod on same node) be masqueraded? I am trying to follow the packet flow and having a hard time figuring out which path it should take.

@rbrtbnfgl
Copy link
Contributor

If you are using the Cluster-IP it's not masquerading the source IP but only changing the destination IP. There aren't any interfaces that are listening on the service-IP; iptables should change the destination IP to the right IP that are listening on that service.

@oe-hbk
Copy link
Author

oe-hbk commented Jan 27, 2023

Thank you @rbrtbnfgl . I finally found the issue. After comparing so many before and after reboots, iptables, config files, tcpdumps, sysctls. One thing I hadn't checked was loaded modules.
And sure enough, the now required br_netfilter module (it wasn't required before with our older 1.21 clusters with docker-shim) was missing after the initial install after a reboot. as soon as I modprobe br_netfilter in the broken state, it fixed itself.

Hopefully this helps someone. The docs lay this out, but I missed this. https://kubernetes.io/docs/setup/production-environment/container-runtimes/#forwarding-ipv4-and-letting-iptables-see-bridged-traffic

@oe-hbk
Copy link
Author

oe-hbk commented Jan 28, 2023

One final thing before I close the issue in case it helps someone else in the future. It's not that the br_netfilter module is newly required, it has long been, and I was config managing the cluster node builds through ansible and had used the https://docs.ansible.com/ansible/latest/collections/community/general/modprobe_module.html module to install br_netfilter. In my older clusters with older flannel, I did not run into any networking issues so never bothered to check, but that module does not persist the module load through reboots, which one would expect it to, either by default, or provide an option to. Anyway, with the new k8s version+flannel and with the missing module after reboot, things broke. So if you're using that ansible module to load kernel modules, be careful.

@oe-hbk oe-hbk closed this as completed Jan 28, 2023
nectar-gerrit pushed a commit to NeCTAR-RC/magnum that referenced this issue Mar 10, 2023
Flannel with VXLAN suffers from a bug[1] where pods on the same node are
unable to send traffic to a service's ClusterIP when the endpoint is on
the same node.

This is due to improper NATTing of the return traffic.

The fix is to load the br_netfilter module as specified in the
kubernetes doc.[2]

[1] flannel-io/flannel#1702
[2] https://kubernetes.io/docs/setup/production-environment/container-runtimes/#forwarding-ipv4-and-letting-iptables-see-bridged-traffic

Change-Id: Ic182bba9d480421c2cb581558ebde8dfb20421c8
openstack-mirroring pushed a commit to openstack/openstack that referenced this issue May 10, 2023
* Update magnum from branch 'master'
  to 2c193622de9a0bd7dfb7498686862a661489e966
  - Merge "Fix pods unable to send traffic to ClusterIP"
  - Fix pods unable to send traffic to ClusterIP
    
    Flannel with VXLAN suffers from a bug[1] where pods on the same node are
    unable to send traffic to a service's ClusterIP when the endpoint is on
    the same node.
    
    This is due to improper NATTing of the return traffic.
    
    The fix is to load the br_netfilter module as specified in the
    kubernetes doc.[2]
    
    [1] flannel-io/flannel#1702
    [2] https://kubernetes.io/docs/setup/production-environment/container-runtimes/#forwarding-ipv4-and-letting-iptables-see-bridged-traffic
    
    Change-Id: Ic182bba9d480421c2cb581558ebde8dfb20421c8
openstack-mirroring pushed a commit to openstack/magnum that referenced this issue May 10, 2023
Flannel with VXLAN suffers from a bug[1] where pods on the same node are
unable to send traffic to a service's ClusterIP when the endpoint is on
the same node.

This is due to improper NATTing of the return traffic.

The fix is to load the br_netfilter module as specified in the
kubernetes doc.[2]

[1] flannel-io/flannel#1702
[2] https://kubernetes.io/docs/setup/production-environment/container-runtimes/#forwarding-ipv4-and-letting-iptables-see-bridged-traffic

Change-Id: Ic182bba9d480421c2cb581558ebde8dfb20421c8
openstack-mirroring pushed a commit to openstack/magnum that referenced this issue May 31, 2023
Flannel with VXLAN suffers from a bug[1] where pods on the same node are
unable to send traffic to a service's ClusterIP when the endpoint is on
the same node.

This is due to improper NATTing of the return traffic.

The fix is to load the br_netfilter module as specified in the
kubernetes doc.[2]

[1] flannel-io/flannel#1702
[2] https://kubernetes.io/docs/setup/production-environment/container-runtimes/#forwarding-ipv4-and-letting-iptables-see-bridged-traffic

Change-Id: Ic182bba9d480421c2cb581558ebde8dfb20421c8
(cherry picked from commit ae7a50e)
nectar-gerrit pushed a commit to NeCTAR-RC/magnum that referenced this issue May 31, 2023
Flannel with VXLAN suffers from a bug[1] where pods on the same node are
unable to send traffic to a service's ClusterIP when the endpoint is on
the same node.

This is due to improper NATTing of the return traffic.

The fix is to load the br_netfilter module as specified in the
kubernetes doc.[2]

[1] flannel-io/flannel#1702
[2] https://kubernetes.io/docs/setup/production-environment/container-runtimes/#forwarding-ipv4-and-letting-iptables-see-bridged-traffic

Change-Id: Ic182bba9d480421c2cb581558ebde8dfb20421c8
(cherry picked from commit ae7a50e)
nectar-gerrit pushed a commit to NeCTAR-RC/magnum that referenced this issue Jun 11, 2024
Flannel with VXLAN suffers from a bug[1] where pods on the same node are
unable to send traffic to a service's ClusterIP when the endpoint is on
the same node.

This is due to improper NATTing of the return traffic.

The fix is to load the br_netfilter module as specified in the
kubernetes doc.[2]

[1] flannel-io/flannel#1702
[2] https://kubernetes.io/docs/setup/production-environment/container-runtimes/#forwarding-ipv4-and-letting-iptables-see-bridged-traffic

Change-Id: Ic182bba9d480421c2cb581558ebde8dfb20421c8
(cherry picked from commit ae7a50e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants