<p>I am trying to host the below (deployment  <strong>frontend</strong>) Kubernetes deployment in the AWS EKS cluster, after deploying deployment and created service and ingress, everything gets successfully deployed and created but when i try to access the Load Balancer DNS from outside then this LoadBalancer is not accessible.
Can someone please point the reason?</p>
<p>**Below code (deployment-2048) is working and Load Balancer is accessible but not in the case of (deployment frontend) **.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: &quot;1&quot;
  creationTimestamp: &quot;2021-03-09T14:08:45Z&quot;
  generation: 2
  name: frontend
  namespace: default
  resourceVersion: &quot;2864&quot;
  uid: a7682f3b-dffa-498f-be47-b231cce0720a
spec:
  minReadySeconds: 20
  progressDeadlineSeconds: 600
  replicas: 4
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      name: webapp
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        name: webapp
    spec:
      containers:
      - image: kodekloud/webapp-color:v2
        imagePullPolicy: IfNotPresent
        name: simple-webapp
        ports:
        - containerPort: 80
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 4
  observedGeneration: 2
  readyReplicas: 4
  replicas: 4
  updatedReplicas: 4

---
apiVersion: v1
kind: Service
metadata:
  namespace: default
  name: service-1
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: LoadBalancer
  selector:
    name: webapp
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: default
  name: ingress-1
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
spec:
  rules:
    - http:
        paths:
          - path: /*
            backend:
              serviceName: service-1
              servicePort: 80
</code></pre>
<p><a href="https://i.stack.imgur.com/a9kcf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a9kcf.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/qlFfW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qlFfW.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/2eOVu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2eOVu.png" alt="enter image description here" /></a></p>
<pre><code>---
apiVersion: v1
kind: Namespace
metadata:
  name: game-2048
---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: game-2048
  name: deployment-2048
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: app-2048
  replicas: 5
  template:
    metadata:
      labels:
        app.kubernetes.io/name: app-2048
    spec:
      containers:
      - image: alexwhen/docker-2048
        imagePullPolicy: Always
        name: app-2048
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  namespace: game-2048
  name: service-2048
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: app-2048
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: game-2048
  name: ingress-2048
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
spec:
  rules:
    - http:
        paths:
          - path: /*
            backend:
              serviceName: service-2048
              servicePort: 80
</code></pre>

user190245
<p>In your original question (without edits and additional information), in <code>frontend</code> deployment you have <code>port</code> values misconfigured.</p>
<ul>
<li><strong>Port</strong> exposes the Kubernetes service on the specified port within the cluster. Other pods within the cluster can communicate with this server on the specified port.</li>
<li><strong>TargetPort</strong> is the port on which the service will send requests to, that your pod will be listening on. Your application in the container will need to be listening on this port also.</li>
<li><strong>ContainerPort</strong> defines the port on which app can be reached out inside the container.</li>
</ul>
<p>In short story, <code>containerPort</code> from deployment must have the same value as <code>targetPort</code> in <code>Service</code>.</p>
<p>User @herbertgoto had good idea, but unfortunately didn't specify exactly what should be done. When you have changed <code>containerPort</code> from <code>8080</code> to <code>80</code> it should work but I guess there was issue with repopulating this change in all resources (recreate ingress resource, redeploying pod).</p>
<p>One of the first troubleshooting steps should be to check if your container is listening on the proper port. That's why I requested to <code>$ netstat</code> output.</p>
<p>Useful command to check is to use <code>$ kubectl get ep</code> to check service endpoints.</p>
<p><strong>Note</strong></p>
<p>If you will skip <code>targetPort</code> in service and have only <code>port</code>, Kubernetes automatically assign <code>targetPort</code> value based on <code>port</code>.</p>
<blockquote>
<p>When i kept only containerPort and TargetPort to 8080. and the others to 80. Why it worked like this.</p>
</blockquote>
<p>Default port port for service is <code>80</code>. So when you create <code>service</code> with port 80, you don't need to specify any additional things. When you have set <code>port</code> in <code>service</code> to <code>8080</code> you also need to specify it.</p>
<p>I've created service with port <code>8080</code> no my <code>GKE</code> cluster.</p>
<pre><code>$ kubectl get svc
NAME         TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
kubernetes   ClusterIP      10.104.0.1      &lt;none&gt;          443/TCP          153m
my-nginx     LoadBalancer   10.104.14.137   34.91.230.207   8080:31311/TCP   9m39s
$ curl 34.91.230.207
curl: (7) Failed to connect to 34.91.230.207 port 80: Connection timed out
$ curl 34.91.230.207:8080
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Welcome to nginx!&lt;/title&gt;
&lt;style&gt;
    body {
...
</code></pre>
<p><strong>Responses from Browser:</strong></p>
<p><em><strong>Only externalIP</strong></em>
<a href="https://i.stack.imgur.com/TS45K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TS45K.png" alt="enter image description here" /></a>
<em><strong>ExternalIP:8080</strong></em>
<a href="https://i.stack.imgur.com/QIwD9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QIwD9.png" alt="enter image description here" /></a>
As you see I needed to specify port <code>8080</code> in browser and curl command when I didn't use default <code>80</code> port.</p>
<h2>Conclusions:</h2>
<p>Deployment <code>containerPort</code> and Service <code>targetPort</code> must have the same value. When you are using service with <code>port</code> different than <code>80</code> you need to specify it by adding <code>:&lt;portNubmer&gt;</code>. That's why in almost all guides in the internet yo can see service <code>port</code> with value <code>80</code>.</p>
