Run a One-Off Task Pod and Collect Its Output
A 4-step recipe with Kubernetes. We can help you get access.
Recipe · 4 steps
Run a One-Off Task Pod and Collect Its Output
with Kubernetes
Create a run-to-completion pod, read its output, and delete it.
- Create the task pod with restartPolicy Never so a failed command is left in the Failed phase for inspection rather than being restarted forever.
- Read the pod until it leaves the Pending phase. Succeeded means the command exited zero; Failed means it exited non-zero.
- Read the container log as the task's output. This is the only place the command's stdout is retained once the pod is deleted.
- Delete the completed task pod so finished one-off runs do not accumulate. The log has already been collected by the previous step.
What you'll need to have ready
- namespace: The namespace to run the task pod in.
- taskName: Name for the one-off pod and its container.
- image: Container image that carries the task.
- command: Entrypoint command array, replacing the image ENTRYPOINT.
- args: Arguments to the entrypoint, replacing the image CMD.
- env: Environment variables to set in the task container.
- serviceAccountName: Service account granting the task pod its API permissions.
- tailLines: Number of log lines to collect from the end of the log.
For your developer
Arazzo workflow kubernetes:run-one-off-pod, 4 operations: createNamespacedPod → getNamespacedPod → readNamespacedPodLog → deleteNamespacedPod. Specs on APIs.io.