DEV Community

Udoh Deborah
Udoh Deborah

Posted on

Day 31: Launching Kubernetes Cluster with Nginx running

What is Minikube?

Minikube is a lightweight tool that quickly sets up a local Kubernetes cluster on macOS, Linux, or Windows.
It can run as a VM, container, or directly on bare-metal, making it flexible for different environments.

Think of it as a pared-down version of Kubernetes that provides nearly all Kubernetes features but with minimal setup effort.
This makes it ideal for:

  • Beginners learning Kubernetes 🌱
  • Developers testing locally before deploying to the cloud πŸš€
  • Edge computing and IoT projects 🌐

Features of Minikube

βœ… Supports the latest Kubernetes releases (+6 previous versions)
βœ… Cross-platform (Linux, macOS, Windows)
βœ… Deploy as VM, container, or bare-metal
βœ… Multiple container runtimes (CRI-O, containerd, Docker)
βœ… Direct API endpoint for fast image load/build
βœ… Advanced features like LoadBalancer, filesystem mounts, FeatureGates, network policies
βœ… Addons for quick installation of common Kubernetes apps (e.g., dashboard, metrics-server)
βœ… Compatible with common CI/CD environments

In short: Minikube = Kubernetes made simple for local use.
It’s the perfect way to practice Kubernetes without needing a full cloud setup.

What is a Pod in Kubernetes?

A Pod is the smallest and simplest Kubernetes object. It represents a single instance of a running process in your cluster.

  • A Pod can run one or multiple containers, but they are always tightly coupled.
  • The containers inside a Pod share:

Networking resources

Configuration (specification) of how they should run

Key points about Pods:

The containers in a Pod are always co-located (run on the same node).

They are co-scheduled (started together)

Step 1: Install Minikube

First, you need to install Minikube on your local machine. This will create a single-node Kubernetes cluster. You can follow the official guide, which has instructions for macOS, Linux, and Windows.

Official Minikube Installation Guide: https://minikube.sigs.k8s.io/docs/start/

Step 2: Create the YAML File

Once Minikube is installed and running, you need a configuration file to tell Kubernetes what to create. This is the YAML file you requested earlier.

You can copy the following code and save it in a file named nginx-pod.yaml:

---
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    app: nginx
spec:
  containers:
  - name: nginx-container
    image: nginx:latest
    ports:
    - containerPort: 80
Enter fullscreen mode Exit fullscreen mode

Step 3: Launch the Pod

Now, use the kubectl command-line tool to apply the configuration and create the Pod. Make sure you are in the same directory as your nginx-pod.yaml file.

Open your terminal or command prompt and run this command:

kubectl apply -f nginx-pod.yaml
Enter fullscreen mode Exit fullscreen mode

You should see a message confirming that the pod was created: pod/nginx-pod created.

Step 4: Verify the Pod is Running

To check the status of your newly created pod, you can use the following command:

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

The output will show a list of pods in your cluster. You should see nginx-pod with a status of Running.

Step 5: Access the Nginx Server

Minikube makes it easy to access services running inside your cluster. To see your Nginx server in action, use the Minikube pod command with the --url flag:

minikube service nginx-pod --url
Enter fullscreen mode Exit fullscreen mode

This command will provide a URL (something like http://127.0.0.1:32000). Copy and paste this URL into your web browser. You should see the default "Welcome to Nginx!" page.

And that's it! You've successfully launched your first Kubernetes Pod and are serving content with Nginx.

Top comments (0)