Skip to main content

Generic Multi-Node Control Plane Toolkit

Project description

BazBeans - Generic Multi-Node Control Plane Toolkit

Orchestrate distributed applications with ease - A reusable toolkit for managing multi-node deployments with automatic health monitoring, load balancer integration, and centralized control.

๐ŸŽฏ What is BazBeans?

BazBeans is a generic control plane toolkit that helps you manage distributed applications across multiple servers. Think of it as the "operating system" for your cluster - it handles the hard parts of distributed coordination so you can focus on your application.

BETA : This project is new. Use at your own risk. We're developing the framework and it's early days. We're using it for our own project(s), but would not recommend using in production without testing and a fallback plan. I mean... we are using it, but don't necessarily do as we do. Or try it, you may love it. :-)

macOS : The project includes macOS support, but has not been tested.

๐Ÿš€ Key Capabilities

  • ๐Ÿฅ Self-Healing Nodes - Nodes monitor their own health and automatically remove themselves from the load balancer when unhealthy
  • ๐ŸŽ›๏ธ Centralized Control - Manage your entire cluster from a simple command-line interface
  • โšก Auto Load Balancing - Automatic Nginx upstream updates via Redis pub/sub
  • ๐Ÿ”Œ Pluggable Architecture - Add custom health checks, commands, and IP resolution strategies
  • ๐Ÿ”„ Zero Project Coupling - Generic design works with any application stack
  • ๐Ÿš€ One-Click CLI Installation - Auto-installs OS-specific CLI when you pip install bazbeans

๐Ÿ›ค๏ธ Choose Your Path (30 seconds)

๐ŸŽฎ I want to manage existing nodes

Goal: Control and monitor a running cluster Start: CLI Setup Guide โ†’ 5-minute setup

๐Ÿค– I want to deploy new agents

Goal: Add BazBeans agents to my applications Start: Agent Deployment Guide โ†’ Production-ready setup

โšก I want to try it right now

Goal: Quick test on my local machine Start: Quick Start Guide โ†’ 5-minute working demo

๐Ÿ“š I want to understand how it works

Goal: Learn the architecture and concepts Start: Architecture Guide โ†’ Deep dive


๐Ÿš€ Quick Start (5 minutes)

Get a working cluster in under 5 minutes:

# 1. Start Redis
redis-server

# 2. Install BazBeans
pip install bazbeans

# The CLI is automatically installed for your OS!
# You can start using 'bazbeans' commands immediately

# 3. Run a test agent
python -c "
from bazbeans import BazBeansConfig, NodeAgent
config = BazBeansConfig(redis_url='redis://localhost:6379/0', node_id='test-node')
NodeAgent(config).run()
" &

# 4. Manage your cluster
bazbeans list-nodes
bazbeans status test-node

โš ๏ธ Note: For production deployment, see the Agent Deployment Guide


๐Ÿ—๏ธ Architecture Overview

graph TB
    subgraph "Control Plane"
        CLI[CLI Interface]
        Redis[(Redis Server)]
    end
    
    subgraph "Data Center 1"
        N1[Node Agent 1]
        N2[Node Agent 2]
    end
    
    subgraph "Data Center 2"
        N3[Node Agent 3]
        N4[Node Agent 4]
    end
    
    subgraph "Load Balancer"
        LB[Nginx Updater]
    end
    
    CLI --> Redis
    N1 --> Redis
    N2 --> Redis
    N3 --> Redis
    N4 --> Redis
    Redis --> LB
    
    N1 -.-> |Health Check| N1
    N2 -.-> |Health Check| N2
    N3 -.-> |Health Check| N3
    N4 -.-> |Health Check| N4

Core Components

Component Purpose Key Features
NodeAgent Runs on each server Health monitoring, command handling, self-management
ControlCLI Administrative interface Cluster management, node control, file deployment
NginxUpdater Load balancer integration Automatic upstream updates, IP resolution
NodePool Redis state management Heartbeats, status tracking, command queues

๐ŸŽฏ Use Cases

๐ŸŒ Web Application Clusters

