Minikube无法启动,kubectl与服务器的连接被拒绝

时间:2018-05-03 18:28:28

标签: kubernetes minikube

针对类似问题的精简堆栈溢出解决方案并没有解决我的问题,因此希望分享我目前正在经历的帮助调试此问题。

这是一个小小的前言;我几天前最初安装了minikube / kubectl。我今天继续尝试关注minikube教程,现在遇到了问题。我跟随minikube getting started guide

我在MacOS上。我的版本:

$ kubectl version

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.2", GitCommit:"81753b10df112992bf51bbc2c2f85208aad78335", GitTreeState:"clean", BuildDate:"2018-04-27T09:22:21Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Unable to connect to the server: net/http: TLS handshake timeout

$ minikube version

minikube version: v0.26.1

$ vboxmanage --version

5.1.20r114629

以下是我试图查看回复的一系列命令。

$ minikube start

Starting VM...
Getting VM IP address...
Moving files into cluster...
E0503 11:08:18.654428   20197 start.go:234] Error updating cluster:  downloading binaries: transferring kubeadm file: &{BaseAsset:{data:[] reader:0xc4200861a8 Length:0 AssetName:/Users/philipyoo/.minikube/cache/v1.10.0/kubeadm TargetDir:/usr/bin TargetName:kubeadm Permissions:0641}}: Error running scp command: sudo scp -t /usr/bin output: : wait: remote command exited without exit status or exit signal

$ minikube status

cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.103

编辑:

我不知道发生了什么,但是再次检查状态又回复了#34;配置错误"。我运行了推荐的命令$ minikube update-context,现在$ minikube ip指向" 172.17.0.1"。 Ping此IP会返回请求超时,100%丢包。双重检查上下文,我仍在使用" minikube"上下文和集群:

$ kubectl config get-cluster

$ kubectl config get-context

$ kubectl get pods

The connection to the server 192.168.99.103:8443 was refused - did you specify the right host or port?

阅读github问题,我遇到了这个:kubernetes#44665。所以......

$ ls / etc / kubernetes

ls: /etc/kubernetes: No such file or directory

仅限最后几个条目

$ minikube logs

May 03 18:10:48 minikube kubelet[3405]: E0503 18:10:47.933251    3405 event.go:209] Unable to write event: 'Patch https://192.168.99.103:8443/api/v1/namespaces/default/events/minikube.152b315ce3475a80: dial tcp 192.168.99.103:8443: getsockopt: connection refused' (may retry after sleeping)
May 03 18:10:49 minikube kubelet[3405]: E0503 18:10:49.160920    3405 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/kubelet.go:465: Failed to list *v1.Service: Get https://192.168.99.103:8443/api/v1/services?limit=500&resourceVersion=0: dial tcp 192.168.99.103:8443: getsockopt: connection refused
May 03 18:10:51 minikube kubelet[3405]: E0503 18:10:51.670344    3405 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/config/apiserver.go:47: Failed to list *v1.Pod: Get https://192.168.99.103:8443/api/v1/pods?fieldSelector=spec.nodeName%3Dminikube&limit=500&resourceVersion=0: dial tcp 192.168.99.103:8443: getsockopt: connection refused
May 03 18:10:53 minikube kubelet[3405]: W0503 18:10:53.017289    3405 status_manager.go:459] Failed to get status for pod "kube-controller-manager-minikube_kube-system(c801aa20d5b60df68810fccc384efdd5)": Get https://192.168.99.103:8443/api/v1/namespaces/kube-system/pods/kube-controller-manager-minikube: dial tcp 192.168.99.103:8443: getsockopt: connection refused
May 03 18:10:53 minikube kubelet[3405]: E0503 18:10:52.595134    3405 rkt.go:65] detectRktContainers: listRunningPods failed: rpc error: code = Unavailable desc = grpc: the connection is unavailable

我不确定如何ping https网址,但是如果我ping ip

$ kube ping 192.168.99.103

PING 192.168.99.103 (192.168.99.103): 56 data bytes
64 bytes from 192.168.99.103: icmp_seq=0 ttl=64 time=4.632 ms
64 bytes from 192.168.99.103: icmp_seq=1 ttl=64 time=0.363 ms
64 bytes from 192.168.99.103: icmp_seq=2 ttl=64 time=0.826 ms
^C
--- 192.168.99.103 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.363/1.940/4.632/1.913 ms

查看kube配置文件... $ cat ~/.kube/config

apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://localhost:6443
  name: docker-for-desktop-cluster
- cluster:
    certificate-authority: /Users/philipyoo/.minikube/ca.crt
    server: https://192.168.99.103:8443
  name: minikube
contexts:
- context:
    cluster: docker-for-desktop-cluster
    user: docker-for-desktop
  name: docker-for-desktop
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: docker-for-desktop
  user:
    client-certificate-data: <removed>
    client-key-data: <removed>
- name: minikube
  user:
    client-certificate: /Users/philipyoo/.minikube/client.crt
    client-key: /Users/philipyoo/.minikube/client.key

并确保我的密钥/ crts在那里:

$ ls~ / .minikube

addons/              ca.pem*              client.key           machines/            proxy-client.key
apiserver.crt        cache/               config/              profiles/
apiserver.key        cert.pem*            files/               proxy-client-ca.crt
ca.crt               certs/               key.pem*             proxy-client-ca.key
ca.key               client.crt           logs/                proxy-client.crt

非常感谢任何调试方面的帮助!

2 个答案:

答案 0 :(得分:13)

对于后人来说,解决这个问题的方法是删除

.minikube

用户主目录中的目录,然后重试。经常修复奇怪的minikube问题。

答案 1 :(得分:0)

启动minikube时遇到了同样的问题。

操作系统

MacOs HighSierra

Minikube

minikube version: v0.33.1

kubectl版本

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.2", GitCommit:"cff46ab41ff0bb44d8584413b598ad8360ec1def", GitTreeState:"clean", BuildDate:"2019-01-10T23:28:14Z", GoVersion:"go1.11.4", Compiler:"gc", Platform:"linux/amd64"}

解决方案1 ​​

我只是更改kubeadm文件的权限,并如下所示启动minikube。然后就可以了。

sudo chmod 777 /Users/buddhi/.minikube/cache/v1.13.2/kubeadm

通常,您必须

sudo chmod 777 <PATH_TO_THE_KUBEADM_FILE>

解决方案2

如果您不再需要现有的minikube集群,则可以尝试一下。

minikube stop
minikube delete
minikube start

在此处停止并删除现有的minikube集群,然后创建另一个集群。

希望这可能对某人有所帮助。