Traefik 入口控制器抛出错误 503 服务不可用

Traefik ingress controller throws error 503 Service Unavailable

我通过 traefik 入口控制器公开了我的 nginx 服务。不幸的是,它会导致 503 错误。

$ kubectl create deployment nginx --image=nginx
$ kubectl expose deployment nginx --port=80

我的 traefik ingress 配置遵循 this 文档。

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: nginx
          servicePort: http

事实证明,我不得不将 servicePort: http 更改为 servicePort: 80,这解决了问题。

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: nginx
          servicePort: 80