MiniKube and pod
Minikube:
➢ It is a tool used to setup single node cluster on K8's.
➢ It contains API Servers, ETDC database and container runtime
➢ It helps you to containerized applications.
➢ It is used for development, testing, and experimentation purposes on local.
➢ Here Master and worker runs on same machine It is a platform Independent.
➢ By default it will create one node only.
➢ Installing MiniKube is simple compared to other tools.
➢ NOTE: But we don’t implement this in real-time
MINIKUBE SETUP:
REQUIREMENTS:
✓ 2 CPUs or more
✓ 2GB of free memory
✓ 20GB of free disk space
✓ Internet connection
✓ Container or virtual machine manager, such as: Docker.
1. Update the Server
Update all packages and upgrade to the latest versions:
sudo apt update -y
sudo apt upgrade -y
2. Install Docker
Install necessary packages and install Docker using the official install script:
sudo apt install curl wget apt-transport-https -y
sudo curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Check Docker installation:
docker --version
Add your user to the Docker group to avoid using sudo with Docker:
sudo usermod -aG docker $USER
newgrp docker
3. Install Minikube
Download the latest Minikube binary and move it to your system path:
sudo curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-
amd64
sudo mv minikube-linux-amd64 /usr/local/bin/minikube
sudo chmod +x /usr/local/bin/minikube
Verify Minikube installation:
minikube version
4. Install kubectl (Kubernetes CLI)
Download and install the latest stable version of kubectl:
sudo curl -LO "https://dl.k8s.io/release/$(curl -L -s
https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo curl -LO https://dl.k8s.io/$(curl -L -s
https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256
Verify the integrity of the binary:
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
Install kubectl:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Check kubectl version:
kubectl version --client
kubectl version --client --output=yaml
5. Start Minikube with Docker Driver
Start Minikube using Docker as the container runtime:
minikube start --driver=docker --force
Note: If you skipped adding your user to the Docker group, you may need to run the
above with sudo.
________________________________________
Final Checks
Ensure everything is running:
kubectl get nodes
minikube status
________________________________________
Notes
• This setup is tested on Ubuntu 20.04+ (should also work on Debian-based distros).
• You must have a system that supports virtualization (for Minikube to work).
• Docker must be running before starting Minikube.
KUBECTL:
kubectl is the CLI which is used to interact with a Kubernetes cluster.
We can create, manage pods, services, deployments, and other resources
We can also monitoring, troubleshooting, scaling and updating the pods.
To perform these tasks it communicates with the Kubernetes API server.
It has many options and commands, to work on.
The configuration of kubectl is in the $HOME/.kube directory.
SYNTAX:
kubectl [command] [TYPE] [NAME] [flags]
POD:
It is a smallest unit of deployment in K8's.
It is a group of containers.
Pods are ephemeral (short living objects)
Mostly we can use single container inside a pod but if we required, we can
create multiple containers inside a same pod.
when we create a pod, containers inside pods can share the same network
namespace, and can share the same storage volumes .
While creating pod, we must specify the image, along with any necessary
configuration and resource limits.
K8's cannot communicate with containers, they can communicate with only
pods.
We can create this pod in two ways,
1. Imperative(command)
2. Declarative (Manifest file)
POD CREATION:
IMPERATIVE:
The imperative way uses kubectl command to create pod.
This method is useful for quickly creating and modifying the pods.
SYNTAX: kubectl run pod_name --image=image_name
COMMAND: kubectl run pod-1 --image=nginx
kubect1 : command line tool
run : action
pod-1 : name of pod
nginx : name of image
DECLARATIVE:
The Declarative way we need to create a Manifest file in YAML Extension.
This file contains the desired state of a Pod.
It takes care of creating, updating, or deleting the resources.
This manifest file need to follow the yaml indentation.
YAML file consist of KEY-VALUE Pair.
Here we use create or apply command to execute the Manifest file.
nginx-pod.yml
SYNTAX: kubectl create/apply -f file_name
CREATE: if you are creating the object for first time we use create only.
APPLY: if we change any thing on files and changes need to apply the resources.
apiVersion: For communicating with master node
Kind: it is a type of resource
Metadata: data about pod
Spec: it is a specifications of a container
Name: Name of the Container
Image: Conatiner image
Ports: To Expose the Application
- : It is called as Array