Skip to content

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.

When you pass --ttl to ksail cluster create, KSail:

  1. Creates the cluster normally.
  2. Blocks the process, waiting for the TTL to elapse.
  3. Auto-deletes the cluster when the timer expires.
Terminal window
# Create a cluster that auto-destroys after 2 hours
ksail cluster create --ttl 2h

Pressing 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.

ScenarioExampleSuggested TTL
Debugging a failing deploymentSpin up a cluster, deploy the broken app, inspect logs and state--ttl 1h
Demo or walkthroughShow a feature to a colleague or stakeholder--ttl 30m
Pair programmingShare a cluster with a teammate for a focused session--ttl 2h
On-call investigationReproduce a production issue in a local cluster--ttl 1h
Learning / experimentationTry out a new Helm chart or CRD--ttl 1h
PR reviewSpin up a cluster to manually verify a pull request--ttl 30m
Terminal window
ksail cluster create --ttl 1h

The 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.

While the cluster is running, you can check the TTL status from another terminal:

Terminal window
ksail cluster info

This appends TTL information to the standard cluster info output, showing the remaining time. You can also see TTL status in the cluster list:

Terminal window
ksail cluster list

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:

Terminal window
ksail cluster delete

If you want to keep using your terminal while the TTL timer runs, background the process:

Terminal window
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.

KSail writes the kubeconfig context to the configured kubeconfig path (default ~/.kube/config, configurable via spec.cluster.connection.kubeconfig). Use kubectl, k9s, or ksail cluster connect immediately after creation. For context name formats per distribution, see Companion Tools.

To share a running ephemeral cluster with a colleague on the same network, they need:

  1. A minimal kubeconfig for the specific cluster context
  2. Network access to the cluster’s API server

Export only the relevant context to avoid leaking unrelated clusters or credentials:

Terminal window
kubectl config view --minify --flatten --context k3d-ksail > /tmp/ksail-kubeconfig.yaml

For 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.

  • 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.

Use the ksail-cluster GitHub Actions composite action to set up KSail, cache Helm charts and mirror images, and run ksail cluster init + ksail cluster create in a single step. See PR Preview Clusters for the full action reference and GitOps CI workflows, or Testing in CI/CD for integration test patterns.