HTTP Load Balancer on Google Container Engine using Ingress

google-kubernetes-enginekubernetesload balancing

I've tried following the following tutorial: https://cloud.google.com/container-engine/docs/tutorials/http-balancer

Everything seems to be working up until the end where doing

kubectl describe ingress basic-ingress

returns

 Name:          basic-ingress
Namespace:      default
Address:        {hidden_external_ip}
Default backend:    nginx:80 ({hidden_internal_ip}:80)
Rules:
  Host  Path    Backends
  ----  ----    --------
  * *   nginx:80 ({hidden_internal_ip}:80)
Annotations:
  backends:     {"k8s-be-00000--0000000000000000":"Unknown"}
  forwarding-rule:  k8s-fw-default-basic-ingress--0000000000000000
  target-proxy:     k8s-tp-default-basic-ingress--0000000000000000
  url-map:      k8s-um-default-basic-ingress--0000000000000000
Events:
  FirstSeen LastSeen    Count   From                SubobjectPath   Type        Reason  Message
  --------- --------    -----   ----                -------------   --    ------    ------  -------
  1m        1m      1   {loadbalancer-controller }          Normal          ADD default/basic-ingress
  23s       23s     1   {loadbalancer-controller }          Normal          CREATE  ip: {hidden_external_ip}

Notice that the backends line ends with "unknown"

Furthemore, curling the external IP returns this:

<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>502 Server Error</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Server Error</h1>
<h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>
<h2></h2>
</body></html>

Any idea what could cause such an issue?

Best Answer

I figured out two things:

  1. The load balancer does a health check on / (which is not documented AFAIK), so you have to make sure that your backend returns 200 on that path.

  2. There is a significant delay between when the load-balancer is created and when it "becomes active" (~10 minutes or so). When it does, the line: backends: {"k8s-be-00000--0000000000000000":"Unknown"} will become either: backends: {"k8s-be-00000--0000000000000000":"Healthy"} or backends: {"k8s-be-00000--0000000000000000":"Unhealthy"}. This delay was the reason the tutorial linked in the question was not working (it really should be documented there...)