Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes clusters by performing various operations on Kubernetes resources. Specifically, for the Services resource with the Run operation, it allows running a pod using a specified container image and command within a given namespace.

Common scenarios where this node is beneficial include:

  • Running a one-off containerized task or script inside a Kubernetes cluster.
  • Testing or debugging by launching temporary pods with custom commands.
  • Automating deployment or maintenance tasks that require executing containers dynamically.

For example, you can use this node to run a diagnostic container in the "default" namespace with a specific image and command, capturing its output for further processing.

Properties

Name Meaning
Image The container image to run inside the pod (e.g., nginx:latest).
Command The command to execute inside the container, provided as a JSON array of strings.
Namespace The Kubernetes namespace where the pod will be run. Defaults to "default".
Resource Name The name of the resource; for the Run operation on Services, typically not required.

Output

The node outputs JSON data representing the result of running the pod. The main field is:

  • stdout: A string containing the standard output captured from the executed pod's container command.

This output allows you to capture and use the command execution results directly in your workflow.

No binary data output is produced by this operation.

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and interact with the cluster.
  • The node depends on an internal Kubernetes client utility to communicate with the Kubernetes API.
  • The user must provide a valid container image and command compatible with the Kubernetes environment.

Troubleshooting

  • Error: "No credentials got returned!"
    This indicates missing or misconfigured Kubernetes API credentials. Ensure that the node has access to valid credentials with sufficient permissions.

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

  • Pod fails to start or command does not execute properly
    Check that the specified container image exists and is accessible from the Kubernetes cluster. Also, verify that the command is valid for the container's environment.

  • Namespace issues
    If the pod cannot be created, confirm that the specified namespace exists and that the credentials have permission to create pods there.

Links and References

Discussion