Skip to content

Commit 01561b5

Browse files
authored
Merge pull request #33 from raffis/chart-improvements
chart improvements, common labels/annotations
2 parents d777ee2 + 79d8ed3 commit 01561b5

13 files changed

+103
-71
lines changed

chart/prometheus-mongodb-query-exporter/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v2
2-
appVersion: 1.0.0-beta7
2+
appVersion: v1.0.0-beta7
33
description: A Prometheus exporter for MongoDB custom aggregations
44
home: https://github.com/raffis/mongodb-query-exporter
55
keywords:
@@ -12,4 +12,4 @@ keywords:
1212
name: prometheus-mongodb-query-exporter
1313
sources:
1414
- https://github.com/raffis/mongodb-query-exporter
15-
version: 1.1.3
15+
version: 1.1.4

chart/prometheus-mongodb-query-exporter/templates/_helpers.tpl

+14
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,17 @@ Determine configmap name, can either be the self-created of an existing one
6464
{{- end -}}
6565
{{- end -}}
6666

67+
68+
{{/*
69+
Common labels
70+
*/}}
71+
{{- define "prometheus-mongodb-query-exporter.labels" -}}{{- if .Values.chartLabels }}
72+
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
73+
app.kubernetes.io/instance: {{ .Release.Name }}
74+
app.kubernetes.io/managed-by: {{ .Release.Service }}
75+
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
76+
{{- end -}}
77+
{{- with .Values.labels }}
78+
{{ . | toYaml }}
79+
{{- end -}}
80+
{{- end -}}

