Switch the active kubeconfig context to the named cluster.
This command accepts a cluster name and automatically resolves it to the
correct kubeconfig context by checking all supported distribution prefixes
(kind-, k3d-, k3k-, admin@, vcluster-docker_, kwok-). The k3k- prefix matches
nested K3s clusters on the Kubernetes provider, and kwok- matches KWOK clusters.
If multiple distributions have contexts for the same cluster name, the
command returns an error listing the matching contexts.
Contexts the kubeconfig does not show as clusters KSail manages, such as a
cloud cluster or a colleague's cluster, can be switched to by their exact
context name. The picker and shell completion list them too, marked
unmanaged as in ksail cluster list, and switching to one prints a notice.
Use --context to select an exact kubeconfig context without managed-name matching.
Unmanaged shell completions use this flag so colliding names remain selectable.
The kubeconfig is resolved in the following priority order:
1. From KUBECONFIG environment variable
2. From ksail.yaml config file (if present)
3. Defaults to ~/.kube/config
When called without arguments, an interactive picker is shown
to select from available clusters. Recently-switched clusters
appear at the top of the list (up to the last 5), followed by
the remaining clusters in alphabetical order. The history is
persisted to ~/.ksail/switch-history.json.
In the picker, press '/' to enter filter mode and type to narrow
the list by keyword (case-insensitive). Press Esc to exit filter mode.
# Switch to a Vanilla (Kind) cluster named "dev"
# Switch to a cluster named "staging"
ksail cluster switch staging
# Select an exact kubeconfig context, even if its name matches a managed cluster
ksail cluster switch --context dev
# Select a cluster interactively (recent clusters shown first)
ksail cluster switch [cluster-name] [flags]
--context string Switch to this exact kubeconfig context
--benchmark[=true|false] Show per-activity benchmark output
--config string Path to config file (default: ksail.yaml found via directory traversal)
--experimental[=true|false] Enable experimental (unstable) commands and features