---
# System prepended metadata

title: Deploying Prometheus on a Kind cluster using Helm
tags: [Documentation, Templates]

---

---
title: 'Deploying Prometheus on a Kind cluster using Helm'
disqus: hackmd
---

Deploying Prometheus on a Kind cluster using Helm
===


## Table of Contents

[TOC]

## Kube-Prometheus-stack

Kube-prometheus stack is a collection of Kubernetes manifests, Grafana dashboards, and Prometheus rules, this provides an easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.

Helm must be installed to use the charts [Helm installation](https://hackmd.io/cGywaGHwSJqheQpBo3NN-g#Install-helm)

#### 1. **Helm Repository**

Add prometheus and stable repo to local helm repository  

```bash=
$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
$ helm repo add stable https://charts.helm.sh/stable
$ helm repo update
```
#### 2. **Create namespace monitoring to deploy all services in that namespace.**

```bash=
$ kubectl create namespace monitoring
namespace/monitoring created
```
#### **3. Install kube-prometheus stack. The services will be exposed on NodePort:**
    a. Prometheus : 30000
    b. Grafana: 31000
    c. AlertManager: 32000

```bash=

#helm install [RELEASE_NAME] prometheus-community/kube-prometheus-stack
$ helm install kind-prometheus prometheus-community/kube-prometheus-stack --namespace monitoring --set prometheus.service.nodePort=30000 --set prometheus.service.type=NodePort --set grafana.service.nodePort=31000 --set grafana.service.type=NodePort --set alertmanager.service.nodePort=32000 --set alertmanager.service.type=NodePort --set prometheus-node-exporter.service.nodePort=32001 --set prometheus-node-exporter.service.type=NodePort
NAME: kind-prometheus
LAST DEPLOYED: Sat Nov  7 01:08:37 2020
NAMESPACE: monitoring
STATUS: deployed
REVISION: 1
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
  kubectl --namespace monitoring get pods -l release=kind-prometheus

Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.

```

#### 4. **Validate kube-prometheus-stack has been installed.**

**Step1:** Check its status by running: 

:::spoiler kubectl --namespace monitoring get pods -l release=kind-prometheus
```bash=
$ kubectl --namespace monitoring get pods -l release=kind-prometheus
NAME                                                  READY   STATUS    RESTARTS   AGE
kind-prometheus-kube-prome-operator-c745544dd-ktm9x   1/1     Running   0          80s
kind-prometheus-prometheus-node-exporter-8tfbw        1/1     Running   0          80s
kind-prometheus-prometheus-node-exporter-lk4sm        1/1     Running   0          80s
kind-prometheus-prometheus-node-exporter-pn7kn        1/1     Running   0          80s
```
:::


**Step2:** Check all the components in the stack

:::spoiler kubectl get all --namespace monitoring
```bash=
$ kubectl get all --namespace monitoring
NAME                                                         READY   STATUS    RESTARTS   AGE
pod/alertmanager-kind-prometheus-kube-prome-alertmanager-0   2/2     Running   0          26m
pod/kind-prometheus-grafana-5ffd86dcc4-89skd                 2/2     Running   0          27m
pod/kind-prometheus-kube-prome-operator-c745544dd-ktm9x      1/1     Running   0          27m
pod/kind-prometheus-kube-state-metrics-747b54b966-f6bz2      1/1     Running   0          27m
pod/kind-prometheus-prometheus-node-exporter-8tfbw           1/1     Running   0          27m
pod/kind-prometheus-prometheus-node-exporter-lk4sm           1/1     Running   0          27m
pod/kind-prometheus-prometheus-node-exporter-pn7kn           1/1     Running   0          27m
pod/prometheus-kind-prometheus-kube-prome-prometheus-0       2/2     Running   1          26m

NAME                                               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
service/alertmanager-operated                      ClusterIP   None            <none>        9093/TCP,9094/TCP,9094/UDP   26m
service/kind-prometheus-grafana                    NodePort    10.96.224.21    <none>        80:31000/TCP                 27m
service/kind-prometheus-kube-prome-alertmanager    NodePort    10.96.106.224   <none>        9093:32000/TCP               27m
service/kind-prometheus-kube-prome-operator        ClusterIP   10.96.213.97    <none>        443/TCP                      27m
service/kind-prometheus-kube-prome-prometheus      NodePort    10.96.239.179   <none>        9090:30000/TCP               27m
service/kind-prometheus-kube-state-metrics         ClusterIP   10.96.6.211     <none>        8080/TCP                     27m
service/kind-prometheus-prometheus-node-exporter   ClusterIP   10.96.103.85    <none>        9100:32001/TCP                     27m
service/prometheus-operated                        ClusterIP   None            <none>        9090/TCP                     26m

NAME                                                      DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
daemonset.apps/kind-prometheus-prometheus-node-exporter   3         3         3       3            3           <none>          27m

NAME                                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/kind-prometheus-grafana               1/1     1            1           27m
deployment.apps/kind-prometheus-kube-prome-operator   1/1     1            1           27m
deployment.apps/kind-prometheus-kube-state-metrics    1/1     1            1           27m

NAME                                                            DESIRED   CURRENT   READY   AGE
replicaset.apps/kind-prometheus-grafana-5ffd86dcc4              1         1         1       27m
replicaset.apps/kind-prometheus-kube-prome-operator-c745544dd   1         1         1       27m
replicaset.apps/kind-prometheus-kube-state-metrics-747b54b966   1         1         1       27m

NAME                                                                    READY   AGE
statefulset.apps/alertmanager-kind-prometheus-kube-prome-alertmanager   1/1     26m
statefulset.apps/prometheus-kind-prometheus-kube-prome-prometheus       1/1     26m
```
:::

Step 3: The dashboard can be accessed at:

1. Prometheus: http://<nodeIP>:30000/graph
2. AlertManager: http://<nodeIP>:32000/graph
3. Grafana: http://<nodeIP>:32000/graph
The Grafana dashboard can be accessed by using the credentials
```
User: admin
Pass: prom-operator
```
![](https://i.imgur.com/9LyQdhg.png)

The following services can also be exposed using NodePort during install using helm by specifying the NodePort

* kube-prometheus-stack-operator
* kube-state-metrics 
* prometheus-node-exporter

## Appendix and FAQ

[Prometheus Helm Charts](https://github.com/prometheus-community/helm-charts)

### Pre-requisites:  [Setting up kind cluster](https://hackmd.io/9Q6dhBmaT6OuQzcxcUNxsg)

:::info
**Find this document incomplete?** Leave a comment!
:::

###### tags: `Templates` `Documentation`


