欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

kubeadm报错:The connection to the server localhost:8080 was refused - did you specify the right host

程序员文章站 2024-01-03 13:59:52
...

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

报错现象

[[email protected] ~]# kubectl apply -f calico.yaml 
The connection to the server localhost:8080 was refused - did you specify the right host or port?

报错原因

kubectl命令需要使用kubernetes-admin来运行

解决方法

将主节点(master节点)中的【/etc/kubernetes/admin.conf】文件拷贝到从节点相同目录下:
scp -r /etc/kubernetes/admin.conf ${node1}:/etc/kubernetes/admin.conf

配置环境变量:
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile

立即生效:
source ~/.bash_profile

上一篇:

下一篇: