PodCreatePodCreate
PodCreateCertified

Create a pod on a Kubernetes cluster, wait until the pod stops and collect its logs.

Create a pod on a Kubernetes cluster, wait until the pod stops and collect its logs.

yaml
type: "io.kestra.plugin.kubernetes.core.PodCreate"

Launch a Pod

yaml
id: kubernetes_pod_create
namespace: company.team

tasks:
  - id: pod_create
    type: io.kestra.plugin.kubernetes.core.PodCreate
    namespace: default
    metadata:
      labels:
        my-label: my-value
    spec:
      containers:
      - name: unittest
        image: debian:stable-slim
        command:
          - 'bash'
          - '-c'
          - 'for i in {1..10}; do echo $i; sleep 0.1; done'
      restartPolicy: Never

Launch a Pod with input files and gather its output files.

yaml
id: kubernetes_pod_create
namespace: company.team

inputs:
  - id: file
    type: FILE

tasks:
  - id: pod_create
    type: io.kestra.plugin.kubernetes.core.PodCreate
    spec:
      containers:
      - name: unittest
        image: centos
        command:
          - cp
          - "{{workingDir}}/data.txt"
          - "{{workingDir}}/out.txt"
      restartPolicy: Never
    waitUntilRunning: PT3M
    inputFiles:
      data.txt: "{{inputs.file}}"
    outputFiles:
      - out.txt

Launch a Pod with input files and gather its output files limiting resources for the init and sidecar containers.

yaml
id: kubernetes_pod_create
namespace: company.team

inputs:
  - id: file
    type: FILE

tasks:
  - id: pod_create
    type: io.kestra.plugin.kubernetes.core.PodCreate
    fileSidecar:
      resources:
        limits:
          cpu: "300m"
          memory: "512Mi"
    spec:
      containers:
      - name: unittest
        image: centos
        command:
          - cp
          - "{{workingDir}}/data.txt"
          - "{{workingDir}}/out.txt"
      restartPolicy: Never
    waitUntilRunning: PT3M
    inputFiles:
      data.txt: "{{inputs.file}}"
    outputFiles:
      - out.txt

Launch a Pod with default container spec applied to all containers for restrictive environments.

yaml
id: kubernetes_pod_create_secure
namespace: company.team

inputs:
  - id: file
    type: FILE

tasks:
  - id: pod_create
    type: io.kestra.plugin.kubernetes.core.PodCreate
    containerDefaultSpec:
      securityContext:
        allowPrivilegeEscalation: false
        capabilities:
          drop:
            - ALL
        readOnlyRootFilesystem: true
        seccompProfile:
          type: RuntimeDefault
      volumeMounts:
        - name: tmp
          mountPath: /tmp
    spec:
      volumes:
        - name: tmp
          emptyDir: {}
      containers:
      - name: main
        image: centos
        command:
          - cp
          - "{{workingDir}}/data.txt"
          - "{{workingDir}}/out.txt"
      restartPolicy: Never
    waitUntilRunning: PT3M
    inputFiles:
      data.txt: "{{inputs.file}}"
    outputFiles:
      - out.txt
Properties

The pod specification

Kubernetes pod specification defining containers, volumes, restart policy, and other pod settings. Must include at least one container. Supports dynamic template expressions including the special variable which resolves to '/kestra/working-dir' when inputFiles or outputFiles are used.

The connection parameters to the Kubernetes cluster

If no connection is defined, we try to load the connection from the current context in the following order:

  1. System properties
  2. Environment variables
  3. Kube config file
  4. Service account token and a mounted CA certificate.

You can pass a full configuration with all options if needed.

Definitions
apiVersionstring
Defaultv1
caCertDatastring
caCertFilestring
clientCertDatastring
clientCertFilestring
clientKeyAlgostring
DefaultRSA
clientKeyDatastring
clientKeyFilestring
clientKeyPassphrasestring
disableHostnameVerificationbooleanstring
keyStoreFilestring
keyStorePassphrasestring
masterUrlstring
Defaulthttps://kubernetes.default.svc
namespacestring
oauthTokenstring
oauthTokenProvider
outputstring
task
passwordstring
trustCertsbooleanstring
trustStoreFilestring
trustStorePassphrasestring
usernamestring

Default container spec applied to all containers in the pod

