<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Kubernetes cluster creation]]></title><description><![CDATA[Kubernetes cluster creation]]></description><link>https://pranaysblogs.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 08:40:07 GMT</lastBuildDate><atom:link href="https://pranaysblogs.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Kubernetes  Cluster Creation Using Kubeadm]]></title><description><![CDATA[Kubernetes
Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It allows you to manage clusters of nodes efficiently.
In this guide, I'll walk you through...]]></description><link>https://pranaysblogs.hashnode.dev/kubernetes-cluster-creation-using-kubeadm</link><guid isPermaLink="true">https://pranaysblogs.hashnode.dev/kubernetes-cluster-creation-using-kubeadm</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[k8s]]></category><category><![CDATA[#k8scluster]]></category><category><![CDATA[kubeadm]]></category><dc:creator><![CDATA[pranay shegaonkar]]></dc:creator><pubDate>Sat, 01 Mar 2025 14:44:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1740839851816/2685c040-3c3e-4594-a144-ee03c68472bb.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Kubernetes</p>
<p>Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It allows you to manage clusters of nodes efficiently.</p>
<p>In this guide, I'll walk you through setting up a multi-node Kubernetes cluster using <strong>Kubeadm</strong>. I used <strong>EC2 instances (t2.medium)</strong> for both the master and worker nodes.</p>
<hr />
<h2 id="heading-prerequisites"><strong>Prerequisites</strong></h2>
<p>Before we start, make sure you have:</p>
<ul>
<li><p><strong>Two or more Ubuntu 18.04 or higher EC2 instances</strong> (t2.medium recommended)</p>
</li>
<li><p><strong>At least 2GB of RAM and 2 CPU cores per instance</strong></p>
</li>
<li><p><strong>Network connectivity between nodes</strong></p>
</li>
<li><p><strong>Root access</strong> to each server</p>
</li>
</ul>
<hr />
<h2 id="heading-step-1-update-and-install-dependencies-run-on-all-nodes"><strong>Step 1: Update and Install Dependencies (Run on All Nodes)</strong></h2>
<p>Update the package list and install required dependencies to ensure the latest versions are available:</p>
<pre><code class="lang-bash">sudo apt-get update
sudo apt install apt-transport-https curl -y
</code></pre>
<hr />
<h2 id="heading-step-2-install-containerd-run-on-all-nodes"><strong>Step 2: Install Containerd (Run on All Nodes)</strong></h2>
<p>Kubernetes requires a container runtime. We will install <strong>Containerd</strong>, which is a lightweight container runtime:</p>
<pre><code class="lang-bash">sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
<span class="hljs-built_in">echo</span> <span class="hljs-string">"deb [arch=<span class="hljs-subst">$(dpkg --print-architecture)</span> signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu <span class="hljs-subst">$(lsb_release -cs)</span> stable"</span> | sudo tee /etc/apt/sources.list.d/docker.list &gt; /dev/null
sudo apt-get update
sudo apt-get install containerd.io -y
</code></pre>
<h3 id="heading-configure-containerd-run-on-all-nodes"><strong>Configure Containerd (Run on All Nodes)</strong></h3>
<p>Generate and update the default configuration file for <strong>Containerd</strong>:</p>
<pre><code class="lang-bash">sudo mkdir -p /etc/containerd
sudo containerd config default | sudo tee /etc/containerd/config.toml
</code></pre>
<p>Enable <code>SystemdCgroup</code> to ensure better compatibility with Kubernetes:</p>
<pre><code class="lang-bash">sudo sed -i -e <span class="hljs-string">'s/SystemdCgroup = false/SystemdCgroup = true/g'</span> /etc/containerd/config.toml
</code></pre>
<p>Alternatively, you can manually open the configuration file and change the setting:</p>
<pre><code class="lang-bash">sudo nano /etc/containerd/config.toml
</code></pre>
<p>Find the line:</p>
<pre><code class="lang-bash">SystemdCgroup = <span class="hljs-literal">false</span>
</code></pre>
<p>Change it to:</p>
<pre><code class="lang-bash">SystemdCgroup = <span class="hljs-literal">true</span>
</code></pre>
<p>Save and exit (<code>CTRL+X</code>, then <code>Y</code>, then <code>Enter</code>).</p>
<p>Restart <strong>Containerd</strong> to apply changes:</p>
<pre><code class="lang-bash">sudo systemctl restart containerd
</code></pre>
<hr />
<h2 id="heading-step-3-install-kubernetes-run-on-all-nodes"><strong>Step 3: Install Kubernetes (Run on All Nodes)</strong></h2>
<p>Install Kubernetes components <strong>(kubelet, kubeadm, and kubectl)</strong> to set up and manage the cluster:</p>
<pre><code class="lang-bash">curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
<span class="hljs-built_in">echo</span> <span class="hljs-string">'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /'</span> | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
sudo systemctl <span class="hljs-built_in">enable</span> --now kubelet
</code></pre>
<hr />
<h2 id="heading-step-4-disable-swap-run-on-all-nodes"><strong>Step 4: Disable Swap (Run on All Nodes)</strong></h2>
<p>Kubernetes requires swap to be disabled for performance reasons:</p>
<pre><code class="lang-bash">sudo swapoff -a
</code></pre>
<p>To make this change permanent, remove swap entries in <code>/etc/fstab</code>:</p>
<pre><code class="lang-bash">sudo nano /etc/fstab
</code></pre>
<hr />
<h2 id="heading-step-5-enable-kernel-modules-and-sysctl-settings-run-on-all-nodes"><strong>Step 5: Enable Kernel Modules and Sysctl Settings (Run on All Nodes)</strong></h2>
<p>Enable kernel modules and IP forwarding for Kubernetes networking:</p>
<pre><code class="lang-bash">sudo modprobe br_netfilter
sudo sysctl -w net.ipv4.ip_forward=1
</code></pre>
<hr />
<h2 id="heading-step-6-initialize-the-kubernetes-cluster-run-on-master-node-only"><strong>Step 6: Initialize the Kubernetes Cluster (Run on Master Node Only)</strong></h2>
<p>Initialize the cluster using <strong>kubeadm</strong>, specifying a pod network CIDR:</p>
<pre><code class="lang-bash">sudo kubeadm init --pod-network-cidr=10.244.0.0/16
</code></pre>
<p>After initialization, configure <code>kubectl</code> for cluster management:</p>
<pre><code class="lang-bash">mkdir -p <span class="hljs-variable">$HOME</span>/.kube
sudo cp -i /etc/kubernetes/admin.conf <span class="hljs-variable">$HOME</span>/.kube/config
sudo chown $(id -u):$(id -g) <span class="hljs-variable">$HOME</span>/.kube/config
</code></pre>
<hr />
<h2 id="heading-step-7-install-flannel-run-on-master-node-only"><strong>Step 7: Install Flannel (Run on Master Node Only)</strong></h2>
<p>Flannel is a <strong>networking solution</strong> that allows pods to communicate across nodes:</p>
<pre><code class="lang-bash">kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
</code></pre>
<p>Verify that all system pods are running:</p>
<pre><code class="lang-bash">kubectl get pods --all-namespaces
</code></pre>
<hr />
<h2 id="heading-step-8-join-worker-nodes-to-the-cluster-run-on-worker-nodes-only"><strong>Step 8: Join Worker Nodes to the Cluster (Run on Worker Nodes Only)</strong></h2>
<p>After initializing the cluster, the <code>kubeadm init</code> command will output a <strong>join command</strong> similar to this:</p>
<pre><code class="lang-bash">kubeadm join &lt;MASTER_NODE_IP&gt;:6443 --token &lt;TOKEN&gt; --discovery-token-ca-cert-hash sha256:&lt;HASH&gt;
</code></pre>
<p>Run this command on <strong>each worker node</strong> to add it to the cluster.</p>
<p>To verify if worker nodes have successfully joined, run this command on the master node:</p>
<pre><code class="lang-bash">kubectl get nodes
</code></pre>
<hr />
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>Congratulations! 🎉 You have successfully set up a multi-node Kubernetes cluster using <strong>Kubeadm</strong>. You can now deploy applications, set up services, and explore more Kubernetes features!</p>
<p>Let me know if you have any questions!</p>
]]></content:encoded></item></channel></rss>