Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes resources, specifically supporting operations such as running, restarting, executing commands, and managing various Kubernetes objects including CronJobs. For the CronJobs - Restart operation, the node facilitates restarting a specified CronJob within a Kubernetes cluster.

Common scenarios where this node is beneficial include automating Kubernetes resource management tasks directly from n8n workflows, such as:

  • Restarting a CronJob to immediately trigger its job execution without waiting for the scheduled time.
  • Managing Kubernetes workloads programmatically as part of CI/CD pipelines or operational automation.
  • Integrating Kubernetes control into broader automation flows involving other systems.

For example, you could use this node to restart a CronJob that runs database backups whenever a certain event occurs, ensuring immediate backup without manual intervention.

Properties

Name Meaning
Image The container image to use when running or restarting pods (required for some operations).
Namespace The Kubernetes namespace where the CronJob resides. Defaults to "default".
Resource Name The name of the specific CronJob resource to target for the restart operation.

Note: Although the bundled code shows many properties, for the CronJobs - Restart operation only these are relevant based on your input.

Output

The node outputs JSON data representing the result of the Kubernetes operation performed. For the restart operation, it returns the standard output (stdout) from running the pod associated with the restart command, encapsulated in an array of JSON objects.

The structure typically looks like:

[
  {
    "stdout": "<output from restarting the CronJob>"
  }
]

No binary data output is indicated for this operation.

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and interact with the Kubernetes cluster.
  • Depends on the internal K8SClient utility class to communicate 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 indicates missing or misconfigured Kubernetes API credentials. Ensure that the required API authentication token or key is properly set up in n8n credentials.

  • Command must be an array!
    If using operations that require a command (like run), ensure the command property is a valid JSON array. For restart, this is less relevant but may appear if command input is malformed.

  • Resource not found or permission denied
    Verify that the specified namespace and resource name exist and that the credentials have sufficient permissions to perform the restart operation.

  • Network connectivity issues between n8n and the Kubernetes API server can cause failures; verify network access and firewall rules.

Links and References

Discussion