Skip to content

Instantly share code, notes, and snippets.

@joglomedia
Forked from alexellis/kvm_minikube.md
Created August 28, 2021 14:57
Show Gist options
  • Save joglomedia/5bfbed3861a594621e41c015394f130e to your computer and use it in GitHub Desktop.
Save joglomedia/5bfbed3861a594621e41c015394f130e to your computer and use it in GitHub Desktop.
Run multiple minikube Kubernetes clusters on Ubuntu Linux with KVM

Use Ubuntu 16.04 as a base installation.

You'll need nested virtualization enabled or a bare metal machine in the cloud. You can find these at Packet.net or Scaleway.

  • Install KVM

https://www.linux-kvm.org/page/Main_Page

Follow instructions here to install packages from apt.

  • Install kubectl

https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
  • Install minikube and the KVM2 driver
curl -SLO https://github.com/kubernetes/minikube/releases/download/v0.28.2/docker-machine-driver-kvm2
curl -SLO https://github.com/kubernetes/minikube/releases/download/v0.28.2/minikube-linux-amd64

chmod +x docker-machine-driver-kvm2
chmod +x minikube-linux-amd64

sudo mv docker-machine-driver-kvm2 /usr/local/bin
sudo mv minikube-linux-amd64 /usr/local/bin/minikube
  • Create a cluster with kubeadm

Using the kubeadm bootstrapper will enable RBAC

Create your first cluster VM:

minikube start --bootstrapper=kubeadm --vm-driver=kvm2 --memory 4096 --cpus 4 --profile cluster1

You can set up additional separate VMs using the --profile flag.

Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Downloading Minikube ISO
 160.27 MB / 160.27 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Downloading kubeadm v1.10.0
Downloading kubelet v1.10.0
Finished Downloading kubelet v1.10.0
Finished Downloading kubeadm v1.10.0
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

You can manage each cluster using kubectl by switching between contexts saved in ~/.kube/config.yaml. The kubectx tool is also popular in the community for switching between these quickly.

kubectl config get-contexts
CURRENT   NAME       CLUSTER    AUTHINFO   NAMESPACE
*         cluster1   cluster1   cluster1   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment