Actions90
- Jobs Actions
- Namespaces Actions
- Pods Actions
- Services Actions
- Deployments Actions
- ReplicaSets Actions
- StatefulSets Actions
- DaemonSets Actions
- CronJobs Actions
Overview
This node allows you to interact with Kubernetes clusters, specifically focusing on managing Pods when using the "Pods" resource and the "Run" operation. The "Run" operation creates and runs a new Pod in a specified namespace using a given container image and command. It then captures and returns the output (stdout) of the Pod execution.
Common scenarios where this node is beneficial include:
- Running short-lived containerized tasks or scripts inside a Kubernetes cluster without manually creating Pod manifests.
- Automating batch jobs or commands that need to be executed inside a Kubernetes environment.
- Quickly testing container images by running them with specific commands and retrieving their output.
Practical example:
- You want to run a diagnostic script inside a Kubernetes cluster by specifying an image that contains the script and passing the script as a command array. The node will create the Pod, execute the command, and return the output for further processing or logging.
Properties
| Name | Meaning |
|---|---|
| Image | The container image to use for the Pod that will be run. |
| Command | The command to execute inside the Pod, provided as a JSON array of strings. |
| Namespace | The Kubernetes namespace where the Pod will be created and run. Defaults to "default". |
| Resource Name | The name of the resource (Pod) if applicable; not used directly in the "run" operation. |
Output
The node outputs JSON data containing the standard output (stdout) from the executed Pod's command. This output represents the result of running the specified command inside the container image within the Kubernetes cluster.
Example output structure:
{
"stdout": "<command output as string>"
}
No binary data output is produced by this operation.
Dependencies
- Requires access to a Kubernetes cluster with appropriate permissions to create and manage Pods.
- Needs an API authentication token or API key credential configured in n8n to authenticate against the Kubernetes API.
- Uses an internal Kubernetes client utility to communicate with the cluster.
Troubleshooting
Error: "No credentials got returned!"
This indicates that the node could not retrieve the required Kubernetes API credentials. Ensure that the API authentication token or key is properly configured and accessible in n8n.Error: "Command must be an array!"
The "Command" property must be a valid JSON array of strings. Verify 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. Check Kubernetes cluster access rights, network connectivity, and validate the image name.
Links and References
- Kubernetes Pods documentation: https://kubernetes.io/docs/concepts/workloads/pods/
- Kubernetes field selectors: https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/
- Kubernetes label selectors: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/