Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Prometeus and Grafana charts #41

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions charts/prometheus-grafana/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
apiVersion: v2
name: prometheus-grafana-helm
dependencies:
- name: prometheus
repository: https://prometheus-community.github.io/helm-charts
version: 27.5.x
- name: grafana
repository: https://grafana.github.io/helm-charts
version: 8.10.x
description: Prometheus and Grafana Helm Chart for Rahti platform
Link to the repo https://github.com/CSCfi/helm-charts
version: 1.1.1
version: 2.0.0
sources:
- https://github.com/CSCfi/helm-charts
icon: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Grafana_icon.svg/351px-Grafana_icon.svg.png
icon: https://miro.medium.com/v2/resize:fit:640/format:webp/0*4G5AVIBCAKMU1Ctl.png
63 changes: 35 additions & 28 deletions charts/prometheus-grafana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ helm upgrade --install graf-prom .
```

## Explanations
This Helm Chart helps you to deploy Grafana and Prometheus on CSC Rahti2 (Openshift 4).
This Helm Chart helps you to deploy Grafana and Prometheus on CSC Rahti (Openshift 4).
If you want to use it with different values, you can edit `values.yaml` file and then run:
```sh
helm upgrade --install graf-prom . -f {custom_values.yaml}
Expand All @@ -15,33 +15,40 @@ The password to access Grafana WebUI is generated randomly and won't change if y

## Parameters

### HedgeDoc parameters

| Name | Description | Value |
| ---------------------------------------------------- | ------------------------------------------------------- | --------------------------------- |
| `prometheus.appName` | Name of your app. | `prometheus` |
| `prometheus.image` | Name of the `prometheus` image | `prom/prometheus:v2.50.1` |
| `prometheus.retentionTime` | Define how long data is kept in time-series database | `15d` |
| `prometheus.limits.memory` | Define the maximum of amount of memory | `4Gi` |
| `prometheus.requests.memory` | Define the minimum guaranteed amount of memory | `4Gi` |
| `prometheus.pvc.storageSize` | Define the size of the Persistent Volume Claim | `5Gi` |
| `prometheus.service.type` | Define the service type | `ClusterIP` |

### Grafana parameters

| Name | Description | Value |
| ---------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------ |
| `grafana.appName` | Name of your app. | `grafana` |
| `grafana.image` | Name of the `prometheus` image | `grafana/grafana:10.2.4` |
| `grafana.limits.memory` | Define the maximum of amount of memory | `1Gi` |
| `grafana.requests.memory` | Define the minimum guaranteed amount of memory | `1Gi` |
| `grafana.random_pw_secret_key` | Key to store the password | `admin-password` |
| `grafana.secret.admin-username` | Name of the user to connect to prometheus webUI | `admin` |
| `grafana.secret.admin-password` | Function that retrieve the generated password | `'{{- include "random_pw_reusable" . - }}` |
| `grafana.service.type` | Define the service type | `ClusterIP` |
| `grafana.route.tls.termination` | Create an OpenShift route | `edge` |
| `grafana.route.tls.insecureEdgeTerminationPolicy` | Create an OpenShift route | `Redirect` |
| `grafana.pvc.storageSize` | Define the size of the Persistent Volume Claim | `5Gi` |
We created a default `values.yaml` file that is compatible with our platform Rahti. This Helm Chart is using the official from Prometheus and Grafana.
Take a look:

