DEV Community

Cover image for πŸš€ Part1: Installing MicroK8s on Ubuntu 24.04+: A Lightweight Kubernetes Setup Guide
kamlesh merugu
kamlesh merugu

Posted on

πŸš€ Part1: Installing MicroK8s on Ubuntu 24.04+: A Lightweight Kubernetes Setup Guide

πŸ“‹ What We'll Cover

✨ Create a non-root user

πŸ›‘οΈ Add the user to the sudo group

πŸ” Optionally copy SSH keys for secure access

βœ”οΈ Improve security and verify configuration

These are foundational tasks for a safe, stable, and hacker-resistant server environment πŸ°πŸ”’


❓ Why These Steps Matter

Using the root account all the time is like driving a Ferrari with no seatbelt at full speed β€” fun, but dangerous πŸ˜…

Creating a dedicated user with sudo privilege improves:

πŸ” Security β€” Limits damage from accidental commands

🧾 Accountability β€” Track who did what

πŸ•΅οΈ Auditability β€” Better logging and compliance

βš™οΈ Access control β€” Fine-grained permissions

SSH keys also give you passwordless login, making your workflow smoother and more secure.


πŸ–₯️ Initial Server Access

Connect to your VPS using the credentials provided by your hosting provider:

ssh root@your-server-ip
Enter fullscreen mode Exit fullscreen mode

Once logged in, proceed with the setup below.


πŸ‘€ Create a New User

Run this to create a new user:

sudo adduser username
Enter fullscreen mode Exit fullscreen mode

You'll be asked for:

  • πŸ”‘ Password
  • πŸ“ Optional user info (totally skippable)

To skip all prompts except password:

sudo adduser --gecos "" username
Enter fullscreen mode Exit fullscreen mode

πŸ› οΈ Add the User to the Sudo Group

Grant administrative privileges:

sudo usermod -aG sudo username
Enter fullscreen mode Exit fullscreen mode

Confirm:

groups username
Enter fullscreen mode Exit fullscreen mode

You should see:

username sudo
Enter fullscreen mode Exit fullscreen mode

Boom! Your user now has superpowers ⚑


πŸ”‘ (Optional) Copy Your SSH Key to the Server

πŸ•΅οΈ Check if you already have an SSH key

On your local machine, run:

ls ~/.ssh/id_ed25519.pub
Enter fullscreen mode Exit fullscreen mode

If not, generate one like a pro:

ssh-keygen -t ed25519
Enter fullscreen mode Exit fullscreen mode

πŸ“€ Copy your key to the server

Simplest method:

ssh-copy-id username@your-server-ip
Enter fullscreen mode Exit fullscreen mode

Manual method (ninja mode πŸ₯·):

cat ~/.ssh/id_ed25519.pub | ssh username@your-server-ip "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
Enter fullscreen mode Exit fullscreen mode

πŸ§ͺ Test SSH Login

Test access:

ssh username@your-server-ip
Enter fullscreen mode Exit fullscreen mode

If it logs in without asking for a password β†’ πŸ₯³πŸŽ‰

Your SSH keys are working perfectly.


πŸ”’ (Optional) Disable Password Authentication

⚠️ Warning: Only do this if key authentication works β€” or you might lock yourself out like losing your house keys outside πŸ”‘πŸšͺ

Edit SSH config:

sudo nano /etc/ssh/sshd_config
Enter fullscreen mode Exit fullscreen mode

Set:

PasswordAuthentication no
Enter fullscreen mode Exit fullscreen mode

Reload SSH service:

sudo systemctl reload ssh
Enter fullscreen mode Exit fullscreen mode

πŸ’Ύ Verify Storage & System Resources

Check available disk space:

df -h
Enter fullscreen mode Exit fullscreen mode

Expected output showing your 120GB storage:

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1       118G  2.1G  110G   2% /
Enter fullscreen mode Exit fullscreen mode

Check RAM:

free -h
Enter fullscreen mode Exit fullscreen mode

Expected output showing ~8GB RAM:

              total        used        free
Mem:           7.8G        500M        7.0G
Enter fullscreen mode Exit fullscreen mode

Check CPU cores:

nproc
Enter fullscreen mode Exit fullscreen mode

Should return: 4


πŸ“‹ Summary Checklist

Step Purpose
πŸ‘€ Create user Avoid root login
πŸ›‘οΈ Add sudo group Admin privileges
πŸ”‘ Copy SSH keys Secure access
πŸ§ͺ Test login Prevent lockouts
πŸ”’ Disable password auth Extra hardening
πŸ’Ύ Verify resources Confirm server specs

🎯 Final Thoughts

Once this setup is complete, your 4-core, 8GB RAM, 120GB Ubuntu server is ready for:

🐳 Docker / Podman β€” Container runtime

πŸ”§ Automation scripts β€” Ansible, Terraform

⚑ CI/CD pipelines β€” Jenkins, GitLab CI

☸️ Kubernetes / K3s / MicroK8s clusters β€” Perfect specs for lightweight K8s

πŸ› οΈ DevOps experimentation β€” n8n, ArgoCD, monitoring stacks

Your VPS has enough resources to comfortably run a MicroK8s cluster with multiple services while maintaining good performance.


πŸ”œ What's Next?

Ready to install Kubernetes? πŸš€

πŸ‘‰ Continue to Part 2: Installing MicroK8s on Ubuntu 24.04+

In Part 2, you'll learn how to:

  • ✨ Install MicroK8s via Snap
  • πŸ”’ Configure user permissions
  • 🧰 Enable essential add-ons (DNS, storage, ingress)
  • πŸ§ͺ Verify the cluster is running
  • 🐳 Deploy a test NGINX application
  • πŸ”„ Ensure MicroK8s auto-starts on boot

Let's turn your server into a Kubernetes powerhouse! ☸️

Top comments (0)