The kubeadm tool is used to bootstrap smaller Kubernetes clusters so that you can experience all the kubernetes features. The cluster spin-up using kubeadm is eligible to pass the Kubernetes Conformance Program. The cluster life-cycle functions and cluster upgrades are also supported by kubeadm.
If you are getting started with Kubernetes, then this is a perfect start to bootstrapping a cluster using kubeadm. If you want to test two or three node clusters, you can do it on your local machine or workstation by creating a guest operating system. You can automate these commands using any configuration management tool.
You can install kubeadm on your local machine or laptop, any of the cloud servers, or on Arduino, Raspberry Pi, etc.
Now that you have qualified the above prerequisites, you can quickly go to the installation process below. It has been divided into steps; for steps 1–9, you have to run on all the nodes on the cluster.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -`
sudo add-apt-repository "deb [arch=amd64]
https://download.docker.com/linux/ubuntu
$(lsb_release -cs)\
stable
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt update -y
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu kubelet=1.15.7-00 kubeadm=1.15.7-00 kubectl=1.15.7-00
sudo apt-mark hold docker-ce kubelet kubeadm kubectl
sysctl.conf
, so that pods can communicate across nodes,echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
What happens when you run kubeadm init to create a Kubernetes native cluster?
It will first run a set of pre-flight checks that will validate the system state. You might get a specific error or warning at the command line. It will then generate a self-signed certificate, or use one of the existing certificates that have already been provided to set up the identities of different components of the master node. The same certificate will be used by the API-server as other components communicate with it. Next, it will setup the kubeconfig
file into the /etc/kubernetes/
directory for kubelet, controller-manager, the scheduler, etc. Note that these components (like API-server, controller-manager, scheduler) are running inside the pod, and the static pod-manifest file for these pods in the control-plane has already been set-up on the master. So, the respective images will be pulled at this time. The init process will also apply labels and taints to the master node so that no additional workload will ever run there. Next, kubeadm will generate a token. This token can be specified by any nodes to join this cluster. Next, a couple of add-ons are set up on the master node as kube-dns and kube-proxy. Finally, you’ll see the steps to start using your cluster. You need to run the following steps as a regular user along with a join token, which we’ll need to run from the worker node to join the cluster.
kubeconfig
, make sure it is as mentioned in the above command’s output. Run the below commands as a regular user, not with root user (as seen in the above screenshot),mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
sudo kubeadm join [kubeadm_init_token]
kubectl get nodes
Compare this result of the kubectl get nodes
command. Now you have a ready cluster with you to test and deploy any application into the Kubernetes cluster. This is not a recommended way to run the Kubernetes applications into a production environment using kudeadm, but it’s very helpful to understand, learn, and experiment with the Kubernetes cluster.
Free Resources