我正在尝试在EKS上运行ingress,这样当您进入前缀为/dc
(即abc.com/dc
(的网站时,它将路由到dc-svc
服务。但由于某种原因,当我进入/dc
时,我得到了404: Not Found
。
服务(dc-svc
(是NodePort,但当我将其更改为LoadBalancer
时,我可以通过LoadBalancer链接进入部署,所以我认为这是入口的唯一问题。
这是亚马尔山脉:
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
看起来您在ingress配置中有一个拼写错误。";http";,以及";主机";两者应在同一节中。
代替:
- http:
paths:
- path: /dc
backend:
serviceName: dc-svc
servicePort: 9090
- host: abc.com
使用
- host: abc.com
http:
paths:
- path: /dc
backend:
serviceName: dc-svc
servicePort: 9090