<p>I am trying to deploy a &quot;Hello World&quot; application on an EKS cluster I created using eksctl. I have the cluster running with 2 pods and am following a tutorial located at <a href="https://shahbhargav.medium.com/hello-world-on-kubernetes-cluster-6bec6f4b1bfd" rel="nofollow noreferrer">https://shahbhargav.medium.com/hello-world-on-kubernetes-cluster-6bec6f4b1bfd</a>. I created a deployment using the following yaml file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-world-deployment
  labels:
    app: hello-world
spec:
  selector:
    matchLabels:
      app: hello-world
  replicas: 2
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - name: hello-world
        image: bhargavshah86/kube-test:v0.1
        ports:
        - containerPort: 80
        resources:
          limits:
            memory: 256Mi
            cpu: &quot;250m&quot;
          requests:
            memory: 128Mi
            cpu: &quot;80m&quot;
---
apiVersion: v1
kind: Service
metadata:
  name: hello-world
spec:
  selector:
    app: hello-world
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30081   
  type: NodePort
</code></pre>
<p>I then created the deploying by running the following command:</p>
<pre><code>kubectl create -f hello-world.yaml
</code></pre>
<p>I am unable to access it on localhost. I believe I am missing a step because the I had created the cluster &amp; deployment on a Linux EC2 instance that I SSH into with Putty and I am accessing localhost on my Windows machine. Any advice how I can connect would be appreciated. Currently I am getting the following when trying to connect to http://localhost:30081/</p>
<p><a href="https://i.stack.imgur.com/gC1MR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gC1MR.png" alt="enter image description here" /></a></p>

<p>As you mention, the problem is that you are trying to access to your local machine at port 30081 but the pods that you have created are in your EKS cluster in the cloud. If you want to try out that the application is working you can SSH into the worker node as you have done and use the <a href="https://linux.die.net/man/1/curl" rel="nofollow noreferrer">curl</a> command like this.</p>
<pre class="lang-sh prettyprint-override"><code>curl localhost:30081
</code></pre>
<p>That command is going to return the website that you have running in the console (without any format).</p>
<p>I think that in your case the best course will be to use the <a href="https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/#forward-a-local-port-to-a-port-on-the-pod" rel="nofollow noreferrer">kubectl port-forward</a> command. This command is going to bind one of your local machine ports into one of the ports of the pods.</p>
<p>Here is the format of the command.</p>
<pre class="lang-sh prettyprint-override"><code>kubectl port-forward POD-NAME-CURRENTLY-RUNNING-IN-CLUSTER UNUSED-PORT-IN-YOUR-PC:APPLICATION-PORT
</code></pre>
<p>Here is an example of how to use it and to check out that's working.</p>
<pre class="lang-sh prettyprint-override"><code>kubectl port-forward hello-world-xxxxxx-xxxxx 8000:80

curl localhost:8000
</code></pre>
<p>Notice here that I am not using the service port to access the pod. This tool is great for debugging!</p>
<p>Another approach could be to open port 30081 with a security group and hit the IPs of the worker nodes but I think that's insecure and also have a lot of extra steps. You should check out the difference between type of <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">services</a>.</p>
<p>Let me know if you have any doubts about my answer. I am not an expert and I could be wrong!</p>
<p>Also English is not my first language.</p>
<p>Cheers</p>
