Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

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!




'Reparing Linux Grub Menu' ?

If you ever wanted to have Linux alongside Windows Operating System, I think you're up to something good. I don't want to use 'Better' because that term is valid for people who're going to have Linux only. [ Note : not the dual boot ]

But, dual boot is good as a start, besides Experiencing tech in plural is  better than holding on to singular mostly. [ Note : use both Windows & Linux ] Among the favourite Linux Distributions Ubuntu has the More friendlier option of installing with Wuibi , which I used to do years ago. But, if you ever messed-up with your Windows Partition you loose your Linux as well.

So, I prefer the other way, which is installing Ubuntu first & Windows Later. But, Whenever you do that you loose your Grub Menu, [ Note : Used to Opt the Operating System During Boot ] Because, Windows installer is used to

To recover your Grub Menu. Follow the Steps.

Step 01 : Pick an Ubuntu image [12.04+] & either create a Live CD/USB. [ Note : use 'Start-up Disk Creator' in a separate Ubuntu ]

Step 02 : Change BIOS settings Boot Order & Boot with the Live CD/USB.

Step 03 : Choose a language [Note : Usual ]  & 'Try Ubuntu' not 'Install Ubuntu'.

Step 04 : Whenever, You're in the Usual Ubuntu Desktop view. Press Ctrl+Alt+T & run Terminal.

Step 05 : Make sure you're connected to Internet & type following Lines to the Terminal.

sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair

Select 'Recommended Repair' in the Boot Repair Window at the end of Package updates & installation of boot-repair.


Restart, the Computer & check whether your Grub Menu is there.

Adding Repositories to Ubuntu ?

                                 The truth as we know it is that, we use Ubuntu 'Update Manager', whenever we need to update software that we've already installed in our Ubuntu OS.

Because, that's Easy (Equivalent to Windows Update) we just have to click a single button.

If you're new to Ubuntu. Please know this, go to Dash & find 'Update Manager'.


                             Even if you aren't familiar with 'Update Manager', automatic prompt will always let you to download Free updates whenever it's available.

Repositories mean, the download sources that Ubuntu OS of yours lets you to download updates from. They're links basically, that directs your software to a download server.

Whenever, we install custom software to Ubuntu, we need to set repositories to download updates for them.

To do that, 

Step 01 :  

Get to know the download source URL. E.g - http://download.virtualbox.org/virtualbox/debian

Step 02 :

It's important to know that there're few types of Repository components available.

  • Main - Official Ubuntu Software.
  • Restricted - Supported software but still not distributed under complete Free License.
  • Universe - Community maintained software, i.e. not officially supported software.
  • Multi-verse - Software that is not free.

Step 03 :

Go to Terminal. (Dash -> Type 'Terminal' -> Click)




Then, type following command in the terminal.

$ cd /etc/apt

You've to edit Sources.list  file in order to set your repositories. Use your vi-editor and open Sources.list  with vi.

$ vi sudo sources.list


Enter your administrator password & in the vi, Go to the bottom of the sources file.



Step 04 :

Add your download source URL in vi --INSERT-- Mode.

## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu oneiric main

You've to include your URL in the 'deb' format. 

But, you've to be careful in editing sources.list & make sure you write your third party software URL entry under the Third Party  software section. Save the file & exit.

Step 05 :

Now, go to Dash & type 'Update Manager'. Then click 'Check' button to check for updates.



Then, click 'install Updates' button to update. Make sure you've already ticked all the updates.



 Okay. It's over Enjoy ! Your Ubuntu Experience.

How to Use VIM Editor with Speed & Knowing ?

Hi!

These stuff were pretty elementary & actually got to know these in early season at campus. But, it's important & I use to use these almost everyday in programming in linux environment & that's why I thought to note down something about this.

Alright, among many of the text editors that can be used in linux environment vim-editor is one of the most commonly used applications.

That's mainly due to it's simplicity. It's usable with Terminal itself & consists of very limited amount of commands (comparing to emacs), which makes it easier to use even to a newbie.

Then, let's get to know VIM-Editor.

1. Check whether you've got VIM-Editor installed.



You'll see your terminal showing something like follows.


if you won't, then, you've got to install VIM-Editor in order to proceed. If you're a complete newbie here's a tip to get vim.

Go to Ubuntu Software Center & Search : GVim. Download & install it.

 You've got it for sure by now. Alright then, let's proceed.


2. Take out the terminal & go to Desktop. (Type: Cd Desktop) Then, type: vi [Your File Name].







3. Good, now you're in VIM Mode & you can't type anything write away. So, in order to go to typing mode : press 'i' in your keyboard. Then, you'll be seeing something like '-- INSERT--' at the bottom edge of your VIM editor which means that now you can type.




 4. Type anything & after you finish type keep in mind to press Esc to exit Typing Mode & come to Command Mode.

5.  Then, try following tips to fix/edit what you've already typed.

  • 'o' - (Letter O) Get an empty line. Bring your cursor to the end of a line & type 'o'. A new line will be opened.


  • 'dd'- (Letter d twice) Delete a line. Bring cursor to the beginning of a line & type 'dd'.


  • 'p' - Right after delete. Bring cursor to a new location & type 'p'. deleted line will be appearing at the new location.


  • 'cw' - Pick a word and a letter closer to the beginning of the word & bring cursor on it & type 'cw'. The rest of the word beginning from the letter you picked will be deleted. Now, you can replace it with something else.


  • Ex: 'Element' - pick lettter 'l' . It'll be 'E' after command 'cw'


  • 'r' - Take your cursor on a letter and type 'r' and then type a letter that you need to replace the previous with.


Enjoy VIM-Editor !

Install XAMPP in Ubuntu Linux ?

Hi!

If you need to install xampp in Ubuntu linux, here's a quick guide of how to do that. It's in steps ! So, it'll be easy to go through the article as usual in my blog.


1. First go through this link and download xampp for Linux.

2 . Now, you'll be having a file named like xampp-linux-y.y.yy.tar

3. Now, get your terminal.


     Type sudo nautilus & hit Enter




4. Now, File Manager window will be opened & you've to go to your root directory & find a directory opt & get inside it.



5. Then, take your xampp-linux-y.y.yy.tar & extract it inside /opt.


You'll see a directory named lampp.

6. Now, take out terminal again & type cd /opt .


7. Then, Type sudo chmod 777 lampp. (Give Read,write & execute privileges to all users).


8. Tpe sudo naulius & take back file manager window & go to /opt/lampp/htdocs.


 Make a directory to store your php files. (Name it the way you want) Ex: MYPHP.

9.  Then, take terminal back & type sudo /opt/lampp/lampp start. 


10. Start Web Browser & type http://localhost in the addressbar.


11. Then, Select English & Type http://localhost/MYPHP to go to your php file directory.




Enjoy! PHP with XAMPP.

File Sharing Between Ubuntu & Windows 7 ?


Hey !

      This is a pretty tricky process & sometimes be hard. But, don't give up on trying though. This explanation is a step by step guide towards 'File Sharing Between Ubuntu & Windows 7'  Computers.

First, let's Make the necessary Adjustments to the Windows 7 Computer which is somewhat familiar for us than Ubuntu Linux.

1. Go to 'Advanced Sharing Settings' of Windows 7 & make settings to allow file sharing in the network.

(The settings are almost similar to the setting we make whenever we need to create a Windows 7 Home Group. So, Click this to see that article about Home group. First 7 Steps Apply here too.)




2. Make your network location Home Network.






Now, Windows 7 is almost ready to go. But, before leave it, make sure to know your WORK GROUP name in windows. To know that. Get Command Prompt & type following

>net config workstation



Before, Leave Make sure you've already shared folders that you need to share. Here's the way to share. Right Click on the folder & do as follows.




Then, let's move to Ubuntu Linux Computer.

3.  First, Take Ubuntu Software Center.


4. Then, Find 'Samba' in Search Box and Install it.  (I've already install it. So, it shows remove but in your case it'll be shown as Install)





5. Then, start Samba & click Plus icon.

Create a Samba Share by, browsing Directory you want to share.

  Change Access Privileges & click OK.



6. Go to Preferences. Under Server Settings, set Work group Your Windows Work Group name & hit OK.

7. Then, Get Ubuntu File Manager & check Browse Network. You'll see that the Computer Name of the connected windows Computer is visible. Double Click it.



8. All the shared folders will be shown.



9. Double Click the folder you need & then You'll  be asked to enter a password. Enter Your Windows Log in Password.




Now You Can Enjoy File Sharing.

"Installing Ubuntu 9.10 Desktop Edition in Windows XP"


First of all, you should have a live CD or a requested Ubuntu Desktop edition to process with this. I prefer a new hard disk to install Ubuntu for the first time, because it’s nothing to panic with the probability of losing your data in the other partitions or disks. (That’s what I did; my next post will be about dual boot settings)
So:
1.Request an Ubuntu CD (Free Linux) from www.Ubuntu.com OR
2.Download Ubuntu from the same website and make an Ubuntu live CD
3.Buy a separate hard disk about 10GB of capacity (make dual boot settings)

My choice was to request and I could have a free CD:


--> It’s Ubuntu 9.10 and it’s the latest which was released October 2009. Just log onto Windows (XP for me) and enter the disc into the disc driver. It has an auto run (otherwise double click on the icon shown below)


And following box will be shown on your screen.



  • Click on ‘Install Inside Windows’ and you’ll see the following:

  • Remember! Select the appropriate installation drive from the drop down menu and select minimum 3GB of space to compress and install Ubuntu which will take some time more than normal.
  • You can add your name and password. Usually, as this is inside windows the user name in windows has taken as the default value.


  • You’ll see the above after you click on ‘Install’.
  • CD would come out of the Rom. Then it is asked to reboot the computer. Click yes and it will straight go to Ubuntu, but remember to select Ubuntu in the dual boot process.
  • After that it’s all about an automatic process. The package which was installed inside windows in the separate hard drive performs and getting installed as an operating system.
Yes, that’s all its easy isn’t it easy. Enjoy Ubuntu Linux 9.10. God protects you all!