Jonathan Scott
Dec 29, 2020

--

Yep, I'll do my best.

It might be easiest with a complete example.

Create and deploy a WebSocket application with the following artifacts. I assume you can adjust the artifacts where necessary to work for your use case.

WebSocket Server:

https://gist.github.com/hyperstripe50/9c0b82671937bbb746d655ed295168d2

WebSocket Client:

https://gist.github.com/hyperstripe50/9b8ca7a5b3e0f05e121dc0baebd09a99

Server Dockerfile:

https://gist.github.com/hyperstripe50/0d8ad047e8b68f09b48ba0955dbf23a2

WebSocket Deployment Yaml:

https://gist.github.com/hyperstripe50/74bfcd5caf3900d2fc081c178db06082

Traefik Service Yaml:

https://gist.github.com/hyperstripe50/9e79bc75781934b4d381476cea59af56

Save all of these files to a directory, modify where needed, and run the following:

npm install ws

Deploy the app:

kubectl create -f nodewebsocketdeployment.yaml

After the container is created, run the client locally:

node nodewebsocketclient.js

You'll see the reply from the server.

--

--

Responses (1)