vcluster Inception Video

Transcript

Hi, I’m Rich with Loft Labs. Recently, I did a video introducing our open source virtual cluster tool for Kubernetes called vcluster, which lets you run a virtual cluster entirely within a namespace of your host cluster. During the video, I mentioned that you can actually run a vcluster inside of a vcluster, and I thought I’d show you how this vcluster inception works. Let’s get to a shell and have a look.

$ kubectl create deployment nginx-deployment -n default --image=nginx --replicas=1

deployment.apps/nginx-deployment created
$ vcluster create vc-level-2 -n level2

[info] Creating namespace level2
[info] execute command: helm upgrade vc-level-2 vcluster --repo https://charts.loft.sh --kubeconfig /var/folders/gy/d3_c4t1x731_hl8qtrfkhr_h0000gn/T/525221466 --namespace level2 --install --repository-config='' --values /var/folders/gy/d3_c4t1x731_hl8qtrfkhr_h0000gn/T/595064305
[done] √ Successfully created virtual cluster vc-level-2 in namespace level2. Use 'vcluster connect vc-level-2 --namespace level2' to access the virtual cluster
$ kubectl get pods -n level2

NAME READY STATUS RESTARTS AGE
vc-level-2-0 0/2 Pending 0 2s
$ vcluster connect vc-level-2 -n level2

[info] Waiting for vCluster to come up...
[done] √ Virtual cluster kube config written to: ./kubeconfig.yaml. You can access the cluster via `kubectl --kubeconfig ./kubeconfig.yaml get namespaces`
[info] Starting port forwarding: kubectl port-forward --namespace level2 vc-level-2-0 8443:8443
Forwarding from 127.0.0.1:8443 -> 8443
Forwarding from [::1]:8443 -> 8443
$ export KUBECONFIG=./kubeconfig.yaml
$ kubectl get namespaces

NAME STATUS AGE
default Active 15m
kube-system Active 15m
kube-public Active 15m
kube-node-lease Active 15m

$ kubectl get pods

No resources found in default namespace.
$ kubectl create deployment nginx-deployment -n default --image=nginx --replicas=2

deployment.apps/nginx-deployment created

$ kubectl get pods

NAME READY STATUS RESTARTS AGE
nginx-deployment-84cd76b964-kp4w6 0/1 ContainerCreating 0 1s
nginx-deployment-84cd76b964-78wnp 0/1 ContainerCreating 0 1s
$ vcluster create vc-level-3 -n level3

[info] Creating namespace level3
[info] execute command: helm upgrade vc-level-3 vcluster --repo https://charts.loft.sh --kubeconfig /var/folders/gy/d3_c4t1x731_hl8qtrfkhr_h0000gn/T/088217689 --namespace level3 --install --repository-config='' --values /var/folders/gy/d3_c4t1x731_hl8qtrfkhr_h0000gn/T/968839140
[done] √ Successfully created virtual cluster vc-level-3 in namespace level3. Use 'vcluster connect vc-level-3 --namespace level3' to access the virtual cluster
$ vcluster connect vc-level-3 -n level3 --local-port=8444

[info] Waiting for vCluster to come up...
[done] √ Virtual cluster kube config written to: ./kubeconfig.yaml. You can access the cluster via `kubectl --kubeconfig ./kubeconfig.yaml get namespaces`
[info] Starting port forwarding: kubectl port-forward --namespace level3 vc-level-3-0 8444:8443
Forwarding from 127.0.0.1:8444 -> 8443
Forwarding from [::1]:8444 -> 8443
$ export KUBECONFIG=./kubeconfig.yaml
$ kubectl create deployment nginx-deployment -n default --image=nginx --replicas=3

deployment.apps/nginx-deployment created

$ kubectl get pods

NAME READY STATUS RESTARTS AGE
nginx-deployment-84cd76b964-czlpz 0/1 ContainerCreating 0 3s
nginx-deployment-84cd76b964-l292w 0/1 ContainerCreating 0 3s
nginx-deployment-84cd76b964-ph79t 0/1 ContainerCreating 0 3s
$ export KUBECONFIG=~/.kube/config
$ kubectl get pods --all-namespaces

NAMESPACE NAME READY STATUS RESTARTS AGE
default nginx-deployment-84cd76b964-64tbh 1/1 Running 0 24m
kube-system coredns-f9fd979d6-mlctd 1/1 Running 0 77m
kube-system coredns-f9fd979d6-pgnh8 1/1 Running 0 77m
kube-system etcd-docker-desktop 1/1 Running 0 76m
kube-system kube-apiserver-docker-desktop 1/1 Running 0 76m
kube-system kube-controller-manager-docker-desktop 1/1 Running 0 76m
kube-system kube-proxy-j42rb 1/1 Running 0 77m
kube-system kube-scheduler-docker-desktop 1/1 Running 0 76m
kube-system storage-provisioner 1/1 Running 0 77m
kube-system vpnkit-controller 1/1 Running 0 77m
level2 coredns-66c464876b-bg95z-x-kube-system-x-vc-level-3--e33a70f289 1/1 Running 0 8m56s
level2 coredns-66c464876b-gl66g-x-kube-system-x-vc-level-2 1/1 Running 0 24m
level2 nginx-deployment-84cd76b964-78wnp-x-default-x-vc-level-2 1/1 Running 0 9m17s
level2 nginx-deployment-84cd76b964-czlpz-x-default-x-vc-lev-af1154c6f7 1/1 Running 0 9s
level2 nginx-deployment-84cd76b964-kp4w6-x-default-x-vc-level-2 1/1 Running 0 9m17s
level2 nginx-deployment-84cd76b964-l292w-x-default-x-vc-lev-91ce9ee9e0 1/1 Running 0 9s
level2 nginx-deployment-84cd76b964-ph79t-x-default-x-vc-lev-5cdee9fab0 1/1 Running 0 9s
level2 vc-level-2-0 2/2 Running 0 24m
level2 vc-level-3-0-x-level3-x-vc-level-2 2/2 Running 0 9m9s

--

--

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

637 Followers

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