Sign inSign up

xomoxcc/openclaw-k8s-toggle-operator

By xomoxcc

Updated 7 months ago

Image
0

2.4K

xomoxcc/openclaw-k8s-toggle-operator repository overview

black-lint mypy and pytests BuildAndPushMultiarch Cumulative Clones PyPI Downloads PyPI

Gemini_Generated_Image_7vikwe7vikwe7vik_250x250.png

openclaw-k8s-toggle-operator

Matrix-controlled Kubernetes deployment toggle operator. Connects to a Matrix homeserver with E2E encryption and listens for chat commands to scale a K8s deployment between 0 and 1 replicas.

Operator startup in K9s

Operator startup with JWT auth and crypto store migration

Old crypto store key import and device trust

Features

  • Scale a Kubernetes Deployment to 0 or 1 replicas via Matrix chat commands
  • E2E encryption via minimatrix (matrix-nio wrapper) with persistent crypto store
  • Session reuse — persists Matrix access token and device ID across restarts
  • Auto-join pending room invites on startup
  • TOFU device trust for allowed users
  • Multiple auth methods: password, SSO, or JWT via Keycloak (ROPC + JWKS)
  • Clean signal handling (SIGTERM/SIGINT) for graceful container shutdown
  • Auto-reconnect with exponential backoff (max 20 retries)
  • Structured logging via loguru

Quick start

docker run --rm xomoxcc/openclaw-k8s-toggle-operator:latest

Bot Commands

CommandAction
start / onScale deployment to 1 replica
stop / offScale deployment to 0 replicas
statusShow deployment replica counts
helpShow available commands

Configuration

VariableDescriptionDefault
MATRIX_HOMESERVERMatrix homeserver URLhttp://synapse.matrix.svc.cluster.local:8008
MATRIX_USERMatrix bot username (required)--
MATRIX_PASSWORDMatrix bot password (required)--
ALLOWED_USERSComma-separated full Matrix user IDs (required)--
DEPLOYMENT_NAMEK8s Deployment to toggleclawdbot
DEPLOYMENT_NAMESPACENamespace of the target Deploymentclawdbot
CRYPTO_STORE_PATHPath for E2E encryption crypto store/data/crypto_store
AUTH_METHODAuth method (password, sso, or jwt)password
ECHO_MODEEcho user messages with lobster emoji before processingtrue
LOGURU_LEVELLog verbosity (DEBUG, INFO, WARNING, ...)DEBUG
JWT Authentication (Keycloak)

Set AUTH_METHOD=jwt to authenticate via Keycloak ROPC grant instead of direct Matrix password login. The bot obtains a JWT from Keycloak and presents it to Synapse for validation via JWKS.

VariableDescriptionDefault
AUTH_METHODAuth method (password, sso, or jwt)password
KEYCLOAK_URLKeycloak base URL (required if jwt)--
KEYCLOAK_REALMKeycloak realm name (required if jwt)--
KEYCLOAK_CLIENT_IDKeycloak client ID (required if jwt)--
KEYCLOAK_CLIENT_SECRETKeycloak client secret""
JWT_LOGIN_TYPEMatrix login type for JWT authcom.famedly.login.token.oauth

Requires synapse-token-authenticator on the Synapse side. See the setup guide for step-by-step instructions.

Kubernetes Deployment

The operator runs as a single-replica Deployment with a namespace-scoped ServiceAccount. The crypto store must be on a persistent volume or the bot loses decryption keys on restart. See the README for full RBAC and Deployment manifests.

Image details

  • Base: python:3.14-slim-trixie
  • Non-root user (pythonuser)
  • Entrypoint: tini -- with openclaw-k8s-toggle-operator as default CMD
  • Requires libolm-dev for E2E encryption
  • Multi-arch: linux/amd64, linux/arm64

Building the image

# Simple local build
docker build -t openclaw-k8s-toggle-operator .

# Multi-arch build & push
./build-container-multiarch.sh

# Local-only build (no push)
./build-container-multiarch.sh onlylocal

# Docker Hub login only
./build-container-multiarch.sh login

License

This project is licensed under the LGPL where applicable/possible — see LICENSE.md. Some files/parts may use other licenses: MIT | GPL | LGPL. Always check per‑file headers/comments.

Authors

  • Repo owner (primary author)
  • Additional attributions are noted inline in code comments

Acknowledgments

  • Inspirations and snippets are referenced in code comments where appropriate.

⚠️ Note

This is a development/experimental project. For production use, review security settings, customize configurations, and test thoroughly in your environment. Provided "as is" without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. Use at your own risk.

Tag summary

Content type

Image

Digest

sha256:fbc00f800

Size

247 MB

Last updated

7 months ago

docker pull xomoxcc/openclaw-k8s-toggle-operator