I deployed a Spring Boot app on AWS Elastic Kubernetes Service. I am facing a 502 Bad Gateway error. I cannot find anything useful from the logs, there is no event to check, it works fine locally and the docker image is also running without any issue.
Right now its just a simple hello world app, Here are the yaml files files or reference.
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-deployment
namespace: my-namespace
labels:
app: backend-java
spec:
replicas: 1
selector:
matchLabels:
app: backend-java
template:
metadata:
labels:
app: backend-java
spec:
containers:
- name: backend-java
image: <docker-image-location>
ports:
- containerPort: 81
resources:
limits:
cpu: "4000m"
memory: "2048Mi"
requests:
cpu: "100m"
memory: "1024Mi"
service.yaml
apiVersion: v1
kind: Service
metadata:
namespace: my-namespace
name: backend-service
spec:
type: NodePort
selector:
app: backend-java
ports:
- port: 81
targetPort: 8080
nodePort: 30019
ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: "my-app-ingress"
namespace: "my-namespace"
annotations:
alb.ingress.kubernetes.io/scheme: internal
alb.ingress.kubernetes.io/backend-protocol: HTTP
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}]'
spec:
ingressClassName: alb
rules:
- host: myapp.aws.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: "backend-service"
port:
number: 81
Similar configuration has worked for deploying a react app, which works as expected. Only while deploying backend it give '502 Bad Gateway'