我在Mac上是新手。我按照instructions安装了kubectl-cli
但是,通过命令kubectl version
检查版本时,出现以下错误:
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T19:44:19Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"darwin/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
我确实遵循了一些questions,发现kubernetes
文件夹中没有名为/etc/
的目录。
答案 0 :(得分:1)
其原因是kubectl version
会同时打印客户端版本和服务器版本(kubernetes版本)。当您只安装kubectl时,它只是kubernets客户端。如果您安装了kubernetes集群,它将同时打印kubectl版本和kubernetes版本。
如果只想打印客户端版本,请使用以下命令:
kubectl version --client=true
该错误表示kubectl tried to contact the kubernetes server to get its version but couldn't connect. Are you specifying the right host or port to connect to the kubernetes server.
错误的原因是您尚未在Mac上安装kubernetes集群。您刚刚安装了kubectl,它只是访问kubernetes集群的客户端。安装kubernetes集群后,kubectl version
的输出将类似于:
[root@ip-10-0-1-138 centos]# kubectl version
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T10:39:04Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:05:37Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
如果要在Mac上安装完整的kubernetes集群,请尝试minikube在本地安装集群