Local Kubernetes setup

DevOps Enginner
Generally for local setup people use minikube , basically minikube is a lightweight Kubernetes implementation that creates a single-node Kubernetes cluster on your local machine. Minikube is also good in testing and debugging Kubernetes applications.
There are many reasons for using minikube:-
1. It is easy setup in windows, macOS, linux system with few commands that we see further in the blog. Once it is installed, you can start a Kubernetes cluster with a single command.
2. It is portable and lightweight.
3. It has some advanced features such as LoadBalancer, filesystem mounts, FeatureGates, and network policy.
4. Deploy as a VM, a container, or on bare metal.
Prerequisites for installing Minikube
Virtualization Software: Choose one of the following:
VirtualBox (Windows, macOS, Linux)
Hyper-V (Windows)
Docker (Windows, macOS, Linux)
KVM2 (Linux)
Hypervisor Driver: Install the corresponding driver for your virtualization choice.
Kubectl: Install and configure the Kubernetes command-line tool (kubectl).
Internet Connection: Ensure an active internet connection for downloads.
Supported OS: Minikube works on Windows, macOS, and Linux.
Modern CPU: Ensure your CPU supports virtualization technology.
Adequate Resources: Have enough RAM and disk space for Minikube and workloads.
Administrative Privileges: Some drivers may require elevated permissions (e.g., sudo on Linux).
Warning:- If you are trying to use 22.4 version of Ubuntu from AWS then may be this installation shows error, so try to use 20.4 to avoid such error.
Step 1- Update your Linux system
sudo apt update
Step 2 - Install the required package
sudo apt install -y curl wget apt-transport-https
Step 3 - Install the docker
sudo apt install -y docker.io
sudo systemctl enable --now docker
sudo usermod -aG docker $USER && newgrp docker
Then reboot the system by "sudo reboot"
Step 4- Install minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Make it executable and set the path
chmod +x minikube
sudo mv minikube /usr/local/bin/
Step5- Start the minikube
minikube start --driver=docker
Step7 - Check Cluster status
minikube status
you can also use kubectl for intracting with you cluster
sudo snap install kubectl --classic
kubectl get nodes
Check the version of kubectl
kubectl version
Creating 2 different pods and doing some hands-on
vim abhi.yml
kind: Pod
apiVersion: v1
metadata:
name: abhi
spec:
containers:
- name: c00
image: ubuntu
command: ["/bin/bash", "-c", "while true; do echo Hello-Bhupinder; sleep 5 ; done"]
- name: container2
image: ubuntu
command: ["/bin/bash", "-c", "while true; do echo Second Container is still running; sleep 3 ; done"]
restartPolicy: Never

vim sid.yml
paste the yml code sid.yml

then follow some commands
kubectl apply -f sid.yml
kubectl apply -f abhi.yml

kubectl get pods

for deleting the POD
kubectl delete pod sid

For cheking the logs
kubectl logs -f abhi

for container logs
kubectl logs -f abhi -c container2

For listing the IP of POD
kubectl exec abhi -c container2 -- hostname --i

finally, delete the abhi pod also
kubectl delete -f abhi.yml

In conclusion, finally, we have done installation and hands-on in minikube and Kubectl. If you find this content interesting the like it.




