A Kubernetes-inspired distributed task orchestrator that schedules and manages containerized tasks across a cluster of worker nodes.
Managing containerized workloads across multiple machines requires sophisticated scheduling, resource management, and fault tolerance. Manual management becomes impractical at scale.
This orchestrator provides:
- Automated scheduling of containerized tasks
- Resource allocation and management
- Health monitoring and self-healing
- Horizontal scaling of worker nodes
- REST API for task management
| Component | Technology |
|---|---|
| Language | Go (for performance and concurrency) |
| Storage | etcd (for distributed consensus and state storage) |
| Container Runtime | Docker |
| Communication | gRPC (internal), HTTP REST API |
| Scheduling Algorithms | Round Robin, Bin Packing, Spread |
| Deployment | Docker, Docker Compose |
- Master-Worker Architecture: Centralized scheduling with distributed execution
- etcd for State Storage: Provides strong consistency for cluster state
- Multiple Scheduling Algorithms: Different strategies for various workload types
- Health Checking: Automated node health monitoring and task rescheduling
- Resource Management: Fine-grained CPU and memory allocation
func (a *BinPackingAlgorithm) SelectNode(task *types.Task, nodes []*types.Node) *types.Node {
var bestNode *types.Node
bestScore := -1.0
for _, node := range nodes {
if !node.HasResourcesFor(task) {
continue
}
// Calculate resource utilization score
cpuUtilization := float64(node.Allocated.CPU+task.Resources.CPU) / float64(node.Capacity.CPU)
memoryUtilization := float64(node.Allocated.Memory+task.Resources.Memory) / float64(node.Capacity.Memory)
score := 0.7*cpuUtilization + 0.3*memoryUtilization
if bestNode == nil || score > bestScore {
bestNode = node
bestScore = score
}
}
return bestNode
}- Docker and Docker Compose
- Go 1.18+ (for development)
- Clone the repository
git clone https://github.com/mosesachizz/distributed-orchestrator.git
cd distributed-orchestrator- Start the cluster
docker-compose up -d- Access the API
- Master API: http://localhost:8080
- etcd: http://localhost:2379
- Build the master
go build -o bin/master ./cmd/master- Build the worker
go build -o bin/worker ./cmd/worker- Start etcd
docker run -d -p 2379:2379 --name etcd quay.io/coreos/etcd:v3.5.0- Start the master
./bin/master- Start workers (in separate terminals)
./bin/workerCreate a task
curl -X POST http://localhost:8080/api/v1/tasks -H "Content-Type: application/json" -d '{
"name": "test-task",
"image": "alpine",
"command": ["echo", "hello world"],
"resources": {
"cpu": 500,
"memory": 256
}
}'List tasks
curl http://localhost:8080/api/v1/tasksList nodes
curl http://localhost:8080/api/v1/nodesThe system provides event streaming at /api/v1/events for real-time monitoring of cluster activities.
To add more workers
docker-compose up -d --scale worker=3This project is licensed under the MIT License - see the LICENSE file for details.