Skip to main content
Connect a Kubernetes cluster so CloudThinker can find crash-looping and pending pods, read logs and events, check node pressure, and review RBAC and network policies. You upload a kubeconfig file that signs in as a dedicated read-only service account; changes such as a rollout restart go through your workspace’s Approvals, and run only if you grant write RBAC (see Write access).

Prerequisites

  • A cluster whose API server CloudThinker can reach over the internet. Commands run in the CloudThinker cloud, so a private-only endpoint fails the connection test. If you restrict API access (EKS public access CIDRs, GKE authorized networks, AKS authorized IP ranges), add CloudThinker’s egress IPs instead of opening it to 0.0.0.0/0. These docs don’t publish CloudThinker’s egress IP list: ask your CloudThinker contact, or contact us. See Reaching private services for other options.
  • kubectl access to that cluster with permission to create a namespace, a ClusterRole, and a ClusterRoleBinding.
  • Managed clusters (EKS, GKE, AKS) hand out kubeconfigs that sign in through aws, gcloud, or az exec plugins, which don’t work in CloudThinker. Step 2 builds one that does. Kubernetes checks the service-account token itself, so you don’t map it in cloud IAM (no EKS access entry, for example).
  • Optional: Metrics Server in the cluster. Without it, agents still report pod status and node conditions, but not live CPU and memory usage.
  • The Admin role in your CloudThinker workspace, which can add and edit connections. See Roles.
You get one Kubernetes connection per workspace, and agents work in the kubeconfig’s current context. Upload a kubeconfig for the one cluster you want inspected. For several clusters, use one workspace per cluster, or add a Rancher connection for inventory and health across the clusters Rancher manages.

Setup

1

Create a read-only service account

Save this manifest as cloudthinker-reader.yaml. It also creates one Secret, the service account’s token, which only you read in step 2. Required permissions covers what the role allows.
Apply it:
It creates the cloudthinker namespace, a cloudthinker-reader service account, a read-only ClusterRole bound to it, and a long-lived token Secret.Success state: kubectl get secret cloudthinker-reader-token -n cloudthinker lists the Secret with a DATA count of 3. Kubernetes fills the token in a few seconds after you apply, so if DATA shows 0, wait and run the command again.
2

Build a kubeconfig for that account

Run this from a shell whose current kubectl context is the target cluster. First, read and check the API server address:
It must print a public hostname or IP. If it shows 127.0.0.1, localhost, or a private address such as 10.x or 192.168.x (common on kind, minikube, k3d, or behind a local proxy), CloudThinker can’t reach it, so stop and fix access first.Then, in the same shell, write cloudthinker-kubeconfig.yaml with the token and CA certificate embedded:
On older macOS releases, replace base64 --decode with base64 -D, and keep the closing EOF at the very start of its line.Success state: kubectl --kubeconfig cloudthinker-kubeconfig.yaml get nodes lists your nodes. This is the same command CloudThinker runs to test the connection.
3

Upload the kubeconfig in CloudThinker

Open More → Workspace settings → Connections, select Kubernetes, and upload cloudthinker-kubeconfig.yaml in the KUBECONFIG field. Click Connect.Success state: the connection shows Connecting and Verifying, then a Connected status.

Connection details

Embed everything in the file. A kubeconfig that points to local certificate files, or signs in through an exec plugin, needs files and tools CloudThinker doesn’t have. The token-based file from step 2 avoids both.

Required permissions

The manifest in step 1 grants read access (get, list, watch) to the resources agents inspect, plus pod logs and metrics. It can’t read Secrets. Read access is cluster-wide, including kube-system, because a ClusterRoleBinding grants the role in every namespace. To cover only some namespaces, replace the ClusterRoleBinding with a RoleBinding to the same ClusterRole in each one. Cluster-scoped resources such as nodes, namespaces, and persistent volumes then drop out of answers, since a RoleBinding can’t grant them. Custom resources aren’t covered, so agents can’t see CRD-based objects such as Argo CD applications or Istio virtual services. To let them, add a rule with each resource’s API group to the ClusterRole.
Trim the role to what you need. Drop configmaps if yours hold sensitive values, and drop the rbac.authorization.k8s.io rule if you don’t want RBAC reviews. A 403 in an answer names the resource the role is missing.

Write access

Agents run a change such as scale, rollout restart, cordon, drain, or apply only when you ask for it in the conversation, and the read-only role above makes it fail with 403. Allow writes on the connection’s detail panel is the second control. It’s on by default, but it can’t widen what the role allows. To lock writes in CloudThinker as well, open More → Workspace settings → Connections, select Kubernetes, and turn off the Allow writes switch on its detail panel. Every change an agent makes goes through your workspace’s Approvals first. On the default Auto · Rules + AI · Ask me mode, AI judgment can let a safe change run without asking — and an Allow Rule can too, once CloudThinker turns on Rule enforcement for your workspace. Choose Manual to approve every change yourself. To allow a specific change, grant only what it needs:
  • Scale and rollout restart act on namespaced workloads. Use a Role in each namespace involved, with patch on deployments and get plus patch on deployments/scale. For StatefulSets, add the same for statefulsets and statefulsets/scale. For DaemonSets, add daemonsets (restart only, since they don’t scale).
  • Apply needs get, create, and patch on each resource type in the manifest you apply, in the namespaces it targets.
  • Cordon and drain act on nodes, which are cluster-scoped, so a namespaced Role can’t allow them. Use a ClusterRole with patch on nodes and create on pods/eviction. The read role already supplies the get and list on pods and DaemonSets that drain needs.
