我怎么知道入口控制器返回的404错误是否可以通过等待自身解决?

时间:2019-11-20 18:38:13

标签: google-kubernetes-engine

我创建我的入口。等待几分钟。然后,当我向其发送HTTP请求时,收到HTTP / 1.1 404 Not Found错误。

但是,如果我再等几分钟再发送完全相同的请求,一切都会正常。

我的问题是:除了等待,我还能做些什么来确保我得到的错误是否是由于配置错误而导致的错误,而不仅仅是等待k8来完成任务?

这是请求失败后的描述:

 ?   >kubectl describe ing ingress-monza-predictors
Name:             ingress-monza-predictors
Namespace:        default
Address:          35.244.250.224
Default backend:  default-http-backend:80 (10.40.2.10:8080)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *     
        /seatbelt-driver      predictor-classification-seatbelt-driver-service-node-port:4444 (<none>)
        /seatbelt-passenger   predictor-classification-seatbelt-passenger-service-node-port:4444 (<none>)
Annotations:
  ingress.kubernetes.io/backends:                    {"k8s-be-30355--62f4c45447b62142":"Unknown","k8s-be-31413--62f4c45447b62142":"Unknown","k8s-be-32727--62f4c45447b62142":"Unknown"}
  ingress.kubernetes.io/forwarding-rule:             k8s-fw-default-ingress-monza-predictors--62f4c45447b62142
  ingress.kubernetes.io/target-proxy:                k8s-tp-default-ingress-monza-predictors--62f4c45447b62142
  ingress.kubernetes.io/url-map:                     k8s-um-default-ingress-monza-predictors--62f4c45447b62142
  kubectl.kubernetes.io/last-applied-configuration:  {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"kubernetes.io/ingress.global-static-ip-name":"ingress-monza-predictors"},"name":"ingress-monza-predictors","namespace":"default"},"spec":{"rules":[{"http":{"paths":[{"backend":{"serviceName":"predictor-classification-seatbelt-driver-service-node-port","servicePort":4444},"path":"/seatbelt-driver"},{"backend":{"serviceName":"predictor-classification-seatbelt-passenger-service-node-port","servicePort":4444},"path":"/seatbelt-passenger"}]}}]}}

  kubernetes.io/ingress.global-static-ip-name:  ingress-monza-predictors
Events:
  Type    Reason  Age   From                     Message
  ----    ------  ----  ----                     -------
  Normal  ADD     96s   loadbalancer-controller  default/ingress-monza-predictors
  Normal  CREATE  22s   loadbalancer-controller  ip: 35.244.250.224

以下是请求成功后的描述(几分钟后):

 ?   >kubectl describe ing ingress-monza-predictors
Name:             ingress-monza-predictors
Namespace:        default
Address:          35.244.250.224
Default backend:  default-http-backend:80 (10.40.2.10:8080)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *     
        /seatbelt-driver      predictor-classification-seatbelt-driver-service-node-port:4444 (<none>)
        /seatbelt-passenger   predictor-classification-seatbelt-passenger-service-node-port:4444 (<none>)
Annotations:
  kubectl.kubernetes.io/last-applied-configuration:  {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"kubernetes.io/ingress.global-static-ip-name":"ingress-monza-predictors"},"name":"ingress-monza-predictors","namespace":"default"},"spec":{"rules":[{"http":{"paths":[{"backend":{"serviceName":"predictor-classification-seatbelt-driver-service-node-port","servicePort":4444},"path":"/seatbelt-driver"},{"backend":{"serviceName":"predictor-classification-seatbelt-passenger-service-node-port","servicePort":4444},"path":"/seatbelt-passenger"}]}}]}}

  kubernetes.io/ingress.global-static-ip-name:  ingress-monza-predictors
  ingress.kubernetes.io/backends:               {"k8s-be-30355--62f4c45447b62142":"HEALTHY","k8s-be-31413--62f4c45447b62142":"HEALTHY","k8s-be-32727--62f4c45447b62142":"HEALTHY"}
  ingress.kubernetes.io/forwarding-rule:        k8s-fw-default-ingress-monza-predictors--62f4c45447b62142
  ingress.kubernetes.io/target-proxy:           k8s-tp-default-ingress-monza-predictors--62f4c45447b62142
  ingress.kubernetes.io/url-map:                k8s-um-default-ingress-monza-predictors--62f4c45447b62142
Events:
  Type    Reason  Age   From                     Message
  ----    ------  ----  ----                     -------
  Normal  ADD     10m   loadbalancer-controller  default/ingress-monza-predictors
  Normal  CREATE  9m5s  loadbalancer-controller  ip: 35.244.250.224

我的直觉是,如果后端显示“未知”状态,我应该等待。 但是,如果后端显示“健康”状态,则问题可能是由于配置错误。 这是正确的吗?

1 个答案:

答案 0 :(得分:1)

是的。根据此article,GKE需要花费几分钟的时间来分配外部IP地址并设置转发规则,直到负载均衡器可以为您的应用服务。