How to setup a websocket in Google Kubernetes Engine

9/8/2018

How do I enable a port on Google Kubernetes Engine to accept websocket connections? Is there a way of doing so other than using an ingress controller?

-- Harry Stuart
google-kubernetes-engine
kubernetes
kubernetes-ingress
websocket

2 Answers

9/15/2018

Web sockets are supported by Google's global load balancer, so you can use a k8s Service of type LoadBalancer to expose such a service beyond your cluster.

Do be aware that load balancers created and managed outside Kubernetes in this way will have a default connection duration of 30 seconds, which interferes with web socket operation and will cause the connection to be closed frequently. This is almost useless for web sockets to be used effectively.

Until this issue is resolved, you will either need to modify this timeout parameter manually, or (recommended) consider using an in-cluster ingress controller (e.g. nginx) which affords you more control.

-- Cosmic Ossifrage
Source: StackOverflow

9/12/2018

As per this article in the GCP documentation, there are 4 ways that you may expose a Service to external applications.

It can be exposed with a ClusterIP, a NodePort, a (TCP/UDP) Load Balancer, or an External Name.

-- Mahmoud Sharif
Source: StackOverflow