# Perfect for FastAPI, Django, Flask applications
# Automatic health checks and load balancer updates
# Rolling updates with zero downtime

๐Ÿ“ฆ Microservices Management

# Manage containerized services
# Docker-compose integration included
# Custom health checks per service

๐Ÿ”„ Background Job Processing

# Monitor Celery, RQ, or custom job queues
# Auto-freeze unhealthy workers
# Centralized job queue management

๐Ÿข Enterprise Applications

# Multi-datacenter deployments
# Custom command handlers for business logic
# Integration with existing monitoring systems

๐Ÿ› ๏ธ Configuration Examples

Basic Web Server Setup

from bazbeans import BazBeansConfig, NodeAgent, DockerComposeCommands

config = BazBeansConfig(
    redis_url="redis://cluster-redis:6379/0",
    node_id="web-server-01",
    data_center="us-east-1",
    node_port=8000,
    cpu_threshold=85,
    memory_threshold=80
)

agent = NodeAgent(config)
agent.register_command_plugin(DockerComposeCommands(config))

# Add web-specific health check
@agent.health_check
def check_web_health():
    import requests
    return requests.get("http://localhost:8000/health").status_code == 200

agent.run()

Database Server Setup

config = BazBeansConfig(
    redis_url="redis://cluster-redis:6379/0",
    node_id="db-server-01",
    data_center="us-east-1",
    cpu_threshold=95,  # Higher threshold for databases
    memory_threshold=90
)

agent = NodeAgent(config)

# Add database-specific health checks
@agent.health_check
def check_database():
    # Your database connection logic
    return database.is_connected()

@agent.health_check
def check_replication():
    # Check replication lag
    return database.replication_lag() < 10

agent.run()

๐ŸŽฎ CLI Commands

Node Management

# List all nodes with health status
bazbeans list-nodes

# Get detailed node information
bazbeans status web-server-01

# Freeze a node (remove from load balancer)
bazbeans freeze web-server-01 --reason "maintenance"

# Unfreeze a node
bazbeans unfreeze web-server-01

Service Control

# Start services on a node
bazbeans start web-server-01

# Stop services
bazbeans stop web-server-01

# Restart services
bazbeans restart web-server-01

# Rolling update across datacenter
bazbeans update --dc us-east-1

Operations

# Execute commands on nodes
bazbeans exec web-server-01 "docker ps"

# Deploy files to nodes
bazbeans deploy-file web-server-01 ./config.yaml /opt/app/config.yaml

# Clean up dead nodes
bazbeans cleanup

๐Ÿ”Œ Extensibility

Custom Health Checks

@agent.health_check
def check_custom_service():
    """Check if your custom service is healthy."""
    try:
        # Your health check logic
        return service.ping()
    except:
        return False

@agent.health_check
def check_disk_space():
    """Custom disk space check."""
    import psutil
    return psutil.disk_usage('/app').percent < 95

Custom Command Handlers

@agent.command_handler("backup")
def handle_backup(command):
    """Handle backup commands."""
    # Your backup logic
    return {"status": "backup_started", "timestamp": time.time()}

@agent.command_handler("custom_action")
def handle_custom(command):
    """Handle custom business logic."""
    # Your custom logic
    return {"status": "completed", "result": "success"}

IP Resolution Strategies

from bazbeans.ip_resolvers import (
    RedisIPResolver,      # Nodes self-register IPs
    DNSIPResolver,        # DNS lookup
    StaticIPResolver,     # Static mapping
    ChainedIPResolver     # Primary + fallback
)

# Choose your strategy
resolver = ChainedIPResolver(
    primary=RedisIPResolver(redis_client),
    fallback=StaticIPResolver({"emergency-ip": "10.0.1.100"})
)

๐Ÿ“Š System Requirements

Minimum Requirements

  • Python: 3.8 or higher
  • Memory: 512MB per node
  • Disk: 100MB free space
  • Network: Port 6379 (Redis) accessible

Recommended for Production

  • Python: 3.9+ with virtual environment
  • Memory: 1GB+ per node
  • Redis: Dedicated server with persistence
  • Network: Private network or VPN
  • Security: Redis AUTH + TLS

