路由在 kubernetes 中无法使用 calico 工作

2024-01-26

I have

  • kubernetes v1.6.0 由 kubeadm v1.6.1 设置
  • 官方设置的 calicoyaml http://docs.projectcalico.org/v2.1/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
  • iptables v1.6.0
  • 节点由阿里云提供

Problem:

cni 网络不工作。任何部署只能从其运行的节点进行访问。我怀疑这与路由表冲突/丢失有关,因为我在 Vultr Cloud 上有另一个集群工作正常,具有相同的设置步骤。

集群信息:

root@iZ2ze8ctk2q17u029a8wcoZ:~# kubectl get pods --all-namespaces -o wide
NAMESPACE     NAME                                              READY     STATUS    RESTARTS   AGE       IP               NODE
kube-system   calico-etcd-66gf4                                 1/1       Running   0          16h       10.27.219.50     iz2ze8ctk2q17u029a8wcoz
kube-system   calico-node-4wxsb                                 2/2       Running   0          16h       10.27.219.50     iz2ze8ctk2q17u029a8wcoz
kube-system   calico-node-6n1g1                                 2/2       Running   0          16h       10.30.248.80     iz2zegw6nmd5t5qxy35lh0z
kube-system   calico-policy-controller-2561685917-7bdd4         1/1       Running   0          16h       10.30.248.80     iz2zegw6nmd5t5qxy35lh0z
kube-system   etcd-iz2ze8ctk2q17u029a8wcoz                      1/1       Running   0          16h       10.27.219.50     iz2ze8ctk2q17u029a8wcoz
kube-system   heapster-bx03l                                    1/1       Running   0          16h       192.168.31.150   iz2zegw6nmd5t5qxy35lh0z
kube-system   kube-apiserver-iz2ze8ctk2q17u029a8wcoz            1/1       Running   0          16h       10.27.219.50     iz2ze8ctk2q17u029a8wcoz
kube-system   kube-controller-manager-iz2ze8ctk2q17u029a8wcoz   1/1       Running   0          16h       10.27.219.50     iz2ze8ctk2q17u029a8wcoz
kube-system   kube-dns-3913472980-kgzln                         3/3       Running   0          16h       192.168.31.149   iz2zegw6nmd5t5qxy35lh0z
kube-system   kube-proxy-ck83t                                  1/1       Running   0          16h       10.30.248.80     iz2zegw6nmd5t5qxy35lh0z
kube-system   kube-proxy-lssdn                                  1/1       Running   0          16h       10.27.219.50     iz2ze8ctk2q17u029a8wcoz
kube-system   kube-scheduler-iz2ze8ctk2q17u029a8wcoz            1/1       Running   0          16h       10.27.219.50     iz2ze8ctk2q17u029a8wcoz

我检查了每个 pod 的日志,没有发现任何错误。

大师信息: 内部IP:10.27.219.50

root@iZ2ze8ctk2q17u029a8wcoZ:~# ifconfig

docker0   Link encap:Ethernet  HWaddr 02:42:56:84:35:19
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 00:16:3e:30:51:ae
          inet addr:10.27.219.50  Bcast:10.27.219.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4400927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3906530 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:564808928 (564.8 MB)  TX bytes:792611382 (792.6 MB)

eth1      Link encap:Ethernet  HWaddr 00:16:3e:32:07:f8
          inet addr:59.110.32.199  Bcast:59.110.35.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1148756 errors:0 dropped:0 overruns:0 frame:0
          TX packets:688177 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1570341044 (1.5 GB)  TX bytes:58104611 (58.1 MB)

tunl0     Link encap:IPIP Tunnel  HWaddr
          inet addr:192.168.201.0  Mask:255.255.255.255
          UP RUNNING NOARP  MTU:1440  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


root@iZ2ze8ctk2q17u029a8wcoZ:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         59.110.35.247   0.0.0.0         UG    0      0        0 eth1
10.27.216.0     0.0.0.0         255.255.252.0   U     0      0        0 eth0
10.30.0.0       10.27.219.247   255.255.0.0     UG    0      0        0 eth0
10.32.0.0       0.0.0.0         255.240.0.0     U     0      0        0 weave
59.110.32.0     0.0.0.0         255.255.252.0   U     0      0        0 eth1
100.64.0.0      10.27.219.247   255.192.0.0     UG    0      0        0 eth0
172.16.0.0      10.27.219.247   255.240.0.0     UG    0      0        0 eth0
172.17.0.0      0.0.0.0         255.255.255.0   U     0      0        0 docker0
192.168.201.0   0.0.0.0         255.255.255.192 U     0      0        0 *

