我是Mac上的新手。我按照说明安装了 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?
我确实遵循了一些问题,发现文件夹中不存在名为kubernetes
/etc/
目录。
这背后的原因是kubectl version
打印客户端版本和服务器版本(kubernetes版本)。当你刚刚安装 kubectl 时,它只是 Kubernetes 客户端。如果你安装了 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 在本地安装集群