The write grants bind to the same cloudthinker-reader service account, so one kubeconfig covers reads and changes. If you plan write access from the start, rename the account (for example cloudthinker-agent) in both manifests and in step 2. This example allows scaling deployments in one namespace, plus cordon and drain. Replace payments with your namespace, save it as cloudthinker-write.yaml, and run kubectl apply -f cloudthinker-write.yaml.
Success state: kubectl auth can-i patch deployments/scale -n payments --as=system:serviceaccount:cloudthinker:cloudthinker-reader prints yes.

Agent capabilities

Verify the connection

You get the namespace list, node count, and node status. If usage numbers are missing, the answer says Metrics Server is not installed.

Example prompts

Rotate the token

Kubernetes is a single-connection service, so it has no pencil icon or Edit Instance dialog while it’s healthy. Create the new token first and delete the old Secret last: deleting it first cuts the cluster off before you have a working replacement.
1

Create a second token Secret

Save this as cloudthinker-reader-token-2.yaml: a second token for the same service account, so both work while you swap.
Apply it:
Success state: kubectl get secret cloudthinker-reader-token-2 -n cloudthinker lists the Secret with a DATA count of 3.
2

Build a kubeconfig from the new token

Repeat step 2 of Setup with cloudthinker-reader-token-2 in place of cloudthinker-reader-token.Success state: kubectl --kubeconfig cloudthinker-kubeconfig.yaml get nodes lists your nodes.
3

Swap it in CloudThinker

While the connection shows Connected, click Disconnect on the Kubernetes detail panel, then connect again and upload the new kubeconfig. While it shows Error, click Replace credentials on the detail panel and upload the new kubeconfig instead, with no disconnect.Success state: the connection shows Connected.
4

Delete the old Secret

Only now, remove the token you replaced:
A disconnect and reconnect starts a new connection:
  • Agents and scheduled automations can’t use the cluster between the disconnect and the reconnect.
  • Discovery runs again and spends credits.
  • Allow writes goes back to on. Turn it off again if you had it off.
  • Check that Rules naming the Kubernetes connection still list it.
If your policy bans long-lived credentials, skip the Secret and build the kubeconfig with a short-lived token from kubectl create token cloudthinker-reader -n cloudthinker --duration=<time>. The connection breaks when that token expires, so you rebuild and upload the kubeconfig each time.

Troubleshooting

A failed test shows Failed to connect to Kubernetes: followed by the first error line from kubectl get nodes. Match that line to an entry below.
CloudThinker could not reach the API server in the kubeconfig. Check that the server address is reachable from the internet, not only from your VPN, and that any API server allowlist permits outside access. Run kubectl --kubeconfig cloudthinker-kubeconfig.yaml get nodes from a machine outside your network to confirm.
The token is wrong, expired, or was revoked. Check that the cloudthinker-reader-token Secret still exists, then rebuild the kubeconfig from step 2 and upload it through Rotate the token.
The ClusterRole doesn’t cover that resource. Confirm the ClusterRoleBinding is applied, then add the resource to the role.
The kubeconfig relies on a local command or file path. Replace it with the token-based kubeconfig from step 2.
Metrics Server is not installed or not ready. Run kubectl top nodes to check. Pod status, events, and node conditions still work without it.
k8s is the Kubernetes connection, and a workspace holds one. There’s no pencil icon to edit it, so to point CloudThinker at a different cluster, click Disconnect on the Kubernetes detail panel and connect again with the other kubeconfig.

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.
  • Keep Secrets out of the role. The manifest above never grants Secret reads, so agents can’t read Secret objects. Pod logs and ConfigMaps are readable, so drop pods/log or configmaps from the role if they hold sensitive data. Env values set directly in a pod spec are readable through pods, so move sensitive ones into Secrets.
  • Rotate the token. The token Secret never expires on its own, so rotate it on your normal schedule. See Rotate the token.
  • Revoke in one command. Delete the token Secret to cut access immediately, or delete the cloudthinker namespace plus the ClusterRole and binding to remove everything.

Rancher

Read cluster inventory and access across clusters Rancher manages

Kubernetes Health Monitoring

Put this connection to work on a recurring cluster health check

Approvals

Decide which cluster changes run, wait for a person, or are refused

Connections Overview

How connection status, testing, and discovery work