Connect using the castctl CLI
Connect or disconnect a Kubernetes cluster from Cast AI using the castctl command-line tool.
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, Microsoft AKS, and Cast AI Anywhere (on-premises, bare metal, and other clouds).
- 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, AKS, or a Cast AI Anywhere supported environment.
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 trust --cask castai/tap/castctl
brew install castctlTo upgrade to the latest version:
brew update && brew upgrade castctlcurl -fsSL https://get.cast.ai/linux | bashThe script installs castctl to ~/.local/bin by default and verifies the SHA256 checksum.
Pin a specific version or change the install location:
# Install to /usr/local/bin
curl -fsSL https://get.cast.ai/linux \
| bashiwr -useb https://get.cast.ai/windows | iexVerify 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.
Connect a Cast AI Anywhere cluster
For clusters running outside EKS, GKE, or AKS — such as on-premises, bare metal, or other cloud providers — use the --provider anywhere flag:
castctl cluster connect --provider anywhereClick here to learn more about Cast AI Anywhere.
Migrate from standalone Helm charts
If your cluster was previously connected using individual Cast AI Helm releases (one chart per component), castctl cluster migrate consolidates them into the unified umbrella chart. This preserves your cluster's Cast AI ID, carries forward any custom Helm values you supplied, and installs only the components that were already running.
The command also handles clusters where the Cast AI agent was installed via raw kubectl apply rather than Helm.
The castai-agent namespace and any non-chart-owned resources (including the castai-agent-metadata ConfigMap that holds the cluster ID) are not deleted.
Brief downtime during migrationThe migration uninstalls all standalone Helm releases before installing the umbrella chart. Cast AI components are absent from the cluster during this window. Node Autoscaling and Workload Autoscaling are paused until the umbrella chart install completes.
Run the migration
-
Switch your kubeconfig to the cluster you want to migrate.
-
Run:
castctl cluster migratecastctlreads the currently installed standalone releases, captures their values, uninstalls them, and then installs the umbrella chart with the reconstructed configuration. -
Review the confirmation prompt and proceed. Use
--yesto skip the prompt in scripts or CI. -
On success,
castctlconfirms that all components are running under the unified chart.
Available flags
| Flag | Description |
|---|---|
--yes | Skip the interactive confirmation prompt. |
--umbrella-version <version> | Install a specific umbrella chart version instead of the latest stable. |
--values-dump-path <path> | On failure, write the preserved standalone release values to this path instead of the default castai-migrate-values-<timestamp>.yaml in the current directory. |
--values-file <path> | Recovery mode: skip standalone detection and uninstall, and install the umbrella chart using the values in this file (see below). |
If the umbrella install fails
When the umbrella chart installation fails — for example, because an immutable field on an existing Deployment cannot be patched — castctl rolls back what it can and writes the captured standalone release values to a local file:
! Preserved standalone release values written to castai-migrate-values-20260730-083248.yaml
Pass this file to `castctl cluster migrate --values-file <path>` or
`helm upgrade castai castai/castai -f <path>` to reapply the custom configuration.
A debug snapshot ZIP is also saved to help diagnose the failure.
Fix the underlying issue (for example, delete the conflicting Deployment and let Helm recreate it), then pass the saved values file to retry. In --values-file mode, castctl skips standalone detection and uninstall entirely — only the umbrella chart installation runs:
castctl cluster migrate --values-file castai-migrate-values-20260730-083248.yamlAlternatively, apply the values directly with Helm:
helm upgrade castai castai/castai -f castai-migrate-values-20260730-083248.yamlThe dump file contains a top-level releases: map with per-release values and the cluster ID, so both approaches restore the original configuration.
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
Updated last month
