Install k3s and rancher on ubuntu VM
What is K3S ?
K3s is a lightweight, certified Kubernetes distribution developed by Rancher Labs. It is designed to be a simplified and easy-to-deploy version of Kubernetes that can run in resource-constrained environments, such as edge computing, IoT devices, and small-scale servers.
Key Features of K3s
Lightweight:
K3s is designed to be compact, with a binary size of less than 100 MB. This makes it suitable for environments with limited resources.
It removes some legacy and non-essential features of Kubernetes to streamline the deployment process.
Simplicity:
K3s is easy to install and set up. It simplifies the Kubernetes installation process by packaging all dependencies, including containerd (a container runtime), into a single binary.
It offers a simple command to set up a single-node or multi-node cluster.
Single Binary:
The entire K3s distribution is contained within a single binary, which includes the Kubernetes API server, controller manager, scheduler, and other components, reducing the complexity of managing multiple binaries.
Optimized for Edge and IoT:
K3s is optimized for running on edge devices and IoT environments, where resources are often constrained, and the overhead of a full Kubernetes installation is unnecessary.
SQLite as Default Data Store:
K3s uses SQLite as the default datastore instead of etcd, which reduces the resource requirements and simplifies the setup. However, it can also be configured to use etcd, MySQL, or PostgreSQL for higher availability and scalability.
Reduced Memory and CPU Usage:
By removing unnecessary drivers and alpha features, K3s significantly reduces the memory and CPU overhead compared to a standard Kubernetes installation.
Compatible with Standard Kubernetes:
Despite its lightweight nature, K3s is a fully certified Kubernetes distribution, meaning it passes all CNCF conformance tests and is compatible with standard Kubernetes tools and APIs.
Embedded Networking and Storage:
K3s includes embedded components for networking (like Flannel) and storage (like local-path-provisioner), making it easier to deploy a functional cluster out of the box.
Why use K3S ?
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 <70MB binary that reduces the dependencies and steps needed to install, run and auto-update a production Kubernetes cluster.
Optimized for ARM
Both ARM64 and ARMv7 are supported with binaries and multiarch images available for both. K3s works great on something as small as a Raspberry Pi to an AWS a1.4xlarge 32GiB server.
In this tutorial i will demonstrate how to first install k3s and then install rancher on that k3s.
Prerequisites:
- A virtual machine.
- HELM installed
Install k3s.
NOTE: i am installing the “v1.25.10-rc1+k3s1” version cuz at that time this is the newest allowed for using latest rancher.
curl https://get.k3s.io | INSTALL_K3S_VERSION=v1.25.10-rc1+k3s1 sh -
Install CRD’s
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.crds.yaml
Add the Jetstack HELM repository and update local chart repository cache
helm repo add jetstack https://charts.jetstack.io && helm repo update
Install the cert manager HELM chart
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.5.1
Install RANCHER
- add rancher stable repository and update
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable && helm repo update
2. install the charts
The ” –set global.cattle.psp.enabled=false” required to get rid of the following error:
Error: INSTALLATION FAILED: execution error at (rancher/templates/validate-psp-install.yaml:4:5): The target cluster does not have the PodSecurityPolicy API resource. Please disable PSPs in this chart before proceeding.
REF: https://github.com/rancher/rancher/issues/41295
“–set hostname=rancher.local” add a relevant value to your hosts file.
helm install rancher rancher-stable/rancher \
--namespace=cattle-system \
--create-namespace \
--set hostname=rancher.local \
--set replicas=3 \
--set bootstrapPassword=admin \
--set global.cattle.psp.enabled=false
And then after a couple of minutes you will be able to load the following URL and start the journey…
https://rancher.local
And thats about it…. you have it :>
Below there are additional tutorials of how to install RKE and RKE2 engines on Ubuntu.
Install a single node RKE cluster and deploy rancher as the kubernetes manager.
Install a single node RKE2 cluster and deploy rancher as the kubernetes GUI manager.