Service
A Service in Odin represents a deployable application unit composed of one or more components. Services are the primary abstraction for managing your applications in Odin.
What is a Service?
Section titled “What is a Service?”A service is a functional unit with defined boundaries that:
- Consists of one or more components (web servers, databases, caches, etc.)
- Can be treated as a blackbox from the outside
- Is versioned and can be deployed independently
- Has lifecycle states and can be operated as a unit
Service Definition
Section titled “Service Definition”Services are defined using JSON files with the following structure:
{ "name": "user-api", "version": "1.0.0", "team": "backend-team", "components": [ { "name": "api-server", "type": "webservice", "version": "2.1.0", "depends_on": ["database", "cache"], "config": { "port": 8080, "replicas": 3 } }, { "name": "database", "type": "postgres", "version": "14.5", "config": { "storage": "100Gi" } }, { "name": "cache", "type": "redis", "version": "7.0", "config": { "memory": "2Gi" } } ]}Service Properties
Section titled “Service Properties”| Property | Description |
|---|---|
name | Unique identifier for the service |
version | Semantic version (e.g., 1.0.0, 1.2.0-SNAPSHOT) |
team | Owning team or organization |
components | Array of component definitions |
Service Lifecycle
Section titled “Service Lifecycle”Deploying a Service
Section titled “Deploying a Service”Deploy a service to an environment:
odin deploy service --env <env-name> \ --file service.json \ --provisioning provisioning.jsonThe deployment process:
- Validates the service definition
- Validates provisioning configuration
- Creates deployment tasks for each component
- Deploys components according to dependency order
- Monitors deployment status and reports progress
Service States
Section titled “Service States”Services transition through several states during their lifecycle:
| State | Description |
|---|---|
DEPLOYING | Deployment in progress |
DEPLOYED | All components successfully deployed |
FAILED | One or more components failed |
UNDEPLOYING | Teardown in progress |
UNDEPLOYED | Service removed from environment |
Checking Service Status
Section titled “Checking Service Status”Check the status of a deployed service:
odin status env <env-name> --service <service-name>Get detailed component-level information:
odin describe env <env-name> --service <service-name>Undeploying a Service
Section titled “Undeploying a Service”Remove a service from an environment:
odin undeploy service <service-name> --env <env-name>Service Operations
Section titled “Service Operations”Operating a Service
Section titled “Operating a Service”Execute lifecycle operations on a service:
odin operate service --name <service-name> \ --env <env-name> \ --operation <operation-type> \ --options '{"key": "value"}'Or use a file for operation parameters:
odin operate service --name <service-name> \ --env <env-name> \ --operation <operation-type> \ --file operation.jsonRedeploying a Service
Section titled “Redeploying a Service”Update a service with new configuration:
odin operate service --name user-api \ --env staging \ --operation redeploy \ --file updated-service.jsonWhen redeploying, Odin shows a diff of pending changes and asks for confirmation.
Adding a Component
Section titled “Adding a Component”Add a new component to an existing service:
odin operate service --name user-api \ --env staging \ --operation ADD_COMPONENT \ --options '{ "component_definition": { "name": "cache", "type": "redis", "version": "7.0" }, "provisioning_config": { "component_name": "cache", "deployment_type": "elasticache-redis" } }'Removing a Component
Section titled “Removing a Component”Remove a component from a service:
odin operate service --name user-api \ --env staging \ --operation REMOVE_COMPONENT \ --options '{"component_name": "old-cache"}'Service Versioning
Section titled “Service Versioning”Odin supports two versioning strategies:
SNAPSHOT Versions
Section titled “SNAPSHOT Versions”Mutable versions for development and QA:
{ "name": "user-api", "version": "1.2.0-SNAPSHOT", ...}- Can be redeployed with changes
- Ideal for fast iteration
- Not suitable for production
CONCRETE Versions
Section titled “CONCRETE Versions”Immutable versions for production:
{ "name": "user-api", "version": "1.2.0", ...}- Cannot be modified once released
- Guarantees reproducibility
- Suitable for production deployments
Service Best Practices
Section titled “Service Best Practices”Service Definition
Section titled “Service Definition”- Use Semantic Versioning: Follow
major.minor.patchformat - Document Dependencies: Clearly specify
depends_onrelationships - Modular Components: Break services into logical components
- Team Ownership: Assign clear team ownership
Development Workflow
Section titled “Development Workflow”- Develop with SNAPSHOT: Deploy
1.0.0-SNAPSHOTto dev environment - Iterate with QA: Test and refine in staging environment
- Release CONCRETE: Create
1.0.0release for production - Deploy to Production: Deploy immutable version to prod
Component Dependencies
Section titled “Component Dependencies”Define dependencies correctly to ensure proper deployment order:
{ "components": [ { "name": "api", "depends_on": ["database", "cache"] }, { "name": "database", "depends_on": [] }, { "name": "cache", "depends_on": [] } ]}Odin deploys in order: database → cache → api
Configuration Management
Section titled “Configuration Management”Use the config field for component-specific settings:
{ "name": "api-server", "config": { "port": 8080, "replicas": 3, "env": { "LOG_LEVEL": "info", "DB_POOL_SIZE": "20" } }}Examples
Section titled “Examples”Simple Web Service
Section titled “Simple Web Service”{ "name": "hello-world", "version": "1.0.0-SNAPSHOT", "team": "platform", "components": [ { "name": "web", "type": "webservice", "version": "1.0.0", "config": { "port": 8080 } } ]}Multi-Component Service
Section titled “Multi-Component Service”{ "name": "ecommerce-api", "version": "2.1.0", "team": "ecommerce", "components": [ { "name": "api", "type": "webservice", "version": "2.1.0", "depends_on": ["database", "cache", "queue"], "config": { "port": 8080, "replicas": 5 } }, { "name": "database", "type": "postgres", "version": "14.5", "config": { "storage": "200Gi", "instance_class": "db.r5.large" } }, { "name": "cache", "type": "redis", "version": "7.0", "config": { "memory": "4Gi" } }, { "name": "queue", "type": "rabbitmq", "version": "3.11", "config": { "queues": ["orders", "notifications"] } } ]}Related Concepts
Section titled “Related Concepts”- Component: Building blocks of services
- Provisioning: Define how services are deployed
- Versioning: Service version management
- Environment: Where services are deployed