Blueprints

Run a Shell script inside of a Kubernetes pod

About this blueprint

CLI Inputs Task Runner

This flow contains a Shell command that is executed in a Kubernetes pod. It is useful to declare resource limits and resource requests.

  • If your script task has inputFiles or namespaceFiles configured, an init container will be added to upload files into the main container.
  • If your script task has outputFiles configured, a sidecar container will be added to download files from the main container.

All containers will use an in-memory emptyDir volume for file exchange.

If a task is resubmitted (e.g. due to a retry or a Worker crash), the new Worker will reattach to the already running (or an already finished) pod instead of starting a new one.

yaml
id: kubernetes_script_runner
namespace: company.team

description: |
  To get the kubeconfig file, run: `kubectl config view --minify --flatten`.
  Then, copy the `server`, `caCert`, `clientKey`, `clientCert`, `user`, and `namespace` values to the configuration below.
  Here is a mapping of the kubeconfig file to the Kubernetes task runner configuration:
  - clientKey: client-key-data
  - clientCert: client-certificate-data
  - caCert: certificate-authority-data
  - masterUrl: server
  - username: user

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 data.txt out.txt

Commands

Kubernetes

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra