Container runtime
The Container runtime allows you to create deployments, jobs and services on Kubernetes.
Prerequisites
Python version and libraries:
python >= 3.9
digitalhub-runtime-container
The package is available on PyPI:
HOW TO
With the Container runtime you can launch pods and services on Kubernetes. It is built having remote online execution capabilities.
Function
The Container runtime introduces a function of kind container
that allows you to deploy deployments, jobs and services on Kubernetes.
Function parameters
Name | Type | Description | Default |
---|---|---|---|
project | str | Project name. Required only if creating from library, otherwise MUST NOT be set | |
name | str | Name that identifies the object | required |
kind | str | Function kind | required |
uuid | str | ID of the object in form of UUID4 | None |
description | str | Description of the object | None |
labels | list[str] | List of labels | None |
embedded | bool | Flag to determine if object must be embedded in project | True |
code_src | str | URI pointer to source code | None |
code | str | Source code (plain text) | None |
base64 | str | Source code (base64 encoded) | None |
handler | str | Function entrypoint | None |
lang | str | Source code language (hint) | None |
image | str | The image to use | None |
base_image | str | The base container image | None (required if task is build ) |
command | str | The command to run inside the container | None |
args | list[str] | The arguments to pass to the command | None |
Function kinds
The kind
parameter must be:
container
Function example
import digitalhub as dh
project = dh.get_or_create_project('my_project')
function = dh.new_function(
kind='container',
name='my_function',
image="hello-world:latest"
)
Task
The container runtime introduces four tasks of kind job
, serve
, build
and deploy
that allows you to run a Kubernetes job, create a service or a deployment and build an image.
A Task
is created with the run()
method, so it's not managed directly by the user. The parameters for the task creation are passed directly to the run()
method, and may vary depending on the kind of task.
Task parameters
Name | Type | Description | Default | Kind specific |
---|---|---|---|---|
action | str | Task action | required | |
node_selector | list[dict] | Node selector | None | |
volumes | list[dict] | List of volumes | None | |
resources | dict | Resources restrictions | None | |
affinity | dict | Affinity | None | |
tolerations | list[dict] | Tolerations | None | |
envs | list[dict] | Env variables | None | |
secrets | list[str] | List of secret names | None | |
profile | str | Profile template | None | |
backoff_limit | int | Backoff limit | None | job |
schedule | str | Schedule for the job | None | job |
fsGroup | int | File system group ID | None | deploy , job |
replicas | int | Number of replicas | None | deploy , serve |
service_ports | list[dict] | Service port where to expose the service | NodePort |
serve |
service_type | str | Service type | NodePort |
serve |
instructions | list[str] | Build instructions to be executed as RUN instructions in Dockerfile | None | build |
Task actions
Actions must be one of the following:
job
build
serve
deploy
Task example
Run
The Run
object is, similar to the Task
, created with the run()
method.
The run's parameters are passed alongside the task's ones.
Run parameters
There are no parameters for the run
spec.
Run example
Run methods
There are no specific methods for the run
container.