chart/prometheus-mongodb-query-exporter/templates/configmap.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ apiVersion: v1
33
kind: ConfigMap
44
metadata:
55
name: {{ include "prometheus-mongodb-query-exporter.configName" . }}
6+
{{- with ( include "prometheus-mongodb-query-exporter.labels" . ) }}
67
labels:
7-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
8-
app.kubernetes.io/instance: {{ .Release.Name }}
9-
app.kubernetes.io/managed-by: {{ .Release.Service }}
10-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
8+
{{- . }}
9+
{{- end }}
10+
{{- with .Values.annotations }}
1111
annotations:
12-
{{- toYaml .Values.annotations | nindent 4 }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
1314
data:
1415
config.yaml: |
1516
{{ .Values.config | nindent 4}}

chart/prometheus-mongodb-query-exporter/templates/deployment.yaml

+19-10
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: {{ include "prometheus-mongodb-query-exporter.fullname" . }}
5+
{{- with ( include "prometheus-mongodb-query-exporter.labels" . ) }}
56
labels:
6-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
7-
app.kubernetes.io/instance: {{ .Release.Name }}
8-
app.kubernetes.io/managed-by: {{ .Release.Service }}
9-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
7+
{{- . }}
8+
{{- end }}
9+
{{- with .Values.annotations }}
1010
annotations:
11-
{{- toYaml .Values.annotations | nindent 4 }}
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
1213
spec:
1314
replicas: {{ .Values.replicas }}
1415
selector:
@@ -52,7 +53,7 @@ spec:
5253
- secretRef:
5354
name: {{ .Values.envFromSecret }}
5455
{{- end }}
55-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
56+
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
5657
imagePullPolicy: {{ .Values.image.pullPolicy }}
5758
args:
5859
- --bind={{ printf ":%s" .Values.port }}
@@ -94,15 +95,23 @@ spec:
9495
secret:
9596
secretName: {{ .secretName }}
9697
{{- end }}
98+
{{- with .Values.affinity }}
9799
affinity:
98-
{{- toYaml .Values.affinity | nindent 8 }}
100+
{{- toYaml . | nindent 8 }}
101+
{{- end }}
102+
{{- with .Values.imagePullSecrets }}
99103
imagePullSecrets:
100-
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
104+
{{- toYaml . | nindent 8 }}
105+
{{- end }}
106+
{{- with .Values.nodeSelector }}
101107
nodeSelector:
102-
{{- toYaml .Values.nodeSelector | nindent 8 }}
108+
{{- toYaml . | nindent 8 }}
109+
{{- end }}
103110
{{- if .Values.priorityClassName }}
104111
priorityClassName: {{ .Values.priorityClassName }}
105112
{{- end }}
106113
terminationGracePeriodSeconds: 30
114+
{{- with .Values.tolerations }}
107115
tolerations:
108-
{{- toYaml .Values.tolerations | nindent 8 }}
116+
{{- toYaml . | nindent 8 }}
117+
{{- end }}

chart/prometheus-mongodb-query-exporter/templates/podsecuritypolicy.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ apiVersion: policy/v1beta1
33
kind: PodSecurityPolicy
44
metadata:
55
name: {{ template "prometheus-mongodb-query-exporter.fullname" . }}
6+
{{- with ( include "prometheus-mongodb-query-exporter.labels" . ) }}
67
labels:
7-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
8-
app.kubernetes.io/instance: {{ .Release.Name }}
9-
app.kubernetes.io/managed-by: {{ .Release.Service }}
10-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
8+
{{- . }}
9+
{{- end }}
10+
{{- with .Values.annotations }}
1111
annotations:
12-
{{- toYaml .Values.annotations | nindent 4 }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
1314
spec:
1415
privileged: false
1516
allowPrivilegeEscalation: false

chart/prometheus-mongodb-query-exporter/templates/prometheusrule.yaml

+10-11
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@ kind: PrometheusRule
44
metadata:
55
metadata:
66
name: {{ template "prometheus-mongodb-query-exporter.fullname" . }}
7-
{{- if .Values.prometheusRule.namespace }}
8-
namespace: {{ .Values.prometheusRule.namespace }}
9-
{{- end }}
7+
{{- $labels := merge ( include "prometheus-mongodb-query-exporter.labels" . | fromYaml) .Values.prometheusRule.labels -}}
8+
{{- with $labels }}
109
labels:
11-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
12-
app.kubernetes.io/instance: {{ .Release.Name }}
13-
app.kubernetes.io/managed-by: {{ .Release.Service }}
14-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
15-
{{- if .Values.prometheusRule.labels }}
16-
{{- toYaml .Values.prometheusRule.labels | nindent 4 }}
17-
{{- end }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- with .Values.annotations }}
1813
annotations:
19-
{{- toYaml .Values.annotations | nindent 4 }}
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
{{- if .Values.prometheusRule.namespace }}
17+
namespace: {{ .Values.prometheusRule.namespace }}
18+
{{- end }}
2019
spec:
2120
{{- with .Values.prometheusRule.rules }}
2221
groups:

chart/prometheus-mongodb-query-exporter/templates/role.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ apiVersion: rbac.authorization.k8s.io/v1
33
kind: Role
44
metadata:
55
name: {{ template "prometheus-mongodb-query-exporter.fullname" . }}
6+
{{- with ( include "prometheus-mongodb-query-exporter.labels" . ) }}
67
labels:
7-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
8-
app.kubernetes.io/instance: {{ .Release.Name }}
9-
app.kubernetes.io/managed-by: {{ .Release.Service }}
10-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
8+
{{- . }}
9+
{{- end }}
10+
{{- with .Values.annotations }}
1111
annotations:
12-
{{- toYaml .Values.annotations | nindent 4 }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
1314
rules:
1415
- apiGroups: ['extensions']
1516
resources: ['podsecuritypolicies']

chart/prometheus-mongodb-query-exporter/templates/rolebinding.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ apiVersion: rbac.authorization.k8s.io/v1
33
kind: RoleBinding
44
metadata:
55
name: {{ template "prometheus-mongodb-query-exporter.fullname" . }}
6+
{{- with ( include "prometheus-mongodb-query-exporter.labels" . ) }}
67
labels:
7-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
8-
app.kubernetes.io/instance: {{ .Release.Name }}
9-
app.kubernetes.io/managed-by: {{ .Release.Service }}
10-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
8+
{{- . }}
9+
{{- end }}
10+
{{- with .Values.annotations }}
1111
annotations:
12-
{{- toYaml .Values.annotations | nindent 4 }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
1314
roleRef:
1415
apiGroup: rbac.authorization.k8s.io
1516
kind: Role

chart/prometheus-mongodb-query-exporter/templates/secret.yaml

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ apiVersion: v1
33
kind: Secret
44
metadata:
55
name: {{ include "prometheus-mongodb-query-exporter.secretName" . }}
6+
{{- with ( include "prometheus-mongodb-query-exporter.labels" . ) }}
67
labels:
7-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
8-
app.kubernetes.io/instance: {{ .Release.Name }}
9-
app.kubernetes.io/managed-by: {{ .Release.Service }}
10-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
8+
{{- . }}
9+
{{- end }}
10+
{{- with .Values.annotations }}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
1114
type: Opaque
1215
data:
1316
{{- if .Values.mongodb }}

chart/prometheus-mongodb-query-exporter/templates/service.yaml

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: {{ include "prometheus-mongodb-query-exporter.fullname" . }}
5+
{{- $labels := merge ( include "prometheus-mongodb-query-exporter.labels" . | fromYaml) .Values.service.labels -}}
6+
{{- with $labels }}
57
labels:
6-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
7-
app.kubernetes.io/instance: {{ .Release.Name }}
8-
app.kubernetes.io/managed-by: {{ .Release.Service }}
9-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
10-
{{- if .Values.service.labels }}
11-
{{ toYaml .Values.service.labels | indent 4 }}
12-
{{- end }}
8+
{{- toYaml . | nindent 4 }}
9+
{{- end }}
10+
{{- with .Values.annotations }}
1311
annotations:
14-
{{- toYaml .Values.service.annotations | nindent 4 }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
1514
spec:
1615
ports:
1716
- port: {{ .Values.service.port }}

chart/prometheus-mongodb-query-exporter/templates/serviceaccount.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ apiVersion: v1
33
kind: ServiceAccount
44
metadata:
55
name: {{ template "prometheus-mongodb-query-exporter.serviceAccountName" . }}
6+
{{- with ( include "prometheus-mongodb-query-exporter.labels" . ) }}
67
labels:
7-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
8-
app.kubernetes.io/instance: {{ .Release.Name }}
9-
app.kubernetes.io/managed-by: {{ .Release.Service }}
10-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
8+
{{- . }}
9+
{{- end }}
10+
{{- with .Values.annotations }}
1111
annotations:
12-
{{- toYaml .Values.annotations | nindent 4 }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
1314
{{- end -}}

chart/prometheus-mongodb-query-exporter/templates/servicemonitor.yaml

+8-9
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ apiVersion: monitoring.coreos.com/v1
33
kind: ServiceMonitor
44
metadata:
55
name: {{ include "prometheus-mongodb-query-exporter.fullname" . }}
6+
{{- $labels := merge ( include "prometheus-mongodb-query-exporter.labels" . | fromYaml) .Values.serviceMonitor.labels -}}
7+
{{- with $labels }}
68
labels:
7-
app.kubernetes.io/name: {{ include "prometheus-mongodb-query-exporter.name" . }}
8-
app.kubernetes.io/instance: {{ .Release.Name }}
9-
app.kubernetes.io/managed-by: {{ .Release.Service }}
10-
helm.sh/chart: {{ include "prometheus-mongodb-query-exporter.chart" . }}
11-
{{- range $key, $value := .Values.serviceMonitor.additionalLabels }}
12-
{{ $key }}: {{ $value | quote }}
13-
{{- end }}
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
11+
{{- with .Values.annotations }}
12+
annotations:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
1415
{{- if .Values.serviceMonitor.namespace }}
1516
namespace: {{ .Values.serviceMonitor.namespace }}
1617
{{- end }}
17-
annotations:
18-
{{- toYaml .Values.annotations | nindent 4 }}
1918
spec:
2019
endpoints:
2120
- port: metrics

chart/prometheus-mongodb-query-exporter/values.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
affinity: {}
22

3+
chartLabels: true
4+
5+
labels: {}
6+
37
annotations: {}
48

59
extraArgs:
@@ -9,7 +13,7 @@ fullnameOverride: ""
913
image:
1014
pullPolicy: IfNotPresent
1115
repository: raffis/mongodb-query-exporter
12-
tag: v1.0.0-beta7
16+
tag:
1317

1418
imagePullSecrets: []
1519

@@ -155,7 +159,7 @@ serviceMonitor:
155159
interval: 30s
156160
scrapeTimeout: 10s
157161
namespace:
158-
additionalLabels: {}
162+
labels: {}
159163
targetLabels: []
160164
metricRelabelings: []
161165
sampleLimit: 0

0 commit comments

Comments
 (0)