Day: 31 Launching your First Kubernetes Cluster with Nginx running

Day: 31 Launching your First Kubernetes Cluster with Nginx running

What is minikube?

Before, we discussed the many Kubernetes parts that go into creating a master and worker node, including the API server, etcd key-value store, controllers, and scheduler on the master, and kubelets and container runtime on the worker nodes. Setting up and installing these components on different systems individually would require a lot of time and work.

Minikube combines all these various parts into a single image and offers us a single-node Kubernetes cluster that is already configured, allowing us to get going quickly.

The entire program is bundled into an ISO image and may be downloaded online.

Understanding Minikube: A Closer Look

Minikube emerges as a lightweight and open-source solution that empowers developers to establish a singular-node Kubernetes cluster right on their local machines. This ingenious tool is tailored for streamlining local application testing and development within the Kubernetes framework, eliminating the need for complex cluster setups.

The functionality of minikube:

  • Easy-to-install Kubernetes application add-ons

  • enables typical CI scenarios

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

  • Cross-platform (Linux, macOS, Windows)

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

and many more.

Features of minikube

(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, containers, 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

Task-01:

Install minikube on your local

Launch EC2 instance with Instance type as “t2.medium”.

  • CPU: 2

  • Memory: 4GB

  • Disk Space: more than 10GB

    Install docker using commands such as “sudo apt-get update” and “sudo apt-get install docker.io”.

      sudo usermod -aG docker $USER 
      sudo systemctl start docker
      sudo systemctl enable docker
    
      curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
    

    After running the CURL command you will see the Minikube folder

    Download the Minikube binary using curl Make it executable and move it into your path:

       chmod +x minikube
       sudo mv minikube /usr/local/bin/
    

To check the version of miniKube -- add below command

minikube version

To confirm successful installation of both a hypervisor and Minikube, you can run the following command to start up a local Kubernetes cluster:

Now lets install kubectl which is command line tool

 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/

Activating Minikube and Checking Status

minikube start --driver=docker

In below image, we used driver_name=docker, so first you need to install docker in your machine.

Once minikube start finishes, run the command below to check the status of the cluster:

minikube status

If you have previously installed Minikube, and run:

minikube start

and minikube start returned an error: machine does not exist

then you need to clear minikube local state:

minikube delete

For log in to minikube use command:

minikube ssh

Pod:

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 that are relatively tightly coupled.

Task-02:

Create your first pod on Kubernetes through minikube.

Install kubectl using command

sudo snap install kubectl --classic

Create a file, inside folder create pod.yaml file for nginx.

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80
# After creating this file , run below command:
# kubectl apply -f <yaml file name>

To create a pod using pod.yaml file use below command:

tl apply -f <pod.yaml>

To check list of pods:

kubectl get pods

💡
Great job! Minikube has been successfully installed on your Ubuntu system, and you're ready to begin deploying Kubernetes applications for development and testing. 🚀 Stay tuned for more insightful Kubernetes blogs in the days ahead! 🎉

Did you find this article valuable?

Support DevOps_journey by becoming a sponsor. Any amount is appreciated!