Rancher icon

Rancher

Interact with Rancher/Kubernetes API

Overview

This node allows interaction with the Rancher/Kubernetes API to manage various Kubernetes resources. Specifically, for the Namespace - Create operation, it enables users to create a new namespace within a specified cluster and optionally within a project. This is useful in scenarios where you want to organize and isolate Kubernetes resources by creating namespaces programmatically as part of your automation workflows.

Practical examples include:

  • Automating environment setup by creating namespaces for development, testing, or production.
  • Dynamically provisioning namespaces when onboarding new teams or projects.
  • Integrating namespace creation into CI/CD pipelines to prepare isolated deployment environments.

Properties

Name Meaning
Cluster Name or ID Select the target Kubernetes cluster by name or ID where the namespace will be created.
Project Name or ID (Optional) Select the project within the cluster under which the namespace will be created.
Namespace Name or ID (Optional) Select or specify the namespace name or ID. For creation, this typically would be the new namespace's name.

Note: For the "Create" operation on Namespace resource, the key required property is the Cluster Name or ID. The Project Name or ID and Namespace Name or ID are optional depending on the context or API requirements.

Output

The output JSON contains the response from the Rancher/Kubernetes API after attempting to create the namespace. It typically includes details about the newly created namespace such as its name, status, metadata, and other relevant Kubernetes namespace information.

No binary data output is involved in this operation.

Example output structure (simplified):

{
  "id": "namespace-id",
  "name": "new-namespace",
  "status": "Active",
  "metadata": {
    "creationTimestamp": "2024-06-01T12:00:00Z",
    "labels": {},
    "annotations": {}
  }
}

Dependencies

  • Requires an active connection to a Rancher or Kubernetes cluster via an API authentication token or API key credential configured in n8n.
  • The node depends on Rancher's Kubernetes API endpoints to perform namespace operations.
  • Proper permissions are needed on the cluster to create namespaces.

Troubleshooting

  • Common issues:

    • Insufficient permissions: The API token used may lack rights to create namespaces.
    • Invalid cluster or project ID: Ensure the selected cluster and project exist and are accessible.
    • Namespace name conflicts: Trying to create a namespace that already exists will cause errors.
    • Network connectivity issues to the Rancher/Kubernetes API endpoint.
  • Error messages:

    • "Forbidden" or "Unauthorized": Check API credentials and permissions.
    • "Namespace already exists": Use a unique namespace name.
    • "Cluster not found": Verify the cluster ID or name is correct and reachable.

Resolving these usually involves verifying credentials, checking cluster/project selections, and ensuring the namespace name is unique.

Links and References

Discussion