How to keep minikube running all the time?

by aglae_feil , in category: General Help , 7 months ago

How to keep minikube running all the time?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by johann , 7 months ago

@aglae_feil 

To keep Minikube running all the time, you can follow the steps below:

  1. Start Minikube: Open a terminal and run the command minikube start. This will start the Minikube cluster and create a new virtual machine where Kubernetes will run.
  2. Keep the terminal open: Minikube runs in the terminal session, so you need to keep the terminal open. If you close the terminal, Minikube will stop running.
  3. Use a terminal multiplexer: Alternatively, you can use a terminal multiplexer like tmux or screen to keep Minikube running even when the terminal session is closed. Here's how to do it with tmux: Install tmux if you don't have it already: sudo apt-get install tmux (for Ubuntu/Debian) or brew install tmux (for macOS/homebrew). Start a new tmux session: Run the command tmux new -s minikube. Start Minikube within the tmux session: Inside the tmux session, run minikube start. Detach from the tmux session: Press Ctrl+b and then d to detach from the tmux session. This will allow Minikube to keep running in the background. Reattach to the tmux session: Whenever you want to interact with Minikube, open a new terminal window and run tmux attach-session -t minikube to reattach to the tmux session.


With either method, Minikube will continue running until you explicitly stop it using minikube stop or by closing the terminal session (if you did not use a terminal multiplexer).

by bobbie.kris , 2 months ago

@aglae_feil 

Additionally, you can configure Minikube to start automatically at system boot by following these steps (for Ubuntu as an example):

  1. Create a Systemd service unit file for Minikube:
1
sudo nano /etc/systemd/system/minikube.service


  1. Add the following content to the file:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[Unit]
Description=Minikube
After=network.target

[Service]
User=<your username>
ExecStart=/usr/local/bin/minikube start
ExecStop=/usr/local/bin/minikube stop
Restart=always

[Install]
WantedBy=multi-user.target


Replace <your username> with your actual username.

  1. Save and close the file by pressing Ctrl + X, Y, and Enter.
  2. Reload the systemd manager configuration:
1
sudo systemctl daemon-reload


  1. Enable the Minikube service to start at system boot:
1
sudo systemctl enable minikube


  1. Start the Minikube service:
1
sudo systemctl start minikube


Now, Minikube will start automatically when the system boots up. You can also manually start, stop, or restart Minikube using the systemd commands like systemctl start minikube, systemctl stop minikube, and systemctl restart minikube.


Remember to adapt these steps accordingly if you are using a different Linux distribution or operating system.