Table of contents
Today, in this blog I am going to guide you on how to launch the Kubernetes cluster on Minikube with Nginx pod using Ubuntu VM.
What is minikube?
- minikube is a tool that lets you run Kubernetes locally. minikube runs an all-in-one or a multi-node local Kubernetes cluster on your personal computer (including Windows, macOS and Linux PCs) so that you can try out Kubernetes, or for daily development work.
What is kubectl?
- The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.
System Specification
2 CPUs or more
2GB of free memory
20GB of free disk space
Internet connection
Container or virtual machine manager, such as Docker
For this project, I used Ubuntu 22.04 LTS on AWS. You can run this on your local computer whether it is MacOS, Windows or Linux.
Getting Started
Installation
Update System
- After connecting the system first run update
sudo apt update
Install container manager
- Here I choose Docker. Run the following command to install Docker
sudo apt-get install docker.io docker-compose -y
Install minikube
- To install Minikube in Linux with an x86-64 system copy and paste the following command
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
If your device is different then follow this link: https://minikube.sigs.k8s.io/docs/start/ Here you can find configs for different devices with different specs.
Add docker to the group
- To minicube work with the docker, the current user needs to be added to the docker group.
sudo usermod -aG docker $USER && newgrp docker
Install and Set Up kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- ARM64
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
- Install kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- Verify installation
kubectl version --client --output=yaml
Reboot system
sudo reboot now
After performing these steps, you are ready to launch the application on Kubernetes.
Create Pod
Start the minikube
minikube start
To build a pod, create a pod file with yaml extension.
vim nginx-pod.yml
Copy and paste the below code into the file and save.
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:stable-alpine3.17-slim
ports:
- containerPort: 80
Finally, enter the below command to create the pod.
kubectl apply -f nginx-pod.yml
To verify:
kubectl get pods
The pod is now created.
Conclusion
In this tutorial, we learned how to create a Kubernetes cluster using minikube. we installed docker for container management and kubectl to access the cluster. Also created a pod with the YAML file on the Linux system.