minikube
3 min read
miniKube
What is minikube?
minikube is a tool that quickly sets up a local Kubernetes cluster on macOS, Linux, and Windows. It can deploy as a VM, a container, or on bare metal.
To be precise, it is a one-node Cluster that runs on a virtual box used for testing purposes.
minikube is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes.
This makes it an interesting option for users who are new to containers, and also for projects in the world of edge computing and the Internet of Things.
Features of minikube
Cross-platform (Linux, macOS, Windows)
Deploy as a VM, a container, or on bare-metal
Multiple container runtimes (CRI-O, containers, docker)
Direct API endpoint for blazing-fast image load and build
Advanced features such as LoadBalancer, filesystem mounts, FeatureGates, and network policy
Addons for easily installed Kubernetes applications
Supports common CI environments
Task1: Installation of Minikube
make sure docker is installed in your local environment.
you can install it with this command
sudo apt install docker.io //start docker sudo systemctl start docker
you can verify by running the command
sudo systemctl status docker
Now download minikube binary(for ubuntu 22.04 (it x86-64 architecture) file from the official Kubernetes site: https://minikube.sigs.k8s.io/docs/start/
Now run the following command to install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube
now start minikube with this command
minikube start
it will show on the terminal like this:
minikube comes with kubectl in-build installed which helps us to interact with the containers running on minikube.
minikube CLI -> used to start/delete the cluster
kubectl CLI -> used to configure the minikube cluster
Task2: Launching a nginx pod on minikube
Start by ensuring that Minikube is running. Open a terminal or command prompt and start Minikube by running the following command: minikube start
Once Minikube is running, you can create an nginx pod using a YAML manifest. Create a file called
nginx-pod.yaml
and open it in a text editor. Paste the following YAML configuration into the file:Kubernetes will create the pod based on the manifest. You can check the status of the pod by running:
kubectl get pods
You should see the
nginx-pod
list with a status of "Running".To access the nginx service running inside the pod, you need to expose the pod as a service. You can use the following command:
kubectl expose pod nginx-pod --type=NodePort --port=80
#NOTE
here, an error can be shown if the nginx-pod is not labeled.
make sure under the metadata add a labels section with the app: nginx.
apiVersion: v1 kind: Pod metadata: name: nginx-pod labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80
To get the URL to access the nginx service, run the following command:
minikube service nginx-pod --url
congratulation!!💜we have created an Nginx pod in minikube.
Happy learning!