1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# source /opt/k8s/bin/environment.sh 3 [root@k8smaster01 work]# for node_ip in ${NODE_IPS[@]} 4 do 5 echo ">>> ${node_ip}" 6 scp flannel/{flanneld,mk-docker-opts.sh} root@${node_ip}:/opt/k8s/bin/ 7 ssh root@${node_ip} "chmod +x /opt/k8s/bin/*" 8 done
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# source /opt/k8s/bin/environment.sh 3 [root@k8smaster01 work]# for node_ip in ${NODE_IPS[@]} 4 do 5 echo ">>> ${node_ip}" 6 ssh root@${node_ip} "mkdir -p /etc/flanneld/cert" 7 scp flanneld*.pem root@${node_ip}:/etc/flanneld/cert 8 done
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# source /opt/k8s/bin/environment.sh 3 [root@k8smaster01 work]# for node_ip in ${NODE_IPS[@]} 4 do 5 echo ">>> ${node_ip}" 6 scp flanneld.service root@${node_ip}:/etc/systemd/system/ 7 done
1 [root@k8smaster01 ~]# source /opt/k8s/bin/environment.sh 2 [root@k8smaster01 ~]# for node_ip in ${NODE_IPS[@]} 3 do 4 echo ">>> ${node_ip}" 5 ssh root@${node_ip} "systemctl daemon-reload && systemctl enable flanneld && systemctl restart flanneld" 6 done
1 [root@k8smaster01 ~]# source /opt/k8s/bin/environment.sh 2 [root@k8smaster01 ~]# for node_ip in ${NODE_IPS[@]} 3 do 4 echo ">>> ${node_ip}" 5 ssh root@${node_ip} "systemctl status flanneld|grep Active" 6 done
1 [root@k8smaster01 ~]# source /opt/k8s/bin/environment.sh 2 [root@k8smaster01 ~]# etcdctl \ 3 --endpoints=${ETCD_ENDPOINTS} \ 4 --ca-file=/etc/kubernetes/cert/ca.pem \ 5 --cert-file=/etc/flanneld/cert/flanneld.pem \ 6 --key-file=/etc/flanneld/cert/flanneld-key.pem \ 7 get ${FLANNEL_ETCD_PREFIX}/config #查看集羣 Pod 網段(/16)
1 [root@k8smaster01 ~]# source /opt/k8s/bin/environment.sh 2 [root@k8smaster01 ~]# etcdctl \ 3 --endpoints=${ETCD_ENDPOINTS} \ 4 --ca-file=/etc/kubernetes/cert/ca.pem \ 5 --cert-file=/etc/flanneld/cert/flanneld.pem \ 6 --key-file=/etc/flanneld/cert/flanneld-key.pem \ 7 ls ${FLANNEL_ETCD_PREFIX}/subnets #查看已分配的 Pod 子網段列表(/24) 8 [root@k8smaster01 ~]# etcdctl \ 9 --endpoints=${ETCD_ENDPOINTS} \ 10 --ca-file=/etc/kubernetes/cert/ca.pem \ 11 --cert-file=/etc/flanneld/cert/flanneld.pem \ 12 --key-file=/etc/flanneld/cert/flanneld-key.pem \ 13 get ${FLANNEL_ETCD_PREFIX}/subnets/172.30.8.0-21 #查看某一 Pod 網段對應的節點 IP 和 flannel 接口地址
1 [root@k8snode02 ~]# ip addr show
1 [root@k8smaster01 ~]# source /opt/k8s/bin/environment.sh 2 [root@k8smaster01 ~]# for all_ip in ${ALL_IPS[@]} 3 do 4 echo ">>> ${all_ip}" 5 ssh ${all_ip} "/usr/sbin/ip addr show flannel.1|grep -w inet" 6 done
1 [root@k8smaster01 ~]# source /opt/k8s/bin/environment.sh 2 [root@k8smaster01 ~]# for all_ip in ${ALL_IPS[@]} 3 do 4 echo ">>> ${all_ip}" 5 ssh ${all_ip} "ping -c 1 172.30.8.0" 6 ssh ${all_ip} "ping -c 1 172.30.32.0" 7 ssh ${all_ip} "ping -c 1 172.30.128.0" 8 ssh ${all_ip} "ping -c 1 172.30.208.0" 9 ssh ${all_ip} "ping -c 1 172.30.216.0" 10 done
原文出處:https://www.cnblogs.com/itzgr/p/11879332.htmlhtml