-
Notifications
You must be signed in to change notification settings - Fork 1
Deploy kubernetes
This directory contains the Kubernetes operator and manifests for deploying
and managing ThemisDB clusters in cloud-native environments. The operator
reconciles ThemisDB custom resources and automatically manages replication
topology, leader election, failover, and topology-aware scheduling.
- Kubernetes 1.21+
- kubectl configured
- Helm 3.0+ (optional)
# Create the operator namespace
kubectl create namespace themisdb-system
# Apply CRDs
kubectl apply -f crds/
# Deploy the operator (RBAC + Deployment + Service)
kubectl apply -f operator/# Create cluster namespace
kubectl create namespace themisdb
# Deploy a 3-node HA cluster with automated topology management
kubectl apply -f examples/themisdb-ha-replication.yaml# Show cluster status with topology info
kubectl get themisdb -n themisdb
# Detailed topology status
kubectl describe themisdb themisdb-ha -n themisdbkubernetes/
βββ README.md # This file
βββ crds/ # Custom Resource Definitions
β βββ themisdb.vcc.io_themisdbs.yaml # ThemisDB CRD with topology fields
βββ operator/ # Operator deployment manifests
β βββ deployment.yaml # Operator Deployment (2 replicas, HA)
β βββ rbac.yaml # ServiceAccount, ClusterRole, Binding
β βββ service.yaml # Metrics Service for Prometheus
βββ examples/ # Example configurations
βββ themisdb-cluster.yaml # 3-node cluster with sharding
βββ themisdb-single.yaml # Single node (dev/test)
βββ themisdb-ha-replication.yaml # 3-node cluster with full replication config
βββ hpa-basic.yaml # HorizontalPodAutoscaler
βββ hpa-gpu.yaml # HPA with GPU metrics
βββ load-balancer.yaml # LoadBalancer service
βββ vpa.yaml # VerticalPodAutoscaler
The operator source code is located at operator/ (Go module):
operator/
βββ cmd/main.go # Entry point / manager setup
βββ api/v1alpha1/
β βββ types.go # ThemisDB CRD Go types
β βββ deepcopy.go # DeepCopy methods (runtime.Object)
βββ internal/controller/
βββ themisdb_controller.go # Reconciler implementation
βββ export_test.go # Exported helpers for testing
βββ themisdb_controller_test.go # Unit tests (32 test cases)
The ThemisDB custom resource now includes a spec.replication block for
configuring the automated topology management:
apiVersion: vcc.io/v1alpha1
kind: ThemisDB
metadata:
name: my-cluster
spec:
replicas: 3
version: "1.0.0"
storage:
size: 100Gi
storageClass: standard
resources:
requests:
memory: "4Gi"
cpu: "2"
limits:
memory: "8Gi"
cpu: "4"
replication:
mode: SEMI_SYNC # SYNC | SEMI_SYNC | ASYNC
minSyncReplicas: 2
leaderElection:
electionTimeoutMinMs: 150
electionTimeoutMaxMs: 300
heartbeatIntervalMs: 100
leaderPreferencePriority: 1
failover:
enabled: true
failureDetectionTimeoutMs: 5000
maxFailoverAttempts: 3
failoverCooldownMs: 30000
lagThresholds:
degradedLagMs: 5000
criticalLagMs: 30000
readShiftEnabled: true
wal:
compression: true
syncOnCommit: true
retentionHours: 168
topologyAware:
spreadAcrossZones: true
spreadAcrossNodes: true
security:
mtls: true
rbac: true
monitoring:
prometheus: true
grafana: trueThe operator continuously reconciles each ThemisDB resource and manages:
| Feature | Description |
|---|---|
| StatefulSet ownership | Operator creates and owns the StatefulSet; rolling updates are applied automatically when spec changes |
| Headless Service | Per-cluster headless Service for stable pod DNS (<pod>.<cluster>-headless.<ns>.svc.cluster.local) |
| PodDisruptionBudget | Quorum-safe PDB: at most floor((replicas-1)/2) pods may be unavailable simultaneously |
| Replication ConfigMap | All replication topology parameters are materialised in a ConfigMap mounted by each pod |
| Topology status | Operator observes pod annotations (vcc.io/replication-role, vcc.io/replication-lag-ms) and updates .status.replicationTopology
|
| Lag-based routing | Replicas exceeding degradedLagMs are listed in .status.replicationTopology.laggingReplicas for upstream routers |
| Failover detection | Unready or terminating followers trigger a fast re-queue cycle (every 5 s) until the topology stabilises |
| Zone-aware placement |
TopologySpreadConstraints keep replicas balanced across zones and nodes |
| Leader election (operator HA) | Two operator replicas run; only one is active via Kubernetes Lease-based leader election |
The operator sets three status conditions on each ThemisDB:
| Condition |
True when |
|---|---|
Available |
All desired replicas are ready |
TopologyReady |
A leader is known and inSyncReplicas β₯ minSyncReplicas
|
Degraded |
At least one replica exceeds degradedLagMs
|
ThemisDB pods publish their replication state via pod annotations that the operator reads during topology reconciliation:
| Annotation | Example | Description |
|---|---|---|
vcc.io/replication-role |
LEADER |
Current role (LEADER, FOLLOWER, CANDIDATE, OBSERVER) |
vcc.io/replication-lag-ms |
350 |
Replication lag behind leader in milliseconds |
| Parameter | Description | Default |
|---|---|---|
mode |
Replication mode (SYNC, SEMI_SYNC, ASYNC) |
SEMI_SYNC |
minSyncReplicas |
Minimum in-sync replicas for quorum writes | 1 |
leaderElection.electionTimeoutMinMs |
Min election timeout (ms) | 150 |
leaderElection.electionTimeoutMaxMs |
Max election timeout (ms) | 300 |
leaderElection.heartbeatIntervalMs |
Leader heartbeat interval (ms) | 100 |
leaderElection.leaderPreferencePriority |
Priority for leader preference | 1 |
failover.enabled |
Enable automatic leader failover | true |
failover.failureDetectionTimeoutMs |
Timeout before node is declared failed | 5000 |
failover.maxFailoverAttempts |
Max failover attempts before giving up | 3 |
failover.failoverCooldownMs |
Min interval between failovers (ms) | 30000 |
lagThresholds.degradedLagMs |
Lag (ms) above which replica is degraded | 5000 |
lagThresholds.criticalLagMs |
Lag (ms) above which replica is excluded from reads | 30000 |
lagThresholds.readShiftEnabled |
Shift reads away from lagging replicas | true |
wal.compression |
Enable Zstd WAL compression | true |
wal.syncOnCommit |
fsync WAL on every commit | true |
wal.retentionHours |
Hours to retain WAL files | 168 |
topologyAware.spreadAcrossZones |
Spread pods across availability zones | true |
topologyAware.spreadAcrossNodes |
Spread pods across Kubernetes nodes | true |
kubectl logs -n themisdb-system -l app.kubernetes.io/name=themisdb-operator -fkubectl get crd themisdbs.vcc.iokubectl get themisdb -n themisdb -o wide
kubectl describe themisdb themisdb-ha -n themisdbkubectl get themisdb themisdb-ha -n themisdb \
-o jsonpath='{.status.replicationTopology}' | jq .kubectl get pods -n themisdb -l app.kubernetes.io/name=themisdb
kubectl describe pod <pod-name> -n themisdb
kubectl logs <pod-name> -n themisdbSee CONTRIBUTING.md for development guidelines.
Apache 2.0 β See LICENSE
ThemisDB 1.9.0-beta Β· Home Β· Module-Index Β· GitHub Β· Issues
ThemisDB 1.9.0-beta Β· Home Β· Wiki-Index Β· Module-Index Β· FAQ Β· Quick-Reference Β· GitHub Β· Issues Β· Discussions Β· License
- Batch Operations
- Best Practices
- CRUD Tutorial
- Custom Document Ingestion
- Getting Started Tutorial
- Interactive Examples
- Schema Design
- Video Tutorials
- AQL Reference
- AQL Examples
- AQL Overview
- AQL Feature Roadmap
- AQL Geospatial Guide
- AQL LLM Migration Guide
- AQL API
- AQL Grammar (EBNF)
- AQL Root Overview
- AQL Examples (root)
- API Reference
- API Module README
- OpenAPI Overview
- Client SDK Overview
- SDK Overview
- Operations
- Operations Overview
- Operations Runbook
- Operations Handbook
- ThemisCtl Admin Guide
- Pipeline E2E SOPs
- Deploy Overview
- Docker Overview
- Docker Hub README
- Helm Overview
- Packaging Overview
- Operator Overview
- Security Policy
- Production Hardening Checklist
- Security Hardening Guide
- Encryption Key Management
- Access Control Framework
- Zero Trust Policy
- API Authentication & Authorization
- HSM Production Setup
- PKCS11 Integration
- DSGVO / SOC2 Checklist
- Access Model Runbooks
- Access Model Dashboard
- Maturity Automation Runbook
- Access Review Automation
- Access Model Dashboard
- Access Model Runbooks
- Rights Revocation
- Dr Checklists
- Dr Testing
- Incident Response Playbook
- Incident Response Testing
- GPU Oom Recovery
- Grammar Debugging
- Metrics Scrape Troubleshooting
- Model Swap Procedure
- Quota Tuning
- Subagent Deployment
- Logging Configuration
- Content Model
- Crypto & Keys
- Feature Flags Reference
- Modular Architecture Roadmap
- Modularization Guide
- Module Architecture Index
- PostgreSQL Wire Protocol
- Query Scheduling
- Raft Consensus Design
- Resource Pooling
- Source Directory Guide
- Unified Access Model
- E1 001 Layered Retrieval Design
- E1 002 Ann Abstraction Strategy
- E1 003 Tensor Summary Types
- E1 004 Lora Package Distinction
- E1 005 Model Switch Compatibility
- E1 006 Federated Tensor Summaries
- E2 001 Evaluation Framework Design
- E2 002 Hardware Profile Strategy
- E2 003 Query Planner Routing Model
- E2 004 Approximation Governance Rules
- E2 005 Cross Layer Fallback Confidence Policy
- E3 001 Distributed Tensor Design
- E3 002 Manifest Coordination Strategy
- E3 003 Recovery And Erasure Choice
- E3 004 Tensor Fabric Infrastructure
- Contributing
- Contributing (root)
- Code of Conduct
- Support
- Maintainers
- CTest Guide
- Build Quick Reference
- Developer Wiki Index
- Build / Test / CI
- Module Index
- Branching Strategy
- Disabled Stub Policy
- Docs PR Policy
- GA Promotion Sign Off
- Github Milestones Setup
- Maturity Claim Verification Checklist
- Maturity Evidence Registry
- Merge Gate Bot Config
- Merge Gate Status Live
- Phase 1 Closure Report
- Phase Closure Policy
- Phase Dependency Graph
- Phase3 Enforcement Runbook
- Plugin Submodule Rollback
- PR Version Targeting
- PR Version Targeting Backfill
- Production Ready 2026 Delivery Plan
- Query Module Status
- Readme
- Release Promotion Gate Policy
- Release Validation Checklist
- Security Module 5671 Evidence Summary
- Sharding P6 Residual Risk Acceptance
- Sourcecode Compliance Governance
- Updates Development Status Sign Off
- Wave C Implementation Complete
- Blob Storage
- Cuda
- Ethics Ai
- Exporters
- Huggingface
- Image Analysis
- Importers
- RPC
- Scraper
- Themisdb Ai Watermark Detector
- User Storage Encrypted
- Chimera Architecture
- Chimera Future
- Chimera Readme
- Chimera Roadmap
- Covina Fastapi Ingestion Architecture
- Covina Fastapi Ingestion Future
- Covina Fastapi Ingestion Roadmap
- Vcc Base Architecture
- Vcc Base Future
- Vcc Base Roadmap
- Vcc Clara Ingestion Architecture
- Vcc Clara Ingestion Future
- Vcc Clara Ingestion Roadmap
- Vcc Veritas Architecture
- Vcc Veritas Future
- Vcc Veritas Roadmap
- 01 Hello World
- 02 Todo App
- 03 Contact Manager
- 04 Inventory System
- 05 Time Series Monitor
- 06 Graph Social Network
- 07 Vector Search Documents
- 08 Dms Erp System
- 09 Iot Sensor Network
- 10 Drone Image Analysis
- 11 Blog Wiki
- 12 Expense Tracker
- 13 Recipe Manager
- 14 Ecommerce Catalog
- 15 Event Management
- 16 Kanban Board
- 17 Crm
- 18 Realtime Chat
- 19 Recommendation Engine
- 20 Smart Home
- 21 Coding Platform
- 22 AQL Diagram Tool
- 23 Traveling Salesman
- 24 Moral Philosophy Debates
- API Versioning
- Distributed Sharding
- Feedback Plugins
- Geo
- Gnn
- Image Analysis
- Legal Lora Training
- LLM
- Lora Sync
- Migration
- Nlp
- Performance
- Railway
- Replication
- Rope Visualization
- Sample Product Config
- Security
- Client SDK Overview
- Quickstart
- Sdk Enhancements
- Sdk Implementation Summary
- Test Suite Readme
- Go
- Java
- Javascript
- Php
- Python
- Ruby
- Rust
- Typescript
- 01 Grundlegende Operationen
- 02 AQL Queries
- 03 Graph Daten
- 04 Multimodell Anwendung
- 01 Quickstart Guide
- 02 AQL Referenz Kurzuebersicht
- 03 Datenmodellierung Guide
- 04 Uebungsaufgaben
- 05 Best Practices Guide
- Training Documents
- Training Overview
- 01 Einfuehrung Und Uebersicht
- 02 Datenmodelle Und Architektur
- 03 AQL Abfragesprache
- 04 Installation Und Setup
- 05 Anwendungsbeispiele
- Training Presentations
- Dependencies Readme
- Processmonitor Readme
- Themis.admintools.shared Readme
- Themis.aqlquerybuilder Readme
- Themis.aqlquerybuilder Roadmap
- Themis.auditlogviewer Readme
- Themis.auditlogviewer Roadmap
- Themis.classificationdashboard Readme
- Themis.classificationdashboard Roadmap
- Themis.compliancereports Readme
- Themis.compliancereports Roadmap
- Themis.gisviewer.controlpanel Readme
- Themis.gisviewer.controlpanel Roadmap
- Themis.impactanalysisviewer Readme
- Themis.impactanalysisviewer Roadmap
- Themis.ingestiontool Readme
- Themis.ingestiontool Roadmap
- Themis.keyrotationdashboard Readme
- Themis.keyrotationdashboard Roadmap
- Themis.piimanager Readme
- Themis.piimanager Roadmap
- Themis.retentionmanager Readme
- Themis.retentionmanager Roadmap
- Themis.sagaverifier Readme
- Themis.sagaverifier Roadmap
- Themis.usbadmintool Readme
- Themis.usbadmintool Roadmap
- CI Readme
- CI Roadmap
- Compiler Diagnostics Readme
- Compiler Diagnostics Roadmap
- Completion Readme
- Copilot Ollama Router Readme
- Copilot Ollama Router Roadmap
- Gnn Readme
- Gnn Roadmap
- Rope Visualizer Readme
- Rope Visualizer Roadmap
- Tco Calculator Readme
- Tco Calculator Roadmap
- Tests Readme
- Tests Roadmap
- Themis Config Wx Readme
- Themis Docs Builder Readme
- Wikipedia Ingestion Readme