This is a quick and basic setup for a single-master, duo worker node Kubernetes
cluster using VirtualBox to virtualize the nodes. The setup uses vagrant to quickly pull VM images (Ubuntu/Focal64
) and bootstraps the nodes, installing docker
, kubelet
, kubectl
, kubeadm
and the Calico CNI
. This is tested for K8s 1.24.0
and kubectl 1.24.0
.
- Windows (
amd64
) Host Machine Vagrant
(>=2.2.19
): To quickly provision and bootstrap the nodesVirtualBox
(>=6.1.30
): For virtualization of the nodesKubernetes
(>=1.24.0
): Tested on this version- >= 2 CPUs and >= 2 GB RAM per node (configurable in
Vagrantfile
) - Each node must have a unique private IP and hostname on the
VirtualBox
host network. (configurable inVagrantfile
under the keyconfig.vm.network
andconfig.vm.provision
respectively) - The K8s cluster uses the Calico as a node networking solution.
- Ensure that the
VirtualBox
UI is running. - Go to
./kube-master
and runvagrant up
- Ensure that the
kube-master
node is properly setup by runningkubectl get nodes
andkubectl get pods --all-namespaces
, all pods should show1/1
and the master node should beREADY
. - Retrieve the following command using
sudo cat /kubeadm.log
in thekube-master
's directory. Ensure thatsudo
is present when running it on the worker node VMs (steps 5,7).
sudo kubeadm join <NODE_IP>:6443 --token <TOKEN> \
--discovery-token-ca-cert-hash sha256:<HASH>
- Go to
./kube-w1
and runvagrant up
- Run the command from step
4
. - Go to
./kube-w2
and runvagrant up
- Run the command from step
4
. - Go back to
kube-master
and runkubectl get nodes
, all 3 nodes should show asREADY
The vagrant default credentials for the vm are vagrant:vagrant
. This can be configured in the Vagrantfile
. Refer to the Vagrant documentation.
The script will look out for ./id_rsa.pub
in the root directory. If present, the SSH key will be uploaded to all of the nodes.
The
id_rsa.pub
is git ignored and will need to be defined after cloning.
The kube installation script runs when the VM is provisioned and first started up and is called bootstrap-kube-xx.sh
. The bash script takes in 2 positional arguments.
- The hostname to set for the node
- The kubernetes version to install (
1.24.0
|x.x.x
)