Connect using the castctl CLI
castctl is the recommended way to connect Kubernetes clusters to Cast AI. It auto-detects your cloud provider, cluster name, and region from your kubeconfig, walks you through feature selection, and handles cluster registration, IAM setup, and the Helm install in a single command.
You can also connect clusters from the Cast AI console or with the Terraform provider.
What castctl supports
- Cloud providers: Amazon EKS, Google GKE, and Microsoft AKS.
- Features: Cost Monitoring (always enabled), Node Autoscaling, and Workload Autoscaling.
- Karpenter: If Karpenter is already installed in the cluster,
castctloffers to keep it as your node provisioner via Cast AI for Karpenter.
Plan requirementsNode Autoscaling and Workload Autoscaling are Premium features. Cost Monitoring is available on every plan.
Before you start
Before you connect a cluster with castctl, make sure you have:
- A Cast AI account (sign up).
- A Kubernetes cluster on EKS, GKE, or AKS.
kubectlconfigured for that cluster with admin access (kubectl auth can-i '*' '*').- Cloud-side permissions equivalent to the console connection script's least-privileged policy — see Cloud permissions.
metrics-serverinstalled in the cluster, if you plan to enable Workload Autoscaling.
castctl bundles its own Helm logic, so you do not need helm, jq, or yq installed locally.
Install castctl
brew tap castai/tap
brew install castctlTo upgrade to the latest version:
brew upgrade castctlVerify the installation:
castctl versionLog in
Authenticate castctl with Cast AI using your browser:
-
Run the login command:
castctl auth login -
castctlopens your default browser and asks to sign in to your Cast AI account. -
After authentication, control returns to your terminal. If you belong to more than one organization, pick one from the interactive list. If you belong to a single organization, it's selected automatically.
-
castctlsaves your token and organization ID to~/.config/castctl/config.yamland prints a confirmation message.
Switching account or organizationRun
castctl auth loginagain — it overwrites the stored credentials.
Connect your cluster
-
Start the interactive connection:
castctl cluster connectcastctldetects the cloud provider, cluster name, and region from your kubeconfig and node labels, then prints the resolved configuration for you to review. -
Select the features you want to enable.
-
Confirm the Proceed with connecting? prompt.
castctlthen:- Registers the cluster with Cast AI.
- Installs the
castaiHelm chart in thecastai-agentnamespace. - Creates the IAM resources required in your cloud account (AWS / GCP / Azure).
-
On success,
castctlprints the cluster's Cast AI console URL. Open it to verify everything is connected.
Preview without making changes
Resolve the configuration and print it as YAML without registering the cluster or modifying anything:
castctl cluster connect --dry-runUseful for validating that auto-detection picked the right provider, region, and cluster name.
Non-interactive mode (CI/scripts)
In CI pipelines or scripts, disable prompts with --non-interactive. The process can be customized using flags passed to the binary.
castctl cluster connect \
--non-interactive \
--cluster-optimization=false \
--workload-autoscaler=trueFor the complete list of flags supported by the current castctl — including feature toggles, GKE credential method, and Helm values overrides — run:
castctl cluster connect --helpCustom umbrella chart values
During cluster onboarding, castctl installs the Cast AI components using an umbrella Helm chart. You can customize the chart values (such as tolerations, node selectors, or resource limits) by providing a YAML values file with the --umbrella-values-file flag:
castctl cluster connect --umbrella-values-file /path/to/custom-values.yamlThis flag accepts a YAML file containing Helm values that are merged with the configuration castctl generates based on your feature selections. This approach provides flexibility to configure values that castctl doesn't explicitly manage through command-line flags.
Example custom-values.yaml:
global:
tolerations:
- key: "dedicated"
operator: "Equal"
value: "castai"
effect: "NoSchedule"For a complete reference of available values in the umbrella chart, see the castai-umbrella Helm chart documentation.
Disconnect a cluster
This removes Cast AI completely
castctl cluster disconnectperforms the equivalent of both Disconnect cluster and Remove cluster in the Cast AI console: it uninstalls the Cast AI Helm releases, deletes the IAM resources created during the connection, and removes the cluster record from Cast AI.
Not for Terraform-managed clustersDo not run
castctl cluster disconnectagainst a cluster that was connected with the Cast AI Terraform provider. The CLI does not coordinate with Terraform state and will leave your Terraform configuration out of sync. For Terraform-managed clusters, runterraform destroyinstead — see Disconnect your cluster.Clusters connected via the Cast AI console or
castctlare supported.
-
Switch your kubeconfig to the cluster you want to disconnect.
-
Run the disconnect command:
castctl cluster disconnectcastctlreads the Cast AI cluster ID from the in-cluster configuration, so you usually do not need to provide it. -
Review the summary box.
castctlprints every cloud resource it removed, any resources that were already absent, and any warnings to follow up on.
If a step fails, castctl prints a failure box noting which step failed and which cloud resources were already cleaned up. Fix the underlying issue and re-run the command — partial progress is preserved.
For the full list of disconnect options (including flags to skip cloud cleanup or the Kubernetes uninstall), run:
castctl cluster disconnect --helpSee also
- Enable automation — what the connection installs in your cluster and cloud account.
- Hosted components — the Kubernetes workloads
castctldeploys. - Cloud permissions — the IAM resources
castctlcreates. - Autoscaler checklist — recommended next steps after the cluster is connected.
- Connect using the Cast AI console — the console-based alternative.
- Disconnect your cluster — manual and Terraform-based disconnect flows.
Updated about 4 hours ago
