Complete guide for configuring and managing service lifecycle in Muster.
Services in Muster are runtime instances created from ServiceClass templates. This guide covers:
- Service creation and configuration
- Lifecycle management (start, stop, restart)
- Health monitoring and status checking
- Parameter customization and environment-specific settings
# Create service from ServiceClass
muster create service my-app web-application
# Create with custom parameters
muster create service database postgres-db \
--param db_name=production_db \
--param max_connections=100Services are created from ServiceClass templates with instance-specific parameters:
# Service instance configuration
apiVersion: muster.giantswarm.io/v1alpha1
kind: ServiceInstance
metadata:
name: my-web-app
namespace: default
spec:
serviceClassName: web-application
parameters:
image: nginx:1.21
port: "8080"
replicas: "3"
environment: production
persistence:
enabled: true
path: /data/my-web-app# Start a service
muster start service my-app
# Start with runtime parameters
muster start service my-app \
--env DATABASE_URL=postgres://... \
--env LOG_LEVEL=debug
# Start multiple services
muster start service web-app database cache# Stop a service gracefully
muster stop service my-app
# Force stop (immediate termination)
muster stop service my-app --force
# Stop all services matching pattern
muster stop service --pattern "web-*"# Restart service (stop + start)
muster restart service my-app
# Restart with new parameters
muster restart service my-app \
--param image=nginx:1.22 \
--param replicas=5# Get detailed service information
muster get service my-app
# Check service health
muster check service my-app
# List all services with status
muster list service --output tableServices can be in one of several states:
| State | Description | Actions Available |
|---|---|---|
stopped |
Service is not running | start |
starting |
Service is initializing | stop (force), status |
running |
Service is active and healthy | stop, restart, status |
stopping |
Service is shutting down | status |
failed |
Service encountered an error | start, restart, logs |
unknown |
Service state cannot be determined | start, stop (force) |
Services inherit health check configuration from their ServiceClass:
# ServiceClass with health checks
apiVersion: muster.giantswarm.io/v1alpha1
kind: ServiceClass
metadata:
name: web-application
spec:
healthCheck:
enabled: true
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3Set during service creation and persist across restarts:
# Create service with static parameters
muster create service api-server web-application \
--param image=myapp:v1.2.0 \
--param replicas=3 \
--param memory_limit=512MiProvided during service start, override static parameters:
# Start with runtime environment variables
muster start service api-server \
--env DEBUG=true \
--env LOG_LEVEL=debug \
--env FEATURE_FLAGS=experimentalUse templating for dynamic parameter values:
# ServiceClass with templated parameters
spec:
parameters:
app_name:
type: string
required: true
image:
type: string
default: "{{.app_name}}:latest"
service_url:
type: string
default: "https://{{.app_name}}.example.com"# Development service configuration
muster create service my-app-dev web-application \
--param environment=development \
--param debug=true \
--param replicas=1 \
--param resources=minimal
# Start with development overrides
muster start service my-app-dev \
--env LOG_LEVEL=debug \
--env HOT_RELOAD=true# Production service configuration
muster create service my-app-prod web-application \
--param environment=production \
--param replicas=5 \
--param resources=standard \
--param monitoring=enabled
# Start with production settings
muster start service my-app-prod \
--env LOG_LEVEL=warn \
--env METRICS_ENABLED=true \
--env HEALTH_CHECK_INTERVAL=30s# Create service with persistence
muster create service database postgres \
--persistence \
--persist-path /data/postgres
# Create with custom persistence settings
muster create service app web-application \
--persistence \
--persist-path /app/data \
--persist-mode shared| Mode | Description | Use Case |
|---|---|---|
exclusive |
Data is isolated per service instance | Databases, unique state |
shared |
Data is shared across service restarts | Configuration, caches |
readonly |
Service can only read persistent data | Static assets, templates |
# View persistent data location
muster get service database --output yaml | grep persistencePath
# Backup persistent data
cp -r ~/.config/muster/persistence/database /backup/
# Restore persistent data
cp -r /backup/database ~/.config/muster/persistence/Services can depend on other services or external resources:
# ServiceClass with dependencies
spec:
dependencies:
- name: database
type: service
required: true
- name: cache
type: service
required: false
- name: external-api
type: external
healthCheck:
url: https://api.example.com/health# Muster automatically resolves dependencies
muster start service web-app
# This will start database and cache first, then web-app
# Check dependency status
muster get service web-app --show-dependencies
# Start with dependency override
muster start service web-app --skip-dependencies# Create service with resource constraints
muster create service heavy-app worker-class \
--param cpu_limit=2 \
--param memory_limit=4Gi \
--param disk_limit=10Gi# Service with custom networking
muster create service api gateway-class \
--param port=8080 \
--param host=0.0.0.0 \
--param protocol=https \
--param cert_path=/certs/api.crt# Service with security settings
muster create service secure-app web-application \
--param security_enabled=true \
--param auth_provider=oauth2 \
--param tls_enabled=true# Validate service configuration before creation
muster create service my-app web-application --dry-run
# Validate with specific parameters
muster create service my-app web-application \
--param invalid_param=value \
--validate-only# Check if service configuration is valid
muster check service my-app
# Validate all services
muster check service --all# Update service with new parameters
muster update service my-app \
--param image=myapp:v1.3.0 \
--param replicas=4
# Update requires restart to take effect
muster restart service my-app# Perform rolling update (if supported by ServiceClass)
muster update service my-app \
--param image=myapp:v1.3.0 \
--strategy rolling
# Monitor update progress
muster get service my-app --watch# Check service status and logs
muster get service my-app
muster logs service my-app
# Validate ServiceClass exists
muster check serviceclass web-application
# Check for parameter validation errors
muster create service my-app web-application --dry-run# List required parameters for ServiceClass
muster get serviceclass web-application --show-parameters
# Validate parameter types and values
muster validate service my-app web-application \
--param port=invalid_port_number# Check health check configuration
muster get service my-app --show-health
# Test health check manually
curl http://localhost:8080/health
# Disable health checks temporarily
muster update service my-app --disable-health-checks# Enable debug logging for service
muster restart service my-app --env LOG_LEVEL=debug
# Check service resource usage
muster get service my-app --show-resources
# View service events
muster get service my-app --show-events# Use descriptive, hierarchical names
muster create service frontend-web-prod web-application
muster create service backend-api-staging api-service
muster create service worker-queue-dev worker-class- Use defaults: Define sensible defaults in ServiceClass
- Environment-specific: Use different parameter sets per environment
- Validation: Always validate parameters before deployment
- Documentation: Document required and optional parameters
- Right-size resources: Start with minimal resources, scale up as needed
- Monitor usage: Use resource monitoring to optimize allocations
- Set limits: Always set resource limits to prevent resource exhaustion
- Least privilege: Grant minimal required permissions
- Secrets management: Use secure secret storage, never hardcode secrets
- Network isolation: Isolate services that don't need to communicate
- Regular updates: Keep service images and dependencies up to date
Services can be managed through workflows for complex orchestration:
# Workflow that manages service lifecycle
apiVersion: muster.giantswarm.io/v1alpha1
kind: Workflow
metadata:
name: deploy-application
spec:
steps:
- id: create-database
tool: core_service_create
args:
name: "{{.app_name}}-db"
serviceClassName: postgres
- id: wait-for-database
tool: core_service_wait_healthy
args:
name: "{{.app_name}}-db"
timeout: 300s
- id: create-application
tool: core_service_create
args:
name: "{{.app_name}}"
serviceClassName: web-application
parameters:
database_url: "postgres://{{.app_name}}-db:5432/app"