Apply a Kubernetes resource (e.g., a Kubernetes deployment).

yaml
type: "io.kestra.plugin.kubernetes.kubectl.Apply"

Apply a Kubernetes resource, using YAML.

yaml
id: create_or_replace_deployment
namespace: company.team

tasks:
  - id: apply
    type: io.kestra.plugin.kubernetes.kubectl.Apply
    namespace: default
    spec: |-
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: mypod

Apply a Kubernetes resource, using a namespace file.

yaml
id: create_or_replace_deployment
namespace: company.team

tasks:
  - id: apply
    type: io.kestra.plugin.kubernetes.kubectl.Apply
    namespaceFiles:
      enabled: true
    namespace: default
    spec: "{{ read('deployment.yaml') }}"

Apply a Kubernetes custom resource definition, using YAML.

yaml
id: k8s
namespace: company.name

tasks:
  - id: apply
    type: io.kestra.plugin.kubernetes.kubectl.Apply
    namespace: default
    spec: |-
      apiVersion: apiextensions.k8s.io/v1
      kind: CustomResourceDefinition
      metadata:
        name: shirts.stable.example.com
      spec:
        group: stable.example.com
        scope: Namespaced
        names:
          plural: shirts
          singular: shirt
          kind: Shirt
        versions:
        - name: v1
          served: true
          storage: true
          schema:
            openAPIV3Schema:
              type: object
              properties:
                apiVersion:
                  type: string
                kind:
                  type: string
                metadata:
                  type: object
                spec:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true # Allows any fields in spec
                  properties:
                    # You should define your actual Shirt properties here later
                    # For example:
                    # color:
                    #   type: string
                    # size:
                    #   type: string
                    #   enum: ["S", "M", "L", "XL"]
                status:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true # Allows any fields in status
                  properties:
                    # Define your status properties here
                    # message:
                    #   type: string

Apply a custom resource and wait for it to become ready.

yaml
id: apply_and_wait_for_custom_resource
namespace: company.team

tasks:
  - id: apply
    type: io.kestra.plugin.kubernetes.kubectl.Apply
    namespace: default
    waitUntilReady: PT10M
    spec: |-
      apiVersion: example.com/v1
      kind: MyResource
      metadata:
        name: my-resource
      spec:
        foo: bar
Properties

The Kubernetes resource spec

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.

Default { "image": "busybox" }

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

SubType string

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.

The Kubernetes namespace

SubType string

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..

Default PT1H
Format duration

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.

Default PT0S
Format duration

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.

Default PT10M
Format duration

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.

SubType

The resource metadata

Default v1

The API version

CA certificate as data

CA certificate as file path

Client certificate as data

Client certificate as a file path

Default RSA

Client key encryption algorithm

default is RSA

Client key as data

Client key as a file path

Client key passphrase

Disable hostname verification

Key store file

Key store passphrase

Default https://kubernetes.default.svc

The URL to the Kubernetes API

The namespace used

Oauth token

Oauth token provider

Password

Trust all certificates

Truststore file

Truststore passphrase

Username

SubType string

List of all annotations of the resource

Name of the current cluster

Format date-time

Creation datetime

Deletetion grace period in seconds

Format date-time

Deletion datetime

SubType string

List of finalizers

Generate name of the resource

Generation

SubType string

List of labels

List of managed fields

Name of the resource

Namespace of the resource

List of owner reference

Resource version

Generated UUID of this resource

Default busybox

The image used for the file sidecar container

The resource requirements applied to the file sidecar container