Beginner's Tutorial: Installing and Using MiniKube
Beginner's Guide to Deploying Kubernetes with MiniKube
Table of Contents
What is Minikube
Installation and setup of Minikube
deploy a first application with minikube
What is Minikube...
As the name suggests, Minikube is a smaller version of Kubernetes that we use to learn and develop Kubernetes.
Minikube is used on a local machine, where a single-node architecture helps in learning and understanding.
Some Features of Minikube:
Local cluster - allows us to test and develop on our local machine
Single-node cluster - master and single-node cluster for easy understanding
Multiple drivers - supports various drivers like VMware, Docker, etc.
Integrated with Kubernetes CLI - we can access kubectl with Minikube
Dashboard - provides a GUI to visually understand each component
Add-ons - bundled with various add-ons like ingress and more
Resource management - allows us to configure resources and memory for the cluster
Installation and Setup
Pre-requisites for minikube installation
2 CPUS or more
2GB of free memory
20GB Free disk space
Docker to be installed and change permission for docker
ubuntu% sudo apt-get install docker.io
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
ubuntu% sudo usermood -aG docker $USER
Minikube installation is completed.
Let's start the cluster now with the minikube start
command.
ubuntu% minikube start
๐ minikube v1.33.1 on Ubuntu 24.04
โจ Using the docker driver based on existing profile
๐ Starting "minikube" primary control-plane node in "minikube" cluster
๐ Pulling base image v0.0.44 ...
๐ Updating the running docker "minikube" container ...
It will take some time to retrieve all files and dependencies for Minikube; once all installations and setup are complete.
Namespace for the application.
A namespace allows us to logically partition resources to organize them properly and avoid collisions between different applications.
Namespaces are useful for separating different environments, projects, teams, or applications within the same cluster
ubuntu% kubectl create namespace demo
Let's check the created namespace with the kubectl get ns
command, we can see here demo namespace is created here
ubuntu% kubectl get ns
NAME STATUS AGE
default Active 162m
demo Active 56s
kube-node-lease Active 162m
kube-public Active 162m
kube-system Active 162m
kubernetes-dashboard Active 149m
ubuntu%
POD Creation and Apply
Now, let's create the first pod in the cluster. Here, I am creating a pod for my application named Slambook.
Creating a Pod involves writing a manifest file, which can be in JSON or YAML syntax. Here, I am using YAML syntax.
apiVersion: v1
kind: Pod
metadata:
name: slambook
namespace: demo
labels:
app: slambook-app
spec:
containers:
- name: slambook-container
image: amittashok/slambook-cicd:latest
ports:
- containerPort: 3000
The type is Pod, as I am creating a manifest file for Pod creation. I am placing this application in my demo namespace with the label slambook-app. In the spec section, we need to provide details of the container to be created in the pod. The name of my container is slambook-container, and the image is pulled from Docker Hub under the name amittashok/slambook-cicd: latest. It will run on port number 3000.
Now, apply this pod manifest file using the command:
ubuntu% kubectl apply -f slambook.yaml
pod/slambook created
ubuntu%
List Pod
Let's check the created pod using the command kubectl get pod
, and it shows the created pod name as slambook.
ubuntu% kubectl get pod
NAME READY STATUS RESTARTS AGE
slambook 1/1 Running 1 (26m ago) 104m
ubuntu%
We can check which pods are running in the created namespace by using the command: kubectl get pods --namespace=<namespace_name>
ubuntu% kubectl get pods --namespace=demo
NAME READY STATUS RESTARTS AGE
slambook 1/1 Running 0 2m33s
ubuntu%
Service file
The service manifest file is a gateway file that tells us how to connect with containers inside a pod. It ensures that traffic should route through the correct Pods.
apiVersion: v1
kind: Service
metadata:
name: slambook-service
spec:
selector:
app: slambook-app
ports:
- protocol: TCP
port: 80
targetPort: 5000
type: NodePort
The type is Service, and the name of the service is slambook-service. The spec section selector ensures that the correct service is attached to the created pods. The protocol is TCP, with port 80 for external connections and targetPort 5000 for routing traffic to the container inside the pod and type NodePort.
To summarize this article, we have seen what Minikube is with installation and setup. Then we delved into how to start and create a cluster. We also checked some important commands used with kubectl for the creation of pods and other tasks.
Thank you for the day...
Seen you soon...