Platform Support

  • โœ… Linux (Ubuntu, CentOS, Debian)
  • โœ… macOS (development only)
  • โœ… Windows (development only)
  • โœ… Docker containers
  • โœ… Kubernetes (with custom setup)

๐Ÿ”’ Security Considerations

Redis Security

# Enable Redis authentication
requirepass your-secure-password

# Use TLS in production
tls-port 6380
tls-cert-file /path/to/redis.crt
tls-key-file /path/to/redis.key

# Network isolation
bind 10.0.1.10 127.0.0.1

Agent Security

# Run as non-root user
# Use virtual environments
# Validate file paths
# Whitelist allowed commands
config.allowed_exec_prefixes = ["docker", "systemctl", "ls"]

Network Security

  • Use VPN or private networks
  • Implement firewall rules
  • Monitor for unauthorized access
  • Regular security audits

๐Ÿ“š Documentation

Getting Started

Advanced Topics

Reference


๐Ÿ†˜ Getting Help

Self-Service

Community

  • GitHub Issues - Bug reports and feature requests
  • Discussions - Questions and best practices
  • Wiki - Community-contributed content

Enterprise Support

  • Priority support channels
  • Custom integration assistance
  • Architecture consulting
  • Training sessions

๐Ÿค Contributing

We welcome contributions! See our Contributing Guide for details.

Quick Contribution Steps

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

๐Ÿ“„ License

This toolkit is designed to be generic and reusable across projects. Please adapt and extend as needed for your specific use case.


๐ŸŽ‰ Release Notes

v0.1.1 - Auto-Installation Feature

๐Ÿš€ New: One-Click CLI Installation

  • Automatic CLI Installation: When you run pip install bazbeans, the OS-specific CLI is now automatically installed
  • Cross-Platform Support: Works seamlessly on Linux, macOS, and Windows
  • Smart OS Detection: Automatically chooses the right installer for your platform
  • Error Handling: Graceful fallbacks if installation fails - Python package still works
  • Skip Options: Multiple ways to skip auto-installation if needed

๐Ÿ› ๏ธ Improvements

  • Enhanced setup experience with automatic PATH configuration
  • Clear installation progress messages
  • Comprehensive troubleshooting documentation
  • Manual installation options still available

๐Ÿ“š Documentation

๐Ÿ”ง Technical Details

  • Custom setuptools commands for integration
  • Post-installation hooks for seamless installation
  • Environment variable controls for customization
  • Non-blocking installation that doesn't affect Python package functionality

What's Next

  • Enhanced cross-platform compatibility testing
  • Additional CLI command improvements
  • More integration examples and patterns

๐ŸŽฏ Next Steps

  1. New Users: Start with Quick Start Guide
  2. Production Setup: Read Agent Deployment Guide
  3. Custom Integration: See Examples folder
  4. Deep Understanding: Review Architecture Guide

โฑ๏ธ Time to First Value: 5 minutes with Quick Start
๐ŸŽฏ Primary Goal: Simplify distributed application management
๐Ÿ”ง Approach: Generic, pluggable, production-ready toolkit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bazbeans-0.1.7.tar.gz (68.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bazbeans-0.1.7-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file bazbeans-0.1.7.tar.gz.

File metadata

  • Download URL: bazbeans-0.1.7.tar.gz
  • Upload date:
  • Size: 68.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for bazbeans-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e7b1f0d0507ae9d13d45baf1c31fd1dda84dfe5655cad9026be7fbd9c4e3ee48
MD5 0359e1e27a3adfb4ee04598775fd390c
BLAKE2b-256 f018055e2d4fee596f1daf90a5622a9e26bc1c336262607fb859baf283f7e52d

See more details on using hashes here.

File details

Details for the file bazbeans-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: bazbeans-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for bazbeans-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1f78167ca60b4ede9be1ddf1e700ec68b4a37f6e401f00825808e2ba698b8a3c
MD5 7cc3d60d5cdca52cfc818af18c74aca6
BLAKE2b-256 12f2f237ec3230423a00c3675b55cb6563248c97ea9810954c23fdc60236724e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page