> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloudthinker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Rancher

> Connect Rancher with an API key so agents can list managed clusters, projects, and nodes, check health, and review who has access

Connect your Rancher server so CloudThinker can list the clusters, projects, and nodes Rancher manages, report cluster health and node readiness, and show who holds Rancher access to a cluster or project. The connection uses a **Rancher API key** (you paste its **Bearer Token** into the **API token** field) and is **read-only by design**: agents can describe what Rancher manages and cannot change any of it.

## Prerequisites

* Rancher 2.8 or later, reachable from the internet over **HTTPS**. Commands run in the CloudThinker cloud. For an internal Rancher, see [Reaching private services](https://docs.cloudthinker.io/guide/connections/overview.md#reaching-private-services). These docs don't publish CloudThinker's egress IP list: ask your CloudThinker contact, or [contact us](https://cloudthinker.io/contact).
* Permission in Rancher to create a user and assign cluster and project roles.
* Optional: the **PEM certificate** of your private certificate authority, if Rancher's certificate is not publicly trusted.

> [!NOTE]
>
> A workspace holds **one** Rancher connection. To inspect workloads, pods, and Kubernetes RBAC inside a cluster, add a [Kubernetes connection](https://docs.cloudthinker.io/guide/connections/kubernetes.md) as well.

## Setup

**1. Create a dedicated Rancher user**

Add a user for CloudThinker instead of reusing a person's account. The API key you create next inherits this user's access, so a dedicated user keeps the scope visible and easy to revoke.

1. Open **☰ → Users & Authentication → Users** and click **Create**. Enter a **Username** such as `cloudthinker` and a **New Password**. Under **Global Permissions**, select **User-Base** instead of the default **Standard User**, which can create clusters. User-Base lets the account sign in and nothing more. Click **Create**.
2. In each cluster you want inspected, open **☰**, select the cluster under **Explore Cluster**, then open **Cluster → Cluster and Project Members** in the left menu.
3. On the **Cluster Membership** tab, add the user with **Cluster Member** (or your custom role).
4. On the **Project Membership** tab, add the user to each project with **Read Only**.

**2. Create an API key**

In a private browser window, so your admin session stays signed in, sign in as that user with the password from step 1. If Rancher asks for a new password, set one. Open the **user avatar → Account & API Keys** in the upper right, and click **Create API Key**.

* **Expiry**: pick a date that matches your rotation schedule, such as 90 days. Rancher caps it at the server's `auth-token-max-ttl-minutes` setting, which you can check in **☰ → Global Settings → Settings**, and uses the cap without warning if you ask for longer. When the key expires, the connection switches to **Error**. Create a new key and enter it with **Replace credentials** on the detail panel, which appears once the connection shows **Error**. See [Rotate a credential](https://docs.cloudthinker.io/guide/connections/overview.md#rotate-a-credential).
* **Scope**: leave it as **No Scope**. A scoped key only works against one cluster's Kubernetes API, which this connection does not use.

Copy the **Bearer Token**. Rancher shows it only once.

**3. Add the connection in CloudThinker**

In the sidebar, click **More → Workspace settings → Connections**, then on the **Builtin Connections** tab select **Rancher**, and fill in the fields from [Connection details](#connection-details). Click **Connect**.

**Success state:** the connection shows **Connecting** and **Verifying**, then a **Connected** status. CloudThinker reads one cluster from Rancher to prove the API key works.

## Connection details

| Field | Required | Description | Example |
| - | - | - | - |
| **Rancher URL** | Yes | The HTTPS address you sign in to. No API path, query string, fragment, or credentials | `https://rancher.example.com` |
| **API token** | Yes | The Bearer Token of the API key, with no quotes, spaces, or line breaks | `token-abc12:xxxxxxxx` |
| **CA certificate bundle** | No | PEM certificates of a private certificate authority, under 256 KB, with no private key | `-----BEGIN CERTIFICATE-----...` |

TLS verification is always on, because the key travels with every request. If Rancher uses a private CA, paste that CA's certificate chain into **CA certificate bundle**. CloudThinker also refuses redirects, so the URL must be the address Rancher answers on directly.

## Required permissions

The API key's user needs **read** access to clusters, nodes, projects, and cluster and project role bindings. Pick one recipe:

* **Built-in roles:** **Cluster Member** on each cluster, plus **Read Only** on each project (Setup step 1, items 3 and 4).
* **Custom role:** the custom cluster role below on each cluster, in place of Cluster Member. Its rule includes projects and project role bindings. Run the check below, and add **Read Only** on a project only if that check reports a permission error for it.

The roles:

| Role | Where | What it gives |
| - | - | - |
| **Cluster Member** | Each cluster to inspect | Views most cluster-level resources. Also lets the user create projects. The connection never uses that, since it sends reads only, but a leaked key could. Use a custom role for strict least privilege |
| **Read Only** | Each project to inspect | Views everything in the project, with no create, update, or delete |
| **Custom role** | Instead of Cluster Member | Only the reads the connection makes. Create it in **☰ → Users & Authentication → Role Templates**, on the **Cluster** tab |

A custom role needs one rule:

```yaml theme={null}
- apiGroups: ["management.cattle.io"]
  resources: ["clusters", "nodes", "projects", "clusterroletemplatebindings", "projectroletemplatebindings"]
  verbs: ["get", "list"]
```

To check the role before you rely on it, connect, then ask `Who holds Rancher access to the <project> project on <cluster>?`. The answer must list bindings. If it reports a permission error, the role doesn't reach that project.

> [!TIP]
>
> A Rancher API key has no read-only switch, so it can see exactly what its user can see. Narrow access through the user's roles. Write permissions never help, because the connection has no way to send a change.

## What this connection cannot reach

The connection only sends read requests to Rancher's management resources. These stay out of reach even if the API key's user could read them:

* Secrets, kubeconfigs, API tokens, and cluster registration tokens
* Cloud credentials, authentication settings, and global settings
* Any change to Rancher: creating, updating, deleting, or scaling
* The older Rancher `v3` API

Ask an agent to change something in Rancher and it tells you the connection cannot, and that nothing changed.

## Agent capabilities

| Capability | What agents do |
| - | - |
| **Cluster inventory** | List the clusters Rancher manages, their projects, and their nodes |
| **Cluster health** | Report the current conditions of one cluster and the readiness of its nodes |
| **Who has access** | Show which users, groups, and service accounts hold a role on one cluster or project |
| **Project scope** | Show which cluster a project belongs to |

Each lookup returns one page of at most 50 rows, and agents can't fetch the next page. When Rancher does not report a total, agents say "returned 12" rather than "12 exist", and they say when more rows exist. For a large fleet, ask cluster by cluster, such as `Show node readiness for the prod-sea cluster`. Whenever a message mentions Rancher, agents query it live instead of reusing a result from an earlier message.

### Verify the connection

```text theme={null}
Summarize the clusters Rancher manages, their projects, and node health
```

You get a list of clusters with their projects and a count of ready and not-ready nodes.

### Example prompts

```text theme={null}
Show the health conditions and node readiness of the prod-sea cluster
Who holds Rancher access to the prod-sea cluster, and is anything broader than it needs to be?
List the projects on staging-cluster and any nodes that are not ready
```

## Troubleshooting

> [accordion] Rancher rejected the API token
>
> The API key expired, was deleted, or was copied incompletely. Rancher shows the Bearer Token only once, so create a new key under **Account & API Keys** and update the connection.

> [accordion] Rancher accepted the token but it lacks read access to managed clusters
>
> The API key signs in, but its user cannot read clusters. Give that user **Cluster Member** (or a custom read role) on the clusters you want inspected, then test the connection again.

> [accordion] The Rancher server did not expose the management.cattle.io RK-API
>
> RK-API is Rancher's Kubernetes-style management API, served under `/apis/management.cattle.io/v3`. The URL points somewhere other than the Rancher server root, or the Rancher release is older than 2.8. Reconnect with the plain Rancher address and check your version.

> [accordion] Could not reach the Rancher server
>
> Nothing answered, or the address redirected elsewhere. Check that the host is reachable from the internet, that the URL is the address Rancher answers on directly, and, for a private CA, that the bundle holds the CA that issued Rancher's certificate.

> [accordion] Rancher URL must use HTTPS outside local development
>
> The address starts with `http://`, which would send the API key in clear text. On CloudThinker's cloud, `http://` is refused for every host, including `localhost`. Serve Rancher over HTTPS and reconnect with an `https://` URL.

> [accordion] Invalid Rancher CA certificate bundle or connection configuration
>
> The bundle is not plain PEM certificates, or the Bearer Token has quotes, spaces, or line breaks around it. Paste only the CA certificate chain, never a private key, and re-copy the Bearer Token as one line.

> [accordion] Connection 'rancher' already exists. Only one instance is allowed.
>
> This workspace already has a Rancher connection. Edit that connection, or disconnect it first.

> [accordion] An agent reports fewer clusters than Rancher shows
>
> The API key's user cannot see the rest, or the answer came from a single page of results. Check the user's cluster roles first, then ask about the specific cluster or project.

## Security

* **Least privilege** — grant only the permissions the agents need for your use case; start read-only and widen later.
* **Read-only by default** — use read-only credentials unless you want agents to make changes through this connection.
* **Rotate credentials** — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
* **Revoke on offboarding** — remove the credential at the provider when you delete a connection or a teammate leaves.

- **Narrow through roles.** The API key sees exactly what its user sees, so the user's roles are your only scope control.
- **Read-only by construction.** The connection can only send read requests, so no permission you grant lets an agent change Rancher.
- **Plan for expiry.** A workspace holds one Rancher connection, so there's no in-place swap while it's healthy. Either wait for **Error** and use **Replace credentials**, or rotate early by disconnecting and connecting again with a new key. Reconnecting reruns Discovery and means checking that Rules still name the connection. See [Rotate a credential](https://docs.cloudthinker.io/guide/connections/overview.md#rotate-a-credential).
- **Revoke at the source.** Delete the API key in **Account & API Keys**, or deactivate the user, to stop all access through this connection.

## Related

> [card] [Kubernetes](https://docs.cloudthinker.io/guide/connections/kubernetes.md)
>
> Inspect pods, logs, nodes, and RBAC inside one cluster

> [card] [Connections Overview](https://docs.cloudthinker.io/guide/connections/overview.md)
>
> How connection status, testing, and discovery work


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.