Kubernetes icon

Kubernetes

Interact with Kubernetes

ReplicaSets → Run

AI-generated

Overview

This node enables interaction with Kubernetes resources, specifically supporting operations on ReplicaSets among other resource types. The Run operation allows you to execute a containerized command by running a pod with a specified image and command inside a given namespace.

Common scenarios where this node is beneficial include:

  • Running ad-hoc commands or scripts inside a Kubernetes cluster without manually creating pods.
  • Automating deployment or maintenance tasks by executing containerized commands dynamically.
  • Testing container images by running them with specific commands in a controlled namespace.

For example, you could use the Run operation on ReplicaSets to start a pod that runs a diagnostic tool or a custom script using a particular container image, 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 created and run (default is default).
Resource Name The name of the target resource (ReplicaSet) if applicable; used for filtering or targeting.

Output

The node outputs JSON data representing the result of the executed command inside the pod. Specifically, it returns an object containing the standard output (stdout) from running the pod with the specified image and command.

The output structure looks like this (example):

{
  "stdout": "<command execution output as string>"
}

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.
  • Depends on the Kubernetes cluster being accessible and properly configured to allow pod creation and execution in the specified namespace.
  • Uses an internal Kubernetes client utility to perform API calls and pod management.

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 creation or execution failures
    These can occur due to insufficient permissions, invalid image names, or network issues. Check Kubernetes cluster logs and ensure the specified namespace exists and the image is accessible.

  • Empty or missing output
    If the command produces no output or the pod fails silently, verify the command correctness and container image functionality.

Links and References

Discussion