K8S丨报错汇总
K8S丨报错汇总
1. 使用二进制方式安装K8S时使用kubectl命令报错
1 | The connection to the server localhost:8080 was refused - did you specify the right host or port? |
造成这个原因是因为kubectl去读取了默认配置文件位置,而我们二进制部署的目录与默认位置不一致
解决思路
1
kubectl 默认从 ~/.kube/config 配置文件获取访问 kube-apiserver 地址、证书、用户名等信息,如果没有配置该文件,或者该文件个别参数配置出错,执行命令时出错:The connection to the server localhost:8080 was refused - did you specify the right host or port?
解决办法
- 查看该文件是否存在,若不存在则生成
- 如果是使用bootstrap生成的证书,则需要找到你生成的位置,然后链接到默认位置
1
2
3# 本实例中,我采用的是bootstrap生成的证书
ln -sv /opt/kubernetes/node/conf.d/kubelet-bootstrap.kubeconfig /root/.kube/config
- 如果是使用bootstrap生成的证书,则需要找到你生成的位置,然后链接到默认位置
2. 部署CoreDns报错unknown field "seccompProfile" in....
查看报错信息,问题出在seccompProfile字段,结合官方模版对比,官方模版里已经没有这个字段了,所以删除即可
1 | [root@k8s-master1 yaml]# kubectl apply -f coredns.yaml |
- 解决办法
- 直接注释
3. kube-proxy报错Failed to delete stale service IP
1 | [root@k8s-node1 conf.d]# systemctl status kube-proxy -l |
- 解决办法
yum install conntrack -y
- 后重启kube-proxy,问题解决
4. port-forward报错
1 | E0121 15:22:45.173375 2172 portforward.go:400] an error occurred forwarding 9090 -> 80: error forwarding port 80 to pod 117dedb4babe56bfecebab1a57f38e739e7fa83ce07fdfd35164c65b6463e2ee, uid : unable to do port forwarding: socat not found |
- 解决办法
yum install socat -y