kubeasz icon indicating copy to clipboard operation
kubeasz copied to clipboard

如何修改nodeport的端口范围?

Open comvir opened this issue 3 years ago • 3 comments

我已经通过此项目部署好了k8s,pod和service功能都测试成功。 现在想修改nodeport的支持范围

超出端口范围给出的反馈

#kubectl create -f /data/docker/nginx/conf/nginx-service.yaml
The Service "nginx-test" is invalid: spec.ports[0].nodePort: Invalid value: 666: provided port is not in the valid range. The range of valid ports is 30000-32767

nginx-service.yaml 此配置的nodeport在默认端口的范围[30000-32767]是行得通的

apiVersion: v1
kind: Service
metadata:
  name: nginx-test
spec:
  selector:
    name: nginx-test
  type: NodePort
  ports:
    - protocol: TCP
      targetPort: 80
      port: 80
      nodePort: 666

comvir avatar Apr 16 '21 02:04 comvir

集群安装前可以配置 /etc/kubeasz/clusters/${集群名}/hosts里面可以配

gjmzj avatar Apr 16 '21 12:04 gjmzj

安装后如何再改?

comvir avatar Apr 16 '21 12:04 comvir

我使用的是centos7版本,修改后不需要重启服务器,已验证可用

 vim /etc/systemd/system/kube-apiserver.service

##修改如下端口号范围为你需要的端口号范围
  --service-node-port-range=20000-32767 \

##保存后重启api服务
systemctl restart kube-apiserver.service 

Oc204 avatar May 06 '22 03:05 Oc204

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Nov 30 '22 21:11 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Dec 08 '22 21:12 github-actions[bot]