What is Kubernetes?
Kubernetes is a free and open source platform built to handle containerized applications, simplifying the process of deploying and managing them over a group of connected machines. It streamlines the scheduling and rollout of applications across various servers. Kubernetes can be intricate, yet Minikube simplifies the initial setup and makes it straightforward to begin working with it.
What is Minikube?
Minikube is a streamlined, single-node Kubernetes setup designed for local development and testing. It enables developers to set up and work with a simplified Kubernetes setup right on their personal computers, making it an ideal tool to explore Kubernetes features without the need for managing a complex, multi-node cluster.
The main purpose of Minikube is to offer a local Kubernetes environment that closely imitates a real production cluster. This small-scale version of Kubernetes allows developers to build their skills and test applications in a manageable, local setting, making it a valuable resource for gaining hands-on experience and experimenting with Kubernetes functionalities.
Prerequisites
- A Virtual Machine (such as the ones provided by NodeShift) with at least:
- 4 vCPUs
- 4GB RAM
- 80GB SSD
- Ubuntu 22.04 VM
- Access to your server via SSH
Step-by-Step process to Install MiniKube on Ubuntu Virtual Machine
For the purpose of this tutorial, we will use a CPU-powered Virtual Machine offered by NodeShift; however, you can replicate the same steps with any other cloud provider of your choice. NodeShift provides the most affordable Virtual Machines at a scale that meets GDPR, SOC2, and ISO27001 requirements.
Step 1: Sign Up and Set Up a NodeShift Cloud Account
- Visit the NodeShift Platform and create an account.
- Once you have signed up, log into your account.
- Follow the account setup process and provide the necessary details and information.
Step 2: Create a Compute Node (CPU Virtual Machine)
NodeShift Compute Nodes offers flexible and scalable on-demand resources like NodeShift Virtual Machines which are easily deployed and come with general-purpose, CPU-powered, or storage-optimized nodes.
- Navigate to the menu on the left side.
- Select the Compute Nodes option.
- Click the Create Compute Nodes button in the Dashboard to create your first deployment.
Step 3: Select a Region and Choose VM Configuration
- In the "Compute Nodes" tab, select a geographical region where you want to launch the Virtual Machine (e.g., the United States).
- In the Choose VM Configuration section, select the number of cores, amount of memory, boot disk type, and size that best suits your needs.
- You will have at least 40 - 80 GB of storage. The disk space should cover the base OS, Minikube, Kubernetes, Docker images, and some application data. If you’re working with larger datasets or multiple containers, consider increasing storage. If you use NodeShift and need more resources, you can always resize to add more CPUs and RAM.
Step 4: Choose an Image
Next, you will need to choose an image for your Virtual Machine. We will deploy the VM on Ubuntu, but you can choose according to your preference. Other options like CentOS and Debian are also available to Install Minikube.
Step 5: Choose the Billing Cycle & Authentication Method
- Select the billing cycle that best suits your needs. Two options are available: Hourly, ideal for short-term usage and pay-as-you-go flexibility, or Monthly, perfect for long-term projects with a consistent usage rate and potentially lower overall cost.
- Select the authentication method. There are two options: Password and SSH Key. SSH keys are a more secure option. To create them, refer to our official documentation.
Step 6: Additional Details & Complete Deployment
- The ‘Finalize Details' section allows users to configure the final aspects of the Virtual Machine.
- After finalizing the details, click the 'Create' button, and your Virtual Machine will be deployed.
Step 7: Virtual Machine Successfully Deployed
You will get visual confirmation that your node is up and running.
Step 8: Connect via SSH
- Open your terminal
- Run the SSH command:
For example, if your username is root, the command would be:
ssh root@ip
- If SSH keys are set up, the terminal will authenticate using them automatically.
- If prompted for a password, enter the password associated with the username on the VM.
- You should now be connected to your VM!
Step 9: Update Your Server
Run the following command to update the server:
Step 10: Install Dependencies
Run the following command to Install the dependencies:
sudo apt install -y apt-transport-https ca-certificates curl
Purpose of the Command
This command ensures that your system can securely download software from HTTPS sources and has the necessary tools (curl) to fetch files from the internet, which is often required for installing tools like Minikube and Docker.
Step 11: Install Docker
Minikube can run using different drivers, but Docker is commonly used. Run the following command to Install the docker:
sudo apt install -y docker.io
sudo systemctl enable --now docker
Docker is an open-source platform that enables developers to build, deploy, run, update and manage containers.
This commands, ensure your user can run Docker commands without sudo by adding it to the docker group:
sudo usermod -aG docker $USER
newgrp docker
Command 1: sudo usermod -aG docker $USER
- sudo: Runs the command with superuser (administrator) privileges.
- usermod: A command to modify user accounts.
- -aG docker: The -a option adds the user to a supplementary group without removing it from other groups. -G docker specifies the group (in this case, docker) to which the user should be added.
- $USER: A variable representing the current logged-in user’s username. Purpose: This command adds the current user to the docker group, giving them permission to run Docker commands without using sudo every time.
Command 2: newgrp docker
- newgrp docker: With this command , make the new group members active immediately without having to log out and log back in. Purpose: When adding a user to a docker group, this command ensures that the current session recognizes other group members, so you do not have to restart your terminal.
Step 12: Install Kubectl
Run the following command to Install the Kubectl:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl, the Kubernetes command-line tool, which Minikube uses to interact with the cluster.
Next, Run the following command to Verify the installation:
kubectl version --client --output=yaml
Step 13: Install Minikube
Run the following command to download the Minikube binary and install it:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
Next, Run the following command to Verify the installation:
Step 14: Create a non-root user
Run the following command to Create a non-root user:
sudo adduser your_username
Then run the following command to add the user to the Docker group to allow it to use Docker without root privileges:
sudo usermod -aG docker your_username
Next, run the following command to log in as the new user:
su - your_username
Step 15: Start Minikube
Run the following command to start Minikube without root privileges:
minikube start --driver=docker
Step 16: Verify Minikube Installation
Run the following command to check the status of Minikube and your Kubernetes cluster:
minikube status
kubectl get nodes
Step 17: Access the Kubernetes Dashboard
Minikube includes a built-in Kubernetes dashboard for visual management. To access it, run the following command:
This will open the Kubernetes dashboard in your default web browser. If you’re working on a remote VM, you may need to forward the port.
Note: However, if you’re running Minikube on a remote VM, this local URL won’t open directly on your local machine.
To access the dashboard from your local machine, you can use SSH port forwarding to tunnel the local URL from the VM to your local system.
Step 18: Access Minikube Dashboard
Open a terminal on your local machine and use SSH port forwarding to access the dashboard. Replace and with the username and IP address of your remote VM. Then, Run the command:
ssh -L 38885:127.0.0.1:38885 <username>@<vm_ip>
For example:
ssh -L 38885:127.0.0.1:38885 nodeshift@84.32.131.29
Run the command on your local machine’s terminal.
Once connected, open the following URL in your local browser to access the Kubernetes dashboard:
http://127.0.0.1:38885/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
Conclusion
Installing Minikube on an Ubuntu virtual machine is straightforward and can be done with dependencies, Docker, and Kubectl. This guide walks you through setting up a NodeShift Cloud account, deploying a CPU-powered VM, and the detailed steps for installing Minikube. With these instructions, you can run Kubernetes on a local machine, creating a single-node cluster in a virtual machine (VM).
For more information about NodeShift:
Top comments (0)