Harry Stuart
Harry Stuart

Reputation: 1929

How to setup a websocket in Google Kubernetes Engine

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?

Upvotes: 2

Views: 5113

Answers (2)

Cosmic Ossifrage
Cosmic Ossifrage

Reputation: 5379

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.

Upvotes: 1

Mahmoud Sharif
Mahmoud Sharif

Reputation: 1103

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.

Upvotes: 1

Related Questions