Day 31 of 90 Days of DevOps Challenge: Launching Your First Kubernetes Cluster with Nginx

·

4 min read

Welcome to Day 31 of the 90 Days of DevOps challenge! 🎉 After learning about Kubernetes architecture yesterday, it’s time to get hands-on with launching your very first Kubernetes cluster using Minikube. In today’s challenge, you’ll install Minikube and create your first Kubernetes pod running Nginx.

Let’s dive in! 🚀


What is Minikube?

Minikube is a tool that allows you to quickly set up a local Kubernetes cluster on macOS, Linux, and Windows. It simplifies the process of running a single-node Kubernetes cluster, enabling you to experiment and develop without needing to configure a full production-grade cluster.

Minikube supports deployment via a virtual machine (VM), a container, or even on bare-metal. It’s an excellent starting point for those new to Kubernetes, and it's widely used in development environments to simulate real Kubernetes deployments.


Features of Minikube

  • Supports Latest Kubernetes Versions: Minikube ensures compatibility with the most recent Kubernetes releases, as well as six prior versions.

  • Cross-Platform: You can install and run Minikube on Linux, macOS, and Windows.

  • Flexible Deployment: Deploy as a VM, in a container, or on bare-metal, depending on your setup and needs.

  • Multiple Container Runtimes: Supports CRI-O, containerd, and Docker runtimes.

  • Direct API Endpoint: Enables fast image loading and builds directly on the API endpoint.

  • Advanced Features: Includes advanced Kubernetes features like LoadBalancer, filesystem mounts, FeatureGates, and network policy.

  • Add-ons: Supports a range of Kubernetes add-ons for quick application installations.

  • CI Compatibility: Works smoothly with popular continuous integration (CI) environments.


Task-01: Install Minikube on Your Local Machine

To begin, you’ll need to install Minikube on your local machine. Follow these instructions to get set up:

Alternatively, you can use package managers like Homebrew (for macOS), APT (for Linux), or Chocolately (for Windows) for quick installation.

Once installed, verify your installation by running:

minikube version


What is a Pod in Kubernetes?

In Kubernetes, a Pod is the smallest and simplest unit of deployment. It represents a single instance of a running process in your cluster. A pod can contain one or more tightly coupled containers, which share storage, network resources, and a runtime environment.

Pods are designed to host containerized applications that are deployed and managed together. Kubernetes ensures that all containers within a pod are co-located on the same host and share the same lifecycle.

  • Pods in Practice: Pods are like application-specific "logical hosts." You can think of them as a unit that holds one or more containers that need to work together and communicate seamlessly within the cluster.

Task-02: Create Your First Pod on Kubernetes

Now that you’ve set up Minikube, it’s time to launch your first Kubernetes pod! We’ll start with a basic Nginx pod, which will serve a simple web page.

Here’s how you can create the pod:

  1. Start Minikube: First, launch Minikube by running the following command:

     minikube start
    

  2. Create an Nginx Pod: Next, create an Nginx pod by using the kubectl command. Here’s the command to create a pod running the Nginx image:

     kubectl run nginx --image=nginx --restart=Never
    
  3. Verify the Pod: To check if the Nginx pod is running, use the following command:

     kubectl get pods
    

    You should see the Nginx pod listed with its current status.

  4. Expose the Nginx Pod: To access the Nginx web server, expose the pod using a service:

     kubectl expose pod nginx --type=NodePort --port=80
    

    You can now access the Nginx pod by getting the Minikube IP:

     minikube service nginx --url
    

  5. Open the provided URL in your browser, and you should see the Nginx welcome page!


What You’ve Achieved Today:

  • Installed and set up Minikube, your local Kubernetes environment.

  • Created your first Kubernetes pod, running the Nginx web server.

  • Exposed your Nginx service, allowing external access.


Conclusion:

By completing today’s task, you’ve successfully launched your first Kubernetes cluster using Minikube and deployed an Nginx pod. This hands-on experience will help solidify your understanding of Kubernetes, and you’re now ready to explore more advanced features of Kubernetes like services, deployments, and scaling.

Remember to share your progress on LinkedIn using #90DaysOfDevOps! Keep pushing your boundaries and enjoy the journey. 🚀

Â