I'm trying to run ingress on EKS, such that when you enter to the website, with prefix /dc
(i.e. abc.com/dc
), it will route to the dc-svc
service.
But for some reason when I enter to /dc
, I get 404: Not Found
.
The service (dc-svc
) is NodePort, but when I changed it to LoadBalancer
, I could enter to the deployment via the LoadBalancer link, so I think its only problem with the ingress.
This is the yamls:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: abc-ingress
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS": 443}]'
alb.ingress.kubernetes.io/inbound-cidrs: 0.0.0.0/0
external-dns.alpha.kubernetes.io/hostname: abc.com, www.abc.com
spec:
tls:
- hosts:
- abc.com
- www.abc.com
rules:
- http:
paths:
- path: /dc
backend:
serviceName: dc-svc
servicePort: 9090
- host: abc.com
- http:
paths:
- backend:
serviceName: abc-svc
servicePort: 8000
- host: www.abc.com
- http:
paths:
- backend:
serviceName: abc-svc
servicePort: 8000
apiVersion: v1
kind: Service
metadata:
name: dc-svc
spec:
type: NodePort
selector:
app: dc
ports:
- port: 9090
name: "serving-dc"
targetPort: 8080
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: dc-deployment
name: dc
spec:
replicas: 3
selector:
matchLabels:
app: dc
template:
metadata:
labels:
app: dc
spec:
containers:
- name: dc-container
image: docker.io/image:1.0
ports:
- containerPort: 8080
Looks like you have a typo in the ingress configuration. The "http", and the "host" should both be in the same section.
Instead of:
- http:
paths:
- path: /dc
backend:
serviceName: dc-svc
servicePort: 9090
- host: abc.com
Use
- host: abc.com
http:
paths:
- path: /dc
backend:
serviceName: dc-svc
servicePort: 9090