homelab infrastructure services
Service Registry#
The service registry is a simple key-value mapping that assigns service numbers to service names within a namespace.
Location#
The service registry is stored in the namespace station NFS export:
- Production:
/volume1/{namespace}/station/prod/service-registry - Test:
/volume1/{namespace}/station/test/service-registry
Implementation: The service registry is automatically created by machine/scripts/setup_station.sh:create_service_registry() during the machine setup process. This function:
- Scans existing system UIDs to discover deployed services
- Creates the registry file with proper ownership (station-prod user)
- Populates it with discovered service mappings
Access Paths:
- NFS location:
/volume1/{namespace}/station/prod/service-registry - Local mount:
/mnt/docker/state/service-registry(accessed bymachine/scripts/lib.sh:calculate_service_uid()) - XDG access:
~/.local/state/{namespace}/@station/service-registry
Format#
The registry uses a simple key=value format, one service per line:
# Service Registry for dynamicalsystem namespace
# Format: service_name=service_number
# Service 0 is reserved for station (namespace infrastructure)
gazette=1
lldap=2
redis=3
prometheus=4
grafana=5
Rules#
- Service 0 is reserved for the namespace station (infrastructure)
- Service names must be lowercase alphanumeric with hyphens allowed
- Service numbers must be unique within a namespace (1-99)
- Comments start with
#and are ignored - Empty lines are ignored
Usage#
Reading the Registry#
Services and tools read the registry to determine their service number:
# Get service number for 'lldap'
service_num=$(grep "^lldap=" /volume1/dynamicalsystem/station/prod/service-registry | cut -d= -f2)
Adding a New Service#
- Edit the registry file on the NAS
- Add a new line with the next available service number
- Ensure no conflicts with existing services
Example Workflow#
# SSH to NAS
ssh admin@nas.local
# Edit registry
sudo vi /volume1/dynamicalsystem/station/prod/service-registry
# Add new service
echo "caddy=6" >> /volume1/dynamicalsystem/station/prod/service-registry
Integration with tinsnip#
The machine/lib.sh script automatically consults the service registry when calculating UIDs:
- If service name is "station", use service number 0
- Otherwise, check the registry file
- If not found in registry, fall back to hardcoded values (for backward compatibility)
- If still not found, return an error
Future Enhancements#
The station service (S=0) could eventually provide:
- REST API for service registration
- Web UI for registry management
- Service discovery endpoints
- Port allocation tracking