containers
Reference for humanitec/containers Workload Profile Feature
The containers feature allows containers to the added to a workload.

Description

The top level of the container feature is a map with user provided IDs as keys and container objects as values. Each container object has a set of properties:
Property
Type
Description
args
Array of strings
The arguments passed to the command in the container. Overrides what is defined in the Dockerfile.
command
Array of strings
The command to execute in the container. Overrides what is defined in the Dockerfile.
files
Object
See Files
id
string
The Image ID specified when the image was added to Humanitec. (This is not necessarily the image name.)
image
string
The fully qualified image path including registry, project, image name and tag.
liveness_probe
Object
Defines the liveness probe for the container. See Probes.
readiness_probe
Object
Defines the readiness probe for the container. See Probes.
startup_probe
Object
Defines the startup probe for the container. See Probes.
resources
Object
variables
Object
volume_mounts
Object

Files

The top level of the files object is a map with file paths as keys and file objects as values. The file paths must be rooted and include at least one directory. They cannot be nested inside any mount points defined in volume_mounts.
Property
Type
Description
mode
String
value
String
The content of the file.

Example

1
{
2
"/app/default.config": {
3
"mode": "0644",
4
"value": "[config]\nkey=value"
5
}
6
}
Copied!

Probes

A probe can be of 3 types: command, http or tcp. The supported properties depends on the value of the type property.

command

Property
Type
Description
command
Array of strings
The command to run.

Example

1
{
2
"command": [
3
"bash",
4
"-c",
5
"/app/is_alive.sh"
6
],
7
"type": "command"
8
}
Copied!

http

Property
Type
Description
headers
Map of strings
A key value map of HTTP headers and their values.
path
String
The HTTP path for the request. Must start with /.
port
Integer
The port to connect to. Must be in range 1 - 65535.

Example

1
{
2
"headers": {
3
"Cache-Control": "no-store"
4
},
5
"path": "/alive",
6
"port": 8080,
7
"type": "http"
8
}
Copied!

tcp

Property
Type
Description
port
Integer
The port to connect to. Must be in range 1 - 65535.

Example

1
{
2
"port": 8080
3
}
Copied!

Container Resources

Specify the minimum and maximum resources required for this container. Pods will not be scheduled unless the minimum requests resources are available for all containers in a Pod on a node. The Pod will either be throttled or terminated if the maximum resource limit is reached.
The minimum resource is specified by the requests property. The maximum resource is specified by the limits property.
Each of these properties supports the following:
Property
Type
Description
cpu
String
A decimal number representing the fractional number of CPUs. e.g. 0.25.
memory
String
The amount of memory as an integer number of bytes. The numbers can be scaled by appending E, P, T, G, M, k or their power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki to the end of the number.

Example

1
{
2
"cpu": "0.250",
3
"memory": "256Mi"
4
}
Copied!

Environment Variables

Environment variables are specified as a map of keys and values where both keys and values are strings. Keys must only contain alphanumeric characters, -, _ or .. There is no restriction on the values.
Workload Profile implementations are required to support a transformed schema that allows for inclusion of ConfigMap and Secret based values.

Example

1
{
2
"MY_ENV_VAR": "Hello World!"
3
}
Copied!

Volume Mounts

The top level of the volume_mounts object is a map with mount points paths as keys and volume mount objects as values. The mount points must be rooted paths and include at least one directory. They cannot be nested inside any other defined mount points or be a parent of any file specified in the Files section.
Both volumes provisioned via Humanitec resources or as built in types are supported.
Persistent Volumes are managed through the resources system and so should be referenced via their resource ID. (e.g. shared.nfs-share). Other volume types can be reference via the definition in the volumes section. (e.g. volumes.common-dir)
Property
Type
Description
id
String
The resource ID or volume ID to mount.
read_only
Boolean
Defines whether the volume should be mounted as read-only.
sub_path
String
Specifies a sub-directory in the volume to mount.

Example

1
{
2
"/shared/common": {
3
"id": "volumes.common-dir",
4
"read_only": false,
5
"sub_path": "/cache"
6
}
7
}
Copied!

Example

1
{
2
"my-container": {
3
"args": [
4
"--run",
5
"webserver"
6
],
7
"command": [
8
"node",
9
"index.js"
10
],
11
"files": {
12
"/app/default.config": {
13
"mode": "0644",
14
"value": "[config]\nkey=value"
15
}
16
},
17
"id": "sample-service",
18
"image": "registry.humanitec.io/public/sample-service:1.2.0",
19
"liveness_probe": {
20
"command": [
21
"bash",
22
"-c",
23
"/app/is_alive.sh"
24
],
25
"type": "command"
26
},
27
"readiness_probe": {
28
"headers": {
29
"Cache-Control": "no-store"
30
},
31
"path": "/alive",
32
"port": 8080,
33
"type": "http"
34
},
35
"resources": {
36
"limits": {
37
"cpu": "0.250",
38
"memory": "256Mi"
39
},
40
"requests": {
41
"cpu": "0.025",
42
"memory": "64Mi"
43
}
44
},
45
"variables": {
46
"MY_ENV_VAR": "Hello World!"
47
},
48
"volume_mounts": {
49
"/shared/common": {
50
"id": "volumes.common-dir",
51
"read_only": false,
52
"sub_path": "/cache"
53
}
54
}
55
}
56
}
Copied!
Last modified 1mo ago