I follow the guide from aws and successfully have a EKS cluster with a NLB in front of the Nginx Ingress Controller. The routes working fine, I can access the /banana and /apple, look okay to me
Then, I try to add another ASP.net app and update the ingress
apiVersion: apps/v1
kind: Deployment
metadata:
name: moba-web-portal
labels:
app: moba-web-portal
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: moba-web-portal
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: moba-web-portal
spec:
containers:
- image: mcr.microsoft.com/dotnet/samples:aspnetapp
imagePullPolicy: Always
name: moba-web-portal
ports:
- containerPort: 3001
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: moba-web-portal
spec:
selector:
app: moba-web-portal
ports:
- protocol: TCP
port: 3001
targetPort: 3001
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-buffering: "on"
nginx.ingress.kubernetes.io/proxy-buffer-size: "128k"
nginx.ingress.kubernetes.io/proxy-buffers-number: "4"
spec:
tls:
- hosts:
- api.kmsmoba.com
secretName: tls-secret
rules:
- host: api.kmsmoba.com
http:
paths:
- pathType: Prefix
path: "/moba"
backend:
service:
name: moba-web-portal
port:
number: 3001
- pathType: Prefix
path: "/apple"
backend:
service:
name: apple-service
port:
number: 5678
- pathType: Prefix
path: "/nodejs"
backend:
service:
name: ecsdemo-nodejs
port:
number: 3000
- pathType: Prefix
path: "/banana"
backend:
service:
name: banana-service
port:
number: 5678
Unfortunately, I cannot figure out why I just got "502 Bad Gateway" when I try to access the path /moba-web-portal
I also tried to switch the service name "moba-web-portal" to use another docker image which is built with nodejs then it works okay, so I am doubt on the asp.net application, but that might not be the problem since I use docker image from Microsoft. So, I guess I missed some configuration for the Ingress, could you advice a clue?
Edited: I also tried to test my docker image inside the EC2 worker node, my docker image looks good with the docker run command
The asp.net core sample listen to port 80 and not 3001, update your deployment:
...
containers:
- image: mcr.microsoft.com/dotnet/samples:aspnetapp
imagePullPolicy: Always
name: moba-web-portal
ports:
- containerPort: 80
...
And the service spec:
...
kind: Service
metadata:
name: moba-web-portal
spec:
selector:
app: moba-web-portal
ports:
- protocol: TCP
port: 3001
targetPort: 80
...
Check the log of the pod:
{"EventId":14,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://[::]:80","State":{"Message":"Now listening on: http://[::]:80","address":"http://[::]:80","{OriginalFormat}":"Now listening on: {address}"}}
Try: http://api.kmsmoba.com:3001/moba
takes you to the homepage "Welcome to .NET"