<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>how to install kubernetes Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/how-to-install-kubernetes/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Thu, 10 Dec 2020 22:33:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.12</generator>
	<item>
		<title>How To Install Kubernetes Cluster On Ubuntu 20.04 Using K3s</title>
		<link>https://www.osradar.com/how-to-install-kubernetes-cluster-on-ubuntu-20-04-using-k3s/</link>
					<comments>https://www.osradar.com/how-to-install-kubernetes-cluster-on-ubuntu-20-04-using-k3s/#respond</comments>
		
		<dc:creator><![CDATA[sabi]]></dc:creator>
		<pubDate>Sun, 13 Dec 2020 01:40:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[how to install kubernetes]]></category>
		<category><![CDATA[How To Install Kubernetes Cluster On Ubuntu 20.04 Using K3s]]></category>
		<category><![CDATA[how to tutorials]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[Ubuntu 20.04 tutorials]]></category>
		<category><![CDATA[ubuntu k3s kubernetes]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=25995</guid>

					<description><![CDATA[<p>Today we are going to learn that how to install Kubernetes Cluster on Ubuntu 20.04 using K3s. Before proceeding towards the installation process, let&#8217;s have a short introduction about the today article. Introduction: Kubernetes used to manage the docker containers across multiple cloud &#38; virtualization platform. Kubernetes was designed by the Google. And k3s is [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-kubernetes-cluster-on-ubuntu-20-04-using-k3s/">How To Install Kubernetes Cluster On Ubuntu 20.04 Using K3s</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Today we are going to learn that how to install Kubernetes Cluster on Ubuntu 20.04 using K3s. Before proceeding towards the installation process, let&#8217;s have a short introduction about the today article.</p>



<h2>Introduction:</h2>



<p>Kubernetes used to manage the docker containers across multiple cloud &amp; virtualization platform. Kubernetes was designed by the Google. And k3s is used to reduce the higher load of k8sdeployment. So, here we&#8217;ll cover the installation of Kubernetes on Ubuntu 20.04 using k3s.</p>



<h3>Setup Requirements:</h3>



<p>We&#8217;ll need one Master node &amp; the 2 worker nodes in order to perform our installation.</p>



<h4>Master Node:</h4>



<p>It handles the cluster, API calls and other process.</p>



<h4>Workers Node:</h4>



<p>Used to control the workloads, where pods deployed &amp; applications run.</p>



<p>So, here we&#8217;ll be using one Master node &amp; two worker nodes in order to complete our installation guide.</p>



<h3>Step 1: Update Your System</h3>



<p>As usual we do, update your system to have the latest updates installed.</p>



<pre class="wp-block-preformatted">sudo apt update &amp;&amp; sudo apt upgrade -y</pre>



<p>Once the update finished, reboot your system.</p>



<pre class="wp-block-preformatted">sudo systemctl reboot</pre>



<h3>Step 2: Mapping the Hosts On Ubuntu 20.04</h3>



<p>Now, map the master and worker nodes on each host. To do this edit the file <strong>/etc/hosts/</strong>. And update according to hosts IP&#8217;s.</p>



<pre class="wp-block-preformatted">sudo nano /etc/hosts
172.16.10.3 master
172.16.10.4 worker01
172.16.10.10 worker02</pre>



<h3>Step 3: Install Docker On Ubuntu 20.04</h3>



<p>Fire the below commands in your terminal to install docker on Ubuntu 20.04 as needed to use the Kubernetes. So, make sure docker is installed and running properly.</p>



<pre class="wp-block-preformatted">sudo apt update<br>sudo apt install apt-transport-https ca-certificates curl software-properties-common -y<br>curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -<br>sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"<br>sudo apt update<br>sudo apt install docker-ce -y</pre>



<p><strong>Note</strong>: Make sure to perform this action(docker installation) on all hosts.</p>



<p>And then start &amp; enable docker services.</p>



<pre class="wp-block-preformatted">sudo systemctl start docker<br>sudo systemctl enable docker</pre>



<p>Verify the status of docker by typing</p>



<pre class="wp-block-preformatted">sabi@ubuntu:~$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-11-30 08:30:39 CET; 19s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 9275 (dockerd)
Tasks: 8
Memory: 35.6M
CGroup: /system.slice/docker.service
└─9275 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Nov 30 08:30:39 ubuntu dockerd[9275]: time="2020-10-30T08:30:39.460569874+01:00" level=warning msg="Your kernel does not support cgroup rt runtime"
Nov 30 08:30:39 ubuntu dockerd[9275]: time="2020-10-30T08:30:39.460672730+01:00" level=warning msg="Your kernel does not support cgroup blkio weight"
Nov 30 08:30:39 ubuntu dockerd[9275]: time="2020-10-30T08:30:39.460820506+01:00" level=warning msg="Your kernel does not support cgroup blkio weight_device"
Nov 30 08:30:39 ubuntu dockerd[9275]: time="2020-10-30T08:30:39.461286028+01:00" level=info msg="Loading containers: start."
Nov 30 08:30:39 ubuntu dockerd[9275]: time="2020-10-30T08:30:39.620849970+01:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0&gt;
Nov 30 08:30:39 ubuntu dockerd[9275]: time="2020-10-30T08:30:39.717281156+01:00" level=info msg="Loading containers: done."
Nov 30 08:30:39 ubuntu dockerd[9275]: time="2020-10-30T08:30:39.754253372+01:00" level=info msg="Docker daemon" commit=4484c46d9d graphdriver(s)=overlay2 version&gt;
Nov 30 08:30:39 ubuntu dockerd[9275]: time="2020-10-30T08:30:39.755461813+01:00" level=info msg="Daemon has completed initialization"
Nov 30 08:30:39 ubuntu systemd[1]: Started Docker Application Container Engine.</pre>



<p>In order to avoid using sudo whenever you type docker commands, simply add your user to docker group. This can be done by typing.</p>



<pre class="wp-block-preformatted">sudo usermod -aG docker ${USER}<br>newgrp docker</pre>



<h3>Step 4: Setup the Master K3s Node</h3>



<p>First of all we&#8217;ll setup the master node. On this node we&#8217;ll install the k3s sevice. To install k3s hit the given command in your terminal.</p>



<pre class="wp-block-preformatted">curl -sfL https://get.k3s.io | sh -s - --docker</pre>



<p>You&#8217;ll see the similar output:</p>



<pre class="wp-block-preformatted">[INFO] Finding release for channel stable
[INFO] Using v1.18.9+k3s1 as release
[INFO] Downloading hash https://github.com/rancher/k3s/releases/download/v1.18.9+k3s1/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/rancher/k3s/releases/download/v1.18.9+k3s1/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s</pre>



<p>Make sure the installation is successfull.</p>



<pre class="wp-block-preformatted">sudo systemctl status k3s
● k3s.service - Lightweight Kubernetes
Loaded: loaded (/etc/systemd/system/k3s.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-11-30 08:32:46 CET; 53s ago
Docs: https://k3s.io
Process: 11151 ExecStartPre=/sbin/modprobe br_netfilter (code=exited, status=0/SUCCESS)
Process: 11152 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Main PID: 11153 (k3s-server)
Tasks: 0
Memory: 420.9M
CGroup: /system.slice/k3s.service
└─11153 /usr/local/bin/k3s server --docker
Nov 30 08:33:32 ubuntu k3s[11153]: I1030 08:33:32.532935 11153 reconciler.go:196] operationExecutor.UnmountVolume started for volume "helm-traefik-token-dmfz6"&gt;
Nov 30 08:33:32 ubuntu k3s[11153]: I1030 08:33:32.533481 11153 reconciler.go:196] operationExecutor.UnmountVolume started for volume "values" (UniqueName: "kub&gt;
Nov 30 08:33:32 ubuntu k3s[11153]: W1030 08:33:32.533849 11153 empty_dir.go:453] Warning: Failed to clear quota on /var/lib/kubelet/pods/d1fae0b1-f3ac-481a-b6a&gt;
Nov 30 08:33:32 ubuntu k3s[11153]: I1030 08:33:32.538649 11153 operation_generator.go:782] UnmountVolume.TearDown succeeded for volume "kubernetes.io/configmap&gt;
Nov 30 08:33:32 ubuntu k3s[11153]: I1030 08:33:32.555370 11153 operation_generator.go:782] UnmountVolume.TearDown succeeded for volume "kubernetes.io/secret/d1&gt;
Nov 30 08:33:32 ubuntu k3s[11153]: I1030 08:33:32.653113 11153 reconciler.go:319] Volume detached for volume "helm-traefik-token-dmfz6" (UniqueName: "kubernete&gt;
Nov 30 08:33:32 ubuntu k3s[11153]: I1030 08:33:32.653137 11153 reconciler.go:319] Volume detached for volume "values" (UniqueName: "kubernetes.io/configmap/d1f&gt;
Nov 30 08:33:33 ubuntu k3s[11153]: W1030 08:33:33.978774 11153 pod_container_deletor.go:77] Container "23d34e0acde3f4ab7e41d99e9cff16e7ba8cd76122158dfc18b64ae0&gt;
Nov 30 08:33:33 ubuntu k3s[11153]: W1030 08:33:33.997821 11153 pod_container_deletor.go:77] Container "a52fe91aa3e7b137ebe4dd993e358c382f96b5df342cb1c098acadb6&gt;
Nov 30 08:33:35 ubuntu k3s[11153]: W1030 08:33:35.022454 11153 pod_container_deletor.go:77] Container "2b9f302427059276bc2e1d012db5cbcaeb72ed373cb52218edb6eb4b</pre>



