- 我已经创建了一个新的 Azure 容器机器并带有
kubernetes
as 编排。 - ssh 到我的主机后,我尝试通过 检查 kubernets 版本
kubectl version
。但无法连接服务器机器。
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-15T06:40:50Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Unable to connect to the server: dial tcp <master-ip>:443: i/o timeout
答案1
根据您的描述,您似乎不是正确配置了服务主体。您可能需要检查以确保凭据已准确提供,并且配置的服务主体对目标订阅具有读写权限。如果您的服务主体配置错误,则所有 Kubernetes 组件都不会以健康的方式启动。我们可以检查一下这是否是问题所在:
jason@k8s-master-955348FB-0:~$ sudo journalctl -u kubelet | grep --text autorest
如果您看到如下输出,则表示您未正确配置服务主体。
jason@k8s-master-955348FB-0:~$ sudo journalctl -u kubelet | grep --text autorest
Jun 05 15:43:59 k8s-master-955348FB-0 docker[5524]: E0605 15:43:59.736607 6020 kubelet.go:1186] Cannot get Node info: failed to get external ID from cloud provider: autores#WithErrorUnlessStatusCode: POST https://login.microsoftonline.com/1fcf418e-66ed-4c99-9449-d8e18bf8737a/oauth2/token?api-version=1.0 failed with 400 Bad Request: StatusCode=400
Jun 05 15:43:59 k8s-master-955348FB-0 docker[5524]: E0605 15:43:59.924924 6020 kubelet_node_status.go:70] Unable to construct api.Node object for kubelet: failed to get external ID from cloud provider: autorest#WithErrorUnlessStatusCode: POST https://login.microsoftonline.com/1fcf418e-66ed-4c99-9449-d8e18bf8737a/oauth2/token?api-version=1.0 failed with 400 Bad Request: StatusCode=400
Jun 05 15:44:00 k8s-master-955348FB-0 docker[5524]: E0605 15:44:00.199542 6020 kubelet_node_status.go:70] Unable to construct api.Node object for kubelet: failed to get external ID from cloud provider: autorest#WithErrorUnlessStatusCode: POST https://login.microsoftonline.com/1fcf418e-66ed-4c99-9449-d8e18bf8737a/oauth2/token?api-version=1.0 failed with 400 Bad Request: StatusCode=400
有关如何使用 Azure CLI 2.0 为 ACS-Engin Kubernetes 集群创建/配置服务主体的更多信息,请参阅此关联。
顺便说一句,我使用错误的服务主体进行了测试,并尝试运行kubectl version
,同样的错误就像你一样:
jason@k8s-master-955348FB-0:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-15T06:40:50Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Unable to connect to the server: dial tcp 40.114.10.73:443: i/o timeout
这里有一个关于 Azure K8S 的类似案例,请参考它。