Step-by-Step Guide: Deploying a Kubernetes Observability Stack on WSL 2 (Prometheus & Grafana)

Running Kubernetes locally on Windows via WSL 2 can sometimes throw networking curveballs—especially when trying to connect your host browser to cluster services. This guide walks through the exact sequence to spin up Minikube, deploy Prometheus and Grafana via Helm, fix local port-forwarding errors, and visualize live cluster metrics.



Step 1: Initialize Your Minikube Cluster

First, ensure your local environment has enough resources allocated to handle containerized monitoring tools like Prometheus and Grafana. Fire up your WSL 2 terminal and start Minikube with increased CPU and memory:


minikube start --cpus=4 --memory=4096

Step 2: Create a Dedicated Monitoring Namespace

Instead of cluttering your default namespace, keep your observability stack organized in its own namespace:

kubectl create namespace monitoring

Step 3: Deploy Prometheus & Grafana Using Helm

Add the official Prometheus community Helm repository and install both Prometheus (the metrics database and scraper) and Grafana (the visualization dashboard) directly into your monitoring namespace:

# Add and update the Helm repo
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
# Install Prometheus and Grafana helm install prometheus prometheus-community/prometheus --namespace monitoring helm install grafana grafana-community/grafana --namespace monitoring

Step 4: Handle the Port-Forwarding Error & Apply the Fix

The Problem

To view Grafana in your web browser, you might normally try standard Kubernetes port forwarding:

kubectl port-forward deployment/grafana 3000:3000 -n monitoring

The Error: You will likely hit a Connection Refused or socket reset error. Because Minikube runs inside an isolated container network sandbox within WSL 2 and Docker Desktop, host-level port forwarding fails to bridge the virtualization boundary properly.

The Fix

Bypass kubectl port-forward entirely by using Minikube's native service routing bridge:

minikube service grafana -n monitoring

This command automatically opens a stable tunnel and provides a direct, accessible URL on your local machine (e.g., [http://127.0.0.1](http://127.0.0.1):xxxxx) that your Windows web browser can reach without dropping connections.

Step 5: Log Into Grafana and Connect Prometheus

  1. Open the URL provided by the minikube service command in your browser.

  2. Retrieve your admin password by running this command in your terminal:

    kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
  3. Log into Grafana using username admin and the decoded password.

  4. Go to Data Sources and click Add data source -> Prometheus.

  5. Crucial FQDN Setting: Do not use http://localhost:9090 (which causes an internal container loop error). Instead, use the internal Kubernetes CoreDNS service address:

    Plaintext
    http://prometheus-server.monitoring.svc.cluster.local
    
  6. Click Save & test. You should see the success confirmation: "Successfully queried the Prometheus API".

Step 6: Import the Kubernetes Overview Dashboard

  1. In Grafana, navigate to the sidebar and click Dashboards -> New -> Import.

  2. Enter the community dashboard ID: 14623 (Kubernetes Monitoring Overview) and click Load.

  3. At the bottom of the screen, select your newly linked Prometheus data source from the dropdown menu.

  4. Click Import.

Your dashboard will instantly populate with real-time graphs tracking your cluster's CPU utilization, memory usage, node health, and active pod lifecycles!




Building a Production-Grade SRE & Cloud Engineering Local Environment on Windows 11 (WSL 2, Docker, Kubernetes & Terraform)

Transitioning to cloud-native architecture and Site Reliability Engineering (SRE) requires a robust, isolated, and high-performance development environment. For engineers working on Windows 11, the combination of WSL 2 (Ubuntu), Docker Desktop, and VS Code provides a seamless Linux-native workspace without leaving the Windows host.

                          (click to maximize image)




This guide outlines the step-by-step process to build, configure, and verify a complete local SRE toolchain—covering Terraform, kubectl, Helm, and Minikube.

Step 1: Initialize WSL 2 and Ubuntu


Ensure your Windows Subsystem for Linux (WSL) is active and running Ubuntu as your default distribution.

  1. Open PowerShell as Administrator and enable WSL (if not already enabled):


    PowerShell
    wsl --install
  2. Set up your Ubuntu username and password upon first launch.

Step 2: Install Visual Studio Code & WSL Integration


Visual Studio Code acts as the primary editor,
linking directly into your isolated Linux filesystem.

  1. Install Visual Studio Code (either via the official installer or the Microsoft Store).

  2. Open VS Code and install the WSL extension by Microsoft from the Extensions marketplace
    (
    Ctrl + Shift + X).

  3. Open your Ubuntu terminal and link VS Code to your current directory:

    Bash
    code .
    

    (This automatically installs the remote VS Code Server backend inside your Linux distribution).

Step 3: Configure Docker Desktop with WSL 2 Integration

Docker Desktop manages containerization natively through the WSL 2 backend.

  1. Install Docker Desktop on Windows.

  2. Open Docker Desktop, navigate to Settings > General, and ensure "Use the WSL 2 based engine" is selected.

  3. Go to Settings > WSL integration:

    • Enable integration with your default WSL distro.

    • Toggle ON the switch for Ubuntu.

    • Click Apply & restart.

Fix Linux Socket Permissions for Docker

To allow your Linux user account to communicate with the Docker daemon without permission errors, run these commands inside your Ubuntu terminal:

Bash
# Add your user to the docker group
sudo usermod -aG docker $USER

# Apply group changes to your current session
newgrp docker

Verify the connection:

Bash
docker ps

(You should see container table headers display cleanly with no permission errors).

Step 4: Install the SRE Toolchain (Terraform, kubectl, Helm, & Minikube)


Run the following comprehensive installation script inside your
Ubuntu terminal to install your core SRE and infrastructure tooling:

Bash
# 1. Update package lists and install basic dependencies
sudo apt update && sudo apt install -y build-essential curl git unzip 
software-properties-common gnupg wget # 2. Install Terraform (via HashiCorp official repository) wget -O- https://apt.releases.hashicorp.com/gpg |
sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg]
https://apt.releases.hashicorp.com $(lsb_release -cs) main"
|
sudo tee /etc/apt/sources.list.d/hashicorp.list sudo apt update && sudo apt install -y terraform # 3. Install kubectl (Kubernetes CLI) curl -LO "https://dl.k8s.io/release/$(curl -L -s
https://dl.k8s.io/release/stable.txt)
/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl # 4. Install Helm (Kubernetes Package Manager) curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash # 5. Install Minikube (Local Kubernetes Cluster Manager) curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube


Step 5: Boot and Verify Your Local Kubernetes Cluster


With the toolchain installed and Docker Desktop running,
spin up your local single-node Kubernetes cluster using the Docker driver:

Bash
# Start Minikube backed by Docker Desktop
minikube start --driver=docker

Verify that all tools are functioning and your cluster node is healthy:

Bash
# Check tool versions
terraform -v
kubectl version --client
helm version
minikube version

# Check cluster node status
kubectl get nodes

When
kubectl get nodes returns minikube with a status of Ready, your enterprise-grade local SRE playground is fully initialized and ready for deployment workflows!


(click to maximize image)


Additionally, Given below are some steps to gracefully shutdown and startup all of the SRE tools on your local computer.