<p>I am new to Kubernetes. I have searched that you can use a <code>LoadBalancer</code> or <code>NodePort</code> to expose services. I am trying to follow tutorials on <a href="https://kubernetes.io/docs/tutorials/" rel="nofollow noreferrer">https://kubernetes.io/docs/tutorials/</a>.</p>

<p>I am able to expose service with <code>LoadBalancer</code> but not <code>NodePort</code>. Here is the command I used.</p>

<pre><code>kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080
</code></pre>

Joshua
<p>I guess you're specifically following <a href="https://kubernetes.io/docs/tasks/access-application-cluster/service-access-application-cluster/" rel="nofollow noreferrer">'Use a Service to Access an Application in a Cluster'</a></p>

<p>Just to note in an answer what you came to already in the comments, you don't set a <code>--port</code> parameter on the <code>expose</code> in that example and just on the <code>run</code>. You set the port that the Pod responds to in the <code>run</code> command but not the port exposed externally in <code>expose</code> - k8s will choose that for you automatically from the NodePort range and then tell you which one it chose. Then you find a public IP for a node in order to access. </p>
