503服务暂时不可用,请使用EKS ALB入口



在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

我认为原因是部署标签与不匹配

相关内容

  • 没有找到相关文章

最新更新