[root@k8s-m1 ~]# kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODENOMINATEDNODEREADINESS GATES busybox 1/1 Running 44h53m 10.244.215.68 k8s-n1 <none><none> nginx-7fb7fd49b4-946941/1 Running 046h10.244.111.195 k8s-n2 <none><none>
  通过tcpdump抓包可以看到首先容器会发送一个arp广播问169.254.1.1的MAC地址是多少,告诉10.244.215.81 这IP。其实这个IP就是当前Pod自己的IP,也就是告诉自己。然后cali03d85d58f77这个ARP请求,并回复告诉容器我拥有这个IP的MAC,他的MAC地址是ee:ee:ee:ee:ee:ee。如果你想验证你可以使用ip link set dev cali03d85d58f77 address ee:ee:ee:ee:11:11修改cali03d85d58f77网卡的MAC地址,然后你在抓包看看效果。
/ # ip neigh 169.254.1.1 dev eth0 lladdr ee:ee:ee:ee:11:11 ref 1 used 0/0/0 probes 1 REACHABLE 192.168.28.13 dev eth0 lladdr ee:ee:ee:ee:ee:ee used 0/0/0 probes 0 STALE
# no effect. This should fall within `--cluster-cidr`. -name:CALICO_IPV4POOL_CIDR value:"10.244.0.0/16" # Cluster type to identify the deployment type -name:CLUSTER_TYPE value:"k8s,bgp" # IP automatic detection -name:IP_AUTODETECTION_METHOD value:"interface=en.*" # Auto-detect the BGP IP address. -name:IP value:"autodetect" # Enable IPIP -name:CALICO_IPV4POOL_IPIP value:"Never" -name:FELIX_IPTABLESBACKEND value:"nft"# iptables大于1.8版本时设置
[root@devops010015001003 ~]# kubectl apply -f calico.yaml configmap/calico-config created customresourcedefinition.apiextensions.k8s.io/bgpconfigurations.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/bgppeers.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/blockaffinities.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/clusterinformations.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/felixconfigurations.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/globalnetworkpolicies.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/globalnetworksets.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/hostendpoints.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/ipamblocks.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/ipamconfigs.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/ipamhandles.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/ippools.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/kubecontrollersconfigurations.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/networkpolicies.crd.projectcalico.org created customresourcedefinition.apiextensions.k8s.io/networksets.crd.projectcalico.org created clusterrole.rbac.authorization.k8s.io/calico-kube-controllers created clusterrolebinding.rbac.authorization.k8s.io/calico-kube-controllers created clusterrole.rbac.authorization.k8s.io/calico-node created clusterrolebinding.rbac.authorization.k8s.io/calico-node created service/calico-typha created deployment.apps/calico-typha created poddisruptionbudget.policy/calico-typha created daemonset.apps/calico-node created serviceaccount/calico-node created deployment.apps/calico-kube-controllers created serviceaccount/calico-kube-controllers created
1 2 3 4 5 6 7 8 9 10
[root@devops010015001003 ~]# kubectl get pod -n kube-system NAME READY STATUS RESTARTS AGE calico-kube-controllers-789f6df884-fxgcl 1/1 Running 04m55s calico-node-28hx71/1 Running 04m55s calico-node-fqk8n1/1 Running 04m55s calico-node-plb4z1/1 Running 04m55s calico-node-ppgpb1/1 Running 04m55s calico-node-x9gfj1/1 Running 04m55s calico-typha-7698958d65-6j5jr 1/1 Running 04m55s calico-typha-7698958d65-b4tn6 1/1 Running 04m55s
[root@devops010015001003 overlord]# calicoctl get bgpconfig -o wide NAME LOGSEVERITY MESHENABLED ASNUMBER defaultfalse64512
此时在反射器节点上使用 calicoctl node status 应该能看到类似如下输出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[root@devops010015001003 overlord]# calicoctl node status Calico process is running.
IPv4 BGP status +--------------+---------------+-------+----------+-------------+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +--------------+---------------+-------+----------+-------------+ | 10.15.1.4 | node specific | up | 01:12:40 | Established | | 10.15.1.5 | node specific | up | 01:12:46 | Established | | 10.15.1.6 | node specific | up | 01:12:46 | Established | | 10.15.1.7 | node specific | up | 01:12:46 | Established | +--------------+---------------+-------+----------+-------------+
IPv6 BGP status No IPv6 peers found.
在非反射器节点上,您应该只看到两个对等体。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
[root@devops010015001005 overlord]# calicoctl node status Calico process is running.
IPv4 BGP status +--------------+---------------+-------+----------+-------------+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +--------------+---------------+-------+----------+-------------+ | 10.15.1.3 | node specific | up | 01:12:46 | Established | | 10.15.1.4 | node specific | up | 01:12:46 | Established | +--------------+---------------+-------+----------+-------------+