Getting Started with Virtual Kubernetes Clusters and Shipa Cloud

Like your virtual machine running another virtual machine [nested virtualization] or Docker-in-Docker [dind], today thanks to Loft Labs, you are now able to run multiple virtual Kubernetes clusters in a Kubernetes cluster. The vcluster project is focused on creating fully functional virtual Kubernetes clusters inside a base cluster allowing for a different approach to multitenancy than spinning up a separate Kubernetes cluster. 

A core use case of Shipa is the ability to have abstractions that make deploying to multiple clusters easy for developers. In this example, we will spin up a pair of virtual clusters and wire them to Shipa [and as a bonus, the base physical cluster]. 

Getting Started With vcluster

 The vcluster project has an excellent quickstart to get you on your way. In this example, I have spun up an Amazon EKS Cluster with eksctl

Validate that there is connectivity. 

kubectl get nodes
Spin up EKS

Next grab the vcluster CLI and validate it’s install.

curl -s -L "" | sed -nE 's!.*"([^"]*vcluster-darwin-amd64)".*!https://github.com1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster;

sudo mv vcluster /usr/local/bin;

vcluster --version
vcluster cli install

Once validated, now it is time to create two virtual clusters which we will expose via a Kubernetes LoadBalancer.

Virtual cluster one:

vcluster create vcluster-1 -n first-virtual-cluster --expose 
Create vcluster

Now connect to your virtual cluster. 

vcluster connect vcluster-1 -n first-virtual-cluster
export KUBECONFIG=./kubeconfig.yaml
Connect to vcluster

Now you are ready to run commands in your virtual cluster.

kubectl get pods -A
vcluster pods

Now you are ready to bind your virtual cluster to Shipa.

Connecting Your Virtual Cluster to Shipa Cloud

If you have not signed up for Shipa Cloud for free yet, make sure to do that before proceeding. Once signed up, binding a cluster to Shipa is now easier than ever. Shipa does work on a concept of Frameworks which are logical groupings of abstractions and policies. So to connect your virtual cluster, create a Shipa Framework first. 

Shipa Cloud -> Frameworks +Create Framework

Select: Deploy applications with reasonable defaults

Create Shipa Framework

Click Next to fill in some details.

Name: myfirstvirtualframework

Plan: shipa-plan

Team: shipa-team

First Virtual Framework

Click Create and you are ready to start to bind the virtual cluster. 

Shipa Cloud -> Clusters + Connect Cluster 

Connect Virtual Cluster to Shipa

Grab the newly generated Kubernetes API Endpoint and paste into the text box.

kubectl cluster-info | grep 'Kubernetes' | awk '/http/ {print $NF}'
Get Kubernetes API Endpoint vcluster

Then click Generate Command. 

Shipa Cluster Connect Command

Back in the terminal which has the context for the virtual cluster, paste in the Shipa Magic Link to bind your virtual cluster. 

Validated Cluster Connect

Execute the kubectl command.

Executing Cluster Connect

In a few moments, your virtual cluster will be available to Shipa. 

Connected Virtual Cluster

With your virtual cluster connected, you can now deploy to your virtual cluster. 

Deploying To Your Virtual Cluster

Deploying an application is really straightforward with Shipa. 

Shipa Cloud -> Applications + Create Application

Name: virtualappone

Framework: myfirstvirtualframework

Team: shipa-team

Virtual Cluster App

Scroll down and wire in a sample application / your application image. If you would like to leverage the sample image, click “Test With Sample Image”.

Image URL:

Virtual Kubernetes Cluster Application

Then hit Deploy. 

Clicking back into the “virtualappone”, you now have a publicly accessible endpoint to check out. Click on the link and you now have access to your workload. 

Deployed Virtual Kubernetes Cluster Application

Clicking on the URL will bring you to your workload!

Running vcluster workload

Now you are ready to create your second virtual cluster. 

The Second Virtual Cluster 

Creating a second virtual cluster is simple with vcluster. All you need to do is to head back to a terminal with the base context of the Kubernetes cluster [e.g one that is not the virtual cluster in this example] and execute the CLI command again. 

vcluster create vcluster-2 -n second-virtual-cluster --expose
vcluster connect vcluster-2 -n second-virtual-cluster
export KUBECONFIG=./kubeconfig.yaml
Second virtual Kubernetes cluster

Then validate that this is fresh. 

kubectl get namespaces
New virtual Kubernetes cluster vcluster

Now you can re-run the same steps to create a Shipa Framework and bind the cluster. 

Connect second vcluster

Once executed, you should be set to be able to deploy to your second virtual cluster. 

Binding second vcluster

Connecting to the root of your Kubernetes cluster e.g the base EKS cluster, you can see the virtual cluster and Shipa workloads running together. 

kubectl get pods -A
Host Kubernetes Cluster

Certainly a lot of the art of the possible with both solutions together. 

Virtual Clusters and Shipa – Better Together

Virtual Kubernetes Clusters with the vcluster project are certainly taking a different approach with Kubernetes multi-tenancy. Though as the number of percieved/avaiable clusters increases, there is an increase in the burden for developers to get the destination correctly. Shipa not only allows for faster velocity for on-boarding and off-boarding of workloads, but also scales with you as the number of virtual clusters increases. This example could have been even more complex as we could have also deployed Shipa onto the physical cluster itself.

Connect Physical Kubernetes Cluster

The finished product:

Hybrid Kubernetes Cluster

Make sure to take both for a spin, today!