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

Vasudev Tadavarthy
Sep 6 · 2 min read

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
Image for post
Image for post
kubernetes nodes status

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

References:

technoVert

Connecting technology to people.

Vasudev Tadavarthy

Written by

Full stack developer | devops | IoT

technoVert

This publication is created for the purpose of sharing tools & solutions used in IoT & Devops space

Vasudev Tadavarthy

Written by

Full stack developer | devops | IoT

technoVert

This publication is created for the purpose of sharing tools & solutions used in IoT & Devops space

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store