- [Prometheus Community](https://github.com/prometheus-community/helm-charts/blob/main/charts/prometheus/README.md)
- [Grafana](https://github.com/grafana/helm-charts/blob/main/charts/grafana/README.md)

There are two mandatory fields that you must fill out:
- `prometheus.serverFiles.prometheus.yml.scrape_configs.1.kubernetes_sd_configs.0.namespaces.names.0`
```yaml
- job_name: 'kubernetes-service-endpoints'
honor_labels: true
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- # Enter the name of your namespace/project here
```

- `prometheus.serverFiles.prometheus.yml.scrape_configs.2.kubernetes_sd_configs.0.namespaces.names.0`
```yaml
- job_name: 'kubernetes-pods'
honor_labels: true
kubernetes_sd_configs:
- role: pods
namespaces:
names:
- # Enter the name of your namespace/project here
```

In order to have your pods monitored by Prometheus, you need to add these annotations:

* `prometheus.io/scrape`: Only scrape pods that have a value of `true`,
* `prometheus.io/path`: If the metrics path is not `/metrics` override this.
* `prometheus.io/port`: Scrape the pod on the indicated port instead of the default of `9102`.

## Cleanup
To delete all the resources, simply uninstall the Helm Chart:
Expand Down
27 changes: 18 additions & 9 deletions charts/prometheus-grafana/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
=======================================
========================================
CSC Prometheus-Grafana Helm deployed
=======================================
========================================
===========
GRAFANA
===========
Wait a few seconds. Time for the application to be fully deployed.

Get the Grafana application URL by running these commands:

export GRAFANA=$(oc get route --namespace={{ .Release.Namespace }} -o yaml | yq '.items[] | select(.metadata.name == "{{ .Values.grafana.appName }}-route") .spec.host' -r)
export GRAFANA=$(oc get route --namespace={{ .Release.Namespace }} -o yaml | yq '.items[] | select(.metadata.name == "grafana") .spec.host' -r)
echo "GRAFANA server URL: http://$GRAFANA"

The password for the access is generated randomly.
To retrieve the information, run these commands:

echo Username: $(oc get secret --namespace={{ .Release.Namespace }} {{ .Values.grafana.appName }} -o jsonpath="{.data.admin-username}" | base64 -d)
echo Password: $(oc get secret --namespace={{ .Release.Namespace }} {{ .Values.grafana.appName }} -o jsonpath="{.data.admin-password}" | base64 -d)
echo Username: $(oc get secret --namespace={{ .Release.Namespace }} {{ .Release.Name }}-grafana -o jsonpath="{.data.admin-user}" | base64 -d)
echo Password: $(oc get secret --namespace={{ .Release.Namespace }} {{ .Release.Name }}-grafana -o jsonpath="{.data.admin-password}" | base64 -d)

The Route to Prometheus is not deployed by default. If you want to access Prometheus, you can type this command:

oc create route edge prometheus-route --service={{ .Values.prometheus.appName }}-service --insecure-policy='Redirect' --port=9090
========================
PROMETHEUS (OPTIONAL)
========================
The Route to Prometheus is not deployed by default. You can change the behaviour by setting `true` in the `values.yaml`
or you can type this command:

And then, you can retrieve the Prometheus URL by running these commands:
oc --namespace {{ .Release.Namespace }} create route edge prometheus --service={{ .Release.Name }}-prometheus-server --insecure-policy='Redirect' --port=9090

export PROMETHEUS=$(oc get route --namespace={{ .Release.Namespace }} -o yaml | yq '.items[] | select(.metadata.name == "{{ .Values.prometheus.appName }}-route") .spec.host' -r)
You can retrieve the Prometheus URL by running these commands:

export PROMETHEUS=$(oc get route --namespace={{ .Release.Namespace }} -o yaml | yq '.items[] | select(.metadata.name == "prometheus") .spec.host' -r)
echo "PROMETHEUS server URL: http://$PROMETHEUS"
86 changes: 0 additions & 86 deletions charts/prometheus-grafana/templates/_helpers.tpl

This file was deleted.

29 changes: 0 additions & 29 deletions charts/prometheus-grafana/templates/grafana/configmap.yaml

This file was deleted.

61 changes: 0 additions & 61 deletions charts/prometheus-grafana/templates/grafana/deployment.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions charts/prometheus-grafana/templates/grafana/pvc.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions charts/prometheus-grafana/templates/grafana/route.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions charts/prometheus-grafana/templates/grafana/secret.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions charts/prometheus-grafana/templates/grafana/service.yaml

This file was deleted.

Loading