Kubernetes
Task runner that executes a task inside a pod in a Kubernetes cluster.
This plugin is only available in the [Enterprise Edition](https://kestra.io/enterprise) (EE).
This task runner is container-based so the `containerImage` property must be set to be able to use it.
To access the task's working directory, use the `{{workingDir}}` Pebble expression or the `WORKING_DIR` environment variable. Input files and namespace files will be available in this directory.
To generate output files you can either use the `outputFiles` task's property and create a file with the same name in the task's working directory, or create any file in the output directory which can be accessed by the `{{outputDir}}` Pebble expression or the `OUTPUT_DIR` environment variables.
Note that when the Kestra Worker running this task is terminated, the pod will still runs until completion, then after restarting, the Worker will resume processing on the existing pod unless `resume` is set to false.
If your cluster is configure with [RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac/), you need to configure the service account running your pod need to have the following authorizations:
- pods: get, create, delete, watch, list
- pods/log: get, watch
- pods/exec: get, watch
As an example, here is a role that grant those authorizations:
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: task-runner
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "create", "delete", "watch", "list"]
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["get", "watch"]
- apiGroups: [""]
resources: ["pods/log"]
verbs: ["get", "watch"]
```
type: "io.kestra.plugin.ee.kubernetes.runner.Kubernetes"
Examples
Execute a Shell command.
id: new-shell
namespace: company.team
tasks:
- id: shell
type: io.kestra.plugin.scripts.shell.Commands
taskRunner:
type: io.kestra.plugin.ee.kubernetes.runner.Kubernetes
commands:
- echo "Hello World"
Pass input files to the task, execute a Shell command, then retrieve output files.
id: new-shell-with-file
namespace: company.team
inputs:
- id: file
type: FILE
tasks:
- id: shell
type: io.kestra.plugin.scripts.shell.Commands
inputFiles:
data.txt: "{{ inputs.file }}"
outputFiles:
- out.txt
containerImage: centos
taskRunner:
type: io.kestra.plugin.ee.kubernetes.runner.Kubernetes
commands:
- cp {{ workingDir }}/data.txt {{ workingDir }}/out.txt
Properties
config Non-dynamicConnection
The configuration of the target Kubernetes cluster.
containerSpec object
Additional YAML spec for the container.
delete booleanstring
true
Whether the pod should be deleted upon completion.
fileSideCarSpec object
Additional YAML spec for the sidecar container.
fileSidecar Non-dynamicSideCar
{
"image": "busybox"
}
The configuration of the file sidecar container that handle download and upload of files.
labels object
The pod custom labels
Kestra will add default labels to the pod with execution and flow identifiers.
namespace string
default
The namespace where the pod will be created.
nodeSelector object
Node selector for pod scheduling
Kestra will assign the pod to the nodes you want (see Assign Pod Nodes)
podSpec object
Additional YAML spec for the pod.
pullPolicy string
ALWAYS
IF_NOT_PRESENT
ALWAYS
NEVER
The image pull policy for a container image and the tag of the image, which affect when Docker attempts to pull (download) the specified image.
resources Non-dynamicKubernetes-Resources
The pod custom resources
resume booleanstring
true
Whether to reconnect to the current pod if it already exists.
serviceAccountName string
The name of the service account.
version Non-dynamicstring
\d+\.\d+\.\d+(-[a-zA-Z0-9-]+)?|([a-zA-Z0-9]+)
The version of the plugin to use.
waitForLogs string
PT5S
duration
The additional duration to wait for logs to arrive after pod completion.
As logs are not retrieved in real time, we cannot guarantee that we have fetched all logs when the pod complete, therefore we wait for a fixed amount of time to fetch late logs.
waitUntilCompletion string
PT1H
duration
The maximum duration to wait for the pod completion unless the task timeout
property is set which will take precedence over this property.
waitUntilRunning string
PT10M
duration
The maximum duration to wait until the pod is created.
This timeout is the maximum time that Kubernetes scheduler can take to
- schedule the pod
- pull the pod image
- and start the pod.
Definitions
io.kestra.plugin.ee.kubernetes.models.OAuthTokenProvider
output string
task Task
io.kestra.core.models.tasks.retrys.Constant
interval *Requiredstring
duration
type *Requiredobject
behavior string
RETRY_FAILED_TASK
RETRY_FAILED_TASK
CREATE_NEW_EXECUTION
maxAttempts integer
>= 1
maxDuration string
duration
warningOnRetry boolean
false
io.kestra.plugin.ee.kubernetes.runner.SideCar
image string
busybox
The image used for the file sidecar container.
io.kestra.core.models.tasks.retrys.Random
maxInterval *Requiredstring
duration
minInterval *Requiredstring
duration
type *Requiredobject
behavior string
RETRY_FAILED_TASK
RETRY_FAILED_TASK
CREATE_NEW_EXECUTION
maxAttempts integer
>= 1
maxDuration string
duration
warningOnRetry boolean
false
io.kestra.plugin.ee.kubernetes.runner.Kubernetes-Resource
cpu string
memory string
io.kestra.plugin.ee.kubernetes.runner.Kubernetes-Resources
limit Kubernetes-Resource
request Kubernetes-Resource
io.kestra.core.models.tasks.retrys.Exponential
interval *Requiredstring
duration
maxInterval *Requiredstring
duration
type *Requiredobject
behavior string
RETRY_FAILED_TASK
RETRY_FAILED_TASK
CREATE_NEW_EXECUTION
delayFactor number
maxAttempts integer
>= 1
maxDuration string
duration
warningOnRetry boolean
false
io.kestra.core.models.tasks.Cache
enabled *Requiredboolean
ttl string
duration
io.kestra.plugin.ee.kubernetes.models.Connection
apiVersion string
v1
The API version
caCertData string
CA certificate as data
caCertFile string
CA certificate as file path
clientCertData string
Client certificate as data
clientCertFile string
Client certificate as a file path
clientKeyAlgo string
RSA
Client key encryption algorithm
default is RSA
clientKeyData string
Client key as data
clientKeyFile string
Client key as a file path
clientKeyPassphrase string
Client key passphrase
disableHostnameVerification booleanstring
Disable hostname verification
keyStoreFile string
Key store file
keyStorePassphrase string
Key store passphrase
masterUrl string
https://kubernetes.default.svc
The url to the Kubernetes API
namespace string
The namespace used
oauthToken string
Oauth token
oauthTokenProvider OAuthTokenProvider
Oauth token provider
password string
Password
trustCerts booleanstring
Trust all certificates
trustStoreFile string
Truststore file
trustStorePassphrase string
Truststore passphrase
username string
Username
io.kestra.core.models.tasks.WorkerGroup
fallback string
FAIL
WAIT
CANCEL