Prerequisites
- A Rancher server on 2.8 or later, reachable from CloudThinker over HTTPS. 2.8 is the first release to support the Rancher Kubernetes API, which is the only thing this connection reads.
- A dedicated Rancher user for CloudThinker with read access to the clusters and projects you want inspected — see Required permissions.
- A Rancher API key for that user.
- Optional: a PEM certificate bundle if your Rancher certificate is issued by a private CA.
Create a dedicated Rancher user rather than reusing a person’s account. The token inherits that user’s access, so a dedicated reader keeps the scope visible and revocable in one place.
Setup
1
Create a read-only Rancher user
Add a user for CloudThinker and give it read access to the clusters and projects it should see. Rancher’s built-in Cluster Member role lets a user view most cluster-level resources, and the Read Only project role lets a user view everything in a project without creating, updating, or deleting anything. For a tighter scope, build a custom role — see Required permissions.
2
Create an API key
Sign in as that user, open the user avatar → Account & API Keys in the upper right, and click Create API Key.Set an Expiry. Rancher caps it at the server’s
auth-token-max-ttl-minutes setting and silently uses that cap when you ask for longer.Leave Scope as No Scope. A scoped key works only against the Kubernetes API of the cluster you scope it to, not against the Rancher API this connection reads. Narrow the access through the user’s roles instead, not through the key.Copy the Bearer Token. Rancher shows it once, along with the Access Key and Secret Key.3
Add the connection in CloudThinker
Navigate to Connections → Rancher and enter:
- Rancher URL: the address you sign in to, such as
https://rancher.example.com - API token: the Bearer Token you just copied
- CA certificate bundle: leave blank unless Rancher uses a private CA
Connection details
The Rancher URL must use
https. The token is sent with every request, so plain http is rejected.Required permissions
The token needs read access to the Rancher management resources the connection inspects:
Start from a built-in role and narrow it:
What this connection cannot reach
The connection can only ask Rancher to read, and only from the small set of management resources listed above. Everything below stays out of reach even when the token itself is allowed to read it:- Secrets and kubeconfigs
- API tokens and cluster registration tokens
- Cloud credentials and authentication settings
- Global settings
- Every change to Rancher — creating, updating, deleting, or scaling anything
- The older Rancher v3 API, which the connection never calls
Ask an agent to change something in Rancher and it will tell you the connection cannot do it, and that nothing changed. It will not try another route.
Agent capabilities
Once connected, agents can read what Rancher knows about your clusters.Verify the connection
Example prompts
Answers are bounded so a broad question cannot pull everything Rancher manages: each lookup returns one page of at most 50 results. When Rancher does not report a total, agents say “returned 12” rather than “12 exist” — a full page is not proof that you have seen everything. Name the cluster or project you care about to get an exact answer.
Each message gets one look at Rancher. Ask two Rancher questions at once and the agent answers the second from what the first returned, rather than fetching again. Send a follow-up message when you want fresh data.
Troubleshooting
Rancher rejected the API token
Rancher rejected the API token
The 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.
The token lacks read access to managed clusters
The token lacks read access to managed clusters
The token authenticated, but its Rancher user cannot read the clusters. Give that user the required read-only role on the clusters you want inspected, then test the connection again.
The Rancher server did not expose the management.cattle.io RK-API
The Rancher server did not expose the management.cattle.io RK-API
The URL points somewhere other than Rancher, or this Rancher is older than 2.8, the first release to support the Rancher Kubernetes API. Reconnect with the Rancher address only, such as
https://rancher.example.com, and check your Rancher version.Rancher applied a rate limit
Rancher applied a rate limit
Rancher, or a proxy or load balancer in front of it, returned HTTP 429. Wait, then ask one narrow question rather than several broad ones.
Could not reach the Rancher server
Could not reach the Rancher server
Nothing answered at that URL. Check the host, the network path from CloudThinker, and — if Rancher uses a private CA — that the CA certificate bundle is the one that issued its certificate.
A redirect was refused
A redirect was refused
The address you entered does not answer directly; something in front of it redirects elsewhere. CloudThinker never follows a redirect, because that would hand your token to a server you did not name. Point the connection at the address that serves Rancher itself.
Rancher URL must use HTTPS
Rancher URL must use HTTPS
The address is plain
http, which would send the token in clear text. Serve Rancher over HTTPS and reconnect.Invalid Rancher CA certificate bundle
Invalid Rancher CA certificate bundle
The bundle is not plain PEM certificates. It must begin with
-----BEGIN CERTIFICATE-----, end with -----END CERTIFICATE-----, stay under 256 KB, and contain no private key. Paste the CA certificate chain only, never a server key.Invalid Rancher connection configuration
Invalid Rancher connection configuration
The API token is empty, or it carries whitespace or quoting that cannot be sent safely in a request header. Re-copy the Bearer Token from Rancher without surrounding quotes or line breaks.
An agent reports fewer clusters than Rancher shows
An agent reports fewer clusters than Rancher shows
Either the token’s user cannot see the rest, or the answer came from a single page of results. Check the user’s cluster access first, then narrow the question to the cluster or project you care about.
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.
- TLS verification is always on — it cannot be disabled, so a private CA needs its bundle pasted in rather than a skipped check.
- Narrow through roles, not the key — a Rancher API key has no read-only setting, so what the token can see is exactly what its user can see. Give that user the least access it needs.
- Watch the expiry — a key that lapses silently breaks the connection; rotate it on schedule and update the connection with the new token.
- Read-only by construction — the connection can only ask Rancher to read, so no permission you grant turns it into a way to change anything.
Related
Kubernetes Connection
Workload analysis, resource optimization, and cluster operations
Kai Agent
Kubernetes-focused operations agent