Getting Started with VCluster
VCluster creates lightweight, isolated virtual Kubernetes clusters that run as Docker containers. This guide walks you through creating your first VCluster, understanding when to use it, and exploring common use cases.
What is VCluster?
Section titled βWhat is VCluster?βVCluster provides virtual Kubernetes clustersβfully functional Kubernetes control planes that run inside Docker containers instead of requiring a host cluster. KSail uses the Vind Docker driver to run VCluster directly on Docker, making it perfect for development and CI/CD without the overhead of a full Kubernetes cluster.
Key Benefits
Section titled βKey Benefitsβ- Lightweight: Control plane runs in a single Docker container
- Fast startup: Clusters ready in seconds
- Isolated: Each VCluster is completely isolated
- Cost-effective: Share Docker infrastructure across multiple clusters
- CI/CD friendly: Perfect for ephemeral test environments
- Multi-tenancy: Run multiple isolated clusters on one machine
When to Use VCluster
Section titled βWhen to Use VClusterβVCluster excels in these scenarios:
β Use VCluster For
Section titled ββ Use VCluster ForβCI/CD Pipelines
- Ephemeral test clusters per PR or test suite
- Fast creation/deletion without infrastructure overhead
- Complete isolation between test runs
- Parallel test execution on shared runners
Development Workflows
- Quick feature branch testing
- Local integration testing
- Microservices development with isolated environments
- Rapid cluster recreation during development
Multi-Tenancy
- Multiple isolated environments on one machine
- Team collaboration without cluster conflicts
- Demo environments for each customer or project
- Sandbox environments for experimentation
Learning and Experimentation
- Safe environment for Kubernetes learning
- Test manifests without affecting other projects
- Experiment with cluster configurations
- Quick reset to clean state
β Consider Other Distributions For
Section titled ββ Consider Other Distributions Forβ- Production workloads β Use Talos (security-focused) or K3s (resource-efficient)
- Bare metal or cloud deployment β Use Talos with Hetzner provider
- Upstream Kubernetes testing β Use Vanilla (Kind) for standard Kubernetes
- Low-resource devices β Use K3s for minimal memory footprint
- Advanced networking features β Use Vanilla or Talos with full CNI control
Quick Start
Section titled βQuick Startβ1. Initialize a VCluster Project
Section titled β1. Initialize a VCluster ProjectβCreate a new VCluster configuration:
mkdir my-vclustercd my-vcluster
ksail cluster init \ --name dev-cluster \ --distribution VCluster \ --gitops-engine FluxThis generates:
ksail.yamlβ KSail cluster configurationvcluster.yamlβ VCluster Helm values (native configuration)k8s/kustomization.yamlβ Directory for Kubernetes manifests
2. Create the Cluster
Section titled β2. Create the Clusterβksail cluster createWhat happens:
- Docker containers are created for the VCluster control plane
- Optional worker nodes are started (if configured)
- GitOps engine (Flux or ArgoCD) is bootstrapped
- Kubeconfig is automatically configured
Expected output:
β Creating VCluster cluster 'dev-cluster'...β Waiting for control plane to be ready...β Cluster created successfullyβ Kubeconfig updated: kubectl config use-context dev-cluster3. Verify the Cluster
Section titled β3. Verify the Clusterβ# Check cluster infoksail cluster info
# List running containersdocker ps | grep dev-cluster
# Test kubectl accesskubectl get nodeskubectl get pods --all-namespaces4. Deploy an Application
Section titled β4. Deploy an Applicationβ# Create a simple deploymentkubectl create deployment nginx --image=nginx:1.25kubectl expose deployment nginx --port=80 --type=NodePort
# Check the servicekubectl get svc nginx5. Clean Up
Section titled β5. Clean Upβ# Delete the cluster when doneksail cluster delete
# Verify containers are removeddocker ps | grep dev-clusterConfiguration Options
Section titled βConfiguration OptionsβBasic Configuration
Section titled βBasic ConfigurationβThe generated ksail.yaml controls cluster behavior:
apiVersion: ksail.io/v1alpha1kind: Clusterspec: cluster: distribution: VCluster gitOpsEngine: Flux # or ArgoCDVCluster-Specific Configuration
Section titled βVCluster-Specific ConfigurationβCustomize VCluster behavior in vcluster.yaml:
# Control plane configurationcontrolPlane: distro: k3s: enabled: true statefulSet: resources: limits: memory: 2Gi requests: memory: 256Mi
# Sync options - what gets synced from virtual to hostsync: persistentVolumes: enabled: true storageClasses: enabled: true nodes: enabled: true
# Networkingnetworking: replicateServices: toHost: - from: default to: vcluster-defaultSee the vCluster configuration documentation for all options.
Common Use Cases
Section titled βCommon Use CasesβUse Case 1: CI/CD Test Clusters
Section titled βUse Case 1: CI/CD Test ClustersβCreate isolated clusters for each test run:
# In CI pipelineBRANCH=$(git rev-parse --short HEAD)ksail cluster init --name "test-${BRANCH}" --distribution VClusterksail cluster create
# Run testskubectl apply -f test-manifests/pytest integration/
# Cleanupksail cluster deleteBenefits:
- Each test run gets a fresh, isolated cluster
- No cross-contamination between runs
- Fast creation/deletion (seconds vs minutes)
- Parallel test execution on same runner
Use Case 2: Multi-Environment Development
Section titled βUse Case 2: Multi-Environment DevelopmentβMaintain separate environments on one machine:
# Create dev environmentksail cluster init --name dev --distribution VClusterksail cluster create
# Create staging environmentksail cluster init --name staging --distribution VClusterksail cluster create
# Create production-like environmentksail cluster init --name prod-sim --distribution VClusterksail cluster create
# Switch between environmentskubectl config use-context devkubectl config use-context stagingkubectl config use-context prod-simUse Case 3: Microservices Development
Section titled βUse Case 3: Microservices DevelopmentβEach team member can have isolated services:
# Developer 1ksail cluster init --name alice-services --distribution VClusterksail cluster createkubectl apply -f alice-manifests/
# Developer 2ksail cluster init --name bob-services --distribution VClusterksail cluster createkubectl apply -f bob-manifests/
# No conflicts - completely isolated!Use Case 4: Feature Branch Testing
Section titled βUse Case 4: Feature Branch TestingβTest features in isolation before merging:
# Create cluster per feature branchgit checkout feature/new-apiksail cluster init --name feature-new-api --distribution VClusterksail cluster createkubectl apply -f manifests/
# Test the featurecurl http://localhost:8080/api/v2
# When done, delete and switch branchesksail cluster deletegit checkout feature/ui-updatesksail cluster init --name feature-ui --distribution VClusterksail cluster createArchitecture
Section titled βArchitectureβHow VCluster Works
Section titled βHow VCluster Worksβββββββββββββββββββββββββββββββββββββββββββββββββ Your Host Machine ββ ββ ββββββββββββββββββββββββββββββββββββββ ββ β Docker Engine β ββ β β ββ β ββββββββββββββββββββββββββββ β ββ β β VCluster Control Plane β β ββ β β (Docker Container) β β ββ β β β β ββ β β β’ API Server β β ββ β β β’ Controller Manager β β ββ β β β’ Scheduler β β ββ β β β’ etcd β β ββ β ββββββββββββββββββββββββββββ β ββ β β ββ β ββββββββββββββββββββββββββββ β ββ β β Worker Nodes (Optional) β β ββ β β (Docker Containers) β β ββ β ββββββββββββββββββββββββββββ β ββ ββββββββββββββββββββββββββββββββββββββ ββ ββ Your applications run in the VCluster ββ and appear as normal pods from the ββ virtual cluster's perspective ββββββββββββββββββββββββββββββββββββββββββββββββComponents
Section titled βComponentsβ- Virtual Control Plane: Runs in a Docker container with Kubernetes API server, scheduler, controller manager, and etcd
- Networking: Uses Docker networking for pod-to-pod communication
- Storage: Volumes are managed within the virtual cluster
- Syncing: Selected resources (pods, services, configmaps) are synced to host cluster if needed
Comparison with Other Distributions
Section titled βComparison with Other Distributionsβ| Feature | VCluster | Vanilla (Kind) | K3s | Talos |
|---|---|---|---|---|
| Startup Time | ~10s | ~30s | ~20s | ~60s |
| Resource Usage | Low | Medium | Low | Medium |
| Multi-Tenancy | β | β | β | β |
| Production Ready | No | No | Yes | Yes |
| Security Isolation | High | Medium | Medium | High |
| Worker Nodes | Optional | Required | Reqβd | Reqβd |
| GitOps Support | β | β | β | β |
| Best For | CI/CD | Testing | Prod | Prod |
| Upstream Kubernetes | No (K3s) | Yes | No | Yes |
Troubleshooting
Section titled βTroubleshootingβCluster Wonβt Start
Section titled βCluster Wonβt StartβSymptom: ksail cluster create hangs or fails
Automatic retry (create phase): KSail automatically retries transient startup failures up to 3 times (with 5-second delays between attempts). If you see log messages like Retrying vCluster create (attempt 2/3)..., this is expected β KSail is recovering from a transient Docker or D-Bus error without any action needed from you.
Automatic retry (connect phase): After the cluster is created, KSail also retries the readiness check up to 3 times. Each attempt allows up to 3 minutes for the cluster to become ready, giving an effective timeout of ~9 minutes. If you see log messages like Retrying vCluster connect (attempt 2/3)..., this is expected behavior on slower machines or CI runners β KSail will keep waiting without any action needed from you.
Common causes for persistent failures:
-
Docker not running
Terminal window docker ps # Should list containers -
Port conflicts
Terminal window # Check if port 6443 is in uselsof -i :6443 -
Insufficient resources
Terminal window # Ensure Docker has enough memory (2GB+ recommended)docker info | grep -i memory
Fix (if all retry attempts fail):
# Delete and recreateksail cluster deleteksail cluster createTransient Startup Failures on CI Runners
Section titled βTransient Startup Failures on CI RunnersβSymptom: ksail cluster create fails with exit status 22 (EINVAL) on CI runners.
KSail automatically retries transient VCluster startup failures with up to 3 attempts and a 5-second delay between attempts, cleaning up partial state between retries. If the issue persists after automatic retries, check Docker resource limits and D-Bus availability on the runner.
kubectl Commands Fail
Section titled βkubectl Commands FailβSymptom: kubectl get nodes returns connection errors
Fix:
# Verify kubeconfig contextkubectl config current-context
# Should show your VCluster name# If not, switch contexts:kubectl config use-context dev-cluster
# Or regenerate kubeconfigksail cluster deleteksail cluster createPod Scheduling Issues
Section titled βPod Scheduling IssuesβSymptom: Pods remain in Pending state
Diagnosis:
kubectl describe pod <pod-name># Look for scheduling errorsCommon fixes:
-
Check resources
Terminal window kubectl top nodes -
Verify node readiness
Terminal window kubectl get nodes# All nodes should show Ready
Slow Performance
Section titled βSlow PerformanceβSymptom: Operations are slower than expected
Possible causes:
- Docker resource limits too low
- Too many clusters running simultaneously
- System under heavy load
Optimization:
# Increase Docker resources in Docker Desktop settings# Recommended: 4GB RAM, 2 CPUs minimum
# Delete unused clustersksail cluster listksail cluster delete unused-clusterAdvanced Topics
Section titled βAdvanced TopicsβWorker Nodes
Section titled βWorker NodesβBy default, VCluster runs workload pods inside the control plane container. For more realistic multi-node scenarios, enable worker nodes:
nodes: enabled: true count: 3This creates separate Docker containers acting as worker nodes.
Custom Distributions
Section titled βCustom DistributionsβVCluster can run different Kubernetes distributions internally:
controlPlane: distro: k3s: enabled: true # Default, lightweight # OR k8s: enabled: true # Standard Kubernetes # OR k0s: enabled: true # K0s distributionResource Limits
Section titled βResource LimitsβControl resource consumption:
controlPlane: statefulSet: resources: limits: cpu: "1" memory: 2Gi requests: cpu: "100m" memory: 256MiNext Steps
Section titled βNext StepsβExplore KSail Features
Section titled βExplore KSail Featuresβ- GitOps Integration: Bootstrap Flux or ArgoCD
- Secret Management: Encrypt secrets with SOPS
- AI Chat: Interactive cluster management with GitHub Copilot
- VSCode Extension: Manage clusters from your editor
Try Other Distributions
Section titled βTry Other Distributionsβ- Vanilla (Kind): Upstream Kubernetes for maximum compatibility
- K3s (K3d): Lightweight K3s for resource-constrained environments and CI/CD
- Talos: Immutable infrastructure for production
Learn More
Section titled βLearn Moreβ- Installation Guide: Install KSail on your system
- CLI Flags: Comprehensive command documentation
- Configuration Reference: Detailed YAML options
- Support Matrix: Detailed VCluster capabilities
- Use Cases: More real-world scenarios
- vCluster Documentation: Upstream VCluster docs
- Contributing: Contribute to KSail development