High-Velocity Engineering with Virtual Kubernetes Clusters

A photo of a set of round, wooden blocks
  • Creating and disposing of new environments
  • Launching and managing environments with minimal admin effort
  • Utilizing resources in a cost-efficient manner

Treat Resources like Cattle

A popular mindset is to treat the cloud as “cattle, not pets”-meaning, infrastructure resources should be cared for but replaced when things go wrong. This phrase was coined by Microsoft engineer Bill Baker in 2012 during his presentation on scaling up versus scaling out. The phrase explains how server treatment has changed over time. Gavin McCance later popularized this when he talked about the OpenStack cloud at CERN.

Cattle Model

In the cattle service model, the servers are given identification numbers, like web01, web02, web03, web04, and web05, just as cattle are tagged. Each server is almost identical to the others, and when one gets sick, you replace it with another one. You scale them by creating more of them, and when one is unavailable, no one notices.

Evolution of the Cattle Model

The cattle service model has evolved from the Iron Age (bare-metal rack-mounted servers) to the Cloud Age (virtualized servers that are programmable through a web interface).

  • Iron Age of computing: there was no concept of hardware virtualization. Robust change configuration tools, like Puppet or Chef, allowed operations to configure systems using automation.
  • First Cloud Age: virtualization was extended to offer Infrastructure as a Service (IaaS) that virtualized the entire infrastructure (networks, storage, memory, and CPU) into programmable resources. Popular platforms offering IaaS are Amazon Web Services, Microsoft Azure, and Google Cloud Platform.
  • Second Cloud Age: automation was built to virtualize aspects of the infrastructure. This allows applications to be segregated into isolated environments without the need to virtualize hardware, which in turn duplicates the operating system per application. Examples of this are Linux Containers and Docker.

Introducing vclusters

Diagram of the vcluster architecture
The vcluster architecture

High-Velocity Engineering with vclusters

In the software development and release cycle, the software moves through multiple environments, like local, dev, test, and preproduction, before it’s released to production. These environments should be close to the production environment to avoid any libraries or dependency version conflicts.

How vcluster Works

Each developer gets an individual virtual cluster with full admin access to use however they please. They can change all available configurations, even the Kubernetes version, independently from other users working on the same physical cluster.

Quick Start Guide

vcluster works with any Kubernetes clusters, like Amazon Elastic Kubernetes Service (EKS), Google Cloud, Microsoft Azure, and DigitalOcean. To install the vcluster, here are the prerequisites:

  • kubectl: check via kubectl version command
  • helm v3: check via helm version command
  • a working kube-context with access to a Kubernetes cluster: check via `kubectl get namespaces’ command

1. Download vcluster CLI

vcluster can be downloaded using one of the following commands based on your operating system:

  • Mac (Intel/AMD)
curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-darwin-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster;
sudo mv vcluster /usr/local/bin;
  • Linux (AMD)
curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster;
sudo mv vcluster /usr/local/bin;
  • Windows (PowerShell)
md -Force "$Env:APPDATA\vcluster"; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12';
Invoke-WebRequest -UseBasicParsing ((Invoke-WebRequest -URI "https://github.com/loft-sh/vcluster/releases/latest" -UseBasicParsing).Content -replace "(?ms).*`"([^`"]*vcluster-windows-amd64.exe)`".*","https://github.com/`$1") -o $Env:APPDATA\vcluster\vcluster.exe;
$env:Path += ";" + $Env:APPDATA + "\vcluster";
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User);

2. Verify Installation

To confirm that the vcluster CLI is successfully installed, test using this command:

vcluster --version

3. Create a vcluster

Create a virtual cluster vcluster-1 in namespace host-namespace-1:

# By default vcluster will connect via port-forwarding
vcluster create vcluster-1 -n host-namespace-1 --connect

# OR: Use --expose to create a vcluster with an externally accessible LoadBalancer
vcluster create vcluster-1 -n host-namespace-1 --connect --expose

4. Use the vcluster

Run this in a separate terminal:

export KUBECONFIG=./kubeconfig.yaml

# Run any kubectl, helm, etc. command in your vcluster
kubectl get namespace
kubectl get pods -n kube-system
kubectl create namespace demo-nginx
kubectl create deployment nginx-deployment -n demo-nginx --image=nginx
kubectl get pods -n demo-nginx

5. Clean up resources

vcluster delete vcluster-1 -n host-namespace-1

Conclusion

Using vclusters can help you tackle challenges, like environment setup, configurations, and dependency management, when you use Kubernetes. Virtual clusters give developers secure, flexible, and cost-efficient Kubernetes access without consuming too many resources, thus increasing your organization’s engineering capability.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Loft Labs

Loft Labs

>> www.loft.sh << Build Your Internal Kubernetes Platform With Virtual Clusters, Namespace Self-Service & Secure Multi-Tenancy