Operator to manager distributed websocket in Kubernetes Environment. Inspired by this article and by the fact that I solved the same issue. Should be experimental.
The websocket-operator
is a Kubernetes operator designed to manage stateful WebSocket connections within a Kubernetes environment. It automates the deployment and scaling of WebSocket proxies alongside application pods, facilitating efficient handling of long-lived connections and message routing.
- SideCar Deployment: Automatically injects a WebSocket Proxy SideCar into application pods based on annotations or labels.
- Load Balancing: Utilizes a LoadBalancer App to distribute WebSocket connections across multiple pods using Rendezvous Hashing.
- Extensible Proxying: Initially supports HTTP proxying - optimizations in the Roadmap
- Controller Automation: Manages the lifecycle and configuration of WebSocket Sidecars within the Kubernetes cluster.
The operator comprises the following components:
- WebSocket Proxy SideCar: Handles WebSocket connections, manages routing keys, and proxies messages via HTTP requests.
- Load Balancer Service: Distributes incoming WebSocket Connections using same algorithm from SideCar.
- Controller: Automates the injection and management of the WebSocket Proxy SideCar in application pods.
To deploy the WebSocket Operator in your Kubernetes cluster:
- Annotate Deployments: Add label
ws.operator/enable: true
to your Deployment to enable SideCar injection. - Expose
ws-proxy-headless
Headless Service - Deploy the Operator: Apply the operator manifests to your cluster to activate the controller and related resources.
- Plugin Support: Develop and integrate plugins for alternative proxying methods beyond HTTP.
- Metrics Exposure: Implement metrics to monitor connection success and failure rates.
- Enhanced Routing: Improve routing algorithms for more efficient message distribution.
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.