In this post, that is actually documentation for myself, I'll guide you thru the deployment of a monitoring environment in your local machine, this can be used for study and prototype. The project will use prometheus to monitor and grafana to plot graphs.
I'm using Ubuntu 20.04.1 LTS as my OS
First you'll need to install a tool to run Kubernetes locally (kind, minikube, k3s or other that you like; Personally I use kind)
The steps are the following
$wget https://github.com/kubernetes-sigs/kind/releases/download/v0.8.1/kind-linux-amd64 $chmod +x kind-linux-amd64 $mv kind-linux-amd64 /usr/local/bin/kind $kind version
and then install Helm
sudo snap install helm --classic
for other ways of installing helm please refer to Helm Documentation
Now that we have our tools installed we need to create a kubernetes cluster
kind create cluster --name
If you don't put the flag
--name the cluster name will be "kind"
Helm is a package manager for Kubernetes
To Add the prometheus charts repo use the command:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
We'll install two helm charts
As per github This chart contains a collection of Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.
helm install prometheus-community/kube-prometheus-stack --generate-name
Pushgateway is a tool that pushes metrics that cannot be scraped
helm install prometheus-community/prometheus-pushgateway --generate-name
kubectl get services to see the services running and some information about them. A detail when deploying prometheus localy is to change the type of the following services
kube-prometheus-stack-1611575778-grafana from ClusterIP to NodePort (if you are deploying it in a cloud environment you shall change to LoadBalancer). More information about Kubernetes services can be found here
To edit the services use the following command
kubectl edit svc your-service-goes-here
this command will open a vim type editor and allow you to edit information about the service
Now all you have to do is expose the ports using the port-forward command, the following example allows me to access alert-manager via browser
kubectl port-forward svc/alertmanager-operated 9093
The syntax is kubectl port-forward TYPE/NAME PORT.
And that's all for today 🤓