k3s

k3s single-node Kubernetes — installation, service management, containerd, and auto-deploy manifests.

Installation

Install k3s single-node server
curl -sfL https://get.k3s.io | sh -
# kubeconfig at /etc/rancher/k3s/k3s.yaml
# systemd service: k3s.service
Install with options
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable traefik --disable servicelb" sh -
# disable built-in ingress/LB when using alternatives
Copy kubeconfig for kubectl access
mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown "$(id -u)":"$(id -g)" ~/.kube/config
chmod 600 ~/.kube/config

Service Management

Control the k3s service
sudo systemctl status k3s
sudo systemctl restart k3s
sudo systemctl stop k3s
journalctl -u k3s -f                   # follow k3s logs
journalctl -u k3s --since "10 minutes ago"

Cluster Verification

Check cluster health
kubectl get nodes -o wide
kubectl get pods -A                     # all pods in all namespaces
kubectl cluster-info
k3s check-config                        # validate system prerequisites
k3s-specific components
kubectl get pods -n kube-system         # coredns, metrics-server, local-path
kubectl get svc -n kube-system          # cluster services

Containerd (k3s Runtime)

Interact with containerd via k3s crictl
sudo k3s crictl ps                      # list running containers
sudo k3s crictl images                  # list cached images
sudo k3s crictl pull docker.io/library/nginx:1.25-alpine
sudo k3s crictl logs <container-id>
k3s uses containerd, not Docker. Use k3s crictl instead of docker commands for low-level container operations.

Storage

Local-path provisioner (default in k3s)
kubectl get storageclass
# local-path is the default StorageClass
# PVs created at /var/lib/rancher/k3s/storage/ on the node

Manifests Auto-Deploy

Drop manifests for automatic deployment
# k3s watches /var/lib/rancher/k3s/server/manifests/
# Any YAML placed here is automatically applied
sudo cp my-deployment.yaml /var/lib/rancher/k3s/server/manifests/

Uninstall

Clean removal
/usr/local/bin/k3s-uninstall.sh         # server uninstall
/usr/local/bin/k3s-agent-uninstall.sh   # agent uninstall (if joined to cluster)