Skip to content

Commit

Permalink
[prometheus-nginx-exporter] Fix Annotation Use in Chart (prometheus-c…
Browse files Browse the repository at this point in the history
…ommunity#4239)

* introduce helper for service & depl annotations

Signed-off-by: Lukas Klinger <[email protected]>

* refactor use of additional annotations

Signed-off-by: Lukas Klinger <[email protected]>

* bump chart version

Signed-off-by: Lukas Klinger <[email protected]>

* integrate review comment feedback

Signed-off-by: Lukas Klinger <[email protected]>

---------

Signed-off-by: Lukas Klinger <[email protected]>
Co-authored-by: MH <[email protected]>
  • Loading branch information
2 people authored and Matiasmct committed Mar 20, 2024
1 parent fd5248d commit 947051a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 22 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-nginx-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v2
description: A Helm chart for the Prometheus NGINX Exporter
name: prometheus-nginx-exporter
version: 0.2.0
version: 0.2.1
appVersion: 0.11.0
home: https://github.com/nginxinc/nginx-prometheus-exporter
sources:
Expand Down
24 changes: 24 additions & 0 deletions charts/prometheus-nginx-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,27 @@ Selector labels
app.kubernetes.io/name: {{ include "prometheus-nginx-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Pod annotations
*/}}
{{- define "prometheus-nginx-exporter.podAnnotations" }}
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations }}
{{- end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations }}
{{- end }}
{{- end }}

{{/*
Service annotations
*/}}
{{- define "prometheus-nginx-exporter.serviceAnnotations" }}
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations }}
{{- end }}
{{- if .Values.service.annotations }}
{{ toYaml .Values.service.annotations }}
{{- end }}
{{- end }}
7 changes: 3 additions & 4 deletions charts/prometheus-nginx-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ metadata:
name: {{ include "prometheus-nginx-exporter.fullname" . }}
namespace: {{ template "prometheus-nginx-exporter.namespace" . }}
{{- with .Values.additionalAnnotations }}
annotations:
{{ toYaml . | indent 4 }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 4 }}
Expand All @@ -24,9 +23,9 @@ spec:
metadata:
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 8 }}
{{- if or .Values.additionalAnnotations .Values.podAnnotations }}
annotations:
{{- with .Values.additionalAnnotations }}
{{ toYaml . | indent 6 }}
{{- include "prometheus-nginx-exporter.podAnnotations" . | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "prometheus-nginx-exporter.serviceAccountName" . }}
Expand Down
5 changes: 2 additions & 3 deletions charts/prometheus-nginx-exporter/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "prometheus-nginx-exporter.fullname" . }}
namespace: {{ template "prometheus-nginx-exporter.namespace" . }}
{{- if .Values.additionalAnnotations }}
annotations:
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- with .Values.additionalAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 4 }}
Expand Down
5 changes: 2 additions & 3 deletions charts/prometheus-nginx-exporter/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "prometheus-nginx-exporter.fullname" . }}
namespace: {{ template "prometheus-nginx-exporter.namespace" . }}
{{- if .Values.additionalAnnotations }}
annotations:
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- with .Values.additionalAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 4 }}
Expand Down
7 changes: 2 additions & 5 deletions charts/prometheus-nginx-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ kind: Service
metadata:
name: {{ include "prometheus-nginx-exporter.fullname" . }}
namespace: {{ template "prometheus-nginx-exporter.namespace" . }}
{{- if or .Values.service.annotations .Values.additionalAnnotations }}
{{- if or .Values.additionalAnnotations .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- with .Values.additionalAnnotations }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- include "prometheus-nginx-exporter.serviceAnnotations" . | indent 4 }}
{{- end }}
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
apiVersion: v1
kind: ServiceAccount
metadata:
{{- if .Values.additionalAnnotations }}
annotations:
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- with .Values.additionalAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ kind: ServiceMonitor
metadata:
name: {{ template "prometheus-nginx-exporter.fullname" . }}
namespace: {{ template "prometheus-nginx-exporter.namespace" . }}
{{- if .Values.additionalAnnotations }}
annotations:
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- with .Values.additionalAnnotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "prometheus-nginx-exporter.labels" . | indent 4 }}
Expand Down

0 comments on commit 947051a

Please sign in to comment.