Kubernetes PodCreate

Kubernetes PodCreate

Certified

Run a Kubernetes pod and collect logs

Creates or resumes a pod from the provided spec, streams container logs, and handles file upload/download via init and sidecar containers. Deletes the pod by default after completion and waits briefly for late-arriving logs.

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

Create a Pod with a service account.

yaml
id: kubernetes_pod_create
namespace: company.team

tasks:
  - id: pod_create
    type: io.kestra.plugin.kubernetes.core.PodCreate
    namespace: default
    connection:
      masterUrl: "{{ secret('K8S_MASTER_URL') }}"
      oauthToken: "{{ secret('K8S_TOKEN') }}"
    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

Create 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
    connection:
      masterUrl: "{{ secret('K8S_MASTER_URL') }}"
      oauthToken: "{{ secret('K8S_TOKEN') }}"
    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

Create 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
    connection:
      masterUrl: "{{ secret('K8S_MASTER_URL') }}"
      oauthToken: "{{ secret('K8S_TOKEN') }}"
    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

Create 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
    connection:
      masterUrl: "{{ secret('K8S_MASTER_URL') }}"
      oauthToken: "{{ secret('K8S_TOKEN') }}"
    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

Pod specification

Kubernetes Pod spec map defining containers, volumes, restart policy, and related settings. Must declare at least one container. Template expressions are allowed, including {{ workingDir }} resolving to '/kestra/working-dir' when inputFiles or outputFiles are configured. See using pods in the Kubernetes documentation for the full spec format.

When inputFiles or outputFiles are configured, Kestra automatically injects file-transfer containers named init-files (init container) and out-files (sidecar). Any user-provided containers with those reserved names will be silently removed and replaced by Kestra's own containers. Additional containers you define alongside your main container are fully preserved as sidecars.

Kubernetes connection

Connection settings for the cluster. If omitted, the client resolves credentials in order: system properties, environment variables, kubeconfig, then in-cluster service account.

Definitions
apiVersionstring
Defaultv1

API version

API group version used by the client. Default v1.

caCertDatastring

CA certificate data

Base64-encoded PEM CA bundle. Whitespace is stripped automatically.

caCertFilestring

CA certificate file

Path to a PEM CA bundle.

clientCertDatastring

Client certificate data

Base64-encoded client cert. Whitespace is stripped automatically.

clientCertFilestring

Client certificate file

clientKeyAlgostring
DefaultRSA

Client key algorithm

Algorithm for the client key. Default RSA.

clientKeyDatastring

Client key data

Base64-encoded client key. Whitespace is stripped automatically.

clientKeyFilestring

Client key file

clientKeyPassphrasestring

Client key passphrase

disableHostnameVerificationbooleanstring

Disable hostname verification

Disables TLS hostname checks. Avoid in production clusters.

enableHttp2booleanstring

Enable HTTP/2

Off by default (HTTP/1.1, the prior behavior). Enable to use HTTP/2, which keeps long-lived watch/log streams alive better through proxies like GKE konnectivity.

keyStoreFilestring

Keystore file

keyStorePassphrasestring

Keystore passphrase

masterUrlstring
Defaulthttps://kubernetes.default.svc

Kubernetes API URL

API server endpoint. Default https://kubernetes.default.svc.

maxConcurrentRequestsintegerstring

Max concurrent HTTP requests

Caps total concurrent HTTP requests issued by this client. Lower this when running many concurrent tasks against a rate-limited API server (e.g. GKE). Fabric8 default: 64.

maxConcurrentRequestsPerHostintegerstring

Max concurrent HTTP requests per host

Caps concurrent HTTP requests to a single host (the API server). Fabric8 default: 5.

namespacestring

Default namespace

Namespace used when resources omit a namespace.

oauthTokenstring

OAuth token

oauthTokenProvider

Dynamically refreshes the OAuth token used to authenticate with the Kubernetes API. Use this when authenticating via a cloud provider (e.g. GCP, AWS, Azure) whose tokens are short-lived (typically 1 hour). Without this, long-running tasks will fail with an unauthorized error once the initial token expires. The provider executes a Kestra task to fetch a fresh token each time the Kubernetes client needs to re-authenticate.

Dynamically refreshes an OAuth token by executing a Kestra task each time the Kubernetes client needs to authenticate. This is essential for cloud providers (e.g. GCP, AWS, Azure) whose tokens are short-lived (typically 1 hour). Without automatic refresh, long-running tasks will fail with an unauthorized error once the initial token expires.

cachestring
DefaultPT5M
Formatduration

Token cache duration

How long a fetched token is reused before the provider executes the task again. Caching avoids hammering the token endpoint on every Kubernetes API call. Defaults to 5 minutes (PT5M). Set to PT0S to disable caching.

outputstring

Token output expression

