<p>Is it possible to have NodePort Default_range + user_defined_range on a kubernetes cluster Or it can be just one range only</p>

<blockquote>
  <blockquote>
    <p>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 ?</p>
  </blockquote>
</blockquote>

<p>Will like to retain default range for other applications in cluster but build one range specific to my application.</p>

<p>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 )</p>

<pre><code>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: {}
</code></pre>

<pre><code>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
</code></pre>

DT.
<p>Unfortunately, it is not possible that way.</p>

<p>The default range is indeed 30000-32767 but it can be changed by setting the
<code>--service-node-port-range</code>
Update the file <code>/etc/kubernetes/manifests/kube-apiserver.yaml</code> and add the line <code>--service-node-port-range=xxxxx-yyyyy</code></p>

<p>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.</p>

<p>I think that the best solution for you would be to set a single but wider range.</p>

<p>I hope it helps. </p>
