Is it possible to have NodePort Default_range + user_defined_range on a kubernetes cluster Or it can be just one range only
Can we configure to have say default range plus a range of user defined values ? Like default range is 30000-32767 can we have additional range from 40000-41000 as well ?
Will like to retain default range for other applications in cluster but build one range specific to my application.
I have tested assigning port outside the range it clearly fails so the range is hard defined will like to understand if there is any way to have two range or user needs to live with default range or custom range (i.e. two diffrent range in single cluster are not supported )
ubuntu@cluster-master:~$ kubectl expose deployment nginx --type=NodePort --port=80 --dry-run -o yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
nodePort: 40000
selector:
run: nginx
type: NodePort
status:
loadBalancer: {}
ubuntu@cluster-master:~$ kubectl create -f service.yaml
The Service "nginx" is invalid: spec.ports[0].nodePort: Invalid value: 40000: provided port is not in the valid range. The range of valid ports is 30000-32767
Unfortunately, it is not possible that way.
The default range is indeed 30000-32767 but it can be changed by setting the
--service-node-port-range
Update the file /etc/kubernetes/manifests/kube-apiserver.yaml
and add the line --service-node-port-range=xxxxx-yyyyy
Be careful however and not to generate any configuration issues as the range was picked to avoid conflicts with anything else on the host machine network.
I think that the best solution for you would be to set a single but wider range.
I hope it helps.