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 at CI/CD pipelines (ephemeral per-PR clusters, parallel test execution on shared runners), local multi-environment development (isolated environments per feature branch or team member), and learning (safe, disposable Kubernetes sandboxes).
Consider other distributions for production workloads (Talos), cloud deployment (Talos with Hetzner Cloud or Omni), standard upstream Kubernetes testing (Vanilla), low-resource devices (K3s), or advanced CNI control (Vanilla or Talos).
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βFor real-world VCluster workflow examples β CI/CD pipelines, multi-environment development, feature branch testing, and microservices isolation β see Use Cases.
Architecture
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βThe VCluster control plane runs in a Docker container and includes a Kubernetes API server, scheduler, controller manager, and etcd. Pods are scheduled to worker node containers (optional) or directly within the control plane container. When VCluster is used in a host-cluster deployment mode (outside KSailβs Docker/Vind setup), selected resources can be synced between the virtual cluster and its host cluster.
Comparison with Other Distributions
Section titled βComparison with Other DistributionsβFor a full comparison across all distributions and supported components, see the Support Matrix.
Troubleshooting
Section titled βTroubleshootingβCluster Wonβt Start
Section titled βCluster Wonβt StartβSymptom: ksail cluster create hangs or fails.
KSail automatically retries transient VCluster startup failures: up to 5 attempts (5-second delays) during create, and up to 3 attempts (3-minute timeout each) during the readiness check. Log messages like Retrying vCluster create (attempt 2/5)... are expected β wait for completion before investigating.
Persistent failures β common causes:
docker ps # Docker must be runninglsof -i :6443 # Check for port 6443 conflictsdocker info | grep -i memory # Ensure 2GB+ RAM allocated to DockerIf all retries fail, run ksail cluster delete && ksail cluster create.
kubectl Commands Fail
Section titled βkubectl Commands FailβSymptom: kubectl get nodes returns connection errors.
kubectl config current-context # Should show your VCluster namekubectl config use-context dev-cluster # Switch if neededIf the context is missing, delete and recreate the cluster.
Pod Scheduling Issues
Section titled βPod Scheduling IssuesβSymptom: Pods remain in Pending state.
kubectl describe pod <pod-name> # Check scheduling errorskubectl top nodes # Check resource availabilitykubectl get nodes # All nodes should show ReadySlow Performance
Section titled βSlow PerformanceβIncrease Docker resources (4 GB RAM, 2 CPUs minimum) in Docker Desktop settings, and delete unused clusters with ksail cluster list / ksail cluster delete.
Advanced 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