在eks上使用ALB入口控制器创建ALB
创建ALB和访问域时返回标题错误
503 Service Temporarily Unavailable
服务和部署如下所示
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-app-b-deployment
namespace: default
spec:
selector:
matchLabels:
app: sample-app-b
template:
metadata:
labels:
app: sample-app-b
spec:
containers:
- name: app-container
image: XXXXXXXXXXXX.dkr.ecr.ap-northeast-1.amazonaws.com/sample:c97e4bdeb61ba6196479f0b0f92347fcba828ff5
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: app-b-service
namespace: default
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app.kubernetes.io/name: sample-app-b
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-app-a-deployment
namespace: default
spec:
selector:
matchLabels:
app: sample-app-a
template:
metadata:
labels:
app: sample-app-a
spec:
containers:
- name: app-container
image: XXXXXXXXXXXX.dkr.ecr.ap-northeast-1.amazonaws.com/sample:c97e4bdeb61ba6196479f0b0f92347fcba828ff5
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: app-a-service
namespace: default
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app.kubernetes.io/name: sample-app-a
入口是这样的
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: alb-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80},{"HTTPS": 443}]'
alb.ingress.kubernetes.io/certificate-arn: my-arn
alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
spec:
rules:
- host: example.com
http:
paths:
- path: /*
backend:
serviceName: ssl-redirect
servicePort: use-annotation
- path: /
backend:
serviceName: app-a-service
servicePort: 80
- path: /app-a
backend:
serviceName: app-a-service
servicePort: 80
- path: /app-b
backend:
serviceName: app-b-service
servicePort: 80
已创建ALB,并且已在Route53中注册了记录集。
我不知道是什么原因,因为日志没有在Cloud Watch上流动。
如有必要,我将显示应用程序代码。
我不知道此错误发生在哪里。
谁能告诉我?
谢谢。
最佳答案
修复选择器
apiVersion: v1
kind: Service
metadata:
name: app-a-service
namespace: default
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: sample-app-a
我认为原因是部署的标签不匹配
关于amazon-web-services - 503服务暂时不可用,使用EKS ALB入口,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61052940/