问题描述
我有一个要求,测试服务器应该使用 20000 - 22767 的端口范围
I have a requirement that a test server should use the port range 20000 - 22767
我用命令编辑了 kubeadm-config
kubectl edit cm kubeadm-config -n kube-system
当我查看结果时,我发现更改似乎已被存储:
When I look at the result I see that the change seems to have been stored:
命令$ kubeadm config view
给了我
apiServer:
extraArgs:
authorization-mode: Node,RBAC
service-node-port-range: 20000-22767
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta1
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controlPlaneEndpoint: ""
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.13.3
networking:
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12
scheduler: {}
但是当我稍后尝试在新端口范围内安装某些东西时,我收到错误
But when I later try to install something within hte new port range I get the error
helm upgrade --install --kubeconfig /external-storage/workspace/potapi-orchestration/clusters/at/admin.conf potapi-services charts/potapi-services -f charts/potapi-services/values.at.yaml
Error: UPGRADE FAILED: Service "potapi-services" is invalid: spec.ports[0].nodePort: Invalid value: 21011: provided port is not in the valid range. The range of valid ports is 30000-32767
我已经摆弄了这里的建议,但没有运气:https://github.com/kubernetes/kubeadm/issues/122
I have fiddled with the suggestions here but with no luck: https://github.com/kubernetes/kubeadm/issues/122
推荐答案
可以更新 service-node-port-range
的默认值.
It is possible to update the service-node-port-range
from it's default values.
我用 --service-node-port-range=20000-22767
更新了文件 /etc/kubernetes/manifests/kube-apiserver.yaml
.
I updated the file /etc/kubernetes/manifests/kube-apiserver.yaml
with --service-node-port-range=20000-22767
.
apiserver 重新启动并更新了端口范围.
The apiserver was restarted and the port range was updated.
我写了一篇博文 关于它.
这篇关于如何设置 service-node-port-range 然后能够使用新的端口范围部署服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!