Skip to content

Commit

Permalink
first draft of prometheus chart (#198)
Browse files Browse the repository at this point in the history
* first draft of prometheus chart

* first draft of prometheus chart
  • Loading branch information
paiusCatalin authored Dec 9, 2022
1 parent df52ac0 commit 76c6219
Show file tree
Hide file tree
Showing 10 changed files with 373 additions and 0 deletions.
24 changes: 24 additions & 0 deletions charts/prometheus/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
tests
31 changes: 31 additions & 0 deletions charts/prometheus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v2
name: prometheus
description: A Helm chart for Prometheus

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: "0.0.1"

icon: https://avatars.githubusercontent.com/u/60230259?s=200&v=4

maintainers:
- name: mastaleru
url: https://github.com/mastaleru
- name: paiusCatalin
url: https://github.com/paiusCatalin
102 changes: 102 additions & 0 deletions charts/prometheus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# prometheus

![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.1](https://img.shields.io/badge/AppVersion-0.0.1-informational?style=flat-square)

A Helm chart for Prometheus

## Requirements

- [helm 3](https://helm.sh/docs/intro/install/)
- These mandatory configuration values:
- serviceName - The name of the service - e.g. `csc`, `eco-iot`
- servicePort - The port of the service - e.g. `80`

## Usage

- [Here](./README.md#values) is a full list of all configuration values.
- The [values.yaml file](./values.yaml) shows the raw view of all configuration values.

## Installation

### Quick install with internal service of type ClusterIP

By default, this helm chart installs the Prometheus as NodePort.
This is to prevent exposing the service to the internet by accident!

It is recommended to put non-sensitive configuration values in a configuration file and pass sensitive/secret values via commandline.

1. Download the values from helm chart `prometheus` and update them accordingly

```shell
helm show values pharmaledger-imi/prometheus > my-values.yaml
```

2. Install via helm to namespace `default`

```bash
helm upgrade my-release-name pharmaledger-imi/prometheus --version=0.0.1 \
--install \
--values my-values.yaml \
```

## Additional helm options

Run `helm upgrade --helm` for full list of options.

1. Install to other namespace

You can install into other namespace than `default` by setting the `--namespace` parameter, e.g.

```bash
helm upgrade my-release-name pharmaledger-imi/prometheus --version=0.0.1 \
--install \
--namespace=my-namespace \
--values my-values.yaml \
```

2. Wait until installation has finished successfully and the deployment is up and running.

Provide the `--wait` argument and time to wait (default is 5 minutes) via `--timeout`

```bash
helm upgrade my-release-name pharmaledger-imi/prometheus --version=0.0.1 \
--install \
--wait --timeout=600s \
--values my-values.yaml \
```

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| mastaleru | | <https://github.com/mastaleru> |
| paiusCatalin | | <https://github.com/paiusCatalin> |

## Values

*Note:* Please scroll horizontally to show more columns (e.g. description)!

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| configMap.evaluationInterval | string | `"15s"` | |
| configMap.mountPath | string | `"/etc/prometheus/prometheus.yml"` | |
| configMap.name | string | `"prometheus-configuration"` | |
| configMap.scrapeInterval | string | `"30s"` | |
| configMap.serviceName | string | `"service"` | |
| configMap.servicePort | int | `80` | |
| configMap.subPath | string | `"prometheus.yml"` | |
| configMap.volumeName | string | `"prometheus-config-volume"` | |
| deployment.imageName | string | `"prom/prometheus"` | |
| deployment.imagePullPolicy | string | `"IfNotPresent"` | |
| deployment.replicaSet | int | `1` | |
| general.defaultNamespace | string | `"default"` | |
| general.httpPort | int | `9090` | |
| general.name | string | `"prometheus"` | |
| general.serviceType | string | `"NodePort"` | |
| storageVolume.mountPath | string | `"/prometheus/"` | |
| storageVolume.storageClassName | string | `""` | |
| storageVolume.storageSize | string | `"5Gi"` | |
| storageVolume.volumeName | string | `"prometheus-storage-volume"` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
78 changes: 78 additions & 0 deletions charts/prometheus/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{{ template "chart.header" . }}

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}

{{ template "chart.description" . }}

## Requirements

- [helm 3](https://helm.sh/docs/intro/install/)
- These mandatory configuration values:
- serviceName - The name of the service - e.g. `csc`, `eco-iot`
- servicePort - The port of the service - e.g. `80`

## Usage

- [Here](./README.md#values) is a full list of all configuration values.
- The [values.yaml file](./values.yaml) shows the raw view of all configuration values.

## Installation

### Quick install with internal service of type ClusterIP

By default, this helm chart installs the Prometheus as NodePort.
This is to prevent exposing the service to the internet by accident!

It is recommended to put non-sensitive configuration values in a configuration file and pass sensitive/secret values via commandline.

1. Download the values from helm chart `prometheus` and update them accordingly

```shell
helm show values pharmaledger-imi/prometheus > my-values.yaml
```

2. Install via helm to namespace `default`

```bash
helm upgrade my-release-name pharmaledger-imi/prometheus --version={{ template "chart.version" . }} \
--install \
--values my-values.yaml \
```

## Additional helm options

Run `helm upgrade --helm` for full list of options.

1. Install to other namespace

You can install into other namespace than `default` by setting the `--namespace` parameter, e.g.

```bash
helm upgrade my-release-name pharmaledger-imi/prometheus --version={{ template "chart.version" . }} \
--install \
--namespace=my-namespace \
--values my-values.yaml \
```

2. Wait until installation has finished successfully and the deployment is up and running.

Provide the `--wait` argument and time to wait (default is 5 minutes) via `--timeout`

```bash
helm upgrade my-release-name pharmaledger-imi/prometheus --version={{ template "chart.version" . }} \
--install \
--wait --timeout=600s \
--values my-values.yaml \
```

{{ template "chart.maintainersSection" . }}

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesHeader" . }}

*Note:* Please scroll horizontally to show more columns (e.g. description)!

{{ template "chart.valuesTable" . }}

{{ template "helm-docs.versionFooter" . }}
26 changes: 26 additions & 0 deletions charts/prometheus/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.configMap.name }}
labels:
name: {{ .Values.configMap.name }}
namespace: {{ .Values.general.defaultNamespace }}
data:
prometheus.yml: |-
global:
scrape_interval: {{ .Values.configMap.scrapeInterval }}
evaluation_interval: {{ .Values.configMap.evaluationInterval }}
external_labels:
type: "governance-metrics"
scrape_configs:
- job_name: "live-metrics"
params:
mode: [ "live" ]
static_configs:
- targets: [ "{{ .Values.configMap.serviceName }}:{{ .Values.configMap.servicePort }}" ]
- job_name: "static-metrics"
params:
mode: [ "static" ]
static_configs:
- targets: [ "{{ .Values.configMap.serviceName }}:{{ .Values.configMap.servicePort }}" ]
40 changes: 40 additions & 0 deletions charts/prometheus/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.general.name }}
spec:
replicas: {{ .Values.deployment.replicaSet }}
selector:
matchLabels:
app: {{ .Values.general.name }}
template:
metadata:
labels:
app: {{ .Values.general.name }}
spec:
securityContext:
fsGroup: 472
supplementalGroups:
- 0
containers:
- name: {{ .Values.general.name }}
image: {{ .Values.deployment.imageName }}
imagePullPolicy: {{ .Values.deployment.imagePullPolicy }}
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/"
ports:
- containerPort: {{ .Values.general.httpPort }}
volumeMounts:
- name: {{ .Values.configMap.volumeName }}
mountPath: {{ .Values.configMap.mountPath }}
subPath: {{ .Values.configMap.subPath }}
- name: {{ .Values.storageVolume.volumeName }}
mountPath: {{ .Values.storageVolume.mountPath }}
volumes:
- name: {{ .Values.configMap.volumeName }}
configMap:
name: {{ .Values.configMap.name }}
- name: {{ .Values.storageVolume.volumeName }}
persistentVolumeClaim:
claimName: {{ .Values.storageVolume.volumeName }}
11 changes: 11 additions & 0 deletions charts/prometheus/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.storageVolume.volumeName }}
spec:
storageClassName: {{ .Values.storageVolume.storageClassName }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.storageVolume.storageSize }}
13 changes: 13 additions & 0 deletions charts/prometheus/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.general.name }}
labels:
app: {{ .Values.general.name }}
spec:
type: {{ .Values.general.serviceType }}
ports:
- port: {{ .Values.general.httpPort }}
targetPort: {{ .Values.general.httpPort }}
selector:
app: {{ .Values.general.name }}
15 changes: 15 additions & 0 deletions charts/prometheus/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "prometheus.fullname" . }}-test-connection"
labels:
{{- include "prometheus.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "prometheus.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
33 changes: 33 additions & 0 deletions charts/prometheus/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
general:
name: prometheus
httpPort: 9090
defaultNamespace: default
serviceType: NodePort

deployment:
replicaSet: 1
imageName: prom/prometheus
imagePullPolicy: IfNotPresent

configMap:
name: prometheus-configuration
volumeName: prometheus-config-volume
mountPath: /etc/prometheus/prometheus.yml
subPath: prometheus.yml

# The interval time when prometheus will start the request
scrapeInterval: 30s
# The amount of time prometheus will wait for the request to be completed
evaluationInterval: 15s

# The name of the service where the API-Hub is deployed (e.g. csc, eco-iot)
serviceName: service
# The port of the service where the API-Hub is deployed
servicePort: 80

storageVolume:
volumeName: prometheus-storage-volume
mountPath: /prometheus/
# If empty or not set then storage class will not be set - which means that the default storage class will be used.
storageClassName: ""
storageSize: 5Gi

0 comments on commit 76c6219

Please sign in to comment.