Use Cases
Learning Kubernetes
Section titled “Learning Kubernetes”For developers new to Kubernetes who want to explore concepts and experiment with different configurations.
Recommended Setup
Section titled “Recommended Setup”ksail cluster init \ --name learning \ --distribution Vanilla \ --cni Cilium \ --gitops-engine NoneWorkflow
Section titled “Workflow”ksail cluster create
# Apply, inspect, and iterateksail workload apply -f my-deployment.yamlksail workload get podsksail workload apply -f updated-deployment.yamlksail workload logs deployment/my-app
ksail cluster delete- Use
ksail workload gento generate example manifests - Use
ksail workload explain <resource>to learn about Kubernetes resources - Use
ksail workload watchto watch for file changes and auto-apply; it scopeskubectl applyto the nearest directory containing a kustomization file recognized by kubectl (kustomization.yaml,kustomization.yml, orKustomization) for faster iteration, falling back tokubectl apply -f <dir> --recursivewhen no kustomization boundary is found; add--initial-applyto sync the cluster at startup before entering the loop - Use
ksail cluster connectto open K9s for interactive exploration
Iterating on Applications
Section titled “Iterating on Applications”For developers building and testing applications locally before deploying to staging or production.
Recommended Setup
Section titled “Recommended Setup”ksail cluster init \ --name dev \ --distribution K3s \ --cni Cilium \ --csi Enabled \ --gitops-engine Flux \ --local-registry localhost:5050Workflow
Section titled “Workflow”ksail cluster create
# Build and push to local registrydocker build -t localhost:5050/my-app:dev .docker push localhost:5050/my-app:dev
# Update k8s/deployment.yaml: image: localhost:5050/my-app:devksail workload pushksail workload reconcile- Use
ksail workload logs -f deployment/my-appfor live log streaming - Use
ksail workload exec deployment/my-app -- /bin/shfor debugging - Keep terminal running with
ksail cluster infoto monitor cluster health - Pair KSail with Tilt, Skaffold, DevSpace, Telepresence, or mirrord to automate the build-deploy loop, hot-reload interpreted code, or bridge local↔remote traffic
Testing in CI/CD
Section titled “Testing in CI/CD”For automated testing in CI/CD pipelines where reproducibility and speed matter.
Recommended Setup
Section titled “Recommended Setup”apiVersion: ksail.io/v1alpha1kind: Clusterspec: cluster: distribution: K3s cni: Cilium gitOpsEngine: Flux localRegistry: registry: localhost:5050 workload: sourceDirectory: k8sGitHub Actions (Recommended)
Section titled “GitHub Actions (Recommended)”Use the official ksail-cluster composite action to provision a cluster in one step. It handles installation, Helm chart caching, mirror registry caching, and image pre-pulling automatically.
name: Integration Tests
on: pull_request: branches: [main]
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Provision KSail cluster id: cluster uses: devantler-tech/ksail/.github/actions/ksail-cluster@v5.59.0 with: distribution: K3s # Vanilla, K3s, Talos, VCluster, KWOK sops-age-key: ${{ secrets.SOPS_AGE_KEY }} # optional: import SOPS key + create sops-age secret delete: true # delete cluster at the end (runs even on failure)
- name: Build and push app image run: | docker build -t localhost:5050/my-app:${{ github.sha }} . docker push localhost:5050/my-app:${{ github.sha }}
- name: Deploy and test env: KUBECONFIG: ${{ steps.cluster.outputs.kubeconfig }} run: | sed -i "s|image:.*|image: localhost:5050/my-app:${{ github.sha }}|" k8s/deployment.yaml ksail workload push ksail workload reconcile ksail workload wait deployment/my-app --for=condition=available npm run test:integrationFor the full action inputs reference, PR preview patterns, and GitOps CI workflows, see PR Preview Clusters.
Other CI Systems
Section titled “Other CI Systems”For non-GitHub CI (GitLab CI, CircleCI, etc.), install KSail directly and run lifecycle commands:
# Install (see https://github.com/devantler-tech/ksail/releases for available versions)VERSION=5.59.0curl -sSL "https://github.com/devantler-tech/ksail/releases/download/v${VERSION}/ksail_${VERSION}_linux_amd64.tar.gz" | tar -xzsudo mv ksail /usr/local/bin/
# Provision cluster (using declarative ksail.yaml)ksail cluster create
# ... run tests ...
# Cleanupksail cluster delete- Use
--timeoutflags to handle slow CI runners - Cache Docker layers for faster builds
- Use matrix builds to test across multiple Kubernetes versions/distributions
- Use
--ttlas a best-effort safety net — the cluster auto-destroys when the TTL elapses provided theksail cluster createprocess stays alive - Consider using
ksail cluster startandksail cluster stopif tests can share a cluster