<p>This is a bit of a beginner's question. I'm attempting to get a simple Hello World Python flask application deployed in a kubernetes cluster on IBM Cloud. The application (<code>main.py</code>):</p>

<pre><code>import os
from flask import Flask

app = Flask(__name__)

@app.route('/')
def welcomeToMyapp():
    return 'Ciao'

port = os.getenv('PORT', '5000')
if __name__ == "__main__":
    app.run(host='0.0.0.0', port=int(port))
</code></pre>

<p>I  build my Docker image with <code>docker build --rm -t kube-hw .</code> and <code>Dockerfile</code>:</p>

<pre><code>FROM ubuntu:latest

WORKDIR /app
ADD requirements.txt /app
RUN apt-get -y update
RUN apt-get -y install python3-pip
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt

ADD main.py /app

EXPOSE 80

CMD ["python3", "main.py"]
</code></pre>

<p>I run it locally with <code>docker run --rm -p 5000:5000 kube-hw</code>. That works fine. I can browse <code>http://0.0.0.0:5000/</code>.</p>

<p>However, when I run the same image on k8s on IBM Cloud I can't seem to access the URL endpoint. My deployment steps are (from the article mentioned in the answer below):</p>

<pre><code>docker tag kube-hw registry.ng.bluemix.net/sudoku/kube-hw:latest
docker push registry.ng.bluemix.net/sudoku/kube-hw:latest
kubectl run kube-hw --image=registry.ng.bluemix.net/sudoku/kube-hw:latest --port=80
kubectl expose deployment kube-hw --port=80 --target-port=5000 --type=NodePort
</code></pre>

<p>I then use <code>kubectl describe pod kube-hw</code> to get the external IP address <code>10.77.223.141</code>:</p>

<pre><code>Name:           kube-hw-3409617459-5bczp
Namespace:      default
Node:           10.77.223.141/10.77.223.141
Start Time:     Sat, 23 Dec 2017 14:52:39 -0500

Status:         Running
IP:             172.30.205.113
</code></pre>

<p>And <code>kubectl describe service kube-hw</code> to get the port <code>30930</code>:</p>

<pre><code>Name:                     kube-hw
Namespace:                default
Labels:                   run=kube-hw
Annotations:              &lt;none&gt;
Selector:                 run=kube-hw
Type:                     NodePort
IP:                       172.21.250.32
Port:                     &lt;unset&gt;  80/TCP
TargetPort:               5000/TCP
NodePort:                 &lt;unset&gt;  30930/TCP
Endpoints:                172.30.205.116:5000
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   &lt;none&gt;
</code></pre>

<p>The URL <code>http:\\10.77.223.141:30930</code> doesn't resolve. I can look at the log and see the app running, but no requests are getting to it. The article uses <code>--target-port=8888</code>. But since I've used port <code>5000</code> in the container I changed to <code>--target-port=5000</code>. I'm wondering if I have a misalignment of port numbers somewhere.</p>

<p>The IP address that you need is the external IP address of a worker node in your cluster. The IP address that you have identified is an internal address.</p>

<p>To get an external IP address, run <code>bx cs workers &lt;cluster_name&gt;</code></p>

<p>Then form the URL as follows: <code>http://&lt;external_node_ip&gt;:&lt;NodePort&gt;</code></p>

<p>Here's a doc with more information on using NodePort: <a href="https://console.bluemix.net/docs/containers/cs_apps.html#cs_apps_public_nodeport" rel="nofollow noreferrer">https://console.bluemix.net/docs/containers/cs_apps.html#cs_apps_public_nodeport</a></p>
