Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

The node provides interaction with Kubernetes clusters, specifically enabling operations on various Kubernetes resources such as Pods. For the Pods - Restart operation, it allows restarting a pod within a specified namespace by leveraging Kubernetes API credentials.

This node is beneficial in scenarios where automated management of Kubernetes workloads is needed, such as:

  • Restarting pods to apply configuration changes or recover from errors.
  • Automating cluster maintenance tasks.
  • Integrating Kubernetes control into broader automation workflows.

For example, you can use this node to restart a specific pod named "my-app-pod" in the "default" namespace after deploying a new container image or fixing an issue.

Properties

Name Meaning
Image The container image name (string). Used when running or restarting pods.
Namespace The Kubernetes namespace where the pod resides. Defaults to "default".
Resource Name The name of the pod resource to target for the operation (e.g., the pod to restart).

Output

The node outputs JSON data representing the result of the Kubernetes operation performed. For the restart operation on pods, the output typically includes the standard output (stdout) from the pod restart command execution, indicating success or failure details.

If the node supports binary data output (not explicitly shown here), it would represent any binary content returned by the Kubernetes API or pod commands, but this is not evident in the provided code.

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and authorize requests.
  • Depends on a Kubernetes client utility (K8SClient), which handles communication with the Kubernetes API.
  • The node expects the Kubernetes cluster to be accessible from the environment where n8n runs.

Troubleshooting

  • No credentials got returned!
    This error occurs if the node cannot retrieve the required Kubernetes API credentials. Ensure that the credentials are properly set up and linked to the node.

  • Command must be an array!
    When running or restarting pods, the command property must be a valid JSON array. Providing a non-array value will cause this error. Verify the command input format.

  • Connectivity issues with the Kubernetes cluster may cause timeouts or failures. Confirm network access and correct API endpoint configuration.

  • Incorrect namespace or resource name will lead to resource not found errors. Double-check these inputs.

Links and References

Discussion