Home Interests Kubernetes

Install Prometheus and Grafana in your Kubernetes cluster

howchoo   (467)
September 19, 2023
6 minutes

Share

Interests
Posted in these interests:
devops • 3 guides
kubernetes • 6 guides

What is Prometheus?

Prometheus is an open source systems monitoring toolkit originally developed by SoundCloud. Prometheus is now a part of the Cloud Native Computing Foundation and is managed independently of SoundCloud. Prometheus is the monitoring toolkit of choice for many Kubernetes users.

What is Grafana?

Grafana is an open source platform for visualizing time series data. It is often used as a front-end for Prometheus (and many other data sources).

What is Prometheus Operator?

Prometheus Operator is a set of resource definitions provided to create, configure, and manage Prometheus in a Kubernetes cluster.

As you can see, Prometheus and Grafana are a great, open source, set of tools for monitoring your Kubernetes cluster. In this guide, I’ll show you how to install prometheus-operator using helm, and start monitoring your cluster in just a few minutes.

1 – Install using helm

We’ll be installing prometheus-operator using this helm chart. According to the chart description, the default installation is sufficient for monitoring whichever cluster its deployed into.

However, if desired, there are plenty of values that can be configured. But for this guide, we’re going to install prometheus-operator with the default configuration.

Upgrade helm, if necessary

This may not be required, but I’m going to put it here just in case. You may need to upgrade helm before installing.

helm init --upgrade

Install the prometheus-operator chart

helm install stable/prometheus-operator --namespace monitoring --name prometheus

In the command above, I’ve run the basic helm install command but also specified the name and the namespace. Otherwise, you’ll get a random release name (something like old-camel or simple-cactus), and it will be installed in the default namespace.

You might be disappointed to hear, but that’s it! You’ve installed Prometheus and Grafana in your k8s cluster. In subsequent steps, I’ll provide a few more tips on getting logged in and set up.

2 – Logging in to Grafana

Get the password

To log in to the Grafana dashboard, you need to grab the admin password:

kubectl get secret --namespace monitoring prometheus-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

Forward port 80

This chart creates a grafana service running on port 80. I’m going to use this service to forward port 3000 on our local machine to one of the grafana pods.

k port-forward -n monitoring service/prometheus-grafana 3000:80

Log in at localhost:3000

Open a browser, and navigate to http://localhost:3000. There you can log in using:

UsernamePassword
admin(the password you retrieved in the first part of this step)

Did you know Kubernetes is compatible with Superset? Check out this guide to install Apache Superset on a GKE Kubernetes Cluster.

NEXT UP

Secure Your Sensitive Data with Kubernetes Secrets

Learn how to create and use Kubernetes secrets.
howchoo   (467)
November 26, 2023

Kubernetes secrets are objects that store and manage sensitive data inside your Kubernetes cluster. One mistake developers often make is storing sensitive information like database passwords, API credentials, etc in a settings file in their codebase. This is very bad practice (hopefully for obvious reasons). Most developers know this, but still choose the option because it’s easy.

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo's writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Discover interesting things!

Explore Howchoo's most popular interests.

Explore