kubernetes 入口总是 return 503

kubernetes ingress always return 503

我在我的电脑上部署了kubernetes,并配置了pod、service、ingress。我卷曲了我配置的域,但出现 503 错误。什么原因?
操作系统:Mac OSX 10.15.3
Docker版本:19.03.8
广告连播:

apiVersion: v1
kind: Pod
metadata:
  name: opengateway
  namespace: openplatform
spec:
  containers:
    - name: opengateway
      image: "karldoenitz/opengateway:1.0"
      ports:
        - containerPort: 8000
          hostPort: 8000
      env:
        - name: etcdiport
          valueFrom:
            configMapKeyRef:
              name: openplatform
              key: etcd-iport
      imagePullPolicy: IfNotPresent

服务

apiVersion: v1
kind: Service
metadata:
  name: webgateway
  namespace: openplatform
spec:
  ports:
    - port: 8000
      targetPort: 8000
  selector:
    app: opengateway

入口

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: openplatform-web-gateway
  namespace: openplatform
spec:
  rules:
    - host: open.platform.com
      http:
        paths:
          - path: /
            backend:
              serviceName: webgateway
              servicePort: 8000

描述 svc webgateway -n openplatform

Name:              webgateway
Namespace:         openplatform
Labels:            <none>
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"webgateway","namespace":"openplatform"},"spec":{"ports":[{"port":...
Selector:          app=opengateway
Type:              ClusterIP
IP:                10.109.103.73
Port:              <unset>  8000/TCP
TargetPort:        8000/TCP
Endpoints:         <none>
Session Affinity:  None
Events:            <none>

ingress-controller 的日志:

192.168.65.3 - - [26/Apr/2020:08:58:37 +0000] "GET /favicon.ico HTTP/1.1" 503 599 "http://open.platform.com/ping" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36" 388 0.000 [openplatform-openplatform-web-gateway-30001] [] - - - - 086d5a61011485f8fa69dca25afd93ae

所有 pod、服务、入口都是 running.I 运行 命令 curl http://open.platform.com,我收到错误 503 Service Temporarily Unavailable。怎么了?

所以这里的问题是该服务有一个标签选择器,它选择带有标签 app: opengateway 的 pods,但 pods 没有这个标签。因此,服务中的 Endpoints 是空的,没有 POD IP。在 Pod 中添加标签 app: opengateway 应该可以解决问题。

apiVersion: v1
kind: Pod
metadata:
  name: opengateway
  namespace: openplatform
  labels:
    app: opengateway
spec:
  containers:
    - name: opengateway
      image: "karldoenitz/opengateway:1.0"
      ports:
        - containerPort: 8000
          hostPort: 8000
      env:
        - name: etcdiport
          valueFrom:
            configMapKeyRef:
              name: openplatform
              key: etcd-iport
      imagePullPolicy: IfNotPresent