I have
- Kubernetes: v.1.1.1
- iptables v1.4.21
- Kernel: 4.2.0-18-generic that ship with Ubuntu wily
- Networking is done through the L2 VLAN completed on the switch.
- cloud provider
What am I doing
I am experimenting with iptables mode for kube-proxy. I included it with the argument --proxy_mode=iptables . The rule seems to be missing:
iptables -t nat -nvL Chain PREROUTING (policy ACCEPT 8 packets, 459 bytes) pkts bytes target prot opt in out source destination 2116 120K KUBE-SERVICES all -- * * 0.0.0.0/0 0.0.0.0/0 Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 2 packets, 120 bytes) pkts bytes target prot opt in out source destination 718 45203 KUBE-SERVICES all -- * * 0.0.0.0/0 0.0.0.0/0 Chain POSTROUTING (policy ACCEPT 5 packets, 339 bytes) pkts bytes target prot opt in out source destination 0 0 MASQUERADE all -- * * 0.0.0.0/0 0.0.0.0/0 mark match 0x4d415351 Chain KUBE-NODEPORTS (1 references) pkts bytes target prot opt in out source destination 0 0 MARK tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:31195 MARK set 0x4d415351 0 0 KUBE-SVC-XZFGDLM7GMJHZHOY tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:31195 0 0 MARK tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:30873 MARK set 0x4d415351 0 0 KUBE-SVC-GLKZVFIDXOFHLJLC tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:30873 Chain KUBE-SEP-5IXMK7UWPGVTWOJ7 (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.160.8 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.160.8:22 Chain KUBE-SEP-BNPLX5HQYOZINWEQ (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.161.6 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.161.6:8086 Chain KUBE-SEP-CJMHKLXPTJLTE3OP (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.254.2 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.254.2:6443 Chain KUBE-SEP-GSM3BZTEXEBWDXPN (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.160.7 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp to:10.116.160.7:53 Chain KUBE-SEP-OAYOAJINXRPUQDA3 (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.160.7 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.160.7:53 Chain KUBE-SEP-PJJZDQNXDGWM7MU6 (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.160.5 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.160.5:443 Chain KUBE-SEP-RWODGLKOVWXGOHUR (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.161.6 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.161.6:8083 Chain KUBE-SEP-WE3Z7KMHA6KPJWKK (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.161.6 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.161.6:8080 Chain KUBE-SEP-YBQVM4LA4YMMZIWH (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.161.3 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.161.3:8082 Chain KUBE-SEP-YMZS7BLP4Y6MWTX5 (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.160.9 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.160.9:5000 Chain KUBE-SEP-ZDOOYAKDERKR43R3 (1 references) pkts bytes target prot opt in out source destination 0 0 MARK all -- * * 10.116.160.10 0.0.0.0/0 MARK set 0x4d415351 0 0 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp to:10.116.160.10:5601 Chain KUBE-SERVICES (2 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SVC-JRXTEHDDTAFMSEAS tcp -- * * 0.0.0.0/0 10.116.0.48 tcp dpt:80 0 0 KUBE-SVC-CK6HVV5A27TDFNIA tcp -- * * 0.0.0.0/0 10.116.0.188 tcp dpt:8086 0 0 KUBE-SVC-DKEW3YDJFV3YJLS2 tcp -- * * 0.0.0.0/0 10.116.0.6 tcp dpt:5000 0 0 KUBE-SVC-TCOU7JCQXEZGVUNU udp -- * * 0.0.0.0/0 10.116.0.2 udp dpt:53 0 0 KUBE-SVC-WEHLQ23XZWSA5ZX3 tcp -- * * 0.0.0.0/0 10.116.0.188 tcp dpt:8083 0 0 KUBE-SVC-XZFGDLM7GMJHZHOY tcp -- * * 0.0.0.0/0 10.116.1.142 tcp dpt:443 0 0 MARK tcp -- * * 0.0.0.0/0 10.116.254.3 tcp dpt:443 MARK set 0x4d415351 0 0 KUBE-SVC-XZFGDLM7GMJHZHOY tcp -- * * 0.0.0.0/0 10.116.254.3 tcp dpt:443 PHYSDEV match ! --physdev-is-in ADDRTYPE match src-type !LOCAL 0 0 KUBE-SVC-XZFGDLM7GMJHZHOY tcp -- * * 0.0.0.0/0 10.116.254.3 tcp dpt:443 ADDRTYPE match dst-type LOCAL 0 0 KUBE-SVC-ERIFXISQEP7F7OF4 tcp -- * * 0.0.0.0/0 10.116.0.2 tcp dpt:53 0 0 KUBE-SVC-7IHGTXJ4CF2KVXJZ tcp -- * * 0.0.0.0/0 10.116.1.126 tcp dpt:80 0 0 KUBE-SVC-GLKZVFIDXOFHLJLC tcp -- * * 0.0.0.0/0 10.116.1.175 tcp dpt:2345 0 0 MARK tcp -- * * 0.0.0.0/0 10.116.254.3 tcp dpt:2345 MARK set 0x4d415351 0 0 KUBE-SVC-GLKZVFIDXOFHLJLC tcp -- * * 0.0.0.0/0 10.116.254.3 tcp dpt:2345 PHYSDEV match ! --physdev-is-in ADDRTYPE match src-type !LOCAL 0 0 KUBE-SVC-GLKZVFIDXOFHLJLC tcp -- * * 0.0.0.0/0 10.116.254.3 tcp dpt:2345 ADDRTYPE match dst-type LOCAL 0 0 KUBE-SVC-6N4SJQIF3IX3FORG tcp -- * * 0.0.0.0/0 10.116.0.1 tcp dpt:443 0 0 KUBE-SVC-B6ZEWWY2BII6JG2L tcp -- * * 0.0.0.0/0 10.116.0.233 tcp dpt:8888 0 0 MARK tcp -- * * 0.0.0.0/0 10.116.254.3 tcp dpt:8888 MARK set 0x4d415351 0 0 KUBE-SVC-B6ZEWWY2BII6JG2L tcp -- * * 0.0.0.0/0 10.116.254.3 tcp dpt:8888 PHYSDEV match ! --physdev-is-in ADDRTYPE match src-type !LOCAL 0 0 KUBE-SVC-B6ZEWWY2BII6JG2L tcp -- * * 0.0.0.0/0 10.116.254.3 tcp dpt:8888 ADDRTYPE match dst-type LOCAL 0 0 KUBE-NODEPORTS all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL Chain KUBE-SVC-6N4SJQIF3IX3FORG (1 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-CJMHKLXPTJLTE3OP all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-7IHGTXJ4CF2KVXJZ (1 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-YBQVM4LA4YMMZIWH all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-B6ZEWWY2BII6JG2L (3 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-ZDOOYAKDERKR43R3 all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-CK6HVV5A27TDFNIA (1 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-BNPLX5HQYOZINWEQ all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-DKEW3YDJFV3YJLS2 (1 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-YMZS7BLP4Y6MWTX5 all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-ERIFXISQEP7F7OF4 (1 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-OAYOAJINXRPUQDA3 all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-GLKZVFIDXOFHLJLC (4 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-5IXMK7UWPGVTWOJ7 all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-JRXTEHDDTAFMSEAS (1 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-WE3Z7KMHA6KPJWKK all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-TCOU7JCQXEZGVUNU (1 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-GSM3BZTEXEBWDXPN all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-WEHLQ23XZWSA5ZX3 (1 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-RWODGLKOVWXGOHUR all -- * * 0.0.0.0/0 0.0.0.0/0 Chain KUBE-SVC-XZFGDLM7GMJHZHOY (4 references) pkts bytes target prot opt in out source destination 0 0 KUBE-SEP-PJJZDQNXDGWM7MU6 all -- * * 0.0.0.0/0 0.0.0.0/0
When I request the ip address of the service, in my case it is 10.116.0.2. I got an error message
;; connection timed out; no servers could be reached
when I request the server 10.116.160.7 it works fine. I see that the traffic is not directed at all to the kube-proxy rules, so maybe something is missing.
I appreciate any hint of a lack of rule
EDIT Ive updated my initial request with the missing information requested by thokin, it pointed out a really good way to debug iptables rules for kube-proxy, and I could identify my problem:
for c in PREROUTING OUTPUT POSTROUTING; do iptables -t nat -I $c -d 10.116.160.7 -j LOG --log-prefix " DBG@ $c: "; done for c in PREROUTING OUTPUT POSTROUTING; do iptables -t nat -I $c -d 10.116.0.2 -j LOG --log-prefix " DBG@ $c: "; done
Then I ran the following commands: # nslookup kubernetes.default.svc.psc01.cluster 10.116.160.7 Server: 10.116.160.7 Address: 10.116.160.7 # 53
Name: kubernetes.default.svc.psc01.cluster Address: 10.116.0.1 # nslookup kubernetes.default.svc.psc01.cluster 10.116.0.2 ;; connection timed out; no servers could be reached
As a result, I have another "source" address and an outgoing interface:
[701768.263847] DBG@OUTPUT : IN= OUT=bond1.300 SRC=10.116.250.252 DST=10.116.0.2 LEN=82 TOS=0x00 PREC=0x00 TTL=64 ID=12436 PROTO=UDP SPT=54501 DPT=53 LEN=62 [702620.454211] DBG@OUTPUT : IN= OUT=docker0 SRC=10.116.176.1 DST=10.116.160.7 LEN=82 TOS=0x00 PREC=0x00 TTL=64 ID=22733 PROTO=UDP SPT=28704 DPT=53 LEN=62 [702620.454224] DBG@POSTROUTING : IN= OUT=docker0 SRC=10.116.176.1 DST=10.116.160.7 LEN=82 TOS=0x00 PREC=0x00 TTL=64 ID=22733 PROTO=UDP SPT=28704 DPT=53 LEN=62 [702626.318258] DBG@OUTPUT : IN= OUT=bond1.300 SRC=10.116.250.252 DST=10.116.0.2 LEN=82 TOS=0x00 PREC=0x00 TTL=64 ID=30608 PROTO=UDP SPT=39443 DPT=53 LEN=62 [702626.318263] DBG@OUTPUT : IN= OUT=bond1.300 SRC=10.116.250.252 DST=10.116.0.2 LEN=82 TOS=0x00 PREC=0x00 TTL=64 ID=30608 PROTO=UDP SPT=39443 DPT=53 LEN=62 [702626.318266] DBG@OUTPUT : IN= OUT=bond1.300 SRC=10.116.250.252 DST=10.116.0.2 LEN=82 TOS=0x00 PREC=0x00 TTL=64 ID=30608 PROTO=UDP SPT=39443 DPT=53 LEN=62 [702626.318270] DBG@OUTPUT : IN= OUT=bond1.300 SRC=10.116.250.252 DST=10.116.0.2 LEN=82 TOS=0x00 PREC=0x00 TTL=64 ID=30608 PROTO=UDP SPT=39443 DPT=53 LEN=62 [702626.318284] DBG@POSTROUTING : IN= OUT=docker0 SRC=10.116.250.252 DST=10.116.160.7 LEN=82 TOS=0x00 PREC=0x00 TTL=64 ID=30608 PROTO=UDP SPT=39443 DPT=53 LEN=62
So by adding a route
ip route add 10.116.0.0/23 dev docker0
Now it works great!