Setup Kubernetes Cluster with Kubeadm and Vagrant
With reference to steps listed at Using kubeadm to Create a Cluster for setting up the Kubernetes cluster with kubeadm. I have been working on an automation to setup the cluster. The result of it is kubeadm-vagrant, a github project with simple steps to setup your kubernetes cluster with more control on vagrant based virtual machines.
Download and install Vagrant specific to your OS
Install few Vagrant plugins required for setting it up.
vagrant plugin install vagrant-hostmanager
vagrant plugin install vagrant-hosts
vagrant plugin install vagrant-env
git clone https://github.com/cloudnative-tech/kubeadm-vagrant
.env
file. Refer section below for details of configuration options.vi .env
mkdir .data
vagrant up
vagrant ssh k8s-master
sudo su
kubectl get pods --all-namespaces
Cluster Configuration Options
vagrant ssh k8s-node-<NodeNumber>
BOX_IMAGE
is currently default with “generic/ubuntu1804” box which is custom box created which can be used for setting up the cluster with basic dependencies for kubernetes node.PROVIDER
is currently default with “virtualbox” It may change in future with more providers.KUBE_VERSION
is the version of Kubernetes cluster you want to set up with. The main branch will always have the latest available versions. You can find older versions in the releases.NW_PLUGIN
is the network plugin you wish to enable with the Kubernetes cluster. Currently it supports calico
an weave
INSECURE_DASHBOARD
can be used. Set its value to yes
https://<MASTER_IP>:31443
and the .kube/config
file from your vagrant directory.LB_IPPOOL
. The format is the range of IP addresses in your host-only network.INSTALL_HELM
to no
ENABLE_OLM
to no
SETUP_MASTER
to true if you want to setup the node. This is true by default for spawning a new cluster. You can skip it for adding new worker nodes.MASTER_IP
to a preferred value from the subnet of your virtualbox host-only network. POD_NW_CIDR
of your choice for particular NW_PLUGIN
MASTER_HOSTNAME
MASTER_CPU
AND MASTER_MEMORY
. The minimum values for both are 2 and 2048 respectively.SETUP_NODES
to true/false depending on whether you are setting up worker nodes in the cluster.NODE_COUNT
as the count of worker nodes in the clusterNODE_IP_NW
as the network IP which can be used for assigning dynamic IPs for cluster nodes from the same network as MasterNODE_HOSTNAME
NODE_CPU
AND NODE_MEMORY
. The minimum values for both are 1 and 1024 respectively.