<p>I am trying to deploy multiple identical docker containers on Google Container Engine. I am using kubectl for that following the instructions here: <a href="https://cloud.google.com/container-engine/docs/tutorials/hello-node" rel="nofollow noreferrer">https://cloud.google.com/container-engine/docs/tutorials/hello-node</a></p>

<p>The instructions describe how to run a redundant service managed by the load balancer, so when I contact the balancer, it sends my request to one of my redundant pods. And in that mode, it works fine.</p>

<p>But I need to do this differently. I need to be able to contact individual pods directly from the client. So I am trying to use --type=NodePort with my "kubectl expose deployment" command:</p>

<pre><code>mac-124307:hellonode ivm$ kubectl expose deployment hello-world --type=NodePort --port 9000 --target-port 9000
service "hello-world" exposed

mac-124307:hellonode ivm$ kubectl get service
NAME          CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-world   10.15.253.149   &lt;nodes&gt;       9000:30513/TCP   21m
kubernetes    10.15.240.1     &lt;none&gt;        443/TCP          46m
</code></pre>

<p>The command does not complain, and I can use "gcloud compute instances list" to see external IP addressed of individual pods:</p>

<pre><code>mac-124307:hellonode ivm$ gcloud compute instances list
NAME                                          ZONE           MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS
gke-hello-cluster-default-pool-402030b2-j60q  us-central1-a  n1-standard-1               10.128.0.3   104.197.72.212  RUNNING
gke-hello-cluster-default-pool-402030b2-q86r  us-central1-a  n1-standard-1               10.128.0.4   35.192.4.43     RUNNING
gke-hello-cluster-default-pool-402030b2-tf7t  us-central1-a  n1-standard-1               10.128.0.2   146.148.72.137  RUNNING
</code></pre>

<p>but when I try to connect to port 9000 at any of these IP addresses, my connection times-out.</p>

<pre><code>mac-124307:hellonode ivm$ curl http://104.197.72.212:9000/
... &lt;time-out&gt;
</code></pre>

<p>What am I doing wrong ?</p>

<p>Note that the node port that was allocated is <code>30513</code>. You are using <code>9000</code>, that's the port for the ClusterIP, <code>10.15.253.149</code> that was assigned.</p>

<p>You also need to have port <code>30513</code> open on the firewall, as suggested by Eric.</p>

<p>If you only need a one-off access to this pod, you can also use <code>kubectl port-forward name-of-a-hello-pod 9000</code> which will forward <code>127.0.0.1:9000</code> on your workstation directly to the pod. Of course this only works as long as <code>kubect port-forward</code> is running.</p>
