Prometheus monitoring stack on Ubuntu 22.04.3 and Micro Kubernetes Cluster (microk8s)Prometheus monitoring stack on Ubuntu 22.04.3 and

1) Install Ubuntu 22.04.3 desktop

2) Configure RDP and VNC –
https://www.youtube.com/watch?v=63uppKZ_Alk
https://www.youtube.com/watch?v=m5U1PgqfGiA – fix the lock problem

3) Install docker

sudo apt install docker.io

4) Check docker version

docker --version

5) Create a Micro Kubernetes Cluster (microk8s)

See here: https://microk8s.io/docs/getting-started

sudo snap install microk8s --classic --channel=1.27

MicroK8s creates a group to enable seamless usage of commands which require admin privilege. To add your current user to the group and gain access to the .kube caching directory, run the following two commands:

sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube

See the node:

microk8s kubectl get nodes

See the running services:

microk8s kubectl get services

Create an alias:

alias kubectl='microk8s kubectl'

Deploy an app:

microk8s kubectl create deployment nginx --image=nginx
microk8s kubectl get pods

Starting and Stopping MicroK8s:

microk8s stop
microk8s start

6) export the cluster configuration

kubectl config view --raw > ~/.kube/config

7) Install helm

$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
$ chmod 700 get_helm.sh
$ ./get_helm.sh

8) Deploy Prometheus monitoring stack to Kubernetes with a single Helm Chart

See: https://dev.to/kaitoii11/deploy-prometheus-monitoring-stack-to-kubernetes-with-a-single-helm-chart-2fbd

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
kubectl create ns prom
helm search repo prometheus-community
helm install prometheus prometheus-community/kube-prometheus-stack -n prom

helm install ksm prometheus-community/kube-state-metrics -n default # install the kube-state-metrics

kubectl --namespace prom get pods

Check configmaps and secrets:

kubectl --namespace prom get configmap
kubectl --namespace prom get secret

Look inside a secret file:

kubectl --namespace prom get secret

Check CRDs

kubectl get crd

9) Access Prometheus Dashboard

$ kubectl port-forward -n prom prometheus-prom-kube-prometheus-stack-prometheus-0 9090

10) Access Grafana Dashboard

$ kubectl port-forward -n prom prometheus-grafana-dcb6cdfb4-kbvpk 3000

OR

$ kubectl port-forward -n prom deployment/prometheus-grafana 3000

default user/password is admin/prom-operator

11) Uninstall Prometheus stack

$ helm uninstall prom -n prom