Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with a Kubernetes cluster by performing various operations on Kubernetes resources. Specifically, the "Run" operation allows users to run a pod in a specified namespace using a given container image and command, then retrieve the output of that pod execution.

Common scenarios for this node include:

  • Running short-lived jobs or scripts inside a Kubernetes cluster without manually creating pod manifests.
  • Automating tasks such as batch processing, data transformation, or triggering containerized commands dynamically.
  • Quickly testing container images or commands within a Kubernetes environment from an n8n workflow.

For example, you could use this node to run a containerized script that processes input data and returns results directly into your workflow, enabling seamless integration between Kubernetes workloads and other automation steps.

Properties

Name Meaning
Image The container image to run inside the pod (e.g., ubuntu:latest).
Command A JSON array representing the command and its arguments to execute inside the container.
Namespace The Kubernetes namespace where the pod will be created and run. Defaults to "default".
Resource Name The name of the Kubernetes resource to target (used in other operations but not required here).

Output

The node outputs JSON data containing the standard output (stdout) of the executed pod command. This output represents the result of running the specified command inside the container image on Kubernetes.

If the pod execution produces binary data, it would typically be included in the JSON output or handled separately, but this node focuses on returning textual command output.

Example output structure:

{
  "stdout": "command execution output text"
}

Dependencies

  • Requires access to a Kubernetes cluster with appropriate API credentials configured in n8n.
  • Needs an API authentication token or similar credential to connect securely to the Kubernetes API.
  • Uses an internal Kubernetes client utility to interact with the cluster.

Troubleshooting

  • Error: No credentials got returned!
    This indicates missing or misconfigured Kubernetes API credentials in n8n. Ensure that valid credentials are set up and linked to the node.

  • Error: Command must be an array!
    The Command property must be a valid JSON array. Check that the input is correctly formatted, e.g., ["ls", "-l"].

  • Pod creation or execution failures
    Could be caused by invalid image names, insufficient permissions, or namespace issues. Verify the image exists and the user has rights to create pods in the specified namespace.

  • Empty or no output
    If the command does not produce output or the pod fails silently, check the command correctness and pod logs via other Kubernetes tools.

Links and References

Discussion