When set, these container spec fields are merged into all containers including:

  • User-defined containers in the spec
  • Init and sidecar containers for file transfer (unless fileSidecar.defaultSpec is set)

This provides a convenient way to apply uniform container settings across all containers, which is especially useful in restrictive environments like GovCloud.

Supports any valid Kubernetes container spec fields such as:

  • securityContext: Security settings for all containers
  • volumeMounts: Volume mounts to add to all containers
  • resources: Resource limits/requests for all containers
  • env: Environment variables for all containers

Merge behavior:

  • For nested objects (like securityContext): deep merge, container-specific values take precedence
  • For lists (like volumeMounts, env): concatenated, with defaults added first
  • Container-specific values always override defaults

Example configuration:

text
containerDefaultSpec: 
  securityContext: 
    allowPrivilegeEscalation: false
    capabilities: 
      drop: 
      - ALL
    readOnlyRootFilesystem: true
    seccompProfile: 
      type: RuntimeDefault
  volumeMounts: 
    - name: tmp
      mountPath: /tmp
  resources: 
    limits: 
      memory: "256Mi"
Definitions
apiVersionstring
Defaultv1

The API version

caCertDatastring

CA certificate as data

caCertFilestring

CA certificate as file path

clientCertDatastring

Client certificate as data

clientCertFilestring

Client certificate as a file path

clientKeyAlgostring
DefaultRSA

Client key encryption algorithm

default is RSA

clientKeyDatastring

Client key as data

clientKeyFilestring

Client key as a file path

clientKeyPassphrasestring

Client key passphrase

disableHostnameVerificationbooleanstring

Disable hostname verification

keyStoreFilestring

Key store file

keyStorePassphrasestring

Key store passphrase

masterUrlstring
Defaulthttps://kubernetes.default.svc

The URL to the Kubernetes API

namespacestring

The namespace used

oauthTokenstring

Oauth token

oauthTokenProvider

Oauth token provider

outputstring
task
passwordstring

Password

trustCertsbooleanstring

Trust all certificates

trustStoreFilestring

Truststore file

trustStorePassphrasestring

Truststore passphrase

usernamestring

Username

Definitions
Defaulttrue

Whether to delete the pod after task completion

When true (default), the pod is automatically deleted after successful completion or failure. Set to false to keep the pod for debugging purposes. Note that pods are always deleted when the task is killed.

Default{ "image": "busybox" }

The configuration of the file sidecar container that handles the download and upload of files

Definitions
defaultSpecobject

Default container spec for the file sidecar and init containers

Default container spec fields applied to the init and sidecar containers used for file transfer. When set, this overrides containerDefaultSpec for file transfer containers only.

Supports the same fields as containerDefaultSpec:

  • securityContext: Security settings for file transfer containers
  • volumeMounts: Volume mounts to add to file transfer containers
  • resources: Resource limits/requests (note: also available as top-level 'resources' property)
  • env: Environment variables for file transfer containers

Example configuration:

text
fileSidecar: 
  defaultSpec: 
    securityContext: 
      allowPrivilegeEscalation: false
      capabilities: 
        drop: 
        - ALL
      readOnlyRootFilesystem: true
      seccompProfile: 
        type: RuntimeDefault
    volumeMounts: 
      - name: tmp
        mountPath: /tmp
imagestring
Defaultbusybox

The image used for the file sidecar container

resourcesobject

The resource requirements applied to the file sidecar container

SubTypestring

The files to create on the local filesystem – it can be a map or a JSON object.

The files will be available inside the kestra/working-dir directory of the container. You can use the special variable {{workingDir}} in your command to refer to it.

Defaultfalse
Definitions

The pod metadata configuration

Kubernetes metadata for the pod, including labels, annotations, and name. If name is not specified, it will be auto-generated based on the task execution context. Supports dynamic template expressions.

Defaultdefault

The namespace where the operation will be done

The Kubernetes namespace in which to execute the operation. Defaults to 'default' if not specified.

SubTypestring

The files from the container filesystem to send to Kestra's internal storage

Only files created inside the kestra/working-dir directory of the container can be retrieved. Must be a list of glob expressions relative to the current working directory, some examples: my-dir/**, my-dir/*/** or my-dir/my-file.txt..

Defaulttrue

Whether to resume execution of an existing pod

