简体   繁体   中英

503 Service Temporarily Unavailable use EKS ALB Ingress

creating ALB with ALB Ingress Controller on eks

Title error returned when creating ALB and accessing domain

503 Service Temporarily Unavailable

service and deployment look like this

---
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

ingress is like this

---
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

The ALB has been created and a record set has been registered in Route53. I don't know what the cause is because the log doesn't flow on the Cloud Watch.

If necessary, I will show the application code.

I have no idea where this error is occurring.

Can anyone tell me?

Thank you.

fix selector

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

I think that the reason is that the label of deployment did not match

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM