kubernetes入口始终返回503

时间:2020-04-26 10:26:33

标签: kubernetes kubernetes-ingress

我将kubernetes部署在我的计算机和配置pod,服务,入口上。我卷曲了配置的域,但收到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>

入口控制器的日志:

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,service和ingress都在运行。我运行命令curl http://open.platform.com,但收到错误503 Service Temporarily Unavailable。怎么了?

1 个答案:

答案 0 :(得分:3)

因此,这里的问题在于该服务具有标签选择器,该选择器选择带有标签app: opengateway的容器,但容器没有此标签。因此,服务中的Endpoints为空,没有POD IP。将标签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