kubernetes logo
0 0
Disclosure: This page uses affiliate links.When you click an affliate link,we get a small compensation at no cost to you.Thanks for your support!Learn more
Read Time:4 Minute, 10 Second

In this post, we are going to take look at Lightweight Kubernetes engine k3s that can run on edge, IoT, and appliances. Rancher k3s is great for offline development, prototyping, and testing purpose. You can very well use it on a VM as a small, cheap, reliable k8s for CI/CD.

What is k3s?

k3s is a fully compliant Kubernetes distribution with the following changes:

  1. Packaged as a single binary.
  2. Lightweight storage backend based on sqlite3 is the default storage mechanism. etcd3, MySQL, Postgres also available.
  3. A simple launcher that handles a lot of the complexity of TLS and options.
  4. Secure by default with reasonable defaults for lightweight environments.
  5. Minimal to no OS dependencies. k3s packages require following dependencies
    • containerd
    • Flannel
    • CoreDNS
    • CNI
    • Host utilities (iptables, socat, etc)
    • Ingress controller (traefik)
    • An embedded service load balancer
    • An embedded network policy controller
How it Works ?
Image – How it Works ?

In the next section, we will look at how to install and deploy sample application on to K3s cluster.

Step#1. Install K3s

In the below steps, we would be installing the k3s cluster, it would install a limited set of components like api-server, controller-manager, scheduler, kubelet, cni, kube-proxy.

Pre-requisites

  • k3s is officially supported and tested on the following operating systems but it can run on any of flavor of Linux
  • Minimum recommendations on Hardware
    • RAM: 512MB Minimum
    • CPU: 1 Minimum
  • For detailed installation requirements, please check here.

k3s can be deployed via installation script located at https://get.k3s.io, use the following command to install.

Subscribe to Emails

More than 100,000 subscribers across the world trust & read Upnxtblog articles. Subscribe to emails updates!
* indicates required
curl -sfL https://get.k3s.io | sh -
Image – Install K3s
Check K3s version
Image – Check K3s version

To avoid colliding with a kubectl already installed and to avoid overwriting any existing Kubernetes configuration file, k3s adds a k3s.kubectl command. If you are only using k3s, consider adding an alias command.

Step#2. Verify Installation

At this point you have installed k3s, check whether the newly deployed node is in Ready state using the following command.

Image – Verify Microk8s Installation

Step#3. Deploy sample application

At this point, you have a fully functional Kubernetes cluster. The following command will deploy the Nginx web application.

Top online courses in Office Productivity

kubectl run nginx --image nginx:alpine

Image – Deploy the application

Once Nginx has been deployed, the application can be exposed with the following command.

Recover over 700 unique file formats. Fully recover documents, emails, photos, videos, audio files and more. Supports 8 different data lost scenarios: deleted files recovery, recycle bin recovery, formatted drive recovery, lost partition recovery, externa

k3s kubectl expose deployment nginx \
--port 80 \
--target-port 80 \
--type ClusterIP \
--selector=run=nginx \
--name nginx

Now that services are exposed outside, we can launch lynx a terminal-based web browser to access the Nginx application using the following command.

export CLUSTER_IP=$(k3s kubectl get svc/nginx -o go-template='{{(index .spec.clusterIP)}}')
echo CLUSTER_IP=$CLUSTER_IP
lynx $CLUSTER_IP:80

Nginx app
Image – Nginx app deployed on Microk8s cluster

Congrats! now you have a deployed Nginx application to a fully functional Kubernetes cluster using k3s.

In the next section, we will look at how to install and configure 2-nodes to this k3s cluster.

Step#4. Install Worker nodes

To install on worker nodes and add them to the cluster, run the installation script with the K3S_URL and K3S_TOKEN environment variables.

curl -sfL https://get.k3s.io | K3S_URL=https://<server>:6443 K3S_TOKEN=<token> sh -

Image – Get the server token from the Master node
Image – Install Worker Node #1

Now go back to Master node, check whether the newly deployed node is in Ready state using the following command.

Top online courses in Graphic Design & Illustration
Image – New Worker Node is in Ready State

Install the next worker node and add them to the cluster using the following command:

curl -sfL https://get.k3s.io | K3S_URL=https://<server>:6443 K3S_TOKEN=<token> sh -

Image – Install 2nd Worker Node

Now go back to Master node, check whether the newly deployed node is in Ready state using the following command.

Image – 2nd Worker node is in Ready state

Congrats! now we have fully functional 2-node Kubernetes cluster using K3s.

Like this post? Don’t forget to share it!

Google IT Support Professional Certificate by Grow with Google (300x600) - 2

Useful Resources :

 

About Post Author

Karthik

Allo! My name is Karthik,experienced IT professional.Upnxtblog covers key technology trends that impacts technology industry.This includes Cloud computing,Blockchain,Machine learning & AI,Best mobile apps, Best tools/open source libs etc.,I hope you would love it and you can be sure that each post is fantastic and will be worth your time.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Summary
How to setup 2 node cluster on K3s?
Article Name
How to setup 2 node cluster on K3s?
Description
In this post, we are going to take look at Lightweight Kubernetes engine K3s, we will also look at how to install 2-node and deploy sample application on to this cluster.
Author
Publisher Name
Upnxtblog
Publisher Logo

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.