Install Prometheus and Grafana Using Helm

As usual, let the official do the explanation.

What is Helm?

Helm helps you manage Kubernetes applications — Helm Charts help you define, install, and upgrade even the most complex Kubernetes application.

What is Prometheus?

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud.

What is Grafana?

Grafana allows you to query, visualize, alert on and understand your metrics no matter where they are stored. Create, explore, and share dashboards with your team and foster a data driven culture.

In this post, as titled, I am going to install Prometheus and Grafana on K8S cluster using Helm. Before I start, there are two terms that I need to introduce first, charts and operator.

What is charts?

Helm uses a packaging format called charts. A chart is a collection of files that describe a related set of Kubernetes resources. A single chart might be used to deploy something simple, like a memcached pod, or something complex, like a full web app stack with HTTP servers, databases, caches, and so on.

What is operator?

Operators are software extensions to Kubernetes that make use of custom resources to manage applications and their components.

So, I am going to use Helm to install Prometheus operator, which is defined by chart, which will install:

Install Prometheus and Grafana Using Helm

With the help of Helm and Operator, it is quite easy to setup everything. The difficult part is understanding them, the concepts. Let’s start by installing Helm on client, which is pretty simple

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

Install Prometheus and Grafana Using Helm

Next, make sure your K8S cluster is up and running. Use Helm to install prometheus-operator.

helm install stable/prometheus-operator --generate-name

Install Prometheus and Grafana Using Helm

Check out what are installed. 1 and 2 are the web service of Prometheus and Grafana, which are the pods we will need to expose later on.

Install Prometheus and Grafana Using Helm
Install Prometheus and Grafana Using Helm

With this Operator, we can see that Prometheus and Grafana are already being exposed, but only internally. All we have to do is to modify ServiceTypes from ClusterIP to LoadBalancer.

Please note that once changed to LoadBalancer on AWS, the FW is opened to public! Please remember to delete the cluster or modify the FW rule.

Install Prometheus and Grafana Using Helm

Let’s edit the Service of Prometheus and modify the type from ClusterIP to LoadBalancer. Note that your Service name is differ from mine.

Once done, save and exit. K8S will auto detect the change and since my cluster is hosted on AWS, it will auto start provisioning the ELB.

kubectl edit svc prometheus-operator-158518-prometheus

Install Prometheus and Grafana Using Helm

Once done, check the service again. Open the ELB url in browser to confirm that it works correctly.

Install Prometheus and Grafana Using Helm
Install Prometheus and Grafana Using Helm

Next, repeat the step to expose Grafana on ELB.

Install Prometheus and Grafana Using Helm
Install Prometheus and Grafana Using Helm

That’s it, we have successfully deploy Prometheus and Grafana on K8S. The last step is to obtain the username and password for Grafana. Note that your secret name is differ from mine.

kubectl get secret prometheus-operator-1585188007-grafana -o jsonpath=”{.data.admin-password}” | base64 --decode ; echo

Install Prometheus and Grafana Using Helm

Default account is admin, decoded password is prom-operator, and, there you go!

Install Prometheus and Grafana Using Helm

AWS Certified SA, SysOps & Developer Associate, Alibaba Cloud certified SA. Focusing on Azure, Prometheus w/ Grafana, ELK and K8S now.