Setting up Kubernetes cluster on Azure using Kubeadm, Terraform & Ansible- Part 2

Vasudev Tadavarthy
Cloud Smiths
Published in
2 min readSep 6, 2020

This is the second part of the two-part series in continuation to part-1 showing how to set up K8s cluster on Azure VMs with ansible using kubeadm utility. Before we dive into setting up the K8s, let’s get some understanding about Ansible.

Ansible

What is Ansible? Ansible is open-source infrastructure automation software, used for IT tasks such as configuration management, application deployment, and provisioning.

How does it work? Ansible works by transferring code/ scripts, called “Ansible modules” to remote nodes using SSH or Winrm. These pieces of instructions are written in a declarative way. Ansible then executes these modules and deletes them when the execution of these scripts are completed.

Kubeadm tool

Now that we kinda know what ansible is, we will ansible scripts to setup K8s with the help kubeadm utility. kubeadm performs the actions necessary to get a minimum viable cluster up and running. kubeadm can also be used for other cluster management activities, such as cluster upgrades and authentication token creation.

Enough of theory, let’s get started with actually spinning up K8s by running ansible scripts. The ansible code and instructions to set up the base infrastructure is available in the following repository

An Ansible playbook is an organized unit of scripts that defines work for a server configuration managed by the automation tool Ansible. Let’s see the list of playbooks we have to run in the current setup under the “k8s/ansible/playbooks” folder. K8s is ready to serve applications, once you run these playbooks in the order specified below:

  1. prerequisites.yml: Disabling swap is meant to fully use of system resources and for better performance.
  2. setting_up_nodes.yml: Configuring network drivers, downloading & installing docker daemon, downloaded & installing kubelet & kubeadm.
  3. configure_master_node.yml: Downloading required control plane docker images, creating kube config file & starting pod network.
  4. configure_worker_nodes.yml: Joining worker nodes with Kubernetes master node.

To check the status of the cluster, use the following command and you should see the following output.

$ kubectl get nodes -o wide
kubernetes nodes status

Voila, your single master K8s cluster is up & ready. This is the end of the 2-part series.

References:

--

--