KUBE_SERVICE 在 iptables 中插入 REJECT 规则

KUBE_SERVICE inserting REJECT rules in iptables

我在 4 台 centos 7 机器上安装了 kubernetes 运行,master 和 minions。我还安装了 flannel 和 skydns。 flannel overlay ip是172.17.0.0/16,我的服务集群ip是10.254.0.0/16。我是 k8 集群上的 运行 spinnaker pods。我看到的是大三角帆服务无法找到对方。每个 pod 从 172.17 切片获取一个 ip,我可以使用该 ip 从任何节点 ping pods。然而,服务本身使用 cluser ip 并且无法相互交谈。由于 Kube-proxy 是应该转发此流量的那个,我查看了 iptable 规则,我看到了这个:

[root@MultiNode4 ~$]iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
DOCKER-ISOLATION  all  --  anywhere             anywhere
DOCKER     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
KUBE-SERVICES  all  --  anywhere             anywhere             /* kubernetes service portals */

Chain DOCKER (1 references)
target     prot opt source               destination

Chain DOCKER-ISOLATION (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain KUBE-SERVICES (1 references)
target     prot opt source               destination
REJECT     tcp  --  anywhere             10.254.206.105       /* spinnaker/spkr-clouddriver: has no endpoints */ tcp dpt:afs3-prserver reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             10.254.162.75        /* spinnaker/spkr-orca: has no endpoints */ tcp dpt:us-srv reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             10.254.62.109        /* spinnaker/spkr-rush: has no endpoints */ tcp dpt:8085 reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             10.254.68.125        /* spinnaker/spkr-echo: has no endpoints */ tcp dpt:8089 reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             10.254.123.127       /* spinnaker/spkr-front50: has no endpoints */ tcp dpt:webcache reject-with icmp-port-unreachable
REJECT     tcp  --  anywhere             10.254.36.197        /* spinnaker/spkr-gate: has no endpoints */ tcp dpt:8084 reject-with icmp-port-unreachable

好像kube-proxy无法转发。我在 kube-proxy 启动时没有错误:

[root@MultiNode4 ~$]systemctl status kube-proxy -l
kube-proxy.service - Kubernetes Kube-Proxy Server
   Loaded: loaded (/usr/lib/systemd/system/kube-proxy.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2016-07-07 02:54:54 EDT; 1h 10min ago
     Docs: https://github.com/GoogleCloudPlatform/kubernetes
 Main PID: 7866 (kube-proxy)
   Memory: 3.6M
   CGroup: /system.slice/kube-proxy.service
           └─7866 /usr/bin/kube-proxy --logtostderr=true --v=0 --master=http://centos-master:8080

Jul 07 02:54:54 clm-aus-015349.bmc.com systemd[1]: Started Kubernetes Kube-Proxy Server.
Jul 07 02:54:54 clm-aus-015349.bmc.com systemd[1]: Starting Kubernetes Kube-Proxy Server...
Jul 07 02:54:54 clm-aus-015349.bmc.com kube-proxy[7866]: E0707 02:54:54.754845    7866 server.go:340] Can't get Node "multiNode4", assuming iptables proxy: nodes "MultiNode4" not found
Jul 07 02:54:54 clm-aus-015349.bmc.com kube-proxy[7866]: I0707 02:54:54.756460    7866 server.go:200] Using iptables Proxier.
Jul 07 02:54:54 clm-aus-015349.bmc.com kube-proxy[7866]: I0707 02:54:54.756527    7866 proxier.go:208] missing br-netfilter module or unset br-nf-call-iptables; proxy may not work as intended
Jul 07 02:54:54 clm-aus-015349.bmc.com kube-proxy[7866]: I0707 02:54:54.756551    7866 server.go:213] Tearing down userspace rules.
Jul 07 02:54:54 clm-aus-015349.bmc.com kube-proxy[7866]: I0707 02:54:54.770100    7866 conntrack.go:36] Setting nf_conntrack_max to 262144
Jul 07 02:54:54 clm-aus-015349.bmc.com kube-proxy[7866]: I0707 02:54:54.770145    7866 conntrack.go:41] Setting conntrack hashsize to 65536
Jul 07 02:54:54 clm-aus-015349.bmc.com kube-proxy[7866]: I0707 02:54:54.771445    7866 conntrack.go:46] Setting nf_conntrack_tcp_timeout_established to 86400

我错过了什么?

当特定服务有 0 个端点时,将插入 REJECT。您的 Service.spec 中的选择器一定是错误的,或者您没有 pods 运行.

我也遇到了同样的问题,结果是选择器不对。 修复后,一切正常。