Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes clusters by performing various operations on Kubernetes resources. Specifically for the Jobs resource and the Restart operation, it allows restarting a Kubernetes Job within a specified namespace.

Common scenarios where this node is beneficial include automating Kubernetes job management tasks such as restarting failed or completed jobs without manually accessing the cluster. For example, if a batch job fails due to transient errors, you can use this node to programmatically restart it as part of an automated workflow.

Properties

Name Meaning
Image The container image to use when running or restarting pods/jobs.
Namespace The Kubernetes namespace where the Job resource exists. Defaults to "default".
Resource Name The name of the specific Job resource to operate on.

Note: Although the bundled code does not explicitly show the restart logic for Jobs, the properties above are relevant inputs for the Restart operation on Jobs.

Output

The node outputs JSON data representing the result of the Kubernetes operation performed. For the Restart operation on Jobs, the output typically includes details about the restarted Job or pod, such as status messages or command execution output.

If the operation involves running pods (e.g., run or restart), the node captures and returns the standard output (stdout) from the pod's execution.

No binary data output is indicated in the source code.

Dependencies

  • Requires access to a Kubernetes cluster with appropriate permissions.
  • Needs an API authentication token or credentials configured in n8n to connect securely to the Kubernetes API.
  • Uses an internal Kubernetes client utility (K8SClient) to interact with the cluster.

Troubleshooting

  • No credentials got returned!
    This error occurs if the node cannot retrieve the necessary Kubernetes credentials. Ensure that valid credentials are configured and accessible in n8n.

  • Command must be an array!
    When running commands inside pods, the command property must be a JSON array. Providing a string or invalid JSON will cause this error.

  • If the Restart operation does not behave as expected, verify that the specified Job name and namespace exist and that the user has sufficient permissions to restart Jobs in the cluster.

Links and References

Discussion