on google container engine, how do i use "expose" with "--public-ip"?

7/22/2015

I've deployed Docker container's on GCE via a Kubernetes cluster using Google's Container Engine tools.

Setting the 'type': 'LoadBalancer' on a service does not support websockets. I want to expose my own nginx service to support websockets but run it inside kubernetes for the dns / service disco.

I see the kubectl expose command has a --public-ip= param. Any hint about how to set up that ip appreciated.

update, tried the expose with --dry-run -o yaml to pass affinity param:

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    name: tfe
  name: mytfe
spec:
  sessionAffinity: ClientIP
  ports:
  - name: default
    nodePort: 0
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    name: tfe
  type: LoadBalancer
status:
  loadBalancer: {}

it opens http fine but I get 400 on the ws GET (after the POST got 200)

"GET /socket.io/?EIO=3&transport=polling&t=1437780794642-2313&sid=JuLWBlEy4Wjk3zHSAAH0 HTTP/1.1" 400

-- navicore
google-compute-engine
google-kubernetes-engine

1 Answer

7/22/2015

Why doesn't it support web sockets? It should. You need to set session affinity on.

Sadly kubectl expose doesn't currently have a flag for session affinity (it should) but if you run kubectl expose --dry-run=true ... it will dump the API object it would send, and then you can add service.spec.sessionAffinity to "ClientIP"

and then run kubectl create -f <file> and it should work. If it doesn't please come on IRC or file a github issue with a repro.

I filed: https://github.com/GoogleCloudPlatform/kubernetes/issues/11718 for adding a flag to kubectl to do this.

Thanks!

-- Brendan Burns
Source: StackOverflow