How do I ssh into the VM for Minikube?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Minikube is a popular tool that enables you to set up a single-node Kubernetes cluster on your local machine. One interesting task you may want to perform is accessing the underlying virtual machine (VM) where Minikube runs. This can be especially useful for debugging or making custom configurations. This article walks you through the process and addresses technical details of using SSH to connect to a Minikube VM.
Understanding Minikube's Architecture
Before diving into execution, it's crucial to understand Minikube's architecture. Minikube starts a VM or a container based on the driver being used. It supports a variety of drivers such as VirtualBox, Docker, Hyper-V, and others. The choice of driver influences how you can SSH into the VM:
- VM Driver: If you are using a VM-based driver like VirtualBox or Hyper-V, Minikube sets up a virtual environment running a Linux kernel.
- Docker Driver: If you are using Docker, Minikube will run a Docker container instead of a full-fledged VM.
The steps to SSH into the VM or the Docker container may differ based on this setup.
Prerequisites
Before attempting to SSH into a Minikube VM, ensure the following:
- Minikube installed: You have Minikube installed and running on your system.
- VM running: Ensure Minikube is up and running using a
minikube startcommand. - SSH client: You have an SSH client installed on your local machine (most Unix-based systems have it by default).
SSH into Minikube VM
The most straightforward method to log into the VM or container is using Minikube's built-in SSH command. Below are the steps and variations for different drivers.
Step-by-Step Guide
- Identify the Driver: Determine the driver you are using with Minikube:
This command will list profiles, allowing you to identify the active driver.
- SSH with Built-In Command: Minikube comes with a built-in SSH feature to simplify accessing its internal VM.
This command seamlessly logs you into the VM, regardless of whether you are using a virtual machine driver or Docker.
- Manually SSH into VM (for more granular control):
- If you need to use SSH directly, typically for VM drivers like VirtualBox, you may need to find the specific SSH port and key:
- Use an SSH command with the identified key and port:
- Exit: After performing the necessary tasks, exit the session using:
Common Issues and Troubleshooting
Even with a straightforward process, you might encounter some issues:
- SSH Key Issues: If you can't connect, ensure the SSH key permissions are set to
600using:
- Driver Issues: If Minikube is not starting properly, ensure the correct drivers are installed and configured.
- Network Issues: Sometimes, firewall settings can prevent SSH access. In such cases, configure firewall rules to open the required SSH port.
Additional Information
Minikube Commands
Here is a table summarizing key Minikube commands relevant to SSH:
| Command | Description |
minikube start | Starts the Minikube VM or container |
minikube stop | Stops the running Minikube instance |
minikube ssh | SSH into Minikube's VM or container |
minikube ip | Displays the IP address of the Minikube VM |
minikube ssh-key | Path to the SSH private key |
minikube profile list | Lists all Minikube profiles |
Conclusion
SSHing into a Minikube environment can be straightforward yet provides deep insights and access to its underlying system for both exploration and debugging. While Minikube offers a convenient built-in SSH command, understanding how to perform the task manually provides additional flexibility, particularly in more customized or constrained environments. With these insights, developers can make the most of Minikube's capabilities and leverage its functionalities to simplify Kubernetes development workflows.
References
Related reading
- How do I ssh to nodes in ACS Kubernetes cluster?
- How do I switch between contexts in K9s when the contexts have already been set up?
- How do I tell if my container is running inside a Kubernetes cluster?
- How do I uninstall minikube on a Mac?
- How do I stop the RabbitMQ server on localhost
- How do I terraform Amazon MSK topics?
- How do I update the args for a Kubernetes deployment
- How do I use minikube's DNS?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.