Workloads Guide
This guide covers deploying different workload types with the Nomad PaaS controlplane.
Web Services
Deploy a long-running HTTP service:
apiVersion: core.oam.dev/v1alpha2
kind: Application
metadata:
name: web-service
spec:
components:
- name: frontend
type: webservice
properties:
image: nginx:1.25-alpine
ports:
- name: http
port: 80
expose: true
resources:
cpu: 500m
memory: 256Mi
env:
- name: NGINX_HOST
value: localhost
traits:
- type: scaler
properties:
replicas: 3
min: 1
max: 10
- type: ingress
properties:
host: example.com
tls: true
Batch Jobs
Deploy a one-shot batch job:
apiVersion: core.oam.dev/v1alpha2
kind: Application
metadata:
name: batch-job
spec:
components:
- name: processor
type: batchworkload.nomad.oam.dev
properties:
driver: docker
image: batch-processor:latest
args:
- process
- --input
- s3://bucket/data
resources:
cpu: 2000m
memory: 2048Mi
restartPolicy:
attempts: 3
interval: 5m
delay: 30s
mode: fail
Cron Jobs
Deploy a periodic job:
apiVersion: core.oam.dev/v1alpha2
kind: Application
metadata:
name: scheduled-job
spec:
components:
- name: backup
type: cron-task
properties:
image: backup-tool:latest
schedule: "0 2 * * *" # Daily at 2 AM
args:
- backup
- --all-databases
resources:
cpu: 1000m
memory: 512Mi
System Daemons
Deploy a daemon that runs on every node:
apiVersion: core.oam.dev/v1alpha2
kind: Application
metadata:
name: node-daemon
spec:
components:
- name: collector
type: systemworkload.nomad.oam.dev
properties:
driver: docker
image: metrics-collector:latest
resources:
cpu: 100m
memory: 64Mi
traits:
- type: affinity
properties:
nodeClass: compute
Multi-Container Applications
Deploy an application with multiple containers:
apiVersion: core.oam.dev/v1alpha2
kind: Application
metadata:
name: multi-container
spec:
components:
- name: api
type: containerizedworkload.nomad.oam.dev
properties:
driver: docker
containers:
- name: api-server
image: myapp/api:1.0
ports:
- name: http
containerPort: 8080
resources:
cpu: 1000m
memory: 512Mi
env:
DB_HOST: postgres
DB_PORT: "5432"
- name: cache
image: redis:7-alpine
ports:
- name: redis
containerPort: 6379
resources:
cpu: 250m
memory: 128Mi
- name: logger
image: log-shipper:latest
env:
OUTPUT: stdout
volumes:
- source: api-data
destination: /data
readOnly: false
traits:
- type: volume
properties:
name: api-data
type: csi
source: api-storage
mountPath: /data
Executable Workloads
Deploy raw executables:
apiVersion: core.oam.dev/v1alpha2
kind: Application
metadata:
name: raw-exec
spec:
components:
- name: worker
type: executableworkload.nomad.oam.dev
properties:
driver: raw_exec
command: /usr/local/bin/worker
args:
- --queue
- default
resources:
cpu: 500m
memory: 256Mi
Resource Management
CPU
CPU is specified in millicores:
Memory
Memory can be specified in Mi or Gi:
Health Checks
Add readiness and liveness probes: