Cloud Native 12 min read

Why Choose K3s? A Quick Guide to Building a Lightweight Kubernetes Cluster

This article introduces K3s, the CNCF‑certified lightweight Kubernetes distribution, explains its core features, walks through installing a local cluster, adding nodes, deploying an Nginx service with ingress, and compares K3s to full‑size K8s to help decide when to use it.

Open Source Linux
Open Source Linux
Open Source Linux
Why Choose K3s? A Quick Guide to Building a Lightweight Kubernetes Cluster

We know Kubernetes (or K8s) is an open‑source platform for managing containerized workloads and services. It orchestrates pods across a cluster and supports zero‑downtime redeployments and self‑healing containers.

If we want to run K8s on embedded systems or quickly spin up a local cluster with nodes, we can try K3s.

K3s: A Lightweight Kubernetes Distribution

K3s is a CNCF‑certified Kubernetes distribution and Sandbox project, designed for low‑resource environments and maintained by Rancher Labs. It provides a smaller‑overhead Kubernetes setup while integrating most of K8s architecture and functionality.

Reasons K3s is lightweight:

Packaged as a single binary with minimal external dependencies

Low hardware and memory requirements

Can run as a single server with high‑availability options

K3s bundles the standard Kubernetes components into a binary under 100 MB by removing extra drivers, optional volume plugins, and third‑party cloud integrations. It runs on a Linux OS with at least 512 MiB RAM (1 GiB recommended) and one CPU.

The architecture still includes a master server and agent nodes, CoreDNS, an Ingress controller, and a built‑in SQLite database. For HA, external databases such as ETCD, MySQL, or PostgreSQL can be used, and Flannel is the default CNI plugin.

Using K3s

3.1 Installation

Basic installation command: $ curl -sfL https://get.k3s.io | sh - Alternatively, specify a version or combine server options with environment variables, e.g., to disable Flannel:

$ curl -sfL https://get.k3s.io | sh -s - --flannel-backend none

Or set the execution flag directly:

$ INSTALL_K3S_EXEC="--flannel-backend none" k3s server

3.2 Cluster Access

K3s installs a kubeconfig file under /etc/rancher/k3s/k3s.yaml. Export it: export KUBECONFIG=/etc/rancher/k3s/k3s.yaml Or copy it to the default location:

mkdir -p ~/.kube
sudo k3s kubectl config view --raw | tee ~/.kube/config
chmod 600 ~/.kube/config

Check nodes and pods:

kubectl get nodes
kubectl get pods --all-namespaces

The default components include Traefik (Ingress), CoreDNS, Local Path Provisioner, and Helm.

3.3 Adding Nodes

Join a worker node with the same install script, providing the server URL and token:

$ curl -sfL https://get.k3s.io | K3S_URL=https://<node-host>:6443 K3S_TOKEN=mynodetoken sh -

Retrieve the token from the server:

cat /var/lib/rancher/k3s/server/node-token

4. Deploying a Service

Create a simple Nginx deployment with three replicas:

$ kubectl create deployment nginx --image=nginx --port=80 --replicas=3

Verify the pods: $ kubectl get pods Expose the deployment with a ClusterIP service:

$ kubectl create service clusterip nginx --tcp=80:80

Define an Ingress resource to route traffic to the service:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx
  annotations:
    ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx
            port:
              number: 80

Apply the Ingress and access the application via the node’s IP address.

5. K8s vs. K3s Differences

K3s is packaged as a single <100 MB binary, whereas K8s runs multiple components as separate processes. K3s starts a cluster in seconds with fewer resources, supports ARM architectures, and is suitable for edge or CI environments. For complex workloads or large clusters, full K8s may be preferable.

6. Conclusion

K3s offers a lightweight, CNCF‑certified alternative to full Kubernetes, requiring fewer resources and providing a fast setup. It remains compatible with standard K8s YAML, supports high‑availability configurations, and is ideal for testing, edge devices, or resource‑constrained environments.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerKubernetesClusterIngressK3slightweight
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.