Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node allows you to interact with Kubernetes Jobs by running a new Job pod in a specified namespace. It is useful for automating the execution of containerized tasks within a Kubernetes cluster, such as batch processing, data transformation, or triggering custom scripts.

In the "Run" operation for Jobs, the node creates and runs a pod using a specified container image and command, then returns the output from that pod's execution. This can be used to programmatically start jobs on-demand and capture their results directly within an n8n workflow.

Practical examples:

  • Running a data processing job inside a Kubernetes cluster by specifying a container image with your processing script and passing the required command arguments.
  • Triggering a maintenance task or cleanup script packaged as a container image.
  • Executing one-off commands in a Kubernetes environment without manually creating pods.

Properties

Name Meaning
Image The container image to use for the Job pod (e.g., myrepo/myimage:latest).
Command The command to run inside the container, provided as a JSON array of strings (e.g., ["/bin/sh", "-c", "echo Hello"]). Must be an array.
Namespace The Kubernetes namespace where the Job pod will be created and run. Defaults to "default".
Resource Name The name of the specific resource (Job) to target. For "run" operation, this is typically not required but available for other operations.

Output

The node outputs JSON data containing the standard output (stdout) from the executed Job pod. This output represents the result of the command run inside the container image.

Example output structure:

{
  "stdout": "output text from the job pod"
}

No binary data output is produced by this operation.

Dependencies

  • Requires access to a Kubernetes cluster with appropriate permissions to create and manage pods/jobs.
  • Needs an API authentication token or credentials configured in n8n to connect securely to the Kubernetes API.
  • The node depends on an internal Kubernetes client utility to communicate with the cluster.

Troubleshooting

  • Error: "No credentials got returned!"
    This indicates that the node could not find or access the required Kubernetes API credentials. Ensure that valid credentials are configured and selected in the node settings.

  • Error: "Command must be an array!"
    The Command property must be a valid JSON array of strings. Check that the input is correctly formatted JSON representing an array, e.g., ["/bin/sh", "-c", "echo Hello"].

  • Pod creation or execution failures
    These may occur due to insufficient permissions, incorrect namespace, invalid image names, or cluster connectivity issues. Verify Kubernetes RBAC permissions, namespace existence, and network access.

  • Empty or missing output
    If the command inside the pod does not produce output or fails silently, check the container image and command correctness.

Links and References

Discussion