K8S calicoctl 客户端工具安装
1. 下载calicoctl二进制文件
wget https://github.com/projectcalico/calicoctl/releases/download/v3.5.4/calicoctl -O /usr/bin/calicoctl
chmod +x /usr/bin/calicoctl
2. 临时测试
DATASTORE_TYPE=kubernetes KUBECONFIG=~/.kube/config calicoctl get nodes
3. 加入配置文件
mkdir -p /etc/calico/
root@master:/etc/calico# cat /etc/calico/calicoctl.cfg
apiVersion: projectcalico.org/v3
kind: CalicoAPIConfig
metadata:
spec:
datastoreType: "kubernetes"
kubeconfig: "/home/master/.kube/config"
4. calicoctl命令
root@master:/etc/calico# calicoctl node status Calico process is running. IPv4 BGP status +----------------+-------------------+-------+----------+-------------+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +----------------+-------------------+-------+----------+-------------+ | 192.168.56.101 | node-to-node mesh | up | 02:46:22 | Established | | 192.168.56.102 | node-to-node mesh | start | 02:46:21 | Passive | +----------------+-------------------+-------+----------+-------------+ IPv6 BGP status No IPv6 peers found.
node-node mesh: 代表所有节点用full mesh的bgp连接
root@master:# netstat -anp | grep ESTABLISH | grep bird
tcp 0 0 192.168.56.100:179 192.168.56.102:43827 ESTABLISHED 5185/bird
tcp 0 0 192.168.56.100:179 192.168.56.101:54099 ESTABLISHED 5185/bird
root@node1:~# netstat -anp | grep ESTABLISH | grep bird
tcp 0 0 192.168.56.101:179 192.168.56.102:47975 ESTABLISHED 4487/bird
tcp 0 0 192.168.56.101:54099 192.168.56.100:179 ESTABLISHED 4487/bird
root@node2:/etc# netstat -anp | grep ESTABLISH | grep bird
tcp 0 0 192.168.56.102:43827 192.168.56.100:179 ESTABLISHED 14014/bird
tcp 0 0 192.168.56.102:47975 192.168.56.101:179 ESTABLISHED 14014/bird