<p>I am trying to deploy a simple FLASK app (python web framework) on a Kubernetes cluster. I am using minikube.</p>

<p>Here's my Helm 3 stuff:</p>

<p>Deployment: </p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: flask-app-deployment
  labels:
    app: flask-app
    some: label
spec:
  replicas: 1
  selector:
    matchLabels:
      app: flask-app-pod
  template:
    metadata:
      labels:
        app: flask-app-pod
    spec:
      containers:
        - name: flask-app-container
          image: flask_app:0.0.1
          imagePullPolicy: Never
          ports:
            - name: app
              containerPort: 5000
              protocol: TCP
          securityContext: # root access for debugging
            allowPrivilegeEscalation: false
            runAsUser: 0
</code></pre>

<p>Service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: flak-app-service
  labels:
    service: flask-app-services
spec:
  type: NodePort
  ports:
    - port: 5000
      targetPort: 5000
      protocol: TCP
      name: https
  selector:
    app: flask-app-pod
</code></pre>

<p>Chart:</p>

<pre><code>apiVersion: v2
name: flask-app
type: application
version: 0.0.1
appVersion: 0.0.1
</code></pre>

<p>I deploy this by doing <code>helm install test-chart/ --generate-name</code>.</p>

<p>Sample output of <code>kubectl get all</code>:</p>

<pre><code>NAME                                       READY   STATUS    RESTARTS   AGE
pod/flask-app-deployment-d94b86cc9-jcmxg   1/1     Running   0          8m19s

NAME                       TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
service/flak-app-service   NodePort    10.98.48.114   &lt;none&gt;        5000:30317/TCP   8m19s
service/kubernetes         ClusterIP   10.96.0.1      &lt;none&gt;        443/TCP          7d2h

NAME                                   READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/flask-app-deployment   1/1     1            1           8m19s

NAME                                             DESIRED   CURRENT   READY   AGE
replicaset.apps/flask-app-deployment-d94b86cc9   1         1         1       8m19s
</code></pre>

<p>I exec'd into the pod to check if it's listening on the correct port, looks fine (netstat output):</p>

<pre><code>Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN      1/python3
</code></pre>

<p>My Dockerfile should be fine. I can create a container and call the app then running a "normal" dcker container.</p>

<p>Must be something stupid. What am I not seeing here?</p>

<p>I would expect to be able to go <code>https://localhost:30317</code> which gets forwarded to the service listening on port 5000 internally, which forwards it into the pod that also listens on port 5000.</p>

user3629892
<p>To validate traffic you can use following as where it is breaking:</p>

<pre><code>kubectl port-forward pods/flask-app-deployment-d94b86cc9-jcmxg 5000:12345
</code></pre>

<p>or </p>

<pre><code>kubectl port-forward deployment/flask-app-deployment 5000:12345
</code></pre>

<p>or </p>

<pre><code>kubectl port-forward service/flak-app-service 5000:12345
</code></pre>

<p>depending upon where you want to debug.</p>

<p>Also please validate by running <code>netstat -tunlp</code> whether your host is listening on the allotted port or not.</p>

<p>Hope this solves your error, or let me know if it does not.</p>
