首页 > 解决方案 > Minikube 和非默认 NodePorts

问题描述

我正在尝试在带有StatefulSet. 该应用程序使用 around 20 ports,其他服务都知道,所以我想在与 docker/k8s 之前相同的端口号上公开它们。为此,我在service.yaml文件中添加了端口映射,如下所示:

- port: 8080
  targetPort: 8080
  nodePort: 8080
  protocol: TCP
  name: serverpool1
- port: 8081
  targetPort: 8081
  nodePort: 8081
  protocol: TCP
  name: serverpool2

为了完成这项工作,我需要能够使用不在默认范围内的 nodePorts。据我所见,它应该像这样工作:

minikube start --extra-config=apiserver.ServiceNodePortRange=5000-46000

问题是,如果我有--extra-config参数,minikube 不会启动,但会出现错误:

Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...

E0904 09:18:24.862606   28110 start.go:305] Error restarting cluster:  restarting kube-proxy: waiting for kube-proxy to be up for configmap update: timed out waiting for the condition

没有--extra-config参数它可以正常启动,但我无法使用较低的端口。

我有一台带有 High Sierra 的 Mac,我使用 VirtualBox 作为 VM,我有minikube version v0.28.2kubectl 版本:

Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-08T16:31:10Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

标签: macosdockerkubernetesminikube

解决方案


我认为您受到此处描述的问题的影响:https ://github.com/kubernetes/minikube/issues/2733我在 Ubuntu 18.04 上的 minikube 上重现了该案例,我可以确认相同的错误,因此它看起来更像问题/错误在迷你库中。


推荐阅读