K3s: Lightweight Kubernetes
Super Simple Cluster Creation
If you are studying for one of the Kubernetes certification exams or if you simply want to learn more about how Kubernetes works, this article is for you.
A quick way to spin up a Kubernetes cluster is by using K3s, a lightweight version of Kubernetes created by Rancher Labs.
Why is it called K3s?
[Rancher Labs] wanted an installation of Kubernetes that was half the size in terms of memory footprint. Kubernetes is a 10-letter word stylized as K8s. So something half as big as Kubernetes would be a 5-letter word stylized as K3s. There is no long form of K3s and no official pronunciation.
Let’s Get Started
These steps are being executed on a virtual machine running Ubuntu 20.04, using Parallels software, on a MacBook Pro.
To install K3s, execute the following command.
curl -sfL https://get.k3s.io | sh -
In less than a minute, the cluster is up and running.
Let’s check the status of the control plane.
sudo k3s kubectl get nodes
Take a look at the cluster’s URL info.
More detailed cluster configuration is shown using this command.
Lastly, review the pods and services across all namespaces.
kubectl get pods, services --all-namespaces
Pods? Deployments? Namespaces?
Want to know more?
Go to the official Kubernetes documentation website.
Building Components on K3s
To test the cluster’s functionality, use the following commands and the yaml file to create several pods, replicasets, and deployments, and then verify all workloads are running.
First, create the nginx-deployment.yaml file using this content.
- name: nginx
- containerPort: 80
# Create Multiple Pods
kubectl run nginx --image=nginx
kubectl run redis --image=redis
kubectl run memcached --image=memcached# Create the Deployment
kubectl create -f nginx-deployment.yaml
Verify all workloads are running.
kubectl get all
And Just Like That…
The status of each workload is running as expected, which confirms the cluster is running in a virtualized environment after executing just a few steps.
To continue exploring what else this cluster can do, check the official Kubernetes tutorials at this link.