Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes clusters, specifically focusing on managing Pods when the "Pods" resource and "Exec" operation are selected. The "Exec" operation allows executing commands inside a running Pod container and retrieving the output of those commands.

Common scenarios where this node is beneficial include:

  • Running diagnostic or maintenance commands inside a Pod without needing direct kubectl access.
  • Automating administrative tasks within containers, such as log inspection, configuration checks, or triggering scripts.
  • Integrating Kubernetes command execution into automated workflows for CI/CD pipelines or monitoring systems.

For example, you could use this node to execute a shell command inside a Pod to check application status or retrieve runtime information dynamically during an automation workflow.

Properties

Name Meaning
Image The container image name used when running or restarting Pods, or relevant for exec context.
Namespace The Kubernetes namespace where the Pod resides (default is "default").
Resource Name The specific Pod name on which to perform the exec operation.

Note: Although the bundled code shows more properties, for the "Pods" resource and "Exec" operation, these three are relevant based on your input.

Output

The node outputs JSON data representing the result of the executed command inside the Pod. Specifically, the json output contains:

  • stdout: A string capturing the standard output from the command run inside the Pod.

No binary data output is indicated for this operation.

Example output JSON structure:

{
  "stdout": "command output here"
}

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 (K8SClient) to communicate with the Kubernetes API.
  • The user must provide the target Pod's namespace and name, along with the command to execute (as a JSON array).

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 provided as a JSON array (e.g., ["ls", "-l"]). Providing a string or other type will cause this error.

  • Pod not found or inaccessible
    Verify that the specified namespace and Pod name are correct and that the credentials have permission to access them.

  • Command execution fails or returns no output
    Check that the command is valid inside the container environment and that the container is running.

Links and References

Discussion