<p>I'm new to Kubernetes. In Kubernetes why NodePort alone has a default port range from <strong>30000 - 32767</strong>? Even if we change the default to user-defined port ranges why only <em><strong>2767</strong></em> ports are allowed?</p>
<p>Please help me understand.
Thanks in advance.</p>

<p>This range was picked to avoid conflicts with anything else on the host machine network since in many cases it is assigned dynamically (manual option is also possible). For example if you'll set it up from range 1-32767 your allocated <code>nodePort</code> might be in conflict with port 22.</p>
<p>The reasons are pretty much well covered <a href="https://github.com/kubernetes/kubernetes/issues/9995" rel="noreferrer">here</a> by @thockin:</p>
<blockquote>
<ol>
<li>We don't want service node ports to tromp on real ports used by the node</li>
<li>We don't want service node ports to tromp on pod host ports.</li>
<li>We don't want to randomly allocate someone port 80 or 443 or 22.</li>
</ol>
</blockquote>
<p>Looking at the code I see that the range is not limited by it. You can find code snippets <a href="https://github.com/kubernetes/kubernetes/blob/59876df736c41093363f4c198aeec05e29c9c902/cmd/kube-apiserver/app/server.go#L197" rel="noreferrer">here</a>, <a href="https://github.com/kubernetes/kubernetes/blob/59876df736c41093363f4c198aeec05e29c9c902/cmd/kube-apiserver/app/server.go#L93" rel="noreferrer">here</a> and in the godocs <a href="https://godoc.org/github.com/mdevilliers/kubernetes/pkg/util#PortRange" rel="noreferrer">here</a>.</p>
<p>I've also performed quick test when I set higher default range it works fine for me:</p>
<pre><code>➜  temp kubectl get svc
NAME          TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
my-service    NodePort    10.100.214.233   &lt;none&gt;        80:14051/TCP   68s
my-service2   NodePort    10.97.67.57      &lt;none&gt;        80:10345/TCP   6s
</code></pre>