<p>Make sure that Master node is running properly.</p>



<pre class="wp-block-preformatted">sudo kubectl get nodes -o wide</pre>



<p>Output:</p>



<pre class="wp-block-preformatted">sabi@ubuntu20:~$ sudo kubectl get nodes -o wide<br>NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME<br>master Ready master 3m2s v1.18.9+k3s1 172.16.10.3 Ubuntu 20.04.1 LTS 5.4.0-52-generic docker://19.3.8</pre>



<h3>Step 5: Allow Firewall Access</h3>



<p>Allow the firewall access to the <strong>443</strong> and <strong>6443</strong> ports in order to start the communication b/w the master &amp; worker nodes.</p>



<pre class="wp-block-preformatted">sudo ufw allow 6443/tcp<br>sudo ufw allow 443/tcp</pre>



<p>Now, run the below command in your terminal to get a tocken from the master node that will be later used on worker node to join the master node.</p>



<pre class="wp-block-preformatted">sudo cat /var/lib/rancher/k3s/server/node-token</pre>



<p>Output:</p>



<pre class="wp-block-preformatted">K1078f2861628c95aa328595484e77f831adc3b58041e9ba9a8b2373926c8b034a3::server:417a7c6f46330b601954d0aaaa1d0f5b</pre>



<h3>Step 6: Install K3s Service On Worker Nodes</h3>



