Skip to main content
Version: main 🚧

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
    brew install loft-sh/tap/vcluster

    The binaries in the tap are signed using the Sigstore framework for enhanced security.

    Confirm that you've installed the correct version of the vCluster CLI.

    vcluster --version
  • Google Cloud SDK (gcloud CLI)
    note

    Ensure 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:

tip

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.

Set environment variables
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:

Configure gcloud
gcloud config set project $PROJECT_ID
gcloud services enable container.googleapis.com

Create the cluster:

Create GKE cluster
gcloud container clusters create $CLUSTER_NAME \
--zone $ZONE \
--machine-type $MACHINE_TYPE \
--num-nodes 2
info

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.

kubeconfig update

This command automatically updates your kubeconfig file with the new cluster configuration.

Verify the cluster creation​

Verify the cluster by listing the nodes:

List cluster 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:

Create virtual cluster
vcluster create my-vcluster --namespace team-x

Verify the Installation​

Check if vCluster pods are running:

Check vCluster pods
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​


Pro Feature

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:

Clean up resources
gcloud container clusters delete $CLUSTER_NAME --zone $ZONE --quiet