Kubectl: 使用Minikube的Kubernetes超时

9
我已安装并启动了minikube自带的Kubernetes集群。
$ minikube start
Starting local Kubernetes cluster...
Kubernetes is available at https://192.168.99.100:443.
Kubectl is now configured to use the cluster.

我也已经安装了 kubectl

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.0", GitCommit:"283137936a498aed572ee22af6774b6fb6e9fd94", GitTreeState:"clean", BuildDate:"2016-07-01T19:26:38Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}

但是我无法成功使用 kubectl 与正在运行的 Kubernetes 集群交互

$ kubectl get nodes
Unable to connect to the server: net/http: TLS handshake timeout

EDIT

$ minikube logs 

E0712 19:02:08.767815    1257 docker_manager.go:1955] Failed to create pod infra container: ImagePullBackOff; Skipping pod "kube-addon-manager-minikubevm_kube-system(48abed82af93bb0b941173334110923f)": Back-off pulling image "gcr.io/google_containers/pause-amd64:3.0"
E0712 19:02:08.767875    1257 pod_workers.go:183] Error syncing pod 48abed82af93bb0b941173334110923f, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause-amd64:3.0\""
E0712 19:02:23.767380    1257 docker_manager.go:1955] Failed to create pod infra container: ImagePullBackOff; Skipping pod "kube-addon-manager-minikubevm_kube-system(48abed82af93bb0b941173334110923f)": Back-off pulling image "gcr.io/google_containers/pause-amd64:3.0"
E0712 19:02:23.767464    1257 pod_workers.go:183] Error syncing pod 48abed82af93bb0b941173334110923f, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause-amd64:3.0\""
E0712 19:02:36.766696    1257 docker_manager.go:1955] Failed to create pod infra container: ImagePullBackOff; Skipping pod "kube-addon-manager-minikubevm_kube-system(48abed82af93bb0b941173334110923f)": Back-off pulling image "gcr.io/google_containers/pause-amd64:3.0"
E0712 19:02:36.766760    1257 pod_workers.go:183] Error syncing pod 48abed82af93bb0b941173334110923f, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause-amd64:3.0\""
E0712 19:02:51.767621    1257 docker_manager.go:1955] Failed to create pod infra container: ImagePullBackOff; Skipping pod "kube-addon-manager-minikubevm_kube-system(48abed82af93bb0b941173334110923f)": Back-off pulling image "gcr.io/google_containers/pause-amd64:3.0"
E0712 19:02:51.767672    1257 pod_workers.go:183] Error syncing pod 48abed82af93bb0b941173334110923f, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause-amd64:3.0\""
E0712 19:03:02.766548    1257 docker_manager.go:1955] Failed to create pod infra container: ImagePullBackOff; Skipping pod "kube-addon-manager-minikubevm_kube-system(48abed82af93bb0b941173334110923f)": Back-off pulling image "gcr.io/google_containers/pause-amd64:3.0"
E0712 19:03:02.766609    1257 pod_workers.go:183] Error syncing pod 48abed82af93bb0b941173334110923f, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause-amd64:3.0\""
E0712 19:03:16.766831    1257 docker_manager.go:1955] Failed to create pod infra container: ImagePullBackOff; Skipping pod "kube-addon-manager-minikubevm_kube-system(48abed82af93bb0b941173334110923f)": Back-off pulling image "gcr.io/google_containers/pause-amd64:3.0"
E0712 19:03:16.766904    1257 pod_workers.go:183] Error syncing pod 48abed82af93bb0b941173334110923f, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause-amd64:3.0\""
E0712 19:04:15.829223    1257 docker_manager.go:1955] Failed to create pod infra container: ErrImagePull; Skipping pod "kube-addon-manager-minikubevm_kube-system(48abed82af93bb0b941173334110923f)": image pull failed for gcr.io/google_containers/pause-amd64:3.0, this may be because there are no credentials on this request.  details: (Error response from daemon: Get https://gcr.io/v1/_ping: dial tcp 74.125.28.82:443: i/o timeout)
E0712 19:04:15.829326    1257 pod_workers.go:183] Error syncing pod 48abed82af93bb0b941173334110923f, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for gcr.io/google_containers/pause-amd64:3.0, this may be because there are no credentials on this request.  details: (Error response from daemon: Get https://gcr.io/v1/_ping: dial tcp 74.125.28.82:443: i/o timeout)"
E0712 19:04:31.767536    1257 docker_manager.go:1955] Failed to create pod infra container: ImagePullBackOff; Skipping pod "kube-addon-manager-minikubevm_kube-system(48abed82af93bb0b941173334110923f)": Back-off pulling image "gcr.io/google_containers/pause-amd64:3.0"

minikube logs 显示了有用的信息吗? - CJ Cullen
@CJCullen 是的,我刚刚更新了问题并附上了错误日志。 - nikk
嗯,看起来Docker无法连接到gcr.io。您能否手动执行“docker pull gcr.io/google_containers/pause-amd64:3.0”?您是否需要配置任何代理设置?(例如https://dev59.com/1Zjga4cB1Zd3GeqPPs81#38312822?noredirect=1#comment64069942_38312822) - CJ Cullen
我在minikube的问题中提出了一个问题。如果你有任何发现,请随意在那里分享。 - CJ Cullen
@CJCullen,谢谢。我之前也在这里提交了一个问题。 [Issue-322]https://github.com/kubernetes/minikube/issues/322 - nikk
显示剩余3条评论
3个回答

5
为了在代理后面运行它,您需要从文档中稍微调整一下设置事项。
a. 确保在VM中运行的docker daemon可以通过代理访问互联网。 b. 确保在主机上运行的kubectl可以直接访问到VM而不需要通过代理。
使用默认的kubectl示例:
1. 确保将代理传递到minikube创建的VM中(这样可以确保VM内部的docker daemon可以访问互联网)。
`minikube start --vm-driver="kvm" --docker-env="http_proxy=xxx" --docker-env="https_proxy=yyy" start`
注意:将xxx和yyy替换为您的代理设置。
2. 获取VM在启动时获得的IP地址。
`minikube ip`
注意:每次设置minikube时都需要执行此操作,因为它可能会更改。
3. 确保kubectl可以与此VM通信而无需通过代理。
`export no_proxy="127.0.0.1,[minikube_ip]"`
4. 现在启动POD并进行测试。
``` kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
kubectl expose deployment hello-minikube --type=NodePort
kubectl get pod
curl $(minikube service hello-minikube --url) ```

在Windows的情况下,它是set NO_PROXY="127.0.0.1,[minikube_ip]" - gdenuf
上述解决方案对我无效。我正在使用Windows 8.1,并通过传递代理详细信息来启动minikube。此外,我已将NO_PROXY设置为minikube IP。仍然出现错误:“无法连接到服务器:net / http:TLS握手超时”。 - user2439278

1
尽管这是一个旧问题,但在此回答以帮助其他人解决此问题。
由于分配的内存不足,我遇到了以下错误。增加RAM应该可以解决此问题。
无法连接到服务器:net / http:TLS握手超时
默认情况下,minikube VM仅配置为使用2GB内存。您可以在minikube启动期间使用--memory标志更改此值。需要停止、删除并重新启动Minikube。

这似乎是一个Github问题,其中包含如何使用--memory标志的示例。 https://github.com/kubernetes/minikube/issues/567 但是对我来说没有用。JFYI。 - rsmets

1

在公司代理后,设置环境变量如下:

export HTTP_PROXY=http://<proxy hostname:port>
export HTTPS_PROXY=https://<proxy hostname:port>
export NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24

然后:

minikube start

更多信息 在这里


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接