Skip to main content

Command Palette

Search for a command to run...

πŸš€πŸ“… Day 57 DevOps Challenge - πŸš€ Launching Your First Kubernetes Cluster with Nginx: A Minikube Adventure! πŸ› οΈ

Published
β€’5 min read
πŸš€πŸ“… Day 57 DevOps Challenge - πŸš€ Launching Your First Kubernetes Cluster with Nginx: A Minikube Adventure! πŸ› οΈ
A

Passionate software engineering student | DevOps enthusiast | Seeking innovation and excellence in software engineering! πŸ‘¨β€πŸ’»

In your previous learning, you gained insights into the architecture of Kubernetes, a fundamental tool in the world of container orchestration. Now, it's time to get hands-on experience and delve into the practical aspects of Kubernetes. We'll start by exploring Minikube, a tool that simplifies setting up a local Kubernetes cluster for development and testing purposes. Let's embark on this exciting adventure! 🌟

What is Minikube? 🌐

Minikube is a powerful tool designed to swiftly set up a local Kubernetes cluster on macOS, Linux, and Windows. It offers the benefits of Kubernetes in a simplified, easy-to-use package, making it an excellent choice for newcomers to the world of containers and developers working on edge computing and IoT projects. Let's uncover the features that make Minikube a go-to option for developers! πŸ›‘οΈ

Features of Minikube:

  1. Supports the latest Kubernetes release: Minikube supports the latest Kubernetes release, along with six previous minor versions.

  2. Cross-platform: It can be used on Linux, macOS, and Windows.

  3. Flexible deployment options: Minikube can be deployed as a VM, a container, or on bare-metal, offering flexibility based on your needs.

  4. Multiple container runtimes: It supports various container runtimes like CRI-O, containerd, and Docker.

  5. Direct API endpoint: Provides a direct API endpoint for fast image load and build.

  6. Advanced features: Offers advanced features like LoadBalancer, filesystem mounts, FeatureGates, and network policy.

  7. Addons for Kubernetes applications: Easily install Kubernetes applications using addons.

  8. Compatibility with common CI environments: Minikube is compatible with common CI environments, enhancing its usability for developers.

Installing Minikube on Ubuntu 🐳

This guide provides step-by-step instructions for installing Minikube on Ubuntu. Minikube allows you to run a single-node Kubernetes cluster locally for development and testing purposes.

Task-01: Install Minikube on your local machine or AWS EC2 instance πŸ’»

To get started, let's install Minikube on your local machine. Before you begin, ensure that you have the following prerequisites:

Prerequisites:

  • 2 CPUs or more

  • 2GB of free memory

  • 20GB of free disk space

  • Internet connection

  • Container or virtual machine manager, such as: Docker, QEMU, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation

I'm using an EC2 instance to install and run Minikube.

Preparing Your EC2 Instance πŸš€

If you prefer using an EC2 instance for Minikube, ensure that you choose an instance type that meets the requirements:

  • Instance Type: t2.medium (2 vCPUs, 4 GB RAM)

By selecting an EC2 instance with these specifications, you can have a seamless experience running Minikube on AWS.

Installation Steps:

  1. Create an EC2 Instance: Create a t2.medium EC2 instance on AWS.

  2. Update and Download kubectl: Update the instance and download kubectl using the following commands:

     sudo apt-get update 
    
     ## Download the latest release with the command
     curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
    
     ## Download the kubectl checksum file
     curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
    
     ## Validate the kubectl binary against the checksum file
     echo "$(cat kubectl.sha256)  kubectl" | sha256sum --check
    
     ## If valid, the output is: kubectl: OK
     ## Install kubectl
     sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
    
     ## Test to ensure the version you installed is up-to-date:
     kubectl version --client
    

  3. Install Docker: Minikube can run a Kubernetes cluster either in a VM or locally via Docker. This guide demonstrates the Docker method.

    • Install, Start and enable Docker:

        sudo apt install -y docker.io
        sudo systemctl start docker
        sudo systemctl enable docker
      

    • Add the current user to the docker group (To use Docker without root):

        sudo usermod -aG docker $USER && newgrp docker
      
    • Logout and log back in for the changes to take effect:

        exit
      

    • Reconnect to your instance.

  4. Install Minikube: Install Minikube using the following command:

     curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
     sudo install minikube-linux-amd64 /usr/local/bin/minikube
    

Now you have Minikube installed on your EC2 instance. You can proceed to start Minikube and set up your local Kubernetes cluster.

  1. 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.

Task-02: Create your first Pod on Kubernetes using Minikube πŸ—οΈ

Now, let's put our knowledge into action and create our first Pod in Kubernetes using Minikube. We'll start by creating an Nginx pod, a popular web server. Let's roll up our sleeves and get our hands dirty with some Kubernetes magic! πŸͺ„

Creating an Nginx Pod

To create an Nginx Pod, follow these steps:

  1. Create a YAML configuration file named pod.yaml and copy the following content into it:

     apiVersion: v1
     kind: Pod
     metadata:
       name: nginx-pod
     spec:
       containers:
       - name: nginx
         image: nginx:1.14.2
         ports:
         - containerPort: 80
    

  2. Apply the configuration using the kubectl command:

     kubectl apply -f pod.yaml
    

    This YAML defines a Pod named nginx-pod running the latest version of the Nginx container.

  3. To access the Nginx Pod, run the following command to access the Minikube VM:

     minikube ssh
    

    Once inside the Minikube VM, you can use curl to access the Pod's IP address. Replace <pod_ip_address> with the actual IP address of your Pod.

     ## To get pod_ip_address run -- kubectl get pods -o wide --
     curl <pod_ip_address>
    

Congratulations on reaching this exciting milestone in your Kubernetes journey! Stay tuned for more tutorials and insights into the fascinating world of Kubernetes. Happy coding! πŸŽ‰

More from this blog

Adarsh Jha

65 posts