当前位置:   article > 正文

二进制安装The connection to the server localhost:8080 was refused - did you specify the right host

the connection to the server localhost:8080 was refused - did you specify th

工作节点执行kubectl get node/pods/apply/相关的集群请求主节点命令会报错

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

原因:

kubectl 默认从 ~/.kube/config 配置文件获取访问 kube-apiserver 地址、证书、用户名等信息,如果没有配置该文件会读取默值,即localhost:8080,而本机的localhost:8080没有服务因而报The connection to the server localhost:8080 was refused - did you specify the right host or port?

解决:

server应该为config中server项的配置值,我的为https://192.168.1.146:6443

/root/.kube/config配置文件实际上是生成的kube-proxy.kubeconfig配置文件,我的放在这个文件夹下/opt/kubernetes/cfg,可以把这个文件复制到/root/.kube/目录下,这样做更新时需要同点维护更新,最好引用过去。

cp /opt/kubernetes/cfg/kubelet.kubeconfig /root/.kube/config

/root/.kube/config文件示例:

  1. apiVersion: v1
  2. clusters:
  3. - cluster:
  4. certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURtakNDQW9LZ0F3SUJBZ0lVRFg4d2RvWlFsaXVQSmFIM3FVUjlsczlYdDgwd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1pURUxNQWtHQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFXcHBibWN4RURBT0JnTlZCQWNUQjBKbAphV3BwYm1jeEREQUtCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByCmRXSmxjbTVsZEdWek1CNFhEVEl5TVRBeU1ERTBOVFF3TUZvWERUSTNNVEF4T1RFME5UUXdNRm93WlRFTE1Ba0cKQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFXcHBibWN4RURBT0JnTlZCQWNUQjBKbGFXcHBibWN4RERBSwpCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByZFdKbGNtNWxkR1Z6Ck1JSUJJakFOQmd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JjL1MxOGRYcGNpVWhubVdCUzdydGg2VzZpTmFDcmhkOTdrOW4KUS90b2R3QU1Bbm1jcDVmMGlYOD0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
  5. server: https://192.168.1.146:6443
  6. name: default-cluster
  7. contexts:
  8. - context:
  9. cluster: default-cluster
  10. namespace: default
  11. user: default-auth
  12. name: default-context
  13. current-context: default-context
  14. kind: Config
  15. preferences: {}
  16. users:
  17. - name: default-auth
  18. user:
  19. client-certificate: /opt/kubernetes/ssl/kubelet-client-current.pem
  20. client-key: /opt/kubernetes/ssl/kubelet-client-current.pem

 网上很多说的应该是kubeadm安装方式部置的解决方式,二进制安装的资料很少,发此资讯帮忙更多的人少走弯路。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/165198
推荐阅读
相关标签
  

闽ICP备14008679号