Skip to content

Commit

Permalink
[prometheus-elasticsearch-exporter] Bump chart api version, min kuber…
Browse files Browse the repository at this point in the history
…netes version, set standard labels (prometheus-community#4636)

* [prometheus-elasticsearch-exporter]: Prevent Duplicate Labels in ServiceMonitor

Signed-off-by: Hoan Lac <[email protected]>

* [prometheus-elasticsearch-exporter]: bump chart version

Signed-off-by: Hoan Lac <[email protected]>

* [prometheus-elasticsearch-exporter]: follows the new Helm Standard Labels recommendations

Signed-off-by: Hoan Lac <[email protected]>

* Update charts/prometheus-elasticsearch-exporter/templates/_helpers.tpl

Co-authored-by: zeritti <[email protected]>
Signed-off-by: Hoan Lac <[email protected]>

* Update charts/prometheus-elasticsearch-exporter/templates/_helpers.tpl

Co-authored-by: zeritti <[email protected]>
Signed-off-by: Hoan Lac <[email protected]>

* Update charts/prometheus-elasticsearch-exporter/values.yaml

Co-authored-by: zeritti <[email protected]>
Signed-off-by: Hoan Lac <[email protected]>

* Update charts/prometheus-elasticsearch-exporter/values.yaml

Co-authored-by: zeritti <[email protected]>
Signed-off-by: Hoan Lac <[email protected]>

* Update charts/prometheus-elasticsearch-exporter/values.yaml

Co-authored-by: zeritti <[email protected]>
Signed-off-by: Hoan Lac <[email protected]>

* Update charts/prometheus-elasticsearch-exporter/values.yaml

Co-authored-by: zeritti <[email protected]>
Signed-off-by: Hoan Lac <[email protected]>

* Add note in README

Signed-off-by: zeritti <[email protected]>

* Bump chart api version

Signed-off-by: zeritti <[email protected]>

* Update NOTES

Signed-off-by: zeritti <[email protected]>

* Insert commonLabels and uncomment namespace fields

Signed-off-by: zeritti <[email protected]>

* Add commonLabels to pods

Signed-off-by: zeritti <[email protected]>

---------

Signed-off-by: Hoan Lac <[email protected]>
Signed-off-by: Hoan Lac <[email protected]>
Signed-off-by: zeritti <[email protected]>
Co-authored-by: zeritti <[email protected]>
  • Loading branch information
hlac9x and zeritti authored Jul 4, 2024
1 parent fd676ad commit 1867ed4
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 99 deletions.
7 changes: 4 additions & 3 deletions charts/prometheus-elasticsearch-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v1
apiVersion: v2
description: Elasticsearch stats exporter for Prometheus
name: prometheus-elasticsearch-exporter
version: 5.9.0
kubeVersion: ">=1.10.0-0"
version: 6.0.0
kubeVersion: ">=1.19.0-0"
appVersion: "v1.7.0"
home: https://github.com/prometheus-community/elasticsearch_exporter
sources:
Expand All @@ -18,3 +18,4 @@ maintainers:
email: [email protected]
- name: zeritti
email: [email protected]
type: application
66 changes: 40 additions & 26 deletions charts/prometheus-elasticsearch-exporter/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
# Elasticsearch Exporter
# Prometheus Elasticsearch Exporter

Prometheus exporter for various metrics about ElasticSearch, written in Go.
Prometheus exporter for various metrics about Elasticsearch, written in Go. For more information, please, see the project's [repository](https://github.com/prometheus-community/elasticsearch_exporter).

Learn more: <https://github.com/prometheus-community/elasticsearch_exporter>

This chart creates an Elasticsearch-Exporter deployment on a [Kubernetes](http://kubernetes.io)
This chart creates an Elasticsearch exporter deployment on a [Kubernetes](http://kubernetes.io)
cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.10+
- Helm 3.7+
- Kubernetes 1.19+

## Get Helm Repository Info

<!-- textlint-disable terminology -->
```console
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
```

_See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._

_See [helm repo](https://helm.sh/docs/helm/helm_repo/) for command documentation._
<!-- textlint-enable -->
## Install Helm Chart

```console
# Helm 3
$ helm install [RELEASE_NAME] prometheus-community/prometheus-elasticsearch-exporter

# Helm 2
$ helm install --name [RELEASE_NAME] prometheus-community/prometheus-elasticsearch-exporter
helm install [RELEASE_NAME] prometheus-community/prometheus-elasticsearch-exporter
```

The command deploys Elasticsearch Exporter on the Kubernetes cluster using the default configuration.
Expand All @@ -39,11 +34,7 @@ _See [helm install](https://helm.sh/docs/helm/helm_install/) for command documen
## Uninstall Helm Chart

```console
# Helm 3
$ helm uninstall [RELEASE_NAME]

# Helm 2
# helm delete --purge [RELEASE_NAME]
helm uninstall [RELEASE_NAME]
```

This removes all the Kubernetes components associated with the chart and deletes the release.
Expand All @@ -53,12 +44,39 @@ _See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command doc
## Upgrading Helm Chart

```console
# Helm 3 or 2
$ helm upgrade [RELEASE_NAME] [CHART] --install
helm upgrade [RELEASE_NAME] prometheus-community/prometheus-elasticsearch-exporter --install
```

_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._

## To 6.0.0

In release 6.0, the chart API version has been increased to v2. From now on, the chart supports Helm 3 only.

The minimum Kubernetes version supported by the chart has been raised to 1.19.

Labels and selectors have been replaced following [Helm 3 label and annotation best practices](https://helmsh/docs/chart_best_practices/labels/):

| Previous | Current |
|---------------------|------------------------------|
| app | app.kubernetes.io/name |
| chart | helm.sh/chart |
| [none] | app.kubernetes.io/version |
| heritage | app.kubernetes.io/managed-by |
| release | app.kubernetes.io/instance |

As the change is affecting immutable selector labels, the deployment must be deleted before upgrading the release, e.g.:

```console
kubectl delete deploy -l app=prometheus-elasticsearch-exporter
```

Once the resources have been deleted, you can upgrade the release:

```console
helm upgrade -i RELEASE_NAME prometheus-community/prometheus-elasticsearch-exporter
```

### To 5.0.0

`securityContext` has been renamed to `podSecurityContext` and `securityContext.enabled` has no effect anymore. To mirror the behaviour of `securityContext.enabled=false` of 4.x unset `podSecurityContext`.
Expand Down Expand Up @@ -100,11 +118,7 @@ See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_h
To see all configurable options with detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands:

```console
# Helm 2
$ helm inspect values prometheus-community/prometheus-elasticsearch-exporter

# Helm 3
$ helm show values prometheus-community/prometheus-elasticsearch-exporter
helm show values prometheus-community/prometheus-elasticsearch-exporter
```

> **Tip**: You can use the default [values.yaml](values.yaml)
6 changes: 4 additions & 2 deletions charts/prometheus-elasticsearch-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "elasticsearch-exporter.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.httpPort }}{{ .Values.web.path }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "elasticsearch-exporter.fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:{{ .Values.service.httpPort }}{{ .Values.web.path }} to use your application"
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template
"elasticsearch-exporter.name" . }}" -o jsonpath="{.items[0].metadata.name}")

kubectl port-forward $POD_NAME {{ .Values.service.httpPort }}:{{ .Values.service.httpPort }} --namespace {{ .Release.Namespace }}
echo "Visit http://127.0.0.1:{{ .Values.service.httpPort }}{{ .Values.web.path }} to use your application"
{{- end }}
23 changes: 23 additions & 0 deletions charts/prometheus-elasticsearch-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,26 @@ Return the correct (overridden global) image registry.
{{- printf "%s" .Values.image.repository -}}
{{- end }}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "elasticsearch-exporter.labels" -}}
helm.sh/chart: {{ include "elasticsearch-exporter.chart" . }}
{{ include "elasticsearch-exporter.selectorLabels" . }}
{{- with .Chart.AppVersion }}
app.kubernetes.io/version: {{ . | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.commonLabels }}
{{ toYaml .Values.commonLabels }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "elasticsearch-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "elasticsearch-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: Secret
metadata:
name: {{ template "elasticsearch-exporter.fullname" . }}-cert
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
type: Opaque
data:
ca.pem: {{ .Values.es.ssl.ca.pem | b64enc }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ kind: Deployment
metadata:
name: {{ template "elasticsearch-exporter.fullname" . }}
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
{{- with .Values.deployment.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand All @@ -19,8 +16,7 @@ spec:
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
selector:
matchLabels:
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
{{- include "elasticsearch-exporter.selectorLabels" . | nindent 6 }}
strategy:
rollingUpdate:
maxSurge: 1
Expand All @@ -29,8 +25,10 @@ spec:
template:
metadata:
labels:
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
{{- include "elasticsearch-exporter.selectorLabels" . | nindent 8 }}
{{- with .Values.commonLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ metadata:
namespace: {{ .Values.podMonitor.namespace }}
{{- end }}
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
{{- if .Values.podMonitor.labels }}
{{- toYaml .Values.podMonitor.labels | nindent 4 }}
{{- end }}
Expand Down Expand Up @@ -45,6 +42,5 @@ spec:
{{- end }}
selector:
matchLabels:
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
{{- include "elasticsearch-exporter.selectorLabels" . | nindent 6 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: PodSecurityPolicy
metadata:
name: {{ template "elasticsearch-exporter.fullname" . }}
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
spec:
privileged: false
allowPrivilegeEscalation: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ metadata:
namespace: {{ .Values.prometheusRule.namespace }}
{{- end }}
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
{{- if .Values.prometheusRule.labels }}
{{- toYaml .Values.prometheusRule.labels | nindent 4 }}
{{- end }}
Expand Down
5 changes: 1 addition & 4 deletions charts/prometheus-elasticsearch-exporter/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: Role
metadata:
name: {{ template "elasticsearch-exporter.fullname" . }}
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
rules:
- apiGroups: ['extensions']
resources: ['podsecuritypolicies']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: RoleBinding
metadata:
name: {{ template "elasticsearch-exporter.fullname" . }}
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ apiVersion: v1
metadata:
name: {{ template "elasticsearch-exporter.fullname" . }}
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
Expand All @@ -22,6 +19,5 @@ spec:
port: {{ .Values.service.httpPort }}
protocol: TCP
selector:
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
{{- include "elasticsearch-exporter.selectorLabels" . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: ServiceAccount
metadata:
name: {{ template "elasticsearch-exporter.fullname" . }}
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ metadata:
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
labels:
chart: {{ template "elasticsearch-exporter.chart" . }}
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "elasticsearch-exporter.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.labels }}
{{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
{{- end }}
Expand All @@ -36,8 +33,7 @@ spec:
jobLabel: {{ default .Release.Name .Values.serviceMonitor.jobLabel }}
selector:
matchLabels:
app: {{ template "elasticsearch-exporter.name" . }}
release: "{{ .Release.Name }}"
{{- include "elasticsearch-exporter.selectorLabels" . | nindent 6 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
Expand Down
Loading

0 comments on commit 1867ed4

Please sign in to comment.