Rancher icon

Rancher

Interact with Rancher/Kubernetes API

Overview

This node provides integration with the Rancher and Kubernetes APIs, enabling users to manage various Kubernetes resources programmatically within n8n workflows. It supports a wide range of Kubernetes resource types such as namespaces, deployments, services, pods, statefulsets, configmaps, secrets, jobs, cronjobs, nodes, and workloads.

Common scenarios where this node is beneficial include:

  • Automating deployment lifecycle tasks like creating, updating, scaling, or deleting deployments and statefulsets.
  • Managing cluster resources such as namespaces, services, and configmaps.
  • Performing operational tasks on pods, including fetching logs or executing commands inside containers.
  • Managing node states (cordon, uncordon, drain) and labels/taints for cluster maintenance.
  • Handling workload operations like pausing, resuming, rolling back, or redeploying workloads.

Practical examples:

  • Automatically scale a deployment based on external triggers.
  • Create a new namespace and deploy services into it as part of a CI/CD pipeline.
  • Fetch pod logs after a failed job execution for debugging.
  • Drain a node before scheduled maintenance using automated workflows.

Properties

Name Meaning
Cluster Name or ID Select the target Kubernetes cluster by name or ID.
Project Name or ID Select the project within the cluster; depends on the selected cluster.
Namespace Name or ID Select the namespace within the project; depends on the selected project.

These three properties are required to scope most operations to the correct cluster context.

Additional input properties relevant to Default Resource and Operation (from provided JSON):

Name Meaning
cluster_id The identifier or name of the Kubernetes cluster to operate on.
project_id The identifier or name of the project within the cluster. Optional depending on operation.
namespace The identifier or name of the namespace within the project. Optional depending on operation.

Note: Since the user requested only the "Default" resource and operation, which correspond to these cluster/project/namespace selectors, the above are the main properties.

Output

The node outputs an array of JSON objects, each representing the result of the executed operation on the specified Kubernetes resource(s). The exact structure of the JSON output depends on the resource type and operation performed but generally includes the Kubernetes API response data for the resource(s).

If binary data is involved (e.g., pod logs or command execution output), it would be included in the JSON output or handled accordingly, but no explicit binary output handling is shown in the provided code snippet.

Dependencies

  • Requires access to a Rancher or Kubernetes API endpoint.
  • Requires an API authentication credential configured in n8n (referred generically as "an API key credential").
  • Uses internal helper modules for managing specific resource operations (namespaces, deployments, services, pods, etc.).
  • Load options methods depend on API calls to fetch clusters, projects, namespaces, deployments, and statefulsets dynamically.

Troubleshooting

  • Missing or invalid credentials: Ensure that the API key or authentication token for Rancher/Kubernetes is correctly configured in n8n.
  • Resource not found errors: Verify that the specified cluster, project, namespace, or resource IDs exist and are accessible with the provided credentials.
  • Permission denied errors: Check that the API token has sufficient permissions to perform the requested operations.
  • Invalid parameters: Make sure all required fields (like cluster_id) are set and valid. For example, creating a deployment requires specifying a name and image.
  • Operation not supported for resource: Confirm that the chosen operation is valid for the selected resource type.
  • Timeouts or connectivity issues: Ensure network connectivity to the Rancher/Kubernetes API endpoint.

Links and References


This summary is based solely on static analysis of the provided source code and property definitions without runtime execution.

Discussion