Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes resources, specifically supporting the "DaemonSets" resource when performing the "Run" operation. The "Run" operation allows you to execute a pod in the specified namespace using a given container image and command. This is useful for running ad-hoc tasks or jobs inside your Kubernetes cluster without needing to create full deployment manifests.

Practical scenarios include:

  • Running a one-off diagnostic or maintenance command inside a DaemonSet context.
  • Executing scripts or commands dynamically on nodes managed by DaemonSets.
  • Testing container images or commands quickly within the Kubernetes environment.

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 specific DaemonSet resource (optional, depending on context).

Output

The node outputs JSON data representing the standard output (stdout) from the executed pod command. The structure is an array of objects, each containing the command output as plain text. There is no binary data output for this operation.

Example output JSON snippet:

[
  {
    "stdout": "command execution output here"
  }
]

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and interact with the cluster.
  • Depends on the Kubernetes API being accessible and properly configured for the user credentials.
  • Uses an internal Kubernetes client utility to manage API calls and pod execution.

Troubleshooting

  • Error: "No credentials got returned!"
    This indicates that the node could not find or access the required Kubernetes API credentials. Ensure that the credentials are correctly set up and linked to the node.

  • Error: "Command must be an array!"
    The "Command" property must be a valid JSON array of strings. For example, ["ls", "-l"]. Passing a string or invalid JSON will cause this error.

  • Pod execution failures or timeouts
    If the pod fails to start or the command does not complete, verify that the specified image exists and is accessible, and that the Kubernetes cluster has sufficient resources.

  • Namespace or resource name issues
    Make sure the namespace exists and the resource name (if used) is correct. Incorrect values may lead to failed API calls.

Links and References

Discussion