<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx 
  labels:
    name: nginx
spec:
  ports:
    # the port that this service should serve on
  - port: 80 
    targetPort: 80
    nodePort: 30000 
  selector:
    name: nginx
  type: NodePort
</code></pre>

<hr>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx 
  labels:
    name: nginx
spec:
  ports:
    # the port that this service should serve on
  - port: 80 
    targetPort: 80
    nodePort: 30000 
  selector:
    name: nginx
  type: LoadBalancer 
</code></pre>

<p>Two methods all support loadbalancer.
And the port range is between 30000-32000,  why?
If I want to use port 3000, what should I do?</p>

<p><a href="http://kubernetes.io/v1.0/docs/user-guide/services.html#type-nodeport" rel="nofollow">http://kubernetes.io/v1.0/docs/user-guide/services.html#type-nodeport</a>:</p>

<blockquote>
  <p>If you set the type field to "NodePort", the Kubernetes master will
  allocate a port from a flag-configured range (default: 30000-32767).</p>
</blockquote>

<p>There is a risk of low ports conflict with real things running on host. That's the reason, why ports are limited. You are still able to configure kube-apiserver - flag <code>--service-node-port-range=</code></p>

<p><a href="http://kubernetes.io/v1.0/docs/admin/kube-apiserver.html" rel="nofollow">http://kubernetes.io/v1.0/docs/admin/kube-apiserver.html</a></p>
