HUB
Sign inSign up
spa-reloader logo

toucansoftware/spa-reloader

By toucansoftware

•Updated almost 5 years ago

Kubernetes Controller for informing Single Page Applications via WebSockets.

Image
0

755

toucansoftware/spa-reloader repository overview

⁠SPA Reloader

SPA Reloader provides a Kubernetes Controller that listens to changes in Deployments container image changes, and informes Single Page Applications via WebSockets.

Problem: Single Page Application (SPA) are great technology, they run on the client browser and do not need round trip to the server every time we move across the application. That means we have to load the entire (or part of the) application in the browser, which will tipically communicate with a REST API in the server. But if we upgrade the SPA, unless we reload the page, the browser has not standard way of knowing if the application has changed and needs to reload it.

Solution: The solution proposed is implies a Server Side component and a Client Side component.

  • Server Side: Use a Kubernetes Controller that listen to changes in the Deployment configuration specified by the user and send a WebSocket message to clients.
  • Client Side: Use a websocket client that subscripts to the server and stores the current image version. If the client recieves a message with a different image version it would fire an event to inform the applition that a it's running diffrent version of the applition and the application can issue an reload from the server to upgrade to the latest.

⁠Configuration

The controller takes the following environment variables in order to configure its behavior.

  • SPA_NAMESPACE: is the name of the environment variable used to watch for changes in a namespace.
  • SPA_NAME: is the name of the environment variable used to watch for changes in deployment name.
  • SPA_RESYNC_SEC: is the number of seconds to resync.

Tag summary

Content type

Image

Digest

Size

17.6 MB

Last updated

almost 5 years ago

docker pull toucansoftware/spa-reloader