8

我已经安装了 minikube 并启动了它内置的 Kubernertes 集群

$ 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

编辑

$ 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"
4

3 回答 3

5

要让它在代理后面运行,您需要设置与文档稍有不同的东西。一种。您需要确保与 VM 一起运行的 docker 守护程序可以通过代理访问 Internet。湾。您需要确保在主机上运行的 kubectl 无需通过代理即可访问虚拟机

使用默认的 kubectl 示例

  1. 确保将代理传递到由 minikube 创建的 VM 中(这可以确保 VM 中的 docker daemon 可以访问 Internet)

minikube start --vm-driver="kvm" --docker-env="http_proxy=xxx" --docker-env="https_proxy=yyy" start

注意:将 xxx 和 yyy 替换为您的代理设置

  1. 获取 VM 在启动时获取的 IP。

minikube ip

注意:每次设置 minikube 时都需要这样做,因为它可以更改

  1. 确保 kubectl 可以与此 VM 对话,而无需通过代理

export no_proxy="127.0.0.1,[minikube_ip]"

  1. 现在启动 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)

于 2016-09-13T19:06:58.173 回答
1

虽然,这是一个老问题,但在这里回答,以便它可以帮助其他人面临这个问题。

我遇到了错误,因为 minikube VM 分配的内存不足。增加 RAM 应该可以解决这个问题。

Unable to connect to the server: net/http: TLS handshake timeout

minikube VM 默认配置为仅使用 2gb 内存。您可以在 minikube 启动期间使用 --memory 标志更改此值。需要 Minikube 停止、删除并重新启动

于 2018-11-23T05:27:45.637 回答
0

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

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

更多信息在这里

于 2019-06-24T12:10:09.307 回答