Load Balancer with Kubernetes returns ERR_EMPTY_RESPONSE

March 18, 2019 930 views
Load Balancing Kubernetes

I’m trying to use a Load Balancer in front of my Kubernetes cluster. The Load Balancer says that the droplet status is healthy, but whenever I try to load the IP or the domain that I pointed to that IP, it just hangs and then I get ERREMPTYRESPONSE in Chrome saying that the page didn’t send any data. Here’s the config for my service:

apiVersion: v1
kind: Service
metadata:
  name: my-app-load-balancer
spec:
  type: LoadBalancer
  selector:
      app: my-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
      name: http

And here’s the config for my deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app
          image: gcr.io/my-app/my-app:v1
          imagePullPolicy: Always
          ports:
          - containerPort: 3000
      imagePullSecrets:
        - name: gcr-json-key

And when I run kubectl get services, I get this:

NAME                               TYPE           CLUSTER-IP      EXTERNAL-IP       PORT(S)        AGE
my-app-load-balancer   LoadBalancer   xxxx   xxxx   80:30262/TCP   5h41m

And when I run kubectl logs $POD_NAME, I get that no requests have been received, just the initial listening message when the app server starts up:

[2019-03-18 04:03:13.89389] [1] [info] Listening at "http://*:3000" 
4 Answers

Additionally, I ran this command against the pod:

kubectl exec my-pod-xyz -c my-app -- curl localhost:3000

And the app server on the pod did return the page, and then running kubectl logs $POD_NAME actually contained the request in the logs. So it seems like the load balancer isn’t reaching the pod at all.

I’m still not sure what the issue was, but I deleted my service and deployment, and then I created the service and then the deployment again, and now things seem to be working.

Have another answer? Share your knowledge.