When true (default), attempts to reconnect to an existing pod with matching taskrun ID and attempt count instead of creating a new pod. This enables recovery from interrupted executions. If no matching pod exists or multiple matching pods are found, a new pod is created.

DefaultPT30S
Formatduration

Additional time to wait for late-arriving logs after pod completion

After the pod completes and initial log collection finishes, wait this duration to capture any remaining logs that may still be in transit. Defaults to 30 seconds. Useful as a safety net for high-throughput scenarios where logs may arrive slightly delayed.

DefaultPT1H
Formatduration

The maximum duration to wait for pod completion

Maximum duration allowed for the pod to complete after reaching Running state. If the pod does not complete within this time, the task will fail and the pod will be deleted. Only used by PodCreate task.

DefaultPT0S
Formatduration

The maximum duration to wait until the resource becomes ready

When set to a positive duration, waits for the resource to report Ready=True in its status conditions. Set to PT0S (zero, default) to skip waiting. Supports Pods, StatefulSets, and custom resources that use the Ready condition. Note: Deployments are not supported as they use the Available condition instead of Ready.

DefaultPT10M
Formatduration

The maximum duration to wait until the pod is running

Maximum time to wait for the pod to reach Running state, including scheduler assignment, image pull, and container startup. Only used by PodCreate task.

The pod metadata

Definitions
annotationsobject
SubTypestring

List of all annotations of the resource

clusterNamestring

Name of the current cluster

creationTimestampstring
Formatdate-time

Creation datetime

deletionGracePeriodSecondsinteger

Deletetion grace period in seconds

deletionTimestampstring
Formatdate-time

Deletion datetime

finalizersarray
SubTypestring

List of finalizers

generateNamestring

Generate name of the resource

generationinteger

Generation

labelsobject
SubTypestring

List of labels

managedFieldsarray

List of managed fields

apiVersionstring
fieldsTypestring
fieldsV1
managerstring
operationstring
subresourcestring
timestring
namestring

Name of the resource

namespacestring

Namespace of the resource

ownerReferencesarray

List of owner reference

apiVersionstring
blockOwnerDeletionboolean
controllerboolean
kindstring
namestring
uidstring
resourceVersionstring

Resource version

selfLinkstring

Direct link to the API of this resource

uidstring

Generated UUID of this resource

SubTypestring

The output files URI in Kestra's internal storage

The pod status

Definitions
additionalPropertiesobject
conditionsarray
lastProbeTimestring
lastTransitionTimestring
messagestring
observedGenerationinteger
reasonstring
statusstring
typestring
containerStatusesarray
allocatedResourcesobject
amountstring
formatstring
allocatedResourcesStatusarray
namestring
resourcesarray
containerIDstring
imagestring
imageIDstring
lastState
running
terminated
waiting
namestring
readyboolean
resources
claimsarray
limitsobject
requestsobject
restartCountinteger
startedboolean
state
running
terminated
waiting
stopSignalstring
user
linux
volumeMountsarray
mountPathstring
namestring
readOnlyboolean
recursiveReadOnlystring
ephemeralContainerStatusesarray
allocatedResourcesobject
amountstring
formatstring
allocatedResourcesStatusarray
namestring
resourcesarray
containerIDstring
imagestring
imageIDstring
lastState
running
terminated
waiting
namestring
readyboolean
resources
claimsarray
limitsobject
requestsobject
restartCountinteger
startedboolean
state
running
terminated
waiting
stopSignalstring
user
linux
volumeMountsarray
mountPathstring
namestring
readOnlyboolean
recursiveReadOnlystring
hostIPstring
initContainerStatusesarray
allocatedResourcesobject
amountstring
formatstring
allocatedResourcesStatusarray
namestring
resourcesarray
containerIDstring
imagestring
imageIDstring
lastState
running
terminated
waiting
namestring
readyboolean
resources
claimsarray
limitsobject
requestsobject
restartCountinteger
startedboolean
state
running
terminated
waiting
stopSignalstring
user
linux
volumeMountsarray
mountPathstring
namestring
readOnlyboolean
recursiveReadOnlystring
messagestring
nominatedNodeNamestring
phasestring
podIPstring
podIPsarray
ipstring
qosClassstring
reasonstring
startTimestring
Formatdate-time

The output variables extracted from the logs of the commands