An expression to extract the token value from the task output, e.g. {{ accessToken.tokenValue }}.

task

Token provider task

A Kestra task that fetches a fresh OAuth token. This task is executed each time the Kubernetes client needs to authenticate, enabling automatic token refresh for long-running operations.

passwordstring

Password

trustCertsbooleanstring

Trust all certificates

When true, skips TLS cert validation. Use only for testing.

trustStoreFilestring

Truststore file

trustStorePassphrasestring

Truststore passphrase

usernamestring

Username

watchReconnectIntervalstring

Watch reconnect interval

Backoff between watch reconnect attempts. Increase to prevent reconnect storms under API server pressure. Fabric8 default: 1s.

websocketPingIntervalstring

WebSocket ping interval

Keepalive ping on exec/log connections so idle streams aren't dropped by a proxy (e.g. GKE konnectivity). Only honored by the OkHttp backend. 0 disables.

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 volumeMounts: concatenated, with defaults added first
  • For env: deduplicated by name — container-specific values always win over defaults on collision
  • Container-specific values always override defaults

Example configuration:

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

Delete pod after task completion

Default true. Deletes the pod after success or failure; set to false to keep it for debugging. Pods are still 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 spec for file transfer containers

Overrides containerDefaultSpec for the init and sidecar containers that move files. Accepts Pod container fields such as securityContext, volumeMounts, resources, and env; useful for hardening or adding mounts used only by file transfer helpers.

Example: fileSidecar: defaultSpec: securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true volumeMounts: - name: tmp mountPath: /tmp

imagestring
Defaultbusybox

Image for file sidecar

Container image used by the init container (uploads input files) and the sidecar (downloads output files). Defaults to busybox.

The image must provide, on its PATH: a POSIX shell (sh), test/[, and sleep — required by the polling script that waits for the transfer to complete before the container exits. find and wc are also used, on a best-effort basis, to verify that uploaded files were fully transferred; if they're missing, verification is skipped rather than failing the task.

resourcesobject

Configure sidecar resource requests/limits

Optional Kubernetes resources block applied to the file transfer sidecar.

Defaultfalse

Inherit cluster auto-config

When true and a connection is set, the client config is seeded from the ambient auto-config (system properties, env, kubeconfig, in-cluster service account) before applying connection, so a partial connection (e.g. only a namespace) keeps the resolved credentials instead of starting blank. Default false.

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.

Pod metadata

Name, labels, and annotations applied to the pod. Name is auto-generated from the task run when omitted. Supports 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..

Reference (ref) of the pluginDefaults to apply to this task.

Defaulttrue

Resume an existing pod when possible

Default true. Reconnects to a pod labeled with the current taskrun ID, whatever attempt created it. A completed (Succeeded) pod is only resumed within the same attempt, so task retries re-run the workload. Stale pods from previous attempts are deleted. Still-active stale pods are removed even when delete is false, to protect quotas and concurrency limits.

DefaultPT30S

Grace period for late logs

Duration to wait after completion before fetching final logs. Default PT30S; increase in high-throughput clusters to avoid missing trailing logs.

DefaultPT1H

Wait for pod completion

Maximum run time after reaching Running (defaults to PT1H). PodCreate fails and deletes the pod when exceeded.

DefaultPT0S

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

Wait for pod to reach Running

Maximum time to reach Running (defaults to PT10M). Covers scheduling, image pulls, and startup. Used by PodCreate.

Returned pod metadata

Metadata from the pod at task completion.

Definitions
annotationsobject

Resource annotations

clusterNamestring

Cluster name

creationTimestampstring
Formatdate-time

Creation timestamp

deletionGracePeriodSecondsinteger

Deletion grace period in seconds

deletionTimestampstring
Formatdate-time

Deletion timestamp

finalizersarray
SubTypestring

Finalizers

generateNamestring

Generated name prefix

generationinteger

Generation

labelsobject

Resource labels

managedFieldsarray

Managed fields

apiVersionstring
fieldsTypestring
fieldsV1
managerstring
operationstring
subresourcestring
timestring
namestring

Resource name

namespacestring

Resource namespace

ownerReferencesarray

Owner references

apiVersionstring
blockOwnerDeletionboolean
controllerboolean
kindstring
namestring
uidstring
resourceVersionstring

Resource version

selfLinkstring

Self link

uidstring

Generated UUID of this resource

SubTypestring

Downloaded output file URIs

Kestra internal storage URIs for files fetched from the pod sidecar.

Returned pod status

Kubernetes status snapshot used to set the task final state.

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
volumeStatus
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
volumeStatus
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
volumeStatus
messagestring
nominatedNodeNamestring
phasestring
podIPstring
podIPsarray
ipstring
qosClassstring
reasonstring
startTimestring
Formatdate-time

Extracted variables from pod logs

Key/value pairs parsed from container log output.