SPORE Nomad Deployment
This directory contains Nomad job specifications for deploying the SPORE stack on HashiCorp Nomad.
Prerequisites
- Install Nomad: https://www.nomadproject.io/downloads
- Docker: Nomad uses Docker to run containers
Note: Consul is not required. This setup uses Nomad's built-in service discovery.
Quick Start
1. Start Nomad
make nomad-start
This starts:
- Nomad at http://localhost:4646
2. Build Docker Images
# Build all images
cd ../spore-gateway && make docker-build
cd ../spore-ledlab && make docker-build
cd ../spore-registry && make docker-build
cd ../spore-ui && make docker-build
3. Deploy the Job
make nomad-job-run
Or manually:
nomad job run spore.hcl
4. Check Status
# Check job status
make nomad-status
# Or use Nomad UI
make nomad-ui
Job Specification
The spore.hcl file defines 5 service groups:
- mqtt - MQTT broker (Mosquitto)
- gateway - Node discovery and WebSocket gateway
- registry - Firmware registry service
- ledlab - LED animation studio
- ui - Web UI for cluster management
Networking
- MQTT, Gateway, LEDLab: Use host networking for UDP/WebSocket
- Registry, UI: Use bridge networking with mapped ports
Resources
Each service has appropriate CPU and memory allocations:
- MQTT: 100 CPU, 128 MB RAM
- Gateway: 200 CPU, 256 MB RAM
- Registry: 200 CPU, 256 MB RAM
- LEDLab: 300 CPU, 512 MB RAM
- UI: 100 CPU, 256 MB RAM
Management
View Logs
make nomad-logs
Or for specific task:
nomad alloc logs <alloc-id> <task-name>
Stop/Start Job
# Stop
make nomad-job-stop
# Start
make nomad-job-run
Scale Services
# Scale a specific group
nomad job scale -group mqtt -count 1 spore
Update Job
Edit spore.hcl and run:
make nomad-job-run
Nomad will perform a rolling update if the job is running.
Service Discovery
Nomad uses built-in service discovery. Services are discoverable via Nomad's internal DNS:
spore-gateway.service.nomadspore-mqtt.service.nomadspore-registry.service.nomadspore-ledlab.service.nomadspore-ui.service.nomad
Health Checks
All services include health checks that:
- Verify TCP connectivity
- Check HTTP endpoints for HTTP-based services
- Automatically restart unhealthy tasks
Volumes
The registry service uses a host volume mount to persist firmware data:
volume "registry" {
type = "host"
source = "registry"
read_only = false
}
Volume data is stored in nomad-data/ directory.
Stopping Everything
make nomad-stop
This stops both Nomad and Consul and cleans up data directories.
Advanced Usage
View Job Status
nomad job status spore
Inspect Task
nomad job inspect spore
Watch Job Events
nomad job status spore -verbose
Connect to Task
nomad alloc exec <alloc-id> <task-name> /bin/sh
Troubleshooting
Services Not Starting
Check logs:
make nomad-logs
Port Conflicts
If ports are in use, modify the job specification in spore.hcl:
network {
mode = "bridge"
port "http" {
static = 3001 # Change this
to = 3001
}
}
Images Not Found
Ensure Docker images are built and available:
docker images | grep wirelos
If using a registry, update the image URLs in spore.hcl.
Production Deployment
For production environments:
- Configure ACLs: Enable authentication
- Use Nomad Agents: Deploy on multiple nodes
- TLS: Enable TLS for all connections
- Resource Limits: Adjust based on cluster capacity
- Persistence: Use external storage for volumes