Deploy vCluster on GKE
This guide provides step-by-step instructions for deploying vCluster
on Google Kubernetes Engine (GKE).
Prerequisites​
Before starting, ensure you have the following tools installed:
kubectl
: Kubernetes command-line tool for interacting with the cluster. See Install and Set Up kubectl for installation instructions.- vCluster CLI
- Homebrew
- Mac (Intel/AMD)
- Mac (Silicon/ARM)
- Linux (AMD)
- Linux (ARM)
- Download Binary
- Windows Powershell
brew install loft-sh/tap/vcluster
The binaries in the tap are signed using the Sigstore framework for enhanced security.
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-darwin-amd64" && sudo install -c -m 0755 vcluster /usr/local/bin && rm -f vcluster
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-darwin-arm64" && sudo install -c -m 0755 vcluster /usr/local/bin && rm -f vcluster
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-linux-amd64" && sudo install -c -m 0755 vcluster /usr/local/bin && rm -f vcluster
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-linux-arm64" && sudo install -c -m 0755 vcluster /usr/local/bin && rm -f vcluster
Download the binary for your platform from the GitHub Releases page and add this binary to your $PATH.
md -Force "$Env:APPDATA\vcluster"; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12';
Invoke-WebRequest -URI "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-windows-amd64.exe" -o $Env:APPDATA\vcluster\vcluster.exe;
$env:Path += ";" + $Env:APPDATA + "\vcluster";
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User);Reboot RequiredYou may need to reboot your computer to use the CLI due to changes to the PATH variable (see below).
Check Environment Variable $PATHLine 4 of this install script adds the install directory
%APPDATA%\vcluster
to the$PATH
environment variable. This is only effective for the current Powershell session, i.e. when opening a new terminal window,vcluster
may not be found.Make sure to add the folder
%APPDATA%\vcluster
to thePATH
environment variable after installing vcluster CLI via Powershell. Afterward, a reboot might be necessary.Confirm that you've installed the correct version of the vCluster CLI.
vcluster --version
- Google Cloud SDK (
gcloud
CLI)noteEnsure you have the necessary IAM permissions to create clusters and manage cloud services.
Create GKE cluster​
Start by creating a zonal GKE cluster using the gcloud
CLI. First, set up your environment variables:
Project ID can be found in the Google Cloud Console under the project name.
Alternatively use gcloud project list
to list all projects and their IDs.
To check which project is active, use gcloud config get-value project
.
export PROJECT_ID=development
export CLUSTER_NAME=vcluster-demo
export ZONE=europe-west1-b
export MACHINE_TYPE=e2-standard-4
Configure gcloud
and enable the required APIs and set default project:
gcloud config set project $PROJECT_ID
gcloud services enable container.googleapis.com
Create the cluster:
gcloud container clusters create $CLUSTER_NAME \
--zone $ZONE \
--machine-type $MACHINE_TYPE \
--num-nodes 2
This process typically takes about 10-15 minutes.
This command creates a GKE cluster named vcluster-demo in the europe-west1-b zone with two nodes of type e2-standard-4.
This command automatically updates your kubeconfig
file with the new
cluster configuration.
Verify the cluster creation​
Verify the cluster by listing the nodes:
kubectl get nodes
You should see output similar to:
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS
vcluster-demo europe-west1-b 1.30.5-gke.1443001 35.187.66.218 e2-standard-4 1.30.5-gke.1443001 2 RUNNING
Create virtual cluster​
Create a virtual cluster using the CLI:
vcluster create my-vcluster --namespace team-x
Verify the Installation​
Check if vCluster pods are running:
kubectl get pods -n team-x
You should see output similar to:
NAME READY STATUS RESTARTS AGE
coredns-666d64755b-k5njg-x-kube-system-x-my-vcluster 1/1 Running 0 3m11s
my-vcluster-0 1/1 Running 0 6m33s
Next steps​
Now that you have vCluster running on GKE, consider setting up the platform UI to mange your virtual clusters.
Workload Identity​
This feature is available in the vCluster Pro tier. Contact us for more details and to start a trial.
When using the platform you can easily enable Workload Identity.
Cleanup​
If you deployed the GKE cluster with this tutorial, and want to clean up the resources, run the following command:
gcloud container clusters delete $CLUSTER_NAME --zone $ZONE --quiet