<p>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.</p>

<p>Exposed named-port for instance group is:</p>

<pre><code>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"
  }
]
</code></pre>

<p>Health check is: </p>

<pre><code>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
</code></pre>

<p>Health port(31318) is also exposed via named port in instance group.</p>

<p>Commands used to create backend-service is:</p>

<pre><code>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"
</code></pre>

<p>Command used to add instance group to backend-service is:</p>

<pre><code>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"
</code></pre>

<p>Finally created backend-service is described as:</p>

<pre><code>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
</code></pre>

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

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

<p>My script is here - I literally just ran this and it worked properly.</p>

<p><a href="https://gist.github.com/thockin/36fea15cc0deb08a768a" rel="nofollow">https://gist.github.com/thockin/36fea15cc0deb08a768a</a></p>

<p>Original response for posterity:</p>

<p>I'm not an expert in the GCE L7 API yet, but I <em>have</em> 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.</p>
