Let's read about minikube and implement k8s in our local machine.
What is minikube?
Minikube serves as a convenient solution for swiftly establishing local Kubernetes clusters on macOS, Linux, and Windows operating systems. Whether deployed as a VM, a container, or on bare-metal, Minikube streamlines the Kubernetes setup process, offering users the advantages of Kubernetes with minimal complexity.
This tool is especially beneficial for newcomers to container technology and for projects exploring edge computing and the Internet of Things (IoT). Its versatility across platforms and simplified configuration make it an accessible option for a diverse range of users seeking to experiment, develop, or test Kubernetes-based applications.
Features of minikube
Minikube supports the latest Kubernetes release along with several previous minor versions.
It is cross-platform, functioning seamlessly on Linux, macOS, and Windows.
Users can deploy Minikube as a VM, a container, or directly on bare-metal infrastructure.
Minikube offers support for multiple container runtimes including CRI-O, containerd, and docker.
It provides a direct API endpoint for rapid image load and build processes.
Advanced features such as LoadBalancer, filesystem mounts, FeatureGates, and network policy configurations are available.
Minikube offers various addons for the easy installation of Kubernetes applications.
It supports integration with common Continuous Integration (CI) environments, facilitating streamlined development workflows.
Task 1: Install Minikube on Your Local Machine
Step 1: Update System Packages
Update your package lists to make sure you are getting the latest version and dependencies.
sudo apt update
Step 2: Install Required Packages
Install some basic required packages.
sudo apt install -y curl wget apt-transport-https
Step 3: Install Docker
Minikube can run a Kubernetes cluster either in a VM or locally via Docker. This guide demonstrates the Docker method.
sudo apt install -y docker.io
Start and enable Docker.
sudo systemctl enable --now docker
Add current user to docker group (To use docker without root)
sudo usermod -aG docker $USER && newgrp docker
Now, logout (use exit
command) and connect again.
Step 4: 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/
Step 5: Install kubectl
Download kubectl, which is a Kubernetes command-line tool.
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Check above image ⬆️ Make it executable and move it into your path:
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
Step 6: Start Minikube
Now, you can start Minikube with the following command:
minikube start --driver=docker
This command will start a single-node Kubernetes cluster inside a Docker container.
Step 7: Check Cluster Status
Check the cluster status with:
minikube status
You can also use kubectl
to interact with your cluster:
kubectl get nodes
Step 8: 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
Understanding Pods in Kubernetes
Pods serve as the fundamental building blocks within the Kubernetes ecosystem. Think of a Pod as the smallest unit of deployment, encapsulating one or more containers along with shared resources for storage and networking.
In Kubernetes terminology, a Pod draws its inspiration from natural entities like pods of whales or pea pods. Just as these entities coexist in a shared environment, containers within a Pod share the same context and resources. This shared context enables them to operate seamlessly together.
Each Pod in Kubernetes represents a logical host for a specific application. It orchestrates one or more application containers, fostering tight coupling and efficient resource utilization.
In essence, Pods embody the core principles of Kubernetes, facilitating the seamless deployment and management of containerized workloads
Task-02: Create your first pod on Kubernetes through minikube.
Now that Minikube is running, let's create our first pod using Kubernetes. We'll start with a simple NGINX pod to serve as our introductory example:
Create a YAML Configuration File: Open your vim text editor and create a file named
nginx-pod.yaml
. Copy and paste the following YAML configuration into the file:yamlCopy codeapiVersion: v1 kind: Pod metadata: name: nginx-pod spec: containers: - name: nginx-container image: nginx:latest ports: - containerPort: 80
This configuration defines a pod named
nginx-pod
running a single container based on the NGINX image, exposing port 80.Apply the Configuration: Save the
nginx-pod.yaml
file and apply the configuration to your Minikube cluster using the following command:Copy codekubectl apply -f nginx-pod.yaml
Kubernetes will create the NGINX pod based on the configuration provided in the YAML file.
Verify Pod Creation: To confirm that the NGINX pod is running successfully, use the following command:
kubectl get pods
You should see the
nginx-pod
listed with a status ofRunning
.
Congratulations! You've successfully installed Minikube on your local machine and created your first pod on Kubernetes.
Follow for more:
Linkedin: https://www.linkedin.com/in/samarjeet-patil-921952251/
#cloud #AWS #kubernetes #k8s