赞
踩
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
文件示例:
- apiVersion: v1
- clusters:
- - cluster:
- certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURtakNDQW9LZ0F3SUJBZ0lVRFg4d2RvWlFsaXVQSmFIM3FVUjlsczlYdDgwd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1pURUxNQWtHQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFXcHBibWN4RURBT0JnTlZCQWNUQjBKbAphV3BwYm1jeEREQUtCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByCmRXSmxjbTVsZEdWek1CNFhEVEl5TVRBeU1ERTBOVFF3TUZvWERUSTNNVEF4T1RFME5UUXdNRm93WlRFTE1Ba0cKQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFXcHBibWN4RURBT0JnTlZCQWNUQjBKbGFXcHBibWN4RERBSwpCZ05WQkFvVEEyczRjekVQTUEwR0ExVUVDeE1HVTNsemRHVnRNUk13RVFZRFZRUURFd3ByZFdKbGNtNWxkR1Z6Ck1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBd01KS1FWbEdqR292b1RIZ2ErVVAKYTRBbHF2UitrY0RtTEZqU2FlZUxKN2dJQWVaNnVoOVcxa2tXdnBMQmV6Y3RORktUYWRsO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ster
- contexts:
- - context:
- cluster: default-cluster
- namespace: default
- user: default-auth
- name: default-context
- current-context: default-context
- kind: Config
- preferences: {}
- users:
- - name: default-auth
- user:
- client-certificate: /opt/kubernetes/ssl/kubelet-client-current.pem
- client-key: /opt/kubernetes/ssl/kubelet-client-current.pem
网上很多说的应该是kubeadm安装方式部置的解决方式,二进制安装的资料很少,发此资讯帮忙更多的人少走弯路。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。