DEV Community

Balaji Sasikumar
Balaji Sasikumar

Posted on

Autostart Minikube on Ubuntu

So You Want Minikube on Autopilot?

Picture this: the system reboots and—bam!—Minikube is already there, ready to go. No coffee required, no minikube start ritual in the morning. Pure bliss. But Linux needs to know: under whose authority shall this magic commence?

Step 1: Unmask Your Secret Identity

Let’s get personal. Who are you? The all-powerful root, the humble johnny, or the mysterious testsms? To find out, type:

whoami
Enter fullscreen mode Exit fullscreen mode

If your reply is root, you’re basically a wizard. If it’s something else, that’s your user.

Now for your gang affiliation (primary group):

id -gn
Enter fullscreen mode Exit fullscreen mode

Most of the time, your user and group are identical—a bit like Clark Kent and Superman. Remember them! You’ll need both for the systemd spell.

Step 2: Write Your Systemd Spellbook

Open /etc/systemd/system/minikube.service, like so:

sudo nano /etc/systemd/system/minikube.service
Enter fullscreen mode Exit fullscreen mode

Type this incantation (replace test with your actual self—yes, you):

[Unit]
Description=Kickoff Minikube Cluster
After=docker.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/minikube start
RemainAfterExit=true
ExecStop=/usr/local/bin/minikube stop
StandardOutput=journal
User=test
Group=test

[Install]
WantedBy=multi-user.target

Enter fullscreen mode Exit fullscreen mode

This script orders Minikube to start and stop as you (so it doesn’t go rogue and start the Kubernetes world domination from your grandma’s account).

Step 3: Make systemd Notice You

Like poking a sleepy cat, do this to wake up systemd to your new magical file:

sudo systemctl daemon-reload
Enter fullscreen mode Exit fullscreen mode

No, it doesn’t reboot the system. It just reads your new scribblings and mutters “OK, fine.”

Step 4: Flip the Startup Switch

Tell Linux to run Minikube every time it wakes up:

sudo systemctl enable minikube
Enter fullscreen mode Exit fullscreen mode

If you don’t want to wait for your next power nap, you can start it right now:

sudo systemctl start minikube
Enter fullscreen mode Exit fullscreen mode

Step 5: Confirm Your Spell’s Success

Don’t trust magic blindly—check if Minikube is alive:

sudo systemctl status minikube
Enter fullscreen mode Exit fullscreen mode

If you see active (running), congratulations! If you see inactive (dead), it's time to check logs...or sacrifice a rubber duck.


Summary:

Discover your mysterious username and group, write your service file, reload its magic, and enable it! Welcome to hands-free Minikube on Ubuntu. Enjoy your extra five minutes of sleep—Kubernetes is already up and brewing as soon as your computer starts

Top comments (0)