root@iZ2ze8ctk2q17u029a8wcoZ:~# ip route list
default via 59.110.35.247 dev eth1
10.27.216.0/22 dev eth0  proto kernel  scope link  src 10.27.219.50
10.30.0.0/16 via 10.27.219.247 dev eth0
10.32.0.0/12 dev weave  proto kernel  scope link  src 10.32.0.1
59.110.32.0/22 dev eth1  proto kernel  scope link  src 59.110.32.199
100.64.0.0/10 via 10.27.219.247 dev eth0
172.16.0.0/12 via 10.27.219.247 dev eth0
172.17.0.0/24 dev docker0  proto kernel  scope link  src 172.17.0.1 linkdown
blackhole 192.168.201.0/26  proto bird

// NOTE: 10.30.0.0/16 via 10.27.219.247 dev eth0
// this rule is important, the worker node's ip is 10.30.xx.xx. If I delete this rule, I cannot ping worker node.
// this rule is 10.0.0.0/8 via 10.27.219.247 dev eth0 by default, I changed it to the above.


root@iZ2ze8ctk2q17u029a8wcoZ:~# iptables -t nat -nvL
Chain PREROUTING (policy ACCEPT 3 packets, 180 bytes)
 pkts bytes target     prot opt in     out     source               destination
20976 1250K cali-PREROUTING  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:6gwbT8clXdHdC1b1 */
21016 1252K KUBE-SERVICES  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes service portals */
20034 1193K DOCKER     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ADDRTYPE match dst-type LOCAL

Chain INPUT (policy ACCEPT 3 packets, 180 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 4 packets, 240 bytes)
 pkts bytes target     prot opt in     out     source               destination
 109K 6580K cali-OUTPUT  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:tVnHkvAo15HuiPy0 */
 111K 6738K KUBE-SERVICES  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes service portals */
 1263 75780 DOCKER     all  --  *      *       0.0.0.0/0           !127.0.0.0/8          ADDRTYPE match dst-type LOCAL

Chain POSTROUTING (policy ACCEPT 4 packets, 240 bytes)
 pkts bytes target     prot opt in     out     source               destination
86584 5235K cali-POSTROUTING  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:O3lYWMrLQYEMJtB5 */
    0     0 MASQUERADE  all  --  *      !docker0  172.17.0.0/24        0.0.0.0/0
3982K  239M KUBE-POSTROUTING  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes postrouting rules */
28130 1704K WEAVE      all  --  *      *       0.0.0.0/0            0.0.0.0/0

