This page describes how to create a minimal on-premises Kubernetes cluster on a workstation using VirtualBox.
You will need to to create 3 virtual machines:
Additional requirements:
sudo
with no passwordCreate a directory and go there:
mkdir my-cluster
cd my-cluster
touch Vagrantfile
Edit Vagrantfile via your favorite IDE or editor. Here is example content:
KUBLR_IP = "172.28.128.10"
MASTER_IP = "172.28.128.11"
WORKER_IP = "172.28.128.12"
MASTER_MEMORY_MB = "5120" #5G
WORKER_MEMORY_MB = "4096" #4G
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.define "kublr" do |kublr|
kublr.vm.network "private_network", ip: KUBLR_IP
kublr.vm.provider "virtualbox" do |vb|
vb.memory = 1536 #1.5G
end
kublr.vm.provision "docker" do |d|
d.run "kublr", # --name kublr
image: "kublr/kublr:1.22.2",
daemonize: true, #-d
restart: "unless-stopped", # --restart=unless-stopped
args: "-p 9080:9080"
end
kublr.vm.provision "shell", inline: "docker exec -i kublr /bin/bash -c 'echo \"KUBLR_HOST=#{KUBLR_IP}:9080\" > /ip.external'; docker restart kublr"
end
config.vm.define "master" do |master|
master.vm.network "private_network", ip: MASTER_IP
master.vm.provider "virtualbox" do |vb|
vb.memory = MASTER_MEMORY_MB
end
end
config.vm.define "worker" do |worker|
worker.vm.network "private_network", ip: WORKER_IP
worker.vm.provider "virtualbox" do |vb|
vb.memory = WORKER_MEMORY_MB
end
end
end
Pay attention to VM IPs:
KUBLR_IP = "172.28.128.10"
MASTER_IP = "172.28.128.11"
WORKER_IP = "172.28.128.12"
Make sure that they belong to a private address space, but not to an existing local network. Vagrant will create a corresponding private network.
Bring up the infrastructure:
vagrant up
It takes a few minutes to create the VMs and install Kublr
Kublr UI will be available at http://172.28.128.10:9080 (with login / password admin
/ kublrbox
)
Go to the Credentials tab and add the SSH private key for the master VM
The key itself is stored in .vagrant/machines/master/virtualbox/private_key
Add the key for the worker VM
It is stored in .vagrant/machines/worker/virtualbox/private_key
Click on Cluster Menu in Left Navigation Menu Bar
Click on Add Cluster
Enter Cluster Name.
Select Provider: Bring Your own Infrastructure
Click the INSTANCES
step.
Use the Master Configuration
section.
Enter master parameters:
vagrant
Vagrantfile
Scroll to the Instance Group
section (default name group1
).
Specify the parameters of the worker node(s) in your group as described below:
vagrant
Vagrantfile
Click the SETUP FEATURES
step.
Leave the following options disabled: Ingress Controller
, Self-Hosted Logging
, Self-Hosted Monitoring
Click the REVIEW AND CREATE
step.
Review the summary and click CONFIRM AND INSTALL
button.
In a few minutes the cluster will be created.