<p>Now, install the k3s service on worker nodes &amp; connect them to the master node.</p>



<pre class="wp-block-preformatted">curl -sfL http://get.k3s.io | K3S_URL=https://&lt;master_IP&gt;:6443 K3S_TOKEN=&lt;join_token&gt; sh -s - --docker</pre>



<p><strong>master_IP</strong>: IP of Master Node<br><strong>join_token</strong>: Token generated on Master Node in above step.</p>



<pre class="wp-block-preformatted">curl -sfL http://get.k3s.io | K3S_URL=https://172.16.10.3:6443 K3S_TOKEN=K1078f2861628c95aa328595484e77f831adc3b58041e9ba9a8b2373926c8b034a3::server:417a7c6f46330b601954d0aaaa1d0f5b sh -s - --docker</pre>



<p>Make sure that k3s-agent is running properly on worker nodes by typing.</p>



<pre class="wp-block-preformatted">sudo systemctl status k3s-agent</pre>



<p>Fire the given command to verify that worker nodes are added to cluster.</p>



<pre class="wp-block-preformatted">sudo kubectl get nodes</pre>



<p>You&#8217;ll see the similar output upon success.</p>



<pre class="wp-block-preformatted">sabi@ubuntu20:~$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master Ready master 14m v1.18.9+k3s1 172.16.10.3 Ubuntu 20.04.1 LTS 5.4.0-52-generic docker://19.3.8
worker02 Ready 90s v1.18.9+k3s1 172.16.10.10 Ubuntu 20.04.1 LTS 5.4.0-52-generic docker://19.3.8
worker01 Ready 41s v1.18.9+k3s1 172.16.10.4 Ubuntu 18.04.5 LTS 4.15.0-122-generic docker://19.3.6</pre>