Chain DOCKER (2 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 RETURN     all  --  docker0 *       0.0.0.0/0            0.0.0.0/0

Chain KUBE-MARK-DROP (0 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            MARK or 0x8000

Chain KUBE-MARK-MASQ (5 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            MARK or 0x4000

Chain KUBE-NODEPORTS (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain KUBE-POSTROUTING (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MASQUERADE  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes service traffic requiring SNAT */ mark match 0x4000/0x4000

Chain KUBE-SEP-2VS52M6CEWASZVOP (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       192.168.31.149       0.0.0.0/0            /* kube-system/kube-dns:dns-tcp */
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/kube-dns:dns-tcp */ tcp to:192.168.31.149:53

Chain KUBE-SEP-3XQHSFTDAPNNNDX3 (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       192.168.31.150       0.0.0.0/0            /* kube-system/heapster: */
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/heapster: */ tcp to:192.168.31.150:8082

Chain KUBE-SEP-CH7KJM5XKO5WGA6D (2 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       10.27.219.50         0.0.0.0/0            /* default/kubernetes:https */
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* default/kubernetes:https */ recent: SET name: KUBE-SEP-CH7KJM5XKO5WGA6D side: source mask: 255.255.255.255 tcp to:10.27.219.50:6443

Chain KUBE-SEP-X3WTOMIYJNS7APAN (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       192.168.31.149       0.0.0.0/0            /* kube-system/kube-dns:dns */
    0     0 DNAT       udp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/kube-dns:dns */ udp to:192.168.31.149:53

Chain KUBE-SEP-YDCHDMTZNPMRRKCX (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       10.27.219.50         0.0.0.0/0            /* kube-system/calico-etcd: */
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/calico-etcd: */ tcp to:10.27.219.50:6666

Chain KUBE-SERVICES (2 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SVC-NPX46M4PTMTKRN6Y  tcp  --  *      *       0.0.0.0/0            10.96.0.1            /* default/kubernetes:https cluster IP */ tcp dpt:443
    0     0 KUBE-SVC-TCOU7JCQXEZGVUNU  udp  --  *      *       0.0.0.0/0            10.96.0.10           /* kube-system/kube-dns:dns cluster IP */ udp dpt:53
    0     0 KUBE-SVC-ERIFXISQEP7F7OF4  tcp  --  *      *       0.0.0.0/0            10.96.0.10           /* kube-system/kube-dns:dns-tcp cluster IP */ tcp dpt:53
    0     0 KUBE-SVC-NTYB37XIWATNM25Y  tcp  --  *      *       0.0.0.0/0            10.96.232.136        /* kube-system/calico-etcd: cluster IP */ tcp dpt:6666
    0     0 KUBE-SVC-BJM46V3U5RZHCFRZ  tcp  --  *      *       0.0.0.0/0            10.96.181.180        /* kube-system/heapster: cluster IP */ tcp dpt:80
    7   420 KUBE-NODEPORTS  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes service nodeports; NOTE: this must be the last rule in this chain */ ADDRTYPE match dst-type LOCAL

Chain KUBE-SVC-BJM46V3U5RZHCFRZ (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SEP-3XQHSFTDAPNNNDX3  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/heapster: */

Chain KUBE-SVC-ERIFXISQEP7F7OF4 (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SEP-2VS52M6CEWASZVOP  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/kube-dns:dns-tcp */

Chain KUBE-SVC-NPX46M4PTMTKRN6Y (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SEP-CH7KJM5XKO5WGA6D  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* default/kubernetes:https */ recent: CHECK seconds: 10800 reap name: KUBE-SEP-CH7KJM5XKO5WGA6D side: source mask: 255.255.255.255
    0     0 KUBE-SEP-CH7KJM5XKO5WGA6D  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* default/kubernetes:https */

Chain KUBE-SVC-NTYB37XIWATNM25Y (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SEP-YDCHDMTZNPMRRKCX  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/calico-etcd: */

Chain KUBE-SVC-TCOU7JCQXEZGVUNU (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SEP-X3WTOMIYJNS7APAN  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/kube-dns:dns */

Chain WEAVE (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 RETURN     all  --  *      *       10.32.0.0/12         224.0.0.0/4
    1    93 MASQUERADE  all  --  *      *      !10.32.0.0/12         10.32.0.0/12
    0     0 MASQUERADE  all  --  *      *       10.32.0.0/12        !10.32.0.0/12

Chain cali-OUTPUT (1 references)
 pkts bytes target     prot opt in     out     source               destination
 109K 6580K cali-fip-dnat  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:GBTAv2p5CwevEyJm */

Chain cali-POSTROUTING (1 references)
 pkts bytes target     prot opt in     out     source               destination
 109K 6571K cali-fip-snat  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:Z-c7XtVd2Bq7s_hA */
 109K 6571K cali-nat-outgoing  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:nYKhEzDlr11Jccal */
    0     0 MASQUERADE  all  --  *      tunl0   0.0.0.0/0            0.0.0.0/0            /* cali:JHlpT-eSqR1TvyYm */ ADDRTYPE match src-type !LOCAL limit-out ADDRTYPE match src-type LOCAL

Chain cali-PREROUTING (1 references)
 pkts bytes target     prot opt in     out     source               destination
20976 1250K cali-fip-dnat  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:r6XmIziWUJsdOK6Z */

Chain cali-fip-dnat (2 references)
 pkts bytes target     prot opt in     out     source               destination

Chain cali-fip-snat (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain cali-nat-outgoing (1 references)
 pkts bytes target     prot opt in     out     source               destination
    4   376 MASQUERADE  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:Wd76s91357Uv7N3v */ match-set cali4-masq-ipam-pools src ! match-set cali4-all-ipam-pools dst

工作节点信息: 内部IP:10.30.248.80

ifconfig

docker0   Link encap:Ethernet  HWaddr 02:42:58:2b:b5:39
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 00:16:3e:2e:3d:fd
          inet addr:10.30.248.80  Bcast:10.30.251.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3856596 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4253613 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:827402268 (827.4 MB)  TX bytes:510838231 (510.8 MB)

eth1      Link encap:Ethernet  HWaddr 00:16:3e:2c:db:d1
          inet addr:47.93.161.177  Bcast:47.93.163.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:890451 errors:0 dropped:0 overruns:0 frame:0
          TX packets:825607 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1695352720 (1.6 GB)  TX bytes:62341312 (62.3 MB)

tunl0     Link encap:IPIP Tunnel  HWaddr
          inet addr:192.168.31.128  Mask:255.255.255.255
          UP RUNNING NOARP  MTU:1440  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


root@iZ2zegw6nmd5t5qxy35lh0Z:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         47.93.163.247   0.0.0.0         UG    0      0        0 eth1
10.0.0.0        10.30.251.247   255.0.0.0       UG    0      0        0 eth0
10.30.248.0     0.0.0.0         255.255.252.0   U     0      0        0 eth0
47.93.160.0     0.0.0.0         255.255.252.0   U     0      0        0 eth1
100.64.0.0      10.30.251.247   255.192.0.0     UG    0      0        0 eth0
172.16.0.0      10.30.251.247   255.240.0.0     UG    0      0        0 eth0
172.17.0.0      0.0.0.0         255.255.255.0   U     0      0        0 docker0
192.168.31.128  0.0.0.0         255.255.255.192 U     0      0        0 *
192.168.31.149  0.0.0.0         255.255.255.255 UH    0      0        0 cali3567b3362cc
192.168.31.150  0.0.0.0         255.255.255.255 UH    0      0        0 cali9d04015b0e7

root@iZ2zegw6nmd5t5qxy35lh0Z:~# ip route list
default via 47.93.163.247 dev eth1
10.0.0.0/8 via 10.30.251.247 dev eth0
10.30.248.0/22 dev eth0  proto kernel  scope link  src 10.30.248.80
47.93.160.0/22 dev eth1  proto kernel  scope link  src 47.93.161.177
100.64.0.0/10 via 10.30.251.247 dev eth0
172.16.0.0/12 via 10.30.251.247 dev eth0
172.17.0.0/24 dev docker0  proto kernel  scope link  src 172.17.0.1 linkdown
blackhole 192.168.31.128/26  proto bird
192.168.31.149 dev cali3567b3362cc  scope link
192.168.31.150 dev cali9d04015b0e7  scope link

// NOTE: 10.0.0.0/8 via 10.30.251.247 dev eth0
// I didn't change this one. So it is default now.


root@iZ2zegw6nmd5t5qxy35lh0Z:~# iptables -t nat -nvL
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
 3524  263K cali-PREROUTING  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:6gwbT8clXdHdC1b1 */
 3527  263K KUBE-SERVICES  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes service portals */
 1031 53882 DOCKER     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ADDRTYPE match dst-type LOCAL

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 4 packets, 240 bytes)
 pkts bytes target     prot opt in     out     source               destination
84174 5099K cali-OUTPUT  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:tVnHkvAo15HuiPy0 */
85201 5163K KUBE-SERVICES  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes service portals */
    0     0 DOCKER     all  --  *      *       0.0.0.0/0           !127.0.0.0/8          ADDRTYPE match dst-type LOCAL

Chain POSTROUTING (policy ACCEPT 7 packets, 420 bytes)
 pkts bytes target     prot opt in     out     source               destination
76279 4644K cali-POSTROUTING  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:O3lYWMrLQYEMJtB5 */
    0     0 MASQUERADE  all  --  *      !docker0  172.17.0.0/24        0.0.0.0/0
87179 5342K KUBE-POSTROUTING  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes postrouting rules */
43815 2646K WEAVE      all  --  *      *       0.0.0.0/0            0.0.0.0/0

Chain DOCKER (2 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 RETURN     all  --  docker0 *       0.0.0.0/0            0.0.0.0/0

Chain KUBE-MARK-DROP (0 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            MARK or 0x8000

Chain KUBE-MARK-MASQ (5 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0            MARK or 0x4000

Chain KUBE-NODEPORTS (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain KUBE-POSTROUTING (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MASQUERADE  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes service traffic requiring SNAT */ mark match 0x4000/0x4000

Chain KUBE-SEP-2VS52M6CEWASZVOP (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       192.168.31.149       0.0.0.0/0            /* kube-system/kube-dns:dns-tcp */
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/kube-dns:dns-tcp */ tcp to:192.168.31.149:53

Chain KUBE-SEP-3XQHSFTDAPNNNDX3 (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       192.168.31.150       0.0.0.0/0            /* kube-system/heapster: */
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/heapster: */ tcp to:192.168.31.150:8082

Chain KUBE-SEP-CH7KJM5XKO5WGA6D (2 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       10.27.219.50         0.0.0.0/0            /* default/kubernetes:https */
    3   180 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* default/kubernetes:https */ recent: SET name: KUBE-SEP-CH7KJM5XKO5WGA6D side: source mask: 255.255.255.255 tcp to:10.27.219.50:6443

Chain KUBE-SEP-X3WTOMIYJNS7APAN (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       192.168.31.149       0.0.0.0/0            /* kube-system/kube-dns:dns */
    0     0 DNAT       udp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/kube-dns:dns */ udp to:192.168.31.149:53

Chain KUBE-SEP-YDCHDMTZNPMRRKCX (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-MARK-MASQ  all  --  *      *       10.27.219.50         0.0.0.0/0            /* kube-system/calico-etcd: */
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/calico-etcd: */ tcp to:10.27.219.50:6666

Chain KUBE-SERVICES (2 references)
 pkts bytes target     prot opt in     out     source               destination
    3   180 KUBE-SVC-NPX46M4PTMTKRN6Y  tcp  --  *      *       0.0.0.0/0            10.96.0.1            /* default/kubernetes:https cluster IP */ tcp dpt:443
    0     0 KUBE-SVC-TCOU7JCQXEZGVUNU  udp  --  *      *       0.0.0.0/0            10.96.0.10           /* kube-system/kube-dns:dns cluster IP */ udp dpt:53
    0     0 KUBE-SVC-ERIFXISQEP7F7OF4  tcp  --  *      *       0.0.0.0/0            10.96.0.10           /* kube-system/kube-dns:dns-tcp cluster IP */ tcp dpt:53
    0     0 KUBE-SVC-NTYB37XIWATNM25Y  tcp  --  *      *       0.0.0.0/0            10.96.232.136        /* kube-system/calico-etcd: cluster IP */ tcp dpt:6666
    0     0 KUBE-SVC-BJM46V3U5RZHCFRZ  tcp  --  *      *       0.0.0.0/0            10.96.181.180        /* kube-system/heapster: cluster IP */ tcp dpt:80
    0     0 KUBE-NODEPORTS  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kubernetes service nodeports; NOTE: this must be the last rule in this chain */ ADDRTYPE match dst-type LOCAL

Chain KUBE-SVC-BJM46V3U5RZHCFRZ (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SEP-3XQHSFTDAPNNNDX3  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/heapster: */

Chain KUBE-SVC-ERIFXISQEP7F7OF4 (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SEP-2VS52M6CEWASZVOP  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/kube-dns:dns-tcp */

Chain KUBE-SVC-NPX46M4PTMTKRN6Y (1 references)
 pkts bytes target     prot opt in     out     source               destination
    3   180 KUBE-SEP-CH7KJM5XKO5WGA6D  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* default/kubernetes:https */ recent: CHECK seconds: 10800 reap name: KUBE-SEP-CH7KJM5XKO5WGA6D side: source mask: 255.255.255.255
    0     0 KUBE-SEP-CH7KJM5XKO5WGA6D  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* default/kubernetes:https */

Chain KUBE-SVC-NTYB37XIWATNM25Y (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SEP-YDCHDMTZNPMRRKCX  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/calico-etcd: */

Chain KUBE-SVC-TCOU7JCQXEZGVUNU (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 KUBE-SEP-X3WTOMIYJNS7APAN  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* kube-system/kube-dns:dns */

Chain WEAVE (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain cali-OUTPUT (1 references)
 pkts bytes target     prot opt in     out     source               destination
84174 5099K cali-fip-dnat  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:GBTAv2p5CwevEyJm */

Chain cali-POSTROUTING (1 references)
 pkts bytes target     prot opt in     out     source               destination
86501 5298K cali-fip-snat  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:Z-c7XtVd2Bq7s_hA */
86501 5298K cali-nat-outgoing  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:nYKhEzDlr11Jccal */
    0     0 MASQUERADE  all  --  *      tunl0   0.0.0.0/0            0.0.0.0/0            /* cali:JHlpT-eSqR1TvyYm */ ADDRTYPE match src-type !LOCAL limit-out ADDRTYPE match src-type LOCAL

Chain cali-PREROUTING (1 references)
 pkts bytes target     prot opt in     out     source               destination
 3524  263K cali-fip-dnat  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:r6XmIziWUJsdOK6Z */

Chain cali-fip-dnat (2 references)
 pkts bytes target     prot opt in     out     source               destination

Chain cali-fip-snat (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain cali-nat-outgoing (1 references)
 pkts bytes target     prot opt in     out     source               destination
   29  1726 MASQUERADE  all  --  *      *       0.0.0.0/0            0.0.0.0/0            /* cali:Wd76s91357Uv7N3v */ match-set cali4-masq-ipam-pools src ! match-set cali4-all-ipam-pools dst

问题发现者是calicoctl node status。 calico/node 使用公共 IP 相互通信。但阿里云中的节点都位于防火墙后面。所以他们不能通过公共 IP 地址来做到这一点。

正如gunjan5建议的那样,我使用了这个环境变量IP_AUTODETECTION_METHOD指定内部接口。问题解决了。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

路由在 kubernetes 中无法使用 calico 工作 的相关文章

  • 支持 Kubernetes NodePort 服务的 SSL/TLS

    问题 我需要通过 https 向外部公开 Kubernetes NodePort 服务 设置 我已经在裸机上部署了 Kubernetes 并且已经部署Polyaxon https github com polyaxon polyaxon通过
  • 如何在 pod 之间或 kubernetes 集群中的节点之间复制文件?

    在 kubernetes 集群中可以这样做吗 我发现的所有示例都是从本地磁盘复制到 Pod 反之亦然 或者是从一个节点复制到另一个节点的唯一选项 例如通过 SSH SCP 或使用其他实用程序 无法进行集群到集群的复制 你需要使用kubect
  • Kubernetes,VolumeMount 一个文件,而不是一个目录

    我将使用 K8S 来编排 docker 容器 在 k8s 中 我需要从主机目录复制一个文件 configs nginx cas server conf 到 pod 容器目录 etc nginx nginx conf 但是目前的k8s只允许挂
  • 获取 Pod 处于挂起状态的平均时间

    我正在尝试使用 prometheus 计算 pod 在 grafana 中处于挂起状态的平均时间 我可以使用此查询生成一个图表 以获取一段时间内处于挂起状态的 Pod 数量 sum kube pod status phase phase P
  • 检查 Kubernetes 资源 CronJob 的日志

    我创建了一个CronJob https kubernetes io docs concepts workloads controllers cron jobs Kubernetes 中的资源 我想检查日志以验证我的 cron 是否正在运行
  • 我应该在 Kubernetes 前面添加 DMZ 吗?

    Kubernetes Ingress 是否足够安全 可以避免在 Kubernetes 前面添加 DMZ 来暴露 Pod 和服务 如果有人 黑进 Pod 会发生什么 Thanks 这是一个意见问题 所以我会用一个选项来回答 如果您遵循 这是非
  • 应用程序网关如何防止请求发送到最近终止的 Pod?

    我目前正在 Azure 中研究和试验 Kubernetes 我正在使用 AKS 和应用程序网关入口 据我了解 当 Pod 添加到服务时 端点会更新 入口控制器会不断轮询此信息 随着新端点的添加 AG 也会更新 当它们被移除时 AG 也被更新
  • 如何在独占节点中运行两个 Pod?

    我想在独占节点中运行两个 Pod 例如 我有 4 个节点 node 1 node 2 node 3 node 4 和 2 个 pod pod 1 pod 2 我希望每个节点中只运行一个 pod 并且每个 pod 运行在两个节点中 例如pod
  • 为什么ReadWriteOnce在不同的节点上工作?

    我们在 K8s 上运行的平台有不同的组件 我们需要在其中两个组件 comp A 和 comp B 之间共享存储 但我们错误地将 PV 和 PVC 定义为ReadWriteOnce即使这两个组件在不同的节点上运行 一切都正常 我们能够从两个组
  • 如何在 Helm 图表中配置 docker 入口点

    我有以下内容docker compose文件 我不明白如何设置working dir and entrypoint在掌舵deployment yaml 有人有关于如何执行此操作的示例吗 docker compose version 3 5
  • 如何在Prometheus中查询容器内存限制

    我正在使用 Prometheus 工具来监控我的 Kubernetes 集群 我在部署中设置了资源限制 内存限制 并且需要配置一个面板来显示可用的总内存 请让我知道在 Prometheus 中运行以获得可用于我的部署的总内存限制所需的查询
  • Kubernetes 水平 Pod 自动缩放初始延迟?

    Kubernetes 水平 Pod 自动缩放中是否有配置来指定在放大 缩小之前运行或创建 Pod 的最小延迟 例如 I am looking for a flag like this horizontal pod autoscale ini
  • Kubernetes 服务 IP 会变化吗?

    我对 kubernetes docker 非常陌生 所以如果这是一个愚蠢的问题 我深表歉意 我有一个正在访问一些服务的 Pod 在我的容器中 我正在运行 python 脚本并需要访问该服务 目前我正在使用服务的 IP 地址来执行此操作 服务
  • 如何在minikube中创建多个集群

    我需要在 minikube 中创建额外的集群 我搜索了一段时间没有找到任何这方面的资源 如何在 minikube 中创建集群 创建第一个名为cluster 1 minikube start p cluster 1 创建第二个集群 名称为cl
  • 如何在 GKE 上为 Kubernetes Ingress 强制使用 SSL

    有没有办法强制对入口负载均衡器上的传入连接进行 SSL 升级 或者 如果这是不可能的 我可以禁用端口 80吗 我还没有找到一个好的文档页面来概述 YAML 文件中的此类选项 预先非常感谢 https github com kubernete
  • 在 Kubernetes Pod 部署名称上添加随机字符串

    我有一个模板 它基本上是一个实用程序容器 用于在 pod 内运行 kubectl 我想要做的是能够使用不同的名称对同一模板进行多个部署 如 utilitypod randomID 中所示 有没有办法通过 kubectl 和一些 shell
  • Kubernetes 的调度器是如何工作的?

    Kubernetes 的调度器是如何工作的 我的意思是说Kubernetes的调度器看起来很简单 我最初的想法是这个调度器只是一个简单的准入控制系统 而不是真正的调度器 是这样正确的吗 我找到了一个简短的描述 但信息并不丰富 kuberne
  • Ingress 未在 GKE 和 GCE 上获取地址

    创建入口时 不会生成地址 并且从 GKE 仪表板查看时 它始终位于Creating ingress地位 描述入口没有显示任何事件 我在 GKE 仪表板上看不到任何线索 有没有人有类似的问题或关于如何调试的任何建议 我的部署 yaml api
  • 如何使用 Fabric8 maven 插件使用环境变量中的值指定 spring.profiles.active 参数?

    我有一个定义 ENVIRONMENT 参数的 K8s 配置映射 该值使用 src fabric8 deployment yml 中的摘录作为环境变量安装在部署 yaml 上 spec template spec containers env
  • 无法访问通过 NodePort 暴露的 Kubernetes 服务

    我正在使用 minikube 在最新的 MacOS 上测试 kubernetes 这是我的相关 YAML 命名空间 yml apiVersion v1 kind Namespace metadata name micro labels na

随机推荐