Introduction
vCluster is a lightweight, virtual Kubernetes cluster solution that allows running multiple Kubernetes clusters within a single Kubernetes host cluster. It is useful for multi-tenancy, development, and testing scenarios without the overhead of managing multiple EKS clusters.
In this guide, we will deploy vCluster on an AWS EKS cluster using Helm.
Prerequisites
Before proceeding, ensure you have the following:
- AWS CLI installed and configured with appropriate permissions.
- kubectl installed and configured to access your EKS cluster.
- Helm installed (v3 recommended).
- eksctl installed to manage EKS clusters.
- An existing AWS EKS cluster or create a new one.
Step 1: Create an EKS Cluster (If Needed)
If you don't have an existing EKS cluster, create one using eksctl:
eksctl create cluster --name my-eks-cluster --region us-west-2 --nodegroup-name standard-workers --node-type t3.medium --nodes 2Verify the cluster:
kubectl get nodesStep 2: Install Helm
If Helm is not installed, you can install it using the following:
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bashVerify the installation:
helm versionStep 3: Add the vCluster Helm Repository
Add the loft Helm repository which contains the vCluster chart:
helm repo add loft-sh https://charts.loft.sh
helm repo updateStep 4: Deploy vCluster Using Helm
Create a namespace for vCluster:
kubectl create namespace vclusterDeploy vCluster using Helm:
helm install my-vcluster loft-sh/vcluster -n vclusterVerify the deployment:
kubectl get pods -n vclusterYou should see the vCluster pods running.
Step 5: Connect to vCluster
To interact with the vCluster, use the following command:
vcluster connect my-vcluster -n vcluster -- kubectl get nodesThis command sets up port forwarding and allows you to interact with the virtual cluster using kubectl.
Step 6: Deploy Workloads in vCluster
Once connected to vCluster, you can deploy workloads as you would on any Kubernetes cluster.
Example:
kubectl apply -f https://k8s.io/examples/application/deployment.yamlVerify the deployment:
kubectl get podsStep 7: Deleting vCluster
To remove vCluster from your EKS cluster:
helm uninstall my-vcluster -n vcluster
kubectl delete namespace vclusterIf you created an EKS cluster specifically for this, you can delete it with:
eksctl delete cluster --name my-eks-clusterConclusion
In this guide, we deployed vCluster on AWS EKS using Helm, connected to the virtual cluster, and deployed workloads within it. vCluster provides a great way to create isolated environments for testing, development, and multi-tenancy within Kubernetes clusters efficiently.
Happy coding!