Built-in Workload Profiles

Each Workload in the Platform Orchestrator has an associated Workload Profile. It is assigned when generating the Deployment Set or Deployment Delta that is passed in to the Platform Orchestrator when deploying the Workload, usually by using the humctl Humanitec CLI . The Overview has more details about the process.

The Platform Orchestrator has three built-in Workload Profiles with a select set of Features . They can cover the majority of use cases. If you need to go beyond what those Workload Profiles offer, consider creating a Custom Workload Profile .

Workload Profile Description
default-cronjob Generates a series of Kubernetes CronJobs . The Workload Profile allows multiple schedules to be defined in one workload.
default-job Generates a of Kubernetes Job that is run at deployment time.
default-module Generates a Kubernetes Deployment which will roll out a ReplicaSet . This is the most commonly used Workload Profile. It is used the the default if no other Workload Profile is specified.

default-cronjob

This Workload Profile generates a series of Kubernetes CronJobs . The Workload Profile allows multiple schedules to be defined in one workload.

Features

Feature Description
containers Add one or more containers to the workload.
cronjob Specify properties for the CronJob object.
job Specify properties for the Job objects created out of the CronJob.
pod Specify properties for the Pod objects created out of the CronJob.
schedules Specify a series of schedules and container overrides for CronJobs .
volumes Define volumes that are not provisioned via the Humanitec resources system.

Example

The following Score File and Score extension file jointly define a single Workload using the Workload Profile humanitec/default-cronjob.

The Workload contains one container, has an environment variable MY_ENV_VAR set in it, has container resources defined, has an additional Pod label prometheus-name, runs under the Service Account my-service-account, and has two Cron schedules defined, each executing a different command inside the container.

Score file Score extension file
apiVersion: score.dev/v1b1
metadata:
  name: my-cronjob

containers:
  my-container:
    image: "registry.humanitec.io/public/sample-service:1.2.0"
    resources:
      limits:
        cpu: "0.250"
        memory: "256Mi"
      requests:
        cpu: "0.025"
        memory: "64Mi"
    variables:
      MY_ENV_VAR: "Hello World!"
apiVersion: humanitec.org/v1b1
profile: humanitec/default-cronjob

spec:
  pod:
    labels:
      prometheus-name: my-cronjob
    serviceAccountName: my-service-account
  schedules:
    daily-run:
      containers:
        my-container:
          command:
            - node
            - daily-cron.js
      schedule: "0 23 * * *"
    6-hour-run:
      containers:
        my-container:
          args:
            - "--hours"
            - "6"
      schedule: "15 1,7,13,19 * * *"

Using the humctl Humanitec CLI to translate the Score file and extension file yields this Deployment Delta:

$ humctl score deploy --dry-run -f score.yaml --extensions humanitec.score.yaml --env development
{
  "externals": null,
  "profile": "humanitec/default-cronjob",
  "spec": {
    "annotations": {
      "humanitec.io/managed-by": "Score",
      "humanitec.io/workload-artefact-name": "my-cronjob-wp"
    },
    "containers": {
      "my-container": {
        "id": "my-container",
        "image": "registry.humanitec.io/public/sample-service:1.2.0",
        "resources": {
          "limits": {
            "cpu": "0.250",
            "memory": "256Mi"
          },
          "requests": {
            "cpu": "0.025",
            "memory": "64Mi"
          }
        },
        "variables": {
          "MY_ENV_VAR": "Hello World!"
        }
      }
    },
    "pod": {
      "labels": {
        "prometheus-name": "my-cronjob"
      },
      "serviceAccountName": "my-service-account"
    },
    "schedules": {
      "6-hour-run": {
        "containers": {
          "my-container": {
            "args": [
              "--hours",
              "6"
            ]
          }
        },
        "schedule": "15 1,7,13,19 * * *"
      },
      "daily-run": {
        "containers": {
          "my-container": {
            "command": [
              "node",
              "daily-cron.js"
            ]
          }
        },
        "schedule": "0 23 * * *"
      }
    }
  }
}

default-job

This Workload Profile generates a of Kubernetes Job that is run at deployment time.

Features

Feature Description
containers Add one or more containers to the workload.
job Specify properties for the Job objects created out of the CronJob.
pod Specify properties for the Pod objects created out of the CronJob.
volumes Define volumes that are not provisioned via the Humanitec resources system.

Example

The following Score File and Score extension file jointly define a single Workload using the Workload Profile humanitec/default-job.

The Workload contains one container, has an environment variable MY_ENV_VAR set in it, has container resources defined, has an additional Pod label prometheus-name, and runs under the Service Account my-service-account.

Score file Score extension file
apiVersion: score.dev/v1b1
metadata:
  name: my-job

containers:
  my-container:
    image: "registry.humanitec.io/public/sample-service:1.2.0"
    resources:
      limits:
        cpu: "0.250"
        memory: "256Mi"
      requests:
        cpu: "0.025"
        memory: "64Mi"
    variables:
      MY_ENV_VAR: "Hello World!"
apiVersion: humanitec.org/v1b1
profile: humanitec/default-job

spec:
  pod:
    labels:
      prometheus-name: my-job
    serviceAccountName: my-service-account

Using the humctl Humanitec CLI to translate the Score file and extension file yields this Deployment Delta:

$ humctl score deploy --dry-run -f score.yaml --extensions humanitec.score.yaml --env development
{
  "externals": null,
  "profile": "humanitec/default-job",
  "spec": {
    "annotations": {
      "humanitec.io/managed-by": "Score",
      "humanitec.io/workload-artefact-name": "my-job"
    },
    "containers": {
      "my-container": {
        "id": "my-container",
        "image": "registry.humanitec.io/public/sample-service:1.2.0",
        "resources": {
          "limits": {
            "cpu": "0.250",
            "memory": "256Mi"
          },
          "requests": {
            "cpu": "0.025",
            "memory": "64Mi"
          }
        },
        "variables": {
          "MY_ENV_VAR": "Hello World!"
        }
      }
    },
    "pod": {
      "labels": {
        "prometheus-name": "my-job"
      },
      "serviceAccountName": "my-service-account"
    }
  }
}

default-module

This Workload Profile generates a Kubernetes Deployment which will roll out a ReplicaSet . It is therefore intended for stateless workloads. In practice this covers the vast majority of workloads used in Kubernetes.

Features

Feature Description
containers Add one or more containers to the workload.
deployment Specify properties for the Deployment object.
pod Specify properties for the Pod objects created out of the Deployment.
service Create a Service object to provide a stable way of addressing the workload within the cluster.
volumes Define volumes that are not provisioned via the Humanitec resources system.

Example

The following Score File and Score extension file jointly define a single Workload using the Workload Profile humanitec/default-module.

The Workload contains one container, has an environment variable MY_ENV_VAR set in it, has container resources defined, has an additional Pod label prometheus-name, runs under the Service Account my-service-account, defines a Service on port 8080, has liveness and readiness probes, and defines a route referencing a requested dns resource.

The files do not need to request the Workload Profile default-module as it is the default Workload Profile to use.

Score file Score extension file
apiVersion: score.dev/v1b1
metadata:
  name: my-workload

containers:
  sample-service:
    image: "registry.humanitec.io/public/sample-service:1.2.0"
    command:
      - "node"
      - "index.js"
    args:
      - "--run"
      - "webserver"
    livenessProbe:
      httpGet:
        path: "/alive"
        port: 8080
    readinessProbe:
      httpGet:
        path: "/ready"
        port: 8080
    resources:
      limits:
        cpu: "0.250"
        memory: "256Mi"
      requests:
        cpu: "0.025"
        memory: "64Mi"
    variables:
      MY_ENV_VAR: "Hello World!"
service:
  ports:
    www:
      port: 8080
      targetPort: 8080
resources:
  dns:
    type: dns
  default-route:
    type: route
    params:
      host: ${resources.dns.host}
      path: /
      port: 8080
apiVersion: humanitec.org/v1b1

spec:
  pod:
    labels:
      prometheus-name: "sample-service"
    serviceAccountName: my-service-account

Using the humctl Humanitec CLI to translate the Score file and extension file yields this Deployment Delta:

$ humctl score deploy --dry-run -f score.yaml --extensions humanitec.score.yaml --env development
{
  "externals": {
    "default-route": {
      "class": "default",
      "params": {
        "host": "${externals.dns.host}",
        "path": "/",
        "port": 8080
      },
      "type": "route"
    },
    "dns": {
      "class": "default",
      "type": "dns"
    }
  },
  "profile": "humanitec/default-module",
  "spec": {
    "annotations": {
      "humanitec.io/managed-by": "Score",
      "humanitec.io/workload-artefact-name": "my-workload"
    },
    "containers": {
      "sample-service": {
        "args": [
          "--run",
          "webserver"
        ],
        "command": [
          "node",
          "index.js"
        ],
        "id": "sample-service",
        "image": "registry.humanitec.io/public/sample-service:1.2.0",
        "liveness_probe": {
          "path": "/alive",
          "port": 8080,
          "type": "http"
        },
        "readiness_probe": {
          "path": "/ready",
          "port": 8080,
          "type": "http"
        },
        "resources": {
          "limits": {
            "cpu": "0.250",
            "memory": "256Mi"
          },
          "requests": {
            "cpu": "0.025",
            "memory": "64Mi"
          }
        },
        "variables": {
          "MY_ENV_VAR": "Hello World!"
        }
      }
    },
    "pod": {
      "labels": {
        "prometheus-name": "sample-service"
      },
      "serviceAccountName": "my-service-account"
    },
    "service": {
      "ports": {
        "www": {
          "container_port": 8080,
          "protocol": "TCP",
          "service_port": 8080
        }
      }
    }
  }
}
Top