Minikube is a tool that makes it easy to run Kubernetes locally. It runs a single-node Kubernetes cluster inside a virtual machine on your computer, allowing you to develop and test your Kubernetes applications without needing a full-blown Kubernetes cluster. In this article, we will guide you through the process of installing Minikube on Ubuntu 20.04.
Prerequisites:
Before starting the installation process, you must have the following prerequisites:- A system running Ubuntu 20.04
- A user account with sudo privileges
- VirtualBox installed on your system
Step 1: Install curl and kubectl
Before installing Minikube, you need to install curl and kubectl. You can do this by running the following commands:
sudo apt update
sudo apt install curl
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 version --client
Step 2: Install Minikube
Once you have installed curl and kubectl, you can install Minikube by running the following commands:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
Step 3: Start Minikube
To start Minikube, run the following command:
minikube start
This will download the necessary ISO file and start a virtual machine with a Kubernetes cluster running inside it. The first time you run this command, it may take a few minutes to complete.
Step 4: Verify Installation
To verify that Minikube is installed and running correctly, you can run the following command:
kubectl get nodes
This command should output information about the Minikube node that is running.
Step 5: Deploy an Application
Now that you have Minikube up and running, you can deploy a sample application to test it out. Here's an example deployment YAML file that you can use:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.17.6
ports:
- containerPort: 80
Save this as nginx-deployment.yaml
and then run the following command to deploy it:
kubectl apply -f nginx-deployment.yaml
This will create a deployment and start a container running the nginx web server.
Step 6: Access the Application
To access the nginx web server that you just deployed, you need to expose it as a service. You can do this by running the following command:
kubectl expose deployment nginx-deployment --type=NodePort --port=80
This will create a service that maps the container port 80 to a random port on the host machine. You can now access the nginx web server by opening a web browser and navigating to http://<minikube ip>:<nodeport>
where <minikube ip>
is the IP address of the Minikube node (which you can get by running minikube ip
) and <nodeport>
is the random port that was assigned to the nginx service.
Related Searches and Questions asked:
That's it for this post. Keep practicing and have fun. Leave your comments if any.
0 Comments