運(yùn)行?kubectl get namespace時報錯:
[root@ip-10-0-0-8 ~]# kubectl get namespace
E0320 07:39:20.866425 32422 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
....
The connection to the server localhost:8080 was refused - did you specify the right host or port?
原因:kubectl命令需要使用kubernetes-admin來運(yùn)行,需要admin.conf文件;而admin.conf 文件是通過 “kubeadmin init” 命令在 /etc/kubernetes 中創(chuàng)建的,從節(jié)點(diǎn)沒有該配置文件;因此需要將admin.conf復(fù)制到從節(jié)點(diǎn)
復(fù)制配置文件并解決此問題:?
sudo mkdir ~/.kube
sudo cp /etc/kubernetes/admin.conf ~/.kube/
cd ~/.kube
sudo mv admin.conf config
sudo service kubelet restart
?或者按以下方式指定配置文件:
kubectl --kubeconfig ~/.kube/config get nodes
?或者配置環(huán)境變量
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile
技術(shù)性分享,轉(zhuǎn)載請注明出處!文章來源:http://www.zghlxwxcb.cn/news/detail-520130.html
歡迎互相交流,共同進(jìn)步!文章來源地址http://www.zghlxwxcb.cn/news/detail-520130.html
到了這里,關(guān)于已解決—The connection to the server localhost:8080 was refused - did you specify the right host or port的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!