Creating Kubernetes cluster in Azure
Hello,
In this article, we will see how to set up a Kubernetes cluster in Azure. For setting cluster we will set up Azure VMs which will act as nodes for the cluster. So let’s start with setup.
Start with creating two VMs one acting as master and the other as worker.
Select a D series VM with a minimum of 2 Vcpus and 8Gib of RAM and Linux OS.
SSH to both VMs and run the below commands (Both Worker and Master Node)
Update the registry
upgrade the registry
Disable the firewall
Remove swap entry
sudo sed –i ‘/swap/d‘ /etc/fstab
Set kernel parameters
net.bridge.bridge–nf–call–iptables = 1
net.bridge.bridge–nf–call–ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sudo systemctl —system
Install certificates
Install Docker
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
Add Kubernetes Repository
curl –fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg –dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo chmod 644 /etc/apt/keyrings/kubernetes–apt–keyring.gpg
Add Repository and install
echo ‘deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /‘ | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list
Update apt and install kubectl, kubeadm and kubelet
sudo apt–get install –y kubeadm kubelet kubectl
Only For Master Node :
Get the IP address of the master node using the below command. Copy IP address for eth0 interface.
Start kubeadm on IP address.
Note: Copy the kubeadm join command from the previous command output.
Export config to KUBECONFIG variable
Create Kubernetes configuration files.
sudo cp –i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id –u):$(id –g) $HOME/.kube/config
Run below command on each worker node.
Run the kubeadm join command copied so that the worker joins the cluster.
—— Example Command ——
Enable Container Network Interface using below command.(Only For Master Node)
Use the cluster using kubectl
kubectl get all –A
Kube join command