New to Kestra?
Use blueprints to kickstart your first workflows.
Orchestrate the full Kubernetes pod lifecycle with Kestra: create an ephemeral pod, fetch its status via kubectl, log results, and delete it automatically.
Run the complete lifecycle of a Kubernetes pod as a single declarative Kestra workflow: create an ephemeral pod, query its live status with kubectl, log what the cluster returns, then tear the pod down so nothing lingers. This solves a common pain point with running one-off jobs on Kubernetes, where pods, unit-test containers, and short-lived processing tasks pile up because nothing reliably cleans them up after they finish. By tying creation and deletion together in one flow, you get a repeatable, auditable pattern for ephemeral compute on a cluster.
create task (io.kestra.plugin.kubernetes.core.PodCreate) launches a debian:stable-slim pod in the monitoring namespace with a custom label and a restartPolicy: Never, running a short bash command. delete: false keeps the pod alive so later tasks can inspect it.get task (io.kestra.plugin.kubernetes.kubectl.Get) lists pods in the namespace with fetchType: FETCH, pulling their status into the flow outputs.log task (io.kestra.plugin.core.log.Log) prints {{ outputs.get.statusItems }} to Kestra's logs for auditing and debugging.delete task (io.kestra.plugin.kubernetes.kubectl.Delete) removes the pod by referencing {{ outputs.create.metadata.name }}, so cleanup always targets the exact pod that was created.Cluster authentication is centralized in pluginDefaults for io.kestra.plugin.kubernetes, injecting masterUrl and oauthToken from secrets with trustCerts: true.
Kubernetes itself has no built-in scheduler that creates a pod, reads its status, and guarantees deletion as one accountable unit. CronJobs run pods but leave orchestration, status capture, and conditional cleanup to you. With Kestra you get event and schedule triggers, automatic retries, full execution lineage across every task, and a declarative YAML definition that lives in version control. The dynamic {{ outputs.create.metadata.name }} reference ties cleanup to the precise resource created, closing the gap the cluster's own tooling leaves open.
monitoring namespace (or change it to one you own)K8S_MASTER_URL: the Kubernetes API server URLK8S_TOKEN: the OAuth token used to authenticate against the clusterK8S_MASTER_URL and K8S_TOKEN secrets to your Kestra instance.log task output to see the fetched pod status, and confirm the pod is gone after delete.resourceType in Get and Delete to manage Deployments, Services, or ConfigMaps.image and command in create to run your own job.Schedule or event trigger to run the lifecycle on a cadence.errors branch to handle transient cluster failures.