Google cloud backend-service for HTTP load balancing ignores custom ports

8/11/2015

I have an app running on port 31280 exposed via nodePorts from a Kubernetes cluster. Same port is exposed through named-port on the instance group used by cluster for load balancing. While creating a backend-service with HTTP protocol, the service is created at default http port(80) even if I specify custom named-port.

Exposed named-port for instance group is:

gcloud preview instance-groups --zone='asia-east1-a' list-services gke-dropwizard-service-31ccc162-group

[
  {
    "endpoints": [
      {
        "name": "dropwizard-example-service-http",
        "port": 31280
      }
    ],
    "fingerprint": "XXXXXXXXXXXXXXXX"
  }
]

Health check is:

gcloud compute http-health-checks describe dropwizard-example-service

checkIntervalSec: 5
creationTimestamp: '2015-08-11T12:08:16.245-07:00'
description: Dropwizard Example Sevice health check ping
healthyThreshold: 2
host: ''
id: 'XXXXXXX'
kind: compute#httpHealthCheck
name: dropwizard-example-service
port: 31318
requestPath: /ping
selfLink: https://www.googleapis.com/compute/v1/projects/XXX/global/httpHealthChecks/dropwizard-example-service
timeoutSec: 3
unhealthyThreshold: 2

Health port(31318) is also exposed via named port in instance group.

Commands used to create backend-service is:

gcloud compute backend-services create "dropwizard-example-external-service" --description "Dropwizard Example Service via Nodeports from Kubernetes cluster" --http-health-check "dropwizard-example-service" --port-name "dropwizard-example-service-http" --timeout "30"

Command used to add instance group to backend-service is:

gcloud compute backend-services add-backend "dropwizard-example-external-service" --group "gke-dropwizard-service-31ccc162-group" --zone "asia-east1-a" --balancing-mode "UTILIZATION" --capacity-scaler "1" --max-utilization "0.8"

Finally created backend-service is described as:

gcloud compute backend-services describe dropwizard-example-external-service

backends:
- balancingMode: UTILIZATION
  capacityScaler: 1.0
  description: ''
  group: https://www.googleapis.com/resourceviews/v1beta2/projects/XXX/zones/asia-east1-a/resourceViews/gke-dropwizard-service-31ccc162-group
  maxUtilization: 0.8
creationTimestamp: '2015-08-11T13:10:46.608-07:00'
description: Dropwizard Example Service via Nodeport from Kubernetes cluster
fingerprint: XXXXXXXXXXXX
healthChecks:
- https://www.googleapis.com/compute/v1/projects/XXX/global/httpHealthChecks/dropwizard-example-service
id: 'XXXX'
kind: compute#backendService
name: dropwizard-example-external-service
port: 80
portName: dropwizard-example-service-http
protocol: HTTP
selfLink: https://www.googleapis.com/compute/v1/projects/XXXX/global/backendServices/dropwizard-example-external-service
timeoutSec: 30

I don't understand which part is wrong. Why backend-service is using port 80?

-- Sunil Kumar
google-cloud-platform
kubernetes

1 Answer

10/4/2015

EDIT: I was wrong. It does seem to work. I had a typo in my script.

My script is here - I literally just ran this and it worked properly.

https://gist.github.com/thockin/36fea15cc0deb08a768a

Original response for posterity:

I'm not an expert in the GCE L7 API yet, but I have made it work in Kubernetes. I think there's a bug in the --port-name logic. If you specify --port directly it seems to work for me. I'm filing an issue internally.

-- Tim Hockin
Source: StackOverflow