<h4>Install Helm CLI Tool On k3s</h4>



<p>Visit the <a href="https://github.com/helm/helm/releases" target="_blank" rel="noreferrer noopener">link</a> to download the latest version of Helm.</p>



<p>And extract the <strong>downloaded file</strong> with the help of tar.</p>



<pre class="wp-block-preformatted">tar -xvcf &lt;downloaded-file&gt;</pre>



<p>Then move the binary file to <strong>/usr/local/bin/helm</strong></p>



<pre class="wp-block-preformatted">mv linux-amd64/helm /usr/local/bin/helm</pre>



<p>Verify the version</p>



<pre class="wp-block-preformatted">heml version</pre>



<p>Finally add helm repo in order to allow installation with helm.</p>



<pre class="wp-block-preformatted">helm repo add stable https://charts.helm.sh/stable<br>helm repo update</pre>



<h4>Deploy Application On K3s</h4>



<p>Here we&#8217;ll add Nginx as test purposes.</p>



<p>Run the below command to install nginx using helm</p>



<pre class="wp-block-preformatted">helm install nginx-ingress stable/nginx-ingress --namespace kube-system \<br>--set defaultBackend.enabled=false</pre>



<p>Verify the added application by typing</p>



<pre class="wp-block-preformatted">kubectl get pods -n kube-system -l app=nginx-ingress -o wide</pre>



<pre class="wp-block-preformatted">sabi@ubuntu20:~$<strong> kubectl get pods -n kube-system -l app=nginx-ingress -o wide
</strong>NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-ingress-controller-56547fb57-vsjdm 1/1 Running 0 28s 10.42.2.6 worker01</pre>



<p>So, it shows that we&#8217;ve successfully deployed nginx on k3s.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="845" height="71" src="//1081754738.rsc.cdn77.org/wp-content/uploads/2020/12/2020-11-30_22h47_27.png" alt="How To Install Kubernetes Cluster On Ubuntu 20.04 Using K3s" class="wp-image-26215" srcset="https://www.osradar.com/wp-content/uploads/2020/12/2020-11-30_22h47_27.png 845w, https://www.osradar.com/wp-content/uploads/2020/12/2020-11-30_22h47_27-300x25.png 300w, https://www.osradar.com/wp-content/uploads/2020/12/2020-11-30_22h47_27-768x65.png 768w, https://www.osradar.com/wp-content/uploads/2020/12/2020-11-30_22h47_27-696x58.png 696w" sizes="(max-width: 845px) 100vw, 845px" /></figure>



<h3>Removing K3s</h3>



<p>In order to remove k3s on the worker nodes, hit</p>



<pre class="wp-block-preformatted">sudo /usr/local/bin/k3s-agent-uninstall.sh<br>sudo rm -rf /var/lib/rancher</pre>



<p>To remove k3s on master node, type</p>



<pre class="wp-block-preformatted">sudo /usr/local/bin/k3s-uninstall.sh<br>sudo rm -rf /var/lib/rancher</pre>



<p>So, this is how you can install kubernetes on Ubuntu 20.04 using k3s.</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-kubernetes-cluster-on-ubuntu-20-04-using-k3s/">How To Install Kubernetes Cluster On Ubuntu 20.04 Using K3s</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/how-to-install-kubernetes-cluster-on-ubuntu-20-04-using-k3s/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
