kubeadm安装k8s所遇到的问题

问题一:

Nov 20 06:13:44 production-elk kubelet: I1120 06:13:44.919624    9429 state_mem.go:36] [cpumanager] initializing new in-memory state store
Nov 20 06:13:44 production-elk kubelet: E1120 06:13:44.919737    9429 container_manager_linux.go:291] failed to initialize cpu manager: could not initialize checkpoint manager: could not restore state from checkpoint: checkpoint is corrupted
Nov 20 06:13:44 production-elk kubelet: Please drain this node and delete the CPU manager checkpoint file "/var/lib/kubelet/cpu_manager_state" before restarting Kubelet.
Nov 20 06:13:44 production-elk kubelet: F1120 06:13:44.919751    9429 server.go:262] failed to run Kubelet: could not initialize checkpoint manager: could not restore state from checkpoint: checkpoint is corrupted
Nov 20 06:13:44 production-elk kubelet: Please drain this node and delete the CPU manager checkpoint file "/var/lib/kubelet/cpu_manager_state" before restarting Kubelet.

解决办法:

rm -rf /var/lib/kubelet/cpu_manager_state

 问题二:

kubectl get cs查看组件状态kube-scheduler和kube-controller-manager显示unhealthy

    $ kubectl get cs
    NAME                 STATUS      MESSAGE                                                                                     ERROR
    controller-manager   Unhealthy   Get http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10252: connect: connection refused
    scheduler            Unhealthy   Get http://127.0.0.1:10251/healthz: dial tcp 127.0.0.1:10251: connect: connection refused
    etcd-0               Healthy     {"health":"true"}

解决方法:

kubernetes版本:v1.20.1

确认kube-scheduler和kube-controller-manager组件配置是否禁用了非安全端口

配置文件路径:/etc/kubernetes/manifests/kube-scheduler.yaml、/etc/kubernetes/manifests/kube-controller-manager.yaml

如controller-manager组件的配置如下:可以去掉--port=0这个设置,然后重启sudo systemctl restart kubelet

 重启服务之后确认组件状态,显示就正常了

查看状态

    $ kubectl get cs
    NAME                 STATUS    MESSAGE             ERROR
    scheduler            Healthy   ok
    controller-manager   Healthy   ok
    etcd-0               Healthy   {"health":"true"}

 问题三:

[root@test ~]# kubectl get nodes
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

解决方法:

执行kubeadm reset命令清除已创建的集群配置之后需要删除 rm -rf  $HOME/.kube 然后重新执行下面的命令

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config
posted @ 2020-11-20 20:11  fat_girl_spring  阅读(1630)  评论(0编辑  收藏  举报