What is Kubernetes ?
Kubernetes is an open-source framework for managing containerized workloads (Docker containers in most cases) and services that allow declarative configuration as well as automation. It has a huge and fast expanding ecosystem. Services, support, and tools for Kubernetes are widely available.
This simply means choosing which machine out of a collection of machines to execute containers on. It also handles upgrades to your containers, so if a new version of the application is released , it will gradually start new containers and kill off old ones.
What is K3s and Why ?
K3s: Lite weight kubernetes distribution.
K3s is a single binary that fully implements the Kubernetes API and is less than 40MB in size.
To do so, they got rid of a lot of additional drivers that didn’t need to be in the core and could easily be replaced with add-ons.
K3s is a Kubernetes product that is CNCF (Cloud Native Computing Foundation) certified. This means you can build your YAML to work with a standard “full-fat” Kubernetes cluster, and it will also work with a k3s cluster.
Because of its minimal resource requirements, a cluster can be run on machines with as little as 512MB of RAM. This means that we can run pods on both the master and the nodes.
We can also install it in a fraction of the time it takes to launch a typical Kubernetes cluster because it’s a tiny binary.
We often establish a k3s cluster with a few nodes in under two minutes, allowing you to deploy apps to learn/test at the drop of a hat. Its reputation and adoption are rapidly expanding as well.
- Perfect for Edge
- K3s is a highly available, certified Kubernetes distribution designed for production workloads in unattended, resource-constrained, remote locations or inside IoT appliances.
- Simplified & Secure
- K3s is packaged as a single <50MB binary that reduces the dependencies and steps needed to install, run and auto-update a production Kubernetes cluster.
How to configure and setup k3s using k3sup:
K3sup : K3sup is a lightweight program for getting from zero to KUBECONFIG with k3s. To acquire kubectl access right away, all you need is ssh access and the k3sup program. The application is written in Go and can be run on Linux, Windows, MacOS, and even Raspberry Pi.
Prerequisites for k3sup servers and agents:
Some Linux hosts are set up so that you can execute sudo without having to retype your password. If you want to use k3sup, you’ll need to make the following adjustments if your system isn’t already set up that way.
# sudo visudo
# Then add to the bottom of the file
# replace "alex" with your username i.e. "ubuntu"
alex ALL=(ALL) NOPASSWD: ALL
This step is usually not required for cloud images for Ubuntu and other distributions.
Do not forget to allow the local machine’s public ssh key in k3s server and worker nodes.
For the master node, I spin up one T2 small EC2 instance in AWS and one T2 medium EC2 instance.
Inbound Rules for K3s Server Nodes:
Protocol | Port | Source | Description |
---|---|---|---|
TCP | 6443 | K3s Agent Nodes | Kubernetes API Server |
UDP | 8472 | K3s Server & Agent Nodes |
Required only for Flannel VXLAN |
TCP | 10250 | K3s Server & Agent Nodes |
Kubelet metrices |
Install k3sup on the local machine:
# curl -sLS https://get.k3sup.dev | sh
# sudo install k3sup /usr/local/bin/
# k3sup --help
Install k3s server using k3sup:
# k3sup install --ip x.x.x.x --user ubuntu
Note: x.x.x.x is public ip address of ec2 instance
We can join and add worker-nodes as needed.
To join k3s worker nodes to k3s server:
# k3sup join --ip x.x.x.x --server-ip y.y.y.y --user ubuntu
Note: Here x.x.x.x is public ip address of worker node-01 and y.y.y.y is public ip address of master node
After installation:
# export KUBECONFIG=\`pwd\`/kubeconfig
# kubectl get node
Kube system resource location in k3s:
- Kubeconfig: /etc/rancher/k3s/k3s.yaml
- master node token: /var/lib/rancher/k3s/server/node-token
We can conclude that k3s is a lightweight and powerful kubernetes distribution. K3s can handle production workload and it’s super easy and fast to configure and setup. With some simple instructions we can get going with deploying our containerized application.
About this article:
This article’s goal is to make readers familiar with kubernetes and k3s and setup k3s quick and easy.
Gurzu is a Ruby on Rails company based in Nepal. Here at Gurzu we transform ideas into world-class products. Our professional team is fluent in 3Rs (Ruby on Rails, React and React Native). We’re ready to design, build and develop something that your users will love. We love building web applications and do so with extreme passion and craftsmanship.
Our services include following. Product Design. Web application development. Mobile application development. Technology trainings. Infrastructure setup and monitoring. Engineers/Designers leasing.