Rancher icon

Rancher

Interact with Rancher/Kubernetes API

Overview

This node enables interaction with Rancher and Kubernetes APIs to manage various Kubernetes resources programmatically within n8n workflows. Specifically, for the Service resource with the Create operation, it allows users to create a new Kubernetes Service in a specified cluster, project, and namespace.

Creating a service is essential for exposing applications running inside Kubernetes pods to other services or external clients. This node is beneficial when automating deployment pipelines, infrastructure provisioning, or dynamic environment setups where services need to be created on-demand.

Practical example:
You have an application deployed as pods in a Kubernetes cluster, and you want to expose it internally via a ClusterIP service or externally via a LoadBalancer. Using this node, you can automate the creation of such services with specific ports and labels, triggered by events or other workflow steps.

Properties

Name Meaning
Name The name of the service resource to create.
Cluster Name or ID Select the Kubernetes cluster where the service will be created. Can be chosen from a list or set via expression.
Project Name or ID (Optional) Select the project within the cluster. Can be chosen from a list or set via expression.
Namespace Name or ID (Optional) Select the namespace within the project where the service will be created. Can be chosen from a list or set via expression.
Service Type Type of the service to create. Options: ClusterIP, NodePort, LoadBalancer.
Service Port The port number that the service will expose.
Labels Key-value pairs to label the service for identification or selection purposes.
Annotations Key-value pairs to annotate the service with metadata.

Output

The node outputs JSON data representing the created service resource as returned by the Rancher/Kubernetes API. This typically includes details such as the service's metadata (name, labels, annotations), spec (type, ports), status, and other relevant information confirming the successful creation.

No binary data output is produced by this node.

Dependencies

  • Requires access to a Rancher or Kubernetes API endpoint.
  • Requires an API authentication token or API key credential configured in n8n to authenticate requests.
  • The node depends on dynamically loaded options for clusters, projects, and namespaces, which require proper API connectivity and permissions.
  • No additional external libraries beyond those bundled are required.

Troubleshooting

  • Common issues:

    • Incorrect or missing cluster/project/namespace IDs can cause failures in resource creation.
    • Insufficient permissions or invalid API credentials may result in authorization errors.
    • Specifying an invalid service type or port number might cause API validation errors.
    • Network connectivity issues to the Rancher/Kubernetes API endpoint can prevent execution.
  • Error messages and resolutions:

    • "Unauthorized" or "Forbidden": Check API credentials and user permissions.
    • "Resource not found": Verify that the cluster, project, and namespace exist and are correctly referenced.
    • "Invalid input": Ensure all required fields are provided and valid, especially the service type and port.
    • Timeouts or connection errors: Confirm network access to the API server and correct endpoint configuration.

Links and References

Discussion