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. 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
annotations Specify Annotations that will be added to Pods generated for the workload.
containers Add one or more containers to the workload.
labels Specify Labels that will be added to Pods generated for the workload.
service-account Specify the Service Account pods should run under.
schedules Specify a series of schedules and container overrides for CronJobs .

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 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:
  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
{
  "metadata": {
    "env_id": "development",
    "name": "Auto-deployment (SCORE)"
  },
  "modules": {
    "add": {
      "my-cronjob": {
        "profile": "humanitec/default-cronjob",
        "spec": {
          "annotations": {
            "humanitec.io/managed-by": "Score"
          },
          "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!"
              }
            }
          },
          "labels": {
            "prometheus-name": "my-cronjob"
          },
          "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 * * *"
            }
          },
          "serviceAccountName": "my-service-account"
        }
      }
    }
  }
}

default-job

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

Features

Feature Description
annotations Specify Annotations that will be added to Pods generated for the workload.
containers Add one or more containers to the workload.
labels Specify Labels that will be added to Pods generated for the workload.
service-account Specify the Service Account pods should run under.

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 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:
  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
{
  "metadata": {
    "env_id": "development",
    "name": "Auto-deployment (SCORE)"
  },
  "modules": {
    "add": {
      "my-job": {
        "profile": "humanitec/default-job",
        "spec": {
          "annotations": {
            "humanitec.io/managed-by": "Score"
          },
          "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!"
              }
            }
          },
          "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
annotations Specify Annotations that will be added to Pods generated for the workload.
containers Add one or more containers to the workload.
labels Specify Labels that will be added to Pods generated for the workload.
replicas A runtime feature allowing the number of replicas to be set.
service Create a Service object to provide a stable way of addressing the workload within the cluster.
service-account Specify the Service Account pods should run under.

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 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:
  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
{
  "metadata": {
    "env_id": "development",
    "name": "Auto-deployment (SCORE)"
  },
  "modules": {
    "add": {
      "my-workload": {
        "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"
          },
          "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!"
              }
            }
          },
          "labels": {
            "prometheus-name": "sample-service"
          },
          "service": {
            "ports": {
              "www": {
                "container_port": 8080,
                "protocol": "TCP",
                "service_port": 8080
              }
            }
          },
          "serviceAccountName": "my-service-account"
        }
      }
    }
  }
}
Top