Open In App

How to Deploy a Kubernetes Cluster in Azure Virtual Machines?

Azure Kubernetes Service provides a platform for managing containers with the help of Kubernetes. It also provides an easy and managed way for the deployment and scaling of containerized applications. Containerized applications are deployed in the Kubernetes cluster in Azure. But we can also manually set up a Kubernetes cluster in Azure. Let’s see how to deploy a Kubernetes cluster on Azure VMs.

Primary Terminologies

Deploy Kubernetes Cluster in Azure VM

Step 1: Deploy Azure VM

Step 2: Disable the firewall for VM



ssh username@public-ip

sudo ufw disable

swapoff -a
sudo sed -i '/swap/d' /etc/fstab

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF

sudo sysctl --system

Step 3: Install the certificate applications.

sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Step 4: Install Docker

sudo su

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

apt update

apt install docker.io

Step 5: Install Kubernetes

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list

apt update

apt-get install -y kubelet kubeadm kubectl

Step 6: Initialize cluster and kubeadm (Only for master node)

ip addr

kubeadm init --apiserver-advertise-address=<apiserver-advertise-address-ip> --pod-network-cidr=192.168.0.0/16  --ignore-preflight-errors=all  

export KUBECONFIG=/etc/kubernetes/admin.conf
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://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s-1.11.yaml"

Step 7: Connect The worker node.

Step 8: Verify the cluster.

kubectl get all -A

Conclusion

Thus we have seen how we can install a Kubernetes cluster manually on Azure Virtual machines . This allows to build kubernetes cluster from scratch allowing to manage each component of Kubernetes separately. This can be furthur modified for complex configurations.

How To Deploy a Kubernetes Cluster in Azure (VM)? – FAQ’s

How do I deploy a Kubernetes cluster in Azure using AKS?

You can deploy an AKS cluster using the Azure Portal, Azure CLI, or Azure PowerShell. The process typically involves specifying cluster details, such as resource group, node size, and the number of nodes.

How does AKS handle updates and maintenance?

AKS automates updates to the Kubernetes control plane, ensuring that your cluster is running the latest version. You have control over node pool updates and can configure maintenance windows for minimal disruption.

What is kubeadm?

kubeadm is a command-line utility in Kubernetes that facilitates the process of setting up a Kubernetes cluster. It is part of the Kubernetes project and is designed to simplify the deployment and initialization of Kubernetes master and worker nodes.

What is master and worker node in kubernetes?

The master node is the control plane of the Kubernetes cluster. It is responsible for managing the overall state of the cluster, making decisions about where to schedule applications, and maintaining communication with nodes in the cluster.

Worker nodes are the machines (physical or virtual) where the actual workloads, such as containers and pods, run. These nodes host the applications and services that make up the work of the cluster.

What is kubectl?

kubectl is a command-line tool used to interact with Kubernetes clusters. It is the primary and official command-line interface (CLI) for managing and deploying applications on Kubernetes. With kubectl, users can execute commands against Kubernetes clusters to create, inspect, update, and delete resources.


Article Tags :