What about doing some hands-on now?
Let's read about minikube and implement k8s in our local machine
What is minikube?
Ans:- Minikube is a tool which quickly sets up a local Kubernetes cluster on macOS, Linux, and Windows. It can deploy as a VM, a container, or on bare-metal.
Minikube is a pared-down version of Kubernetes that gives you all the benefits of Kubernetes with a lot less effort.
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
Ans :-
(a) Supports the latest Kubernetes release (+6 previous minor versions)
(b) Cross-platform (Linux, macOS, Windows)
(c) Deploy as a VM, a container, or on bare-metal
(d) Multiple container runtimes (CRI-O, containerd, docker)
(e) Direct API endpoint for blazing fast image load and build
(f) Advanced features such as LoadBalancer, filesystem mounts, FeatureGates, and network policy
(g) Addons for easily installed Kubernetes applications
(h) Supports common CI environments
ā¢ What is difference between k8s and minikube ?
- Kubernetes (k8s): Kubernetes is a powerful open-source platform designed to automate deploying, scaling, and operating application containers. It is typically used to manage clusters of nodes in production environments, which can span multiple machines and data centers.
Minikube: Minikube is a tool that makes it easy to run Kubernetes locally. It sets up a single-node Kubernetes cluster inside a virtual machine (VM) on your local machine. Minikube is primarily used for development and testing purposes, providing a simplified environment to learn and experiment with Kubernetes , in short minikube is a docker container.
Note :- Minikube is work under dind (docker in docker) principal
Let's understand the concept pod
Ans:-
Pods are the smallest deployable units of computing that you can create and manage in Kubernetes.
A Pod (as in a pod of whales or pea pod) is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers. A Pod's contents are always co-located and co-scheduled, and run in a shared context. A Pod models an application-specific "logical host": it contains one or more application containers which are relatively tightly coupled.
You can read more about pod from here .
Task-01:
Install minikube on your local
For installation, you can Visit this page.
If you want to try an alternative way, you can check this.
There are some types of Installation of K8s
Minikube: Docker Inside Docker (DIND) - Least used in production, easiest to set up.
Kubeadm: Bare-metal tool - Used in production, intermediate setup.
KIND: Kubernetes in Docker
Managed K8s Cluster:
AWS: EKS (Elastic Kubernetes Service)
Azure: AKS (Azure Kubernetes Service)
GCP: GKE (Google Kubernetes Engine)
Installation of Minikube
Launch an AWS instance (t2-medium recommended cause of Minikube need atleast 2 cpu and 4gb ram to run)
Update System Packages:
Update your package lists to make sure you are getting the latest version and dependencies.
sudo apt update
Install necessary packages:
Install some basic required packages.
sudo apt install -y curl wget apt-transport-https
Install and start Docker:
sudo apt install -y docker.io
Give Permission to docker
sudo usermod -aG docker $USER sudo systemctl start docker sudo systemctl enable docker
If you getting error when run docker ps command then run below command before docker ps
sudo chmod 666 /var/run/docker.sock
Install Minikube
First, download the Minikube binary using
curl
:curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Make it executable and move it into your path:
chmod +x minikube sudo mv minikube /usr/local/bin/
Now install kubectl:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Make it executable and move it into your path:
chmod +x kubectl sudo mv kubectl /usr/local/bin/
Start Minikube:
This command will start a single-node Kubernetes cluster inside a Docker container.
minikube start --driver=docker --vm=true
Check Cluster Status
Check the cluster status with:
minikube status
You can also use
kubectl
to interact with your cluster:kubectl get nodes
Stop Minikube
When you are done, you can stop the Minikube cluster with:
minikube stop
Optional: Delete Minikube Cluster
If you wish to delete the Minikube cluster entirely, you can do so with:
minikube delete
Task-02:
Create Your First Pod on Kubernetes through Minikube
Start Minikube (if not running):
minikube start
Create a Pod YAML Manifest:
# first-pod.yml apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80
Create the pod:
kubectl apply -f first-pod.yml
Check pod status:
kubectl get pods
Thankyou for reading !!!!!