Skip to content

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:

resources:
  cpu: 1000m    # 1 CPU core
  cpu: 500m     # 0.5 CPU cores
  cpu: 250m     # 0.25 CPU cores

Memory

Memory can be specified in Mi or Gi:

resources:
  memory: 256Mi   # 256 mebibytes
  memory: 1Gi     # 1 gibibyte
  memory: 512Mi   # 512 mebibytes

Health Checks

Add readiness and liveness probes:

properties:
  readinessProbe:
    httpGet:
      path: /ready
      port: 8080
    initialDelaySeconds: 5
    periodSeconds: 10
    timeoutSeconds: 3
    failureThreshold: 3
  livenessProbe:
    httpGet:
      path: /health
      port: 8080
    initialDelaySeconds: 15
    periodSeconds: 20