This document provides a comprehensive overview of the Hivemind container orchestration platform's architecture, explaining how the various components work together to provide a robust, distributed system.
Hivemind is a lightweight container orchestration platform built in Go, designed to provide Kubernetes-like features with significantly lower complexity and resource requirements. The system follows a modular architecture with clear separation of concerns between components.
The App Manager is responsible for application and container lifecycle management:
- Container Deployment: Handles the deployment of containers from images
- Application Scaling: Manages the scaling of applications up or down
- Container Lifecycle: Manages the lifecycle of containers (create, start, stop, remove)
- Service Configuration: Manages service configurations for applications
Key interfaces:
AppManager: Main interface for application managementServiceConfig: Configuration for services
The Deployment Manager handles advanced deployment strategies:
- Strategy Selection: Chooses the appropriate deployment strategy
- Blue-Green Deployments: Manages blue-green deployments with zero downtime
- Canary Deployments: Manages canary deployments with incremental rollout
- A/B Testing: Manages A/B testing deployments with traffic splitting
- Rollback Management: Handles rollbacks in case of deployment failures
Key interfaces:
DeploymentManager: Main interface for deployment managementDeploymentExecutor: Executes deployment strategiesDeploymentStrategy: Defines deployment strategies
The Node Manager handles cluster coordination and node discovery:
- Node Registration: Registers nodes in the cluster
- Node Status: Tracks the status of nodes
- Resource Tracking: Monitors node resources (CPU, memory, disk)
- Node Coordination: Coordinates operations across nodes
Key interfaces:
NodeManager: Main interface for node managementNodeResources: Represents node resources
The Node Membership Protocol implements the SWIM protocol for cluster membership management:
- Failure Detection: Detects node failures through direct and indirect pinging
- Dissemination: Spreads membership information through gossip
- Suspicion Mechanism: Reduces false positives by marking nodes as suspected before declaring them dead
- Leader Election: Elects a leader node for coordination tasks
Key interfaces:
MembershipProtocol: Implements the SWIM protocolMember: Represents a node in the clusterNodeState: Represents the state of a node (Alive, Suspected, Dead, Left)
The Service Discovery system enables containers and applications to find and communicate with each other:
- Service Registry: Maintains a registry of all services and their endpoints
- DNS Server: Provides DNS resolution for service names
- Health Checking: Monitors the health of service endpoints
- Load Balancing: Distributes traffic across healthy endpoints
Key interfaces:
ServiceDiscovery: Main interface for service discoveryLoadBalancingStrategy: Strategies for load balancing (RoundRobin, LeastConnections, etc.)
The Storage Manager handles volume and persistence management:
- Volume Creation: Creates persistent volumes
- Volume Mounting: Mounts volumes to containers
- Volume Deletion: Deletes volumes
- Volume Monitoring: Monitors volume usage
Key interfaces:
StorageManager: Main interface for storage management
The Container Manager integrates with the container runtime:
- Container Runtime Integration: Integrates with containerd
- Container Operations: Performs container operations (create, start, stop, remove)
- Image Management: Manages container images
- Container Monitoring: Monitors container status and metrics
Key interfaces:
ContainerdManager: Integrates with containerdContainer: Represents a containerContainerStatus: Represents the status of a container
The Network Manager handles container networking:
- IP Address Management: Allocates and manages IP addresses
- Overlay Network: Creates a virtual network spanning all nodes
- Network Policies: Controls traffic flow between containers
- Network Monitoring: Monitors network health and performance
Key interfaces:
NetworkManager: Main interface for network managementIpamManager: Manages IP address allocationOverlayNetwork: Manages the overlay networkNetworkPolicy: Defines network policies
The Scheduler is responsible for container placement:
- Node Selection: Selects the best node for container placement
- Resource Allocation: Allocates resources for containers
- Affinity/Anti-Affinity: Places containers based on affinity rules
- Network Topology Awareness: Considers network topology for placement
Key interfaces:
ContainerScheduler: Main interface for container schedulingBinPackingStrategy: Strategies for container placement
The Health Monitor tracks the health of containers and nodes:
- Container Health Checking: Monitors container health
- Node Health Checking: Monitors node health
- Auto-Healing: Automatically restarts failed containers
- Alerting: Generates alerts for health issues
Key interfaces:
HealthMonitor: Main interface for health monitoringHealthStatus: Represents health statusAlert: Represents a health alert
The Security Manager provides comprehensive security features:
- Container Scanning: Scans container images for vulnerabilities
- Network Policy Enforcement: Enforces network security policies
- RBAC: Manages role-based access control
- Secret Management: Securely stores and distributes secrets
- Tenant Management: Manages multi-tenancy and resource isolation
Key interfaces:
SecurityManager: Main interface for security managementContainerScanner: Scans container imagesNetworkPolicyEnforcer: Enforces network policiesRbacManager: Manages RBACSecretManager: Manages secretsTenantManager: Manages tenants and resource quotas
The CI/CD Manager provides integration with CI/CD pipelines:
- Pipeline Management: Manages CI/CD pipelines
- GitHub Actions Integration: Integrates with GitHub Actions
- Automated Testing: Manages automated testing
- Automated Deployment: Manages automated deployment
- Release Management: Manages releases
Key interfaces:
CicdManager: Main interface for CI/CD managementCicdProvider: Provider interface for CI/CD platformsPipelineConfig: Configuration for CI/CD pipelines
The Cloud Manager provides integration with cloud providers:
- Provider Management: Manages cloud provider integrations
- Instance Management: Manages cloud instances
- Load Balancer Management: Manages cloud load balancers
- Storage Management: Manages cloud storage
- Network Management: Manages cloud networks
Key interfaces:
CloudManager: Main interface for cloud managementCloudProviderInterface: Provider interface for cloud platformsCloudInstance: Represents a cloud instanceCloudLoadBalancer: Represents a cloud load balancer
The Helm Manager provides support for Helm charts:
- Chart Management: Manages Helm charts
- Repository Management: Manages Helm repositories
- Release Management: Manages Helm releases
- Chart Creation: Creates Helm charts for Hivemind applications
Key interfaces:
HelmManager: Main interface for Helm managementHelmChart: Represents a Helm chartHelmRelease: Represents a Helm releaseHelmRepository: Represents a Helm repository
The Observability Manager provides comprehensive observability features:
- Metrics Collection: Collects metrics from various components
- Distributed Tracing: Provides distributed tracing
- Log Aggregation: Aggregates logs from various components
- Dashboard Integration: Integrates with dashboards for visualization
Key interfaces:
ObservabilityManager: Main interface for observability managementMetricCollector: Collects metricsOpenTelemetryTracer: Provides distributed tracingLogAggregator: Aggregates logs
The Web UI provides a dashboard for monitoring and management:
- Dashboard: Provides an overview of the system
- Container Management: Manages containers through the UI
- Node Management: Manages nodes through the UI
- Monitoring: Displays monitoring information
- Advanced Features: Provides access to advanced features
- User submits a container deployment request via CLI or API
- App Manager validates the request
- Scheduler selects the best node for the container
- Container Manager creates the container on the selected node
- Network Manager sets up networking for the container
- Service Discovery registers the container's service
- Health Monitor begins monitoring the container's health
- Container needs to communicate with a service
- Container performs a DNS lookup for the service name
- Service Discovery resolves the service name to an endpoint
- Service Discovery selects an endpoint based on load balancing strategy
- Container connects directly to the selected endpoint
- Node starts up and joins the cluster
- Node Membership Protocol registers the node
- Node begins periodic pinging of other nodes
- If a node fails to respond, indirect pinging is attempted
- If indirect pinging fails, the node is marked as suspected
- If the node remains unresponsive, it is marked as dead
- Membership changes are disseminated through gossip
- Health Monitor periodically checks container health
- If a container is unhealthy, it is marked for restart
- Container Manager restarts the unhealthy container
- Health Monitor also checks node health
- If a node is unhealthy, containers are rescheduled to other nodes
- Container image is scanned for vulnerabilities before deployment
- Network policies are applied to control traffic between containers
- User authentication and authorization is performed via RBAC
- Secrets are securely stored, encrypted, and distributed to containers
- Tenant resource quotas are enforced during container deployment
The App Manager works with the Scheduler to place containers on nodes:
- App Manager receives a deployment request
- App Manager asks the Scheduler to select a node
- Scheduler evaluates nodes based on resources, affinity, and network topology
- Scheduler returns the selected node
- App Manager deploys the container to the selected node
The Network Manager works with Service Discovery to enable container communication:
- Network Manager sets up networking for a container
- Network Manager assigns an IP address to the container
- Service Discovery registers the container's service
- Service Discovery provides DNS resolution for the service
- Containers can communicate using service names
The Health Monitor works with the Container Manager to ensure container health:
- Health Monitor checks container health
- If a container is unhealthy, Health Monitor notifies Container Manager
- Container Manager restarts the unhealthy container
- Health Monitor continues monitoring the container
The Security Manager works with the App Manager to ensure secure deployments:
- App Manager receives a deployment request
- Security Manager scans the container image
- Security Manager checks compliance with security policies
- If compliant, App Manager proceeds with deployment
- Security Manager applies network policies to the container
- Tenant Manager checks resource quotas before deployment
Hivemind is designed to be highly scalable and performant:
- Lightweight Components: All components are designed to be lightweight and efficient
- Go Implementation: Built in Go for simplicity and performance
- Efficient Protocols: Uses efficient protocols like SWIM for membership management
- Minimal Resource Usage: Requires minimal resources compared to other orchestration platforms
- Network-Aware Scheduling: Optimizes container placement for network performance
- Efficient Service Discovery: Fast DNS-based service discovery
- Cloud Integration: Seamless scaling to cloud environments
- Advanced Deployment Strategies: Efficient deployment with minimal downtime
- Observability: Comprehensive monitoring for performance optimization
Hivemind provides robust fault tolerance:
- Node Failure Detection: Quickly detects node failures
- Container Auto-Healing: Automatically restarts failed containers
- Leader Election: Elects a new leader if the current leader fails
- Distributed State: Maintains distributed state across nodes
- Graceful Degradation: Continues operating with reduced functionality during failures
Hivemind includes comprehensive security features:
- Container Scanning: Scans container images for vulnerabilities
- Network Policies: Controls traffic flow between containers
- RBAC: Controls access to resources based on role IDs or role names
- Secret Management: Securely stores, encrypts, and distributes secrets
- Storage Encryption: Encrypts persistent volumes for data protection
- Tenant Isolation: Isolates resources between tenants
- Audit Logging: Logs all security-related events
Hivemind is designed to be extensible:
- Modular Architecture: Clear separation of concerns between components
- Plugin System: Supports plugins for extending functionality
- API-First Design: All functionality is available through APIs
- Custom Schedulers: Supports custom scheduling algorithms
- Custom Health Checks: Supports custom health checking logic
- CI/CD Integration: Extensible CI/CD pipeline integration
- Cloud Provider Integration: Extensible cloud provider integration
- Helm Chart Support: Extensible Helm chart support
- Observability Integration: Extensible observability integration
Hivemind's architecture provides a robust, scalable, and secure platform for container orchestration. The modular design allows for easy extension and customization, while the lightweight implementation ensures efficient resource usage. The combination of these features makes Hivemind an excellent choice for organizations looking for a simpler alternative to Kubernetes without sacrificing essential functionality.
Hivemind is designed with testability in mind:
- Mock Interfaces: All components have mock implementations for testing
- Test Skip Flags: Components that interact with external systems (like iptables) have flags to skip those operations in tests
- Flexible Context Handling: Tests use flexible context matchers to avoid brittle tests
- Timing Considerations: Tests account for asynchronous operations with appropriate wait times
- Resource Quota Testing: Special test cases for tenant resource quota enforcement
- Integration Tests: Comprehensive integration tests for component interactions
