Ephemeral Clusters with --ttl
KSailâs --ttl flag creates ephemeral clusters that auto-destroy after a specified duration. This is useful when you want to give yourself or others temporary access to a cluster â for debugging, demos, pair programming, or on-call investigation â without worrying about cleaning it up afterwards.
How --ttl Works
Section titled âHow --ttl WorksâWhen you pass --ttl to ksail cluster create, KSail:
- Creates the cluster normally.
- Blocks the process, waiting for the TTL to elapse.
- Auto-deletes the cluster when the timer expires.
# Create a cluster that auto-destroys after 2 hoursksail cluster create --ttl 2hPressing Ctrl+C (or sending SIGINT/SIGTERM) cancels the TTL wait and leaves the cluster running. This lets you extend a session â just delete the cluster manually when youâre done.
When to Use --ttl
Section titled âWhen to Use --ttlâ| Scenario | Example | Suggested TTL |
|---|---|---|
| Debugging a failing deployment | Spin up a cluster, deploy the broken app, inspect logs and state | --ttl 1h |
| Demo or walkthrough | Show a feature to a colleague or stakeholder | --ttl 30m |
| Pair programming | Share a cluster with a teammate for a focused session | --ttl 2h |
| On-call investigation | Reproduce a production issue in a local cluster | --ttl 1h |
| Learning / experimentation | Try out a new Helm chart or CRD | --ttl 1h |
| PR review | Spin up a cluster to manually verify a pull request | --ttl 30m |
Basic Usage
Section titled âBasic UsageâCreate a Time-Limited Cluster
Section titled âCreate a Time-Limited Clusterâksail cluster create --ttl 1hThe process blocks and prints a message:
âš cluster will auto-destroy in 1h0m0s (press Ctrl+C to cancel)When the timer expires, KSail automatically deletes the cluster and exits.
Check Remaining Time
Section titled âCheck Remaining TimeâWhile the cluster is running, you can check the TTL status from another terminal:
ksail cluster infoThis appends TTL information to the standard cluster info output, showing the remaining time. You can also see TTL status in the cluster list:
ksail cluster listCancel the TTL
Section titled âCancel the TTLâPress Ctrl+C in the terminal running ksail cluster create --ttl .... The cluster stays running and you can continue using it. Delete it manually when youâre done:
ksail cluster deleteRunning in the Background
Section titled âRunning in the BackgroundâIf you want to keep using your terminal while the TTL timer runs, background the process:
ksail cluster create --ttl 2h &The cluster creates normally and the TTL countdown runs in the background. When the timer expires, the cluster is auto-deleted.
Kubeconfig Context
Section titled âKubeconfig ContextâKSail writes the kubeconfig context to the configured kubeconfig path (defaults to ~/.kube/config, configurable via spec.cluster.connection.kubeconfig) during cluster creation. You can use kubectl, k9s, or any other Kubernetes tool immediately.
The context name depends on the distribution:
| Distribution | Context name |
|---|---|
| Vanilla (Kind) | kind-<name> |
| K3s (K3d) | k3d-<name> |
| Talos | admin@<name> |
| VCluster | vcluster-docker_<name> |
To connect with K9s for interactive debugging:
ksail cluster connectSharing a Cluster
Section titled âSharing a ClusterâTo share a running ephemeral cluster with a colleague on the same network, they need:
- A minimal kubeconfig for the specific cluster context
- Network access to the clusterâs API server
Export only the relevant context to avoid leaking unrelated clusters or credentials:
kubectl config view --minify --flatten --context k3d-ksail > /tmp/ksail-kubeconfig.yamlFor local Docker-based clusters, this typically means running on the same machine. For Talos clusters on Hetzner or Omni, the API server is network-accessible and the kubeconfig can be shared directly.
TTL Sizing Guide
Section titled âTTL Sizing GuideâChoose a TTL based on how long you expect to need the cluster, plus some buffer:
| Session type | Recommended TTL |
|---|---|
| Quick check (< 15 min) | --ttl 30m |
| Debugging session | --ttl 1h |
| Extended investigation | --ttl 2h |
| Workshop or demo | --ttl 4h |
Set the TTL to roughly 2Ă your expected session length â long enough that you wonât be interrupted, short enough that forgotten clusters donât waste resources.
Distribution Tips
Section titled âDistribution Tipsâ- K3s starts fastest and uses the fewest resources â good for quick debugging sessions.
- Vanilla (Kind) provides standard upstream Kubernetes â useful when you need exact API compatibility.
- Talos is immutable and secure â ideal for reproducing production-like environments.
- VCluster uses the Vind Docker driver to run the control plane directly in Docker containers â no pre-existing host cluster required, useful for lightweight isolated environments.
Next Steps
Section titled âNext Stepsâ- Use Cases â Workflows for learning, development, and CI/CD
- Companion Tools â Pair KSail with Tilt, Skaffold, or mirrord
- Configuration â Complete configuration reference