Skip to content

Commit

Permalink
Merge #153
Browse files Browse the repository at this point in the history
153: ServiceMonitor resource for Prometheus scraping r=alallema a=nlamirault

# Pull Request

## Related issue

- [#3523](meilisearch/meilisearch#3523)

## What does this PR do?
- Creates a ServiceMonitor Kubernetes resources.

Prometheus metrics must be enabled using the `--experimental-enable-metrics` CLI argument

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
Co-authored-by: Amélie <alallema@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 27, 2023
2 parents 0dda412 + 073d0bb commit 3926596
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/meilisearch/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "v1.2.0"
description: A Helm chart for the Meilisearch search engine
name: meilisearch
version: 0.2.0
version: 0.2.1
icon: https://res.cloudinary.com/meilisearch/image/upload/v1597822872/Logo/logo_img.svg
home: https://github.com/meilisearch/meilisearch-kubernetes/tree/main/charts/meilisearch
maintainers:
Expand Down
11 changes: 10 additions & 1 deletion charts/meilisearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Helm chart for the Meilisearch search engine

![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![AppVersion: v1.2.0](https://img.shields.io/badge/AppVersion-v1.2.0-informational?style=flat-square)
![Version: 0.2.1](https://img.shields.io/badge/Version-0.2.1-informational?style=flat-square) ![AppVersion: v1.2.0](https://img.shields.io/badge/AppVersion-v1.2.0-informational?style=flat-square)

Helm works as a package manager to run pre-configured Kubernetes resources.

Expand Down Expand Up @@ -106,6 +106,15 @@ You can also use `auth.existingMasterKeySecret` to use an existing secret that h
| serviceAccount.annotations | object | `{}` | Additional annotations for created service account |
| serviceAccount.create | bool | `true` | Should this chart create a service account |
| serviceAccount.name | string | `""` | Custom service account name, if not created by this chart |
| serviceMonitor | object | `{"additionalLabels":{},"enabled":false,"interval":"1m","metricRelabelings":[],"relabelings":[],"scrapeTimeout":"10s","targetLabels":[],"telemetryPath":"/metrics"}` | Monitoring with Prometheus Operator |
| serviceMonitor.additionalLabels | object | `{}` | Set of labels to transfer from the Kubernetes Service onto the target |
| serviceMonitor.enabled | bool | `false` | Enable ServiceMonitor to configure scraping |
| serviceMonitor.interval | string | `"1m"` | Set scraping frequency |
| serviceMonitor.metricRelabelings | list | `[]` | MetricRelabelConfigs to apply to samples before ingestion |
| serviceMonitor.relabelings | list | `[]` | Set relabel_configs as per https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config |
| serviceMonitor.scrapeTimeout | string | `"10s"` | Set scraping timeout |
| serviceMonitor.targetLabels | list | `[]` | Set of labels to transfer from the Kubernetes Service onto the target |
| serviceMonitor.telemetryPath | string | `"/metrics"` | Set path to metrics |
| startupProbe.InitialDelaySeconds | int | `1` | |
| startupProbe.failureThreshold | int | `60` | |
| startupProbe.periodSeconds | int | `1` | |
Expand Down
5 changes: 4 additions & 1 deletion charts/meilisearch/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ metadata:
{{- include "meilisearch.labels" . | nindent 4 }}
data:
{{- range $key, $value := .Values.environment }}
{{ $key }}: {{ $value | quote}}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if $.Values.serviceMonitor.enabled }}
MEILI_EXPERIMENTAL_ENABLE_METRICS: "true"
{{- end }}
47 changes: 47 additions & 0 deletions charts/meilisearch/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- if.Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "meilisearch.fullname" . }}
labels:
{{- include "meilisearch.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
jobLabel: {{ .Release.Name }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "meilisearch.selectorLabels" . | nindent 6 }}
endpoints:
- port: http
path: {{ .Values.serviceMonitor.telemetryPath }}
{{- with .Values.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- if .Values.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{ toYaml .Values.serviceMonitor.metricRelabelings | indent 4 }}
{{- end }}
{{- if .Values.serviceMonitor.relabelings }}
relabelings:
{{ toYaml .Values.serviceMonitor.relabelings | nindent 4 }}
{{- end }}
{{- if or (.Values.environment.MEILI_MASTER_KEY) (.Values.auth.existingMasterKeySecret) (eq .Values.environment.MEILI_ENV "production") }}
- bearerTokenSecret:
name: meilisearch-master-key
key: MEILI_MASTER_KEY
{{- end }}
{{- if .Values.serviceMonitor.targetLabels }}
targetLabels:
{{- range .Values.serviceMonitor.targetLabels }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/meilisearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,22 @@ affinity: {}

# -- Pod command
command: []

# -- Monitoring with Prometheus Operator
serviceMonitor:
# -- Enable ServiceMonitor to configure scraping
enabled: false
# -- Set of labels to transfer from the Kubernetes Service onto the target
additionalLabels: {}
# -- Set scraping frequency
interval: 1m
# -- Set scraping timeout
scrapeTimeout: 10s
# -- Set path to metrics
telemetryPath: /metrics
# -- Set of labels to transfer from the Kubernetes Service onto the target
targetLabels: []
# -- MetricRelabelConfigs to apply to samples before ingestion
metricRelabelings: []
# -- Set relabel_configs as per https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
relabelings: []
2 changes: 1 addition & 1 deletion manifests/meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec:
app.kubernetes.io/component: search-engine
app.kubernetes.io/part-of: meilisearch
annotations:
checksum/config: 2feedcfe9e2a9425200a2c547238c64e882bd9160bf3a521e1dbab0e83ee246f
checksum/config: 502c6defe0f829ec66f986679faf8ae9ac5866ca466c25a16b5c2be368015508
spec:
serviceAccountName: meilisearch
securityContext:
Expand Down

0 comments on commit 3926596

Please sign in to comment.