Shashikant shah

Monday, 9 June 2025

Install K3s and configuration.

K3s is a lightweight Kubernetes distribution developed by Rancher (now part of SUSE). It is designed to be:




Who Should Use K3s?

  • Developers building Kubernetes-based apps locally

  • Edge & IoT deployments

  • Lightweight clusters for testing or CI/CD

  • Anyone needing Kubernetes with less complexity


1.Install the k3s.

# curl -sfL https://get.k3s.io | sh -

2.Check Cluster Status
k3s kubectl get nodes
k3s kubectl get pods -A  # View all pods across namespaces

# kubectl get pods -A
# kubectl get nodes







 (Optional) Enable kubeconfig for your user.


mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config

3.Deploy an Application

Create a simple deployment:

k3s kubectl create deployment nginx --image=nginx

Expose it with a service:

k3s kubectl expose deployment nginx --type=NodePort --port=80

Find the assigned port:

k3s kubectl get svc nginx

4.Enable Traefik Ingress

K3s comes with Traefik as the default ingress controller. To check its status:

k3s kubectl get pods -n kube-system | grep traefik

You can create an Ingress rule to expose your applications.

 

How to Uninstall K3s?

If you want to remove K3s from your system:

🔸 On the Master Node:

/usr/local/bin/k3s-uninstall.sh

🔸 On Worker Nodes:

/usr/local/bin/k3s-agent-uninstall.sh

 

Local Storage → HostPath (default in K3s).

Flannel  (Default in K3s) → Simple overlay network.

No comments:

Post a Comment