Traits
Traits provide operational capabilities to components. They are attached to components and modify how the workload is deployed.
Available Traits
| Trait | Description | Applies To |
|---|---|---|
scaler |
Horizontal autoscaling | All |
ingress |
HTTP routing via Traefik | Containerized |
volume |
Volume mounts | All |
vault-secret |
Vault secrets injection | All |
affinity |
Node affinity/spread | All |
updatestrategy.nomad.oam.dev |
Deployment strategy | All |
migration.nomad.oam.dev |
Node migration settings | All |
servicediscovery.nomad.oam.dev |
Consul registration | Containerized |
Trait Properties
Scaler Trait
Configures horizontal pod autoscaling:
type: scaler
properties:
replicas: 3 # Current replicas
min: 1 # Minimum replicas
max: 10 # Maximum replicas
scaleMetric: cpu # Metric: cpu, memory, custom
scaleTarget: 70 # Target value (percentage)
Ingress Trait
Configures Traefik HTTP routing:
type: ingress
properties:
host: example.com # Domain
pathPrefix: /api # Path prefix
port: 8080 # Backend port
tls: true # Enable TLS
stripPrefix: true # Strip path prefix
middleware: # Additional middleware
- rate-limit
- auth
Volume Trait
Mounts volumes to containers:
type: volume
properties:
name: data-volume # Volume name
type: host | csi # Volume type
source: my-volume # Volume source
mountPath: /data # Mount destination
readOnly: false # Read-only mount
Vault Secret Trait
Injects secrets from Vault:
type: vault-secret
properties:
path: secret/data/db-creds # Vault path
changeMode: restart # restart, signal
changeSignal: SIGTERM # Signal to send
env: # Field to env mapping
username: DB_USER
password: DB_PASS
Affinity Trait
Controls pod scheduling:
type: affinity
properties:
nodeClass: compute-optimized # Node class
cloud: aws # Cloud provider
region: us-east-1 # Region
nodeMeta: # Node metadata
gpu: "true"
spread: true # Spread across DCs
Update Strategy Trait
Configures deployment strategy:
type: updatestrategy.nomad.oam.dev
properties:
strategy: rolling # rolling, canary, blue-green
maxParallel: 2 # Parallel updates
canary: 1 # Canary count
healthCheck: checks # checks, task_states, manual
minHealthyTime: 30s # Min healthy duration
healthyDeadline: 5m # Healthy deadline
progressDeadline: 10m # Progress deadline
autoRevert: true # Auto-revert on failure
Migration Trait
Configures node draining behavior:
type: migration.nomad.oam.dev
properties:
maxParallel: 1 # Parallel migrations
healthCheck: checks # checks, task_states
minHealthyTime: 15s # Min healthy duration
healthyDeadline: 5m # Healthy deadline
Service Discovery Trait
Configures Consul service registration:
type: servicediscovery.nomad.oam.dev
properties:
serviceName: my-service # Service name
tags: # Service tags
- v1
- production
port: http # Port label
check: # Health check
type: http # http, tcp, script
path: /health # Check path
interval: 10s # Check interval
timeout: 3s # Check timeout
Attaching Traits
Traits are attached to components in the application: