<p>I'm setting up a kubernetes cluster, having one master node(a physical miniPC, running ubuntu server 18.04) and one slave-node(a laptop, running ubuntu 16.04).</p>

<p>Docker is the container I'm using in conjunction with kubernetes.</p>

<p>I run a demo application via</p>

<pre class="lang-py prettyprint-override"><code>kubectl run hello-world --image=gcr.io/google-samples/hello-app:1.0  --port 8080
</code></pre>

<p>and expose it via</p>

<pre class="lang-py prettyprint-override"><code>kubectl expose deployment hello-world --port=8080 --target-port=8080
</code></pre>

<p>The application starts on slave-node</p>

<pre><code>alecu@slave-node:~$ sudo docker ps
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS               NAMES
91967f160a7c        bc5c421ecd6c           "./hello-app"            About an hour ago   Up About an hour                        k8s_hello-world_hello-world-5bcc568dd9-xktwg_default_875609f4-90d0-11e9-9940-7cd30a0da72f_0

</code></pre>

<p>And I can access it from inside the container</p>

<pre><code>alecu@slave-node:~$ sudo nsenter -t 21075 -n curl http://localhost:8080
Hello, world!
Version: 1.0.0
Hostname: hello-world-6899bf7846-t5pb7
</code></pre>

<p>But when I try to access it from outside the container I get connection refused:</p>

<pre><code>alecu@slave-node:~$ curl http://localhost:8080
curl: (7) Failed to connect to localhost port 8080: Connection refused

</code></pre>

<p>netstat is not showing 8080 port</p>

<pre><code>alecu@slave-node:~$ netstat -tnlp | grep 8080
</code></pre>

<p>curl is not working from master-node either</p>

<pre><code>alecu@master-node:~$ kubectl describe service hello-world
Name:              hello-world
Namespace:         default
Labels:            &lt;none&gt;
Annotations:       &lt;none&gt;
Selector:          run=hello-world
Type:              ClusterIP
IP:                10.100.48.99
Port:              &lt;unset&gt;  8080/TCP
TargetPort:        8080/TCP
Endpoints:         192.168.1.18:8080
Session Affinity:  None
Events:            &lt;none&gt;

alecu@master-node:~$ curl -v http://192.168.1.18:8080
* Rebuilt URL to: http://192.168.1.18:8080/
*   Trying 192.168.1.18...
* TCP_NODELAY set
^C
alecu@master-node:~$ curl -v http://10.100.48.99:8080
* Rebuilt URL to: http://10.100.48.99:8080/
*   Trying 10.100.48.99...
* TCP_NODELAY set
^C
alecu@master-node:~$
</code></pre>

<p>I 'ctrl+c'ed the curl command as it was endlessly waiting.</p>

<p>I do not get it why on slave-node port 8080 is not opened.</p>

<p>[EDIT]
I patched the service to use NodePort</p>

<pre><code> kubectl patch svc hello-world --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"}]'
</code></pre>

<p>but the curl is not working either on <a href="http://nodeIP:nodePort" rel="nofollow noreferrer">http://nodeIP:nodePort</a></p>

<pre><code>alecu@master-node:~$ kubectl describe svc hello-world
Name:                     hello-world
Namespace:                default
Labels:                   run=hello-world
Annotations:              &lt;none&gt;
Selector:                 run=hello-world
Type:                     NodePort
IP:                       10.100.171.36
Port:                     &lt;unset&gt;  8080/TCP
TargetPort:               8080/TCP
NodePort:                 &lt;unset&gt;  30988/TCP
Endpoints:                192.168.1.21:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   &lt;none&gt;
alecu@master-node:~$ curl -v http://10.100.171.36:30988
* Rebuilt URL to: http://10.100.171.36:30988/
*   Trying 10.100.171.36...
* TCP_NODELAY set
^C
</code></pre>

Alecu Constantin-Alexandru
<p>update the service type to NodePort. then you should be able to access the app from outside using <a href="http://NODEIP:NODEPORT" rel="nofollow noreferrer">http://NODEIP:NODEPORT</a>
Or use the clusterIP to access the app from the cluster.</p>

<p>get the clusterIP from below command</p>

<pre><code>kubectl get svc
</code></pre>

<p>see below for instructions</p>

<pre><code>master $ kubectl run hello-world --image=gcr.io/google-samples/hello-app:1.0  --port 8080
deployment.apps/hello-world created
master $
master $ kubectl expose deployment hello-world --port=8080 --target-port=8080
service/hello-world exposed
master $
master $ kubectl get svc
NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
hello-world   ClusterIP   10.104.172.60   &lt;none&gt;        8080/TCP        4s
kube-dns      ClusterIP   10.96.0.10      &lt;none&gt;        53/UDP,53/TCP   1h
master $
master $ curl 10.104.172.60:8080
Hello, world!
Version: 1.0.0
Hostname: hello-world-6654767c49-r2mnz
</code></pre>
