kubeadm-vagrant
kubeadm-vagrant copied to clipboard
Setup Kubernetes Cluster with Kubeadm and Vagrant
Setup Kubernetes Cluster with Kubeadm and Vagrant
Introduction
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.
Installation
-
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
- Clone the kubeadm-vagrant repo
git clone https://github.com/cloudnative-tech/kubeadm-vagrant
- For setting up up the Nodes configure the cluster parameters in
.envfile. Refer section below for details of configuration options.
vi .env
- Create a directory to store artifacts created during cluster creation.
mkdir .data
- Spin up the cluster
vagrant up
- This will spin up new Kubernetes cluster. You can check the status of cluster with following command,
- For Master Node
vagrant ssh k8s-master sudo su kubectl get pods --all-namespaces - For Worker Node
vagrant ssh k8s-node-<NodeNumber>
- For Master Node
Cluster Configuration Options
- Generic Properties
BOX_IMAGEis 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.PROVIDERis currently default with "virtualbox" It may change in future with more providers.KUBE_VERSIONis 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_PLUGINis the network plugin you wish to enable with the Kubernetes cluster. Currently it supportscalicoanweave- A secure dashboard is enabled by default. To enable
INSECURE_DASHBOARDcan be used. Set its value toyes- You can login to dashboard using
https://<MASTER_IP>:31443and the.kube/configfile from your vagrant directory.
- You can login to dashboard using
- A Load Balancer IP Pool can be provided with
LB_IPPOOL. The format is the range of IP addresses in your host-only network. - The sandbox by default will install HELM v 3.x. To disable it, update
INSTALL_HELMtono - The sandbox by default will enable operator-sdk and OLM. To disable it, update
ENABLE_OLMtono
- Master Node Properties
- Set
SETUP_MASTERto 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. - Set
MASTER_IPto a preferred value from the subnet of your virtualbox host-only network. - Specify custom
POD_NW_CIDRof your choice for particularNW_PLUGIN - Specify Master node hostname with
MASTER_HOSTNAME - Provide your recommended values for
MASTER_CPUANDMASTER_MEMORY. The minimum values for both are 2 and 2048 respectively.
- Worker Noder Properties
- Set
SETUP_NODESto true/false depending on whether you are setting up worker nodes in the cluster. - Specify
NODE_COUNTas the count of worker nodes in the cluster - Specify
NODE_IP_NWas the network IP which can be used for assigning dynamic IPs for cluster nodes from the same network as Master - Specify Worker node hostname with
NODE_HOSTNAME - Provide your recommended values for
NODE_CPUANDNODE_MEMORY. The minimum values for both are 1 and 1024 respectively.