check that the calico/node container is running and has mounted /var/lib/calico/

k8s运行pod节点后出现如下错误:

网上查询资料后,发现自己的网络没有设置好。 

check that the calico/node container is running and has mounted /var/lib/calico/_第1张图片

 check that the calico/node container is running and has mounted /var/lib/calico/_第2张图片

1.在所有节点重置k8s

kubeadm reset

 2.删除kubectl

rm -fr ~/.kube/

3.启用ipvs

modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4

4.导出并修改配置文件

kubeadm config print init-defaults --kubeconfig ClusterConfiguration > kubeadm.yml

主要修改配置文件的几个属性:advertiseAddress imageRepository kubernetesVersion podSubnet 

5.kubeadm 初始化

kubeadm init --config=kubeadm.yml

 6.配置kubectl

# 配置 kubectl
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config

# 验证是否成功
kubectl get node

7.下载calico配置文件并修改

wget https://docs.projectcalico.org/v3.10/manifests/calico.yaml

由于calico自身网络发现机制有问题,因为需要修改 calico使用的物理网卡,添加607及608行,ens33为自己机器的网卡,还有修改后面CALICO_IPV4POOL_CIDR,不能与初始值“192.168.0.0/16”相同。

            - name: IP_AUTODETECTION_METHOD
              value: "interface=ens33"

check that the calico/node container is running and has mounted /var/lib/calico/_第3张图片

 执行安装

kubectl apply -f calico.yaml

8.其他节点加入集群

kubeadm join 192.168.0.199:6443 --token abcdef.0123456789abcdef \
    --discovery-token-ca-cert-hash sha256:ff4249f345e3ca1c98737e2d0fa2f5cgg8eb045a971ba936f42ab5fe4e389caf 

9.验证

kubectl get node

check that the calico/node container is running and has mounted /var/lib/calico/_第4张图片

kubectl get pods --all-namespaces

check that the calico/node container is running and has mounted /var/lib/calico/_第5张图片

你可能感兴趣的:(云原生)