Minikube Kubernetes kubectl MacOS 错误

Minikube Kubernetes kubectl MacOS Error

我只是按照说明使用 brew 在我的 Mac 上安装了 Minikube:

https://github.com/kubernetes/minikube

brew cask install minikube

然后我只是按照说明进行测试:

minikube start

给我以下信息:

MacBook-Pro:~ joe$ minikube start
Starting local Kubernetes v1.6.4 cluster...
Starting VM...
Moving files into cluster...
Setting up certs...
Starting cluster components...
Connecting to cluster...
Setting up kubeconfig...
Kubectl is now configured to use the cluster

然后我尝试询问 kubectl 版本:

MacBook-Pro:~ joe$ kubectl version
Client Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.5", GitCommit:"5a0a696437ad35c133c0c8493f7e9d22b0f9b81b", GitTreeState:"clean", BuildDate:"2016-10-29T01:38:40Z", GoVersion:"go1.7.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"dirty", BuildDate:"2017-06-22T04:31:09Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}

然后我尝试了下面常见的 hello world 示例,这导致了错误(也如下所示):

MacBook-Pro:~ joe$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
error: group map[extensions:0xc4204c6000 policy:0xc4204c6070 rbac.authorization.k8s.io:0xc4200ea070 storage.k8s.io:0xc4200ea150 federation:0xc4203ba0e0 apps:0xc4203ba620 authentication.k8s.io:0xc4203ba690 batch:0xc4203baa10 certificates.k8s.io:0xc4203baa80 componentconfig:0xc4203baaf0 :0xc4203ba5b0 authorization.k8s.io:0xc4203ba7e0 autoscaling:0xc4203ba850] is already registered

我找不到合适的答案。我想我的 kubectl 客户端应该更新了。但是如何在我的 Mac 上执行此操作?我猜它都是使用brew安装的。那么有什么办法可以解决这个问题吗?

编辑:尝试了来自 Sebastien Goasguen

的 post

她的就是我得到的:

MacBook-Pro:~ joe$ brew upgrade kubectl
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (caskroom/cask, homebrew/core).
==> Updated Formulae
bacula-fd           etcd                fio                 gx-go               kibana              metricbeat          packetbeat          subversion          webpack
certbot             exa                 gnumeric            heroku              libuv               mikutter            paket               tippecanoe          you-get
dos2unix            exploitdb           goffice             hugo                llnode              neovim              pyenv               vagrant-completion
elasticsearch       filebeat            gx                  irssi               logstash            numpy               remarshal           vim

Error: kubectl 1.7.0 already installed
MacBook-Pro:~ joe$ kubectl config use-context minikube
switched to context "minikube".
MacBook-Pro:~ joe$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
Unable to connect to the server: dial tcp 192.168.99.101:8443: i/o timeout
MacBook-Pro:~ joe$ minikube delete
Deleting local Kubernetes cluster...
Machine deleted.
MacBook-Pro:~ joe$

所以先更新kubectl。如果你用 brew 安装它:

brew upgrade kubectl

否则,请在此处查看 kubectl 安装文档:https://kubernetes.io/docs/tasks/tools/install-kubectl/

然后确保你的目标是你的 minikube:

kubectl config use-context minikube

如果仍然失败,停止并删除 minikube,然后从 GitHub 发布页面下载发布重新安装:

https://github.com/kubernetes/minikube/releases