首页 > 解决方案 > minikube apiserver.service-node-port-range 不喜欢逗号分隔的端口列表

问题描述

我可以apiserver.service-node-port-range使用端口范围配置额外配置,10000-19000但是当我指定逗号分隔的端口列表时,例如17080,13306minkube 不会启动它会引导循环并出现以下错误

  initialization failed, will try again: wait: /bin/bash -c "sudo env PATH=/var/lib/minikube/binaries/v1.20.2:$PATH kubeadm init --config /var/tmp/minikube/kubeadm.yaml  --ignore-preflig
ht-errors=DirAvailable--etc-kubernetes-manifests,DirAvailable--var-lib-minikube,DirAvailable--var-lib-minikube-etcd,FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml,FileAvailabl
e--etc-kubernetes-manifests-kube-apiserver.yaml,FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml,FileAvailable--etc-kubernetes-manifests-etcd.yaml,Port-10250,Swap,Mem,S
ystemVerification,FileContent--proc-sys-net-bridge-bridge-nf-call-iptables": Process exited with status 1
stdout:
[init] Using Kubernetes version: v1.20.2
[preflight] Running pre-flight checks
[preflight] The system verification failed. Printing the output from the verification:
KERNEL_VERSION: 5.10.26-1rodete1-amd64
DOCKER_VERSION: 20.10.5
OS: Linux
CGROUPS_CPU: enabled
CGROUPS_CPUSET: enabled
CGROUPS_DEVICES: enabled
CGROUPS_FREEZER: enabled
CGROUPS_MEMORY: enabled
CGROUPS_PIDS: enabled
CGROUPS_HUGETLB: enabled
[preflight] Pulling images required for setting up a Kubernetes cluster
.
.
.
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[kubelet-check] Initial timeout of 40s passed.

        Unfortunately, an error has occurred:
                timed out waiting for the condition

        This error is likely caused by:
                - The kubelet is not running
                - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

        If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
                - 'systemctl status kubelet'
                - 'journalctl -xeu kubelet'

        Additionally, a control plane component may have crashed or exited when started by the container runtime.
        To troubleshoot, list all containers using your preferred container runtimes CLI.

        Here is one example how you may list all Kubernetes containers running in docker:
                - 'docker ps -a | grep kube | grep -v pause'
                Once you have found the failing container, you can inspect its logs with:
                - 'docker logs CONTAINERID'


stderr:

我检查了kube-apiserver并且只使用了端口范围。minikube 是否支持逗号分隔的端口列表?

--service-node-port-range <a string in the form 'N1-N2'> Default: 30000-32767

标签: kubernetesminikube

解决方案


将此作为社区 wiki 发布,请随时提供有关此主题的更多详细信息和发现。

我们唯一可以找到有关逗号分隔的端口列表和端口范围信息的地方是minikube 文档

增加 NodePort 范围

默认情况下,minikube 只公开端口 30000-32767。如果这对您不起作用,您可以使用以下方法调整范围:

minikube start --extra-config=apiserver.service-node-port-range=1-65535

此标志还接受以逗号分隔的端口和端口范围列表

另一方面来自k8s 文档

--service-node-port-range <a string in form 'N1-N2'> Default: 30000-32767

我已经使用 k8s v 1.20 对此进行了测试,并且逗号分隔的端口列表也不适用于我。Kube-apiserver 接受两种方法:

set 解析形式为“value”、“min-max”或“min+offset”的字符串,包括两端

--service-node-port-range=30100-31000   # using "min-max" approach
--service-node-port-range=25000+100     # using "min+offset" approach (valid ranges will be 25000-25100)

其他资源:


推荐阅读