1
votes

I'm trying to load balance a cluster that is exposing port 7654. I've followed the instructions here. When following it exactly (creating the nginx cluster), it works fine, but when I try to apply it to my containers I can't get it to pass the health check. If I use kubectl to expose 7654 with LoadBalancer instead of NodePort, I'm able to connect, so it seems that the container is working fine. Does anyone have any advice for creating a load balancer?

1
If you look at the logs for your web server, do you see the health check requests? Are they being served a 200 response? In my experience when the backends are listed as unhealthy it means that the healthchecker isn't able to reach them (usually because of a mis-configured firewall rule). - Robert Bailey
The logs show the health check requests. I was able to make it work by changing the response from the server from an empty 200 response to a 200 response with valid HTML content. It appears that the health check doesn't only look for the 200 response. - user3113357

1 Answers

0
votes

According to https://cloud.google.com/compute/docs/load-balancing/health-checks#overview a successful health check "must return a valid HTTP response with code 200 and close the connection normally within the timeoutSec period". It's possible that your empty response wasn't closing the HTTP connection and adding HTML content caused your backend to close the connection.