How to Install K3s: Lightweight Kubernetes
How to Install K3s: Lightweight Kubernetes
K3s is a lightweight Kubernetes distribution designed for resource-constrained environments and edge computing scenarios. It is a perfect fit for developers looking to deploy containerized applications with a minimal footprint. In this tutorial, you will learn how to install K3s on your system step-by-step.
Prerequisites
- A machine or virtual environment running Linux (Ubuntu or CentOS recommended).
- Sudo or root privileges on the system.
- A connection to the internet for downloading necessary packages.
Step 1: Update Your System
Before installing K3s, ensure your system is up-to-date. Run the following commands:
sudo apt update && sudo apt upgrade -y # For Ubuntu
sudo yum update -y # For CentOS
Step 2: Install K3s
Installing K3s is straightforward, thanks to its installer script. Execute the command below in your terminal:
curl -sfL https://get.k3s.io | sh -
This command will download and install K3s, setting it up with default configurations.
Step 3: Verify K3s Installation
Once K3s is installed, verify the installation by checking the service status:
sudo systemctl status k3s
Your K3s service should be active and running.
Step 4: Configure Kubeconfig
K3s provides a kubeconfig file to interact with your Kubernetes clusters. Configure your shell to use it:
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
Verify the Kubernetes nodes with:
kubectl get nodes
Troubleshooting K3s Installation
If you encounter issues, check the logs with:
journalctl -u k3s
Ensure no firewall is blocking the ports used by K3s, primarily port 6443 for API server communication.
Summary Checklist
- Ensure your system is updated.
- Run the K3s installer script.
- Check the K3s service status.
- Configure kubeconfig for managing the cluster.
For detailed network configuration or scaling your deployments with K3s, consult the official K3s documentation (Official site).
Related Articles
Explore other articles like How to Scan Clusters with Kube-hunter for enhancing your Kubernetes security skills.
