k8s部署安装常见错误

1. kubectl 执行kubectl get nodes

错误描述:

The connection to the server localhost:8080 was refused - did you specify the right host or port?

错误原因:

kubectl 默认从 ~/.kube/config 配置文件获取访问 kube-apiserver 地址、证书、用户名等信息,如果没有配置该文件,或者该文件个别参数配置出错,执行命令时出错:The connection to the server localhost:8080 was refused - did you specify the right host or port?

解决办法:

查看文件是否存在,或者缺失字段等

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

你可能感兴趣的:(k8s部署安装常见错误)