Launching your First Kubernetes Cluster with Nginx running [Day-30 Task]

Launching your First Kubernetes Cluster with Nginx running [Day-30 Task]

1. What is Minikube?

Minikube is a tool that quickly sets up a local Kubernetes cluster on macOS, Linux, and Windows. It creates a single node cluster contained in a virtual machine (VM).

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.

2.Features of minikube

  • Supports the latest Kubernetes release (+6 previous minor versions)

  • Cross-platform (Linux, macOS, Windows)

  • Deploy as a VM, a container, or on bare-metal

  • Multiple container runtimes (CRI-O, container, docker)

  • Direct API endpoint for blazing-fast image load and build

  • Advanced features such as LoadBalancer, filesystem mounts, FeatureGates, and network policy

  • Addons for easily installed Kubernetes applications

  • Supports common CI environments

3. Advantages and Disadvantages Of Using Minikube?

Pros:

Easy to use: When compared to other Kubernetes tools, minikube is easy to use and initially set up.

Development: Minikube is ideal for developers that need to test their containers or deployments before sending them into production. By the same logic, it is also helpful for Kubernetes administrators to see how something runs before pushing the settings to their production Kubernetes cluster such as kubeadm[multi node cluster].

It gives us all the tools we need to package a containerized application, launch it as a pod, and then play with deployment settings via the Kubectl command.

Cons

Limited scope: Since minikube is only meant for development and testing purposes, it is just a single node and will not give much benefit to running Kubernetes via minikube rather than running a container directly. It is not meant for production use.

Performance: You can't expect a high level of performance from it as it is based on a single-node cluster and does not have many of the features of a different Kubernetes tool like Kubeadm.

4. Installation of Minikube In Ec2 Instance

Prerequisites:

1) Launce your Ec2 Instance in AWS:

Give a name to your instance.

Select Ubuntu or any other AMI as per your choice.

Now, as per the requirement, you can't choose a t2.micro free tier as it provides only 1 GB memory and 1vcpu. So instead of selecting t2.micro, select t2.medium.

Give a key-pair name and click on the launch instance.

Once your Instance is ready, login to the console via SSH or you can directly connect via EC2 connect.

2) Installation Steps:

Step 1

First, update your server

Install Docker

Step 2:

Add the user to the docker group

Step 3:

Follow the steps, Install Minikube (https://minikube.sigs.k8s.io/docs/start/)

Step 4:

Install kubectl

Step 5:

Start Minikube as per the image and check Minikube status

Step 6:

Check if minikube cluster has been set up successfully or not by checking pods or namespace status.

To summarize: Minikube Installation Steps:

5. What Is Pod?

In Kubernetes, we don't create containers directly as it creates inside of a logical boundary or you can say a wrapper, this wrapper is called POD. So a pod is the smallest deployable unit of Kubernetes where we run our application.

If a pod (or the node it executes on) fails, Kubernetes can automatically create a new replica of that pod to continue operations(this is known as the Kubernetes auto-healing process and it's possible because of the Kubernetes deployment controller. Pods include one or more containers (such as Docker containers).

When a pod is created it is allocated to a unique IP address and it is done by the kube proxy component which is located in the Data lane or worker node.

A Pod also has persistent storage volumes (as required)

and configuration information that determines how a container should run.

Although most pods contain a single container, many will have a few containers that work closely together to execute a desired function.

6. Create your first pod on Kubernetes through Minikube.

In Kubernetes, everything is written in a YAML file (known as Manifest File) which is a key-value combination.

To create a pod do vi pod.yml

This is the pod file.

We are just creating a container, the image will be nginx and the container port is 80, in which the container will be listening

run the kubectl and apply the command to create a pod.

Check the pod's status by kubectl get pods, you can see a pod is created successfully from its status

Run the kubectl get pods -o wide command to get more detailed information about the pod.

To check if nginx is running locally or not, do minikube ssh to go inside of the minikube cluster.

Do curl IP address of the pod

You can see Nginx is running locally.