K3s Automation Script for Lightweight Cluster Ops

A streamlined bash automation script for installing, uninstalling, and managing K3s clusters, built for rapid iteration, CKA exam prep, and lightweight Kubernetes experimentation.

K3s Automation Script for Lightweight Cluster Ops

Overview

This project showcases a custom bash script designed to automate the lifecycle of a K3s cluster, from installation to teardown. Built as part of my preparation for the 2025 Certified Kubernetes Administrator (CKA) exam, the script enables fast, repeatable cluster setups ideal for local testing, learning, and experimentation. It leverages official K3s documentation and wraps it into a clean, reusable CLI tool.

---

Challenges & Lessons Learned

  • Repetitive Setup Fatigue: During intensive CKA practice, I found myself reinstalling K3s multiple times a day. Manual steps quickly became a bottleneck.

  • Permission Pitfalls: Managing system permissions and cleanup between installs required careful scripting to avoid lingering artifacts.

  • Need for Speed: Unlike kubeadm, K3s offered a lightweight alternative, but only if setup could be automated and error-free.

  • Solution: I built a bash script that handles install, uninstall, permission fixes, and cluster verification, all in one place. It’s fast, reliable, and based on the official K3s install flow.

---

Script Highlights

  • Install K3s
    (following the official instructions using curl -sfL https://get.k3s.io | sh -)

  • Pulls latest version from official source

  • Configures systemd and permissions

  • Uninstall K3s
    (following the official practice using this script sudo /usr/local/bin/k3s-uninstall.sh)

  • Cleans up binaries, services, and residual configs

  • Reconfigure & Retry

  • Ideal for rapid iteration and testing cluster behaviour

  • Cluster Verification

  • Includes kubectl checks to confirm node readiness

Technologies Used

Project Type

DevOps Automation / Kubernetes Tooling

Project URL

https://github.com/shubbarm/ops-scripts/tree/master/custom-k3s-ops

Related Resources / Blog Posts

Check out other projects below:

View More Projects