<p>I created in AWS a EKS Cluster via Terraform using terraform-aws-modules/eks/aws as module. This cluster has one pod (golang app) using nodeport as service and ingress. The problem I have is that I'm getting 502 bad gateway when I hit the endpoint.</p>
<p>My config:</p>
<p><strong>Deployment:</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: golang-deployment
  labels:
    app: golang-app
spec:
  replicas: 1
  selector:
    matchLabels:
      name: golang-app
  template:
    metadata:
      labels:
        name: golang-app
    spec:
      containers:
      - name: golang-app
        image: 019496914213.dkr.ecr.eu-north-1.amazonaws.com/goland:1.0
        ports:
          - containerPort: 9000
</code></pre>
<p><strong>service:</strong></p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: golang-service
spec:
  type: NodePort
  selector:
    app: golang-app
  ports:
    - protocol: TCP
      port: 9000
      targetPort: 9000
</code></pre>
<p><strong>Ingress:</strong></p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
    kubernetes.io/ingress.class: alb
  labels:
    app: app
spec:
  rules:
    - http:
        paths:
          - path: /api/v2
            pathType: ImplementationSpecific
            backend:
              service:
                name: golang-service
                port:
                  number: 9000



kubectl get service
golang-service    NodePort    172.20.44.34     &lt;none&gt;        9000:32184/TCP   106m
</code></pre>
<p>The security groups for the cluster and nodes were created by terraform-aws-modules/eks/aws module.</p>
<p>I checked severals things:</p>
<pre><code>kubectl port-forward golang-deployment-5894d8d6fc-ktmmb 9000:9000
</code></pre>
<p><strong>WORKS!</strong> I can see the golang app using localhost:9000 in my computer</p>
<pre><code>kubectl exec curl -i --tty nslookup golang-app

Server:    172.20.0.10
Address 1: 172.20.0.10 kube-dns.kube-system.svc.cluster.local

Name:      golang-app
Address 1: 172.20.130.130 golang-app.default.svc.cluster.local
</code></pre>
<p><strong>WORKS!</strong></p>
<pre><code>kubectl exec curl -i --tty curl golang-app:9000

curl: (7) Failed to connect to golang-app port 9000: Connection refused
</code></pre>
<p><strong>NOT WORKS</strong></p>
<p>Any idea?</p>

wipcrep
<p>You should be calling the <strong>service</strong> not deployment.</p>
<p><strong>golang-service</strong> is svc name instead of deployment name</p>
<pre><code>kubectl exec curl -i --tty curl golang-service:9000
</code></pre>
