Skip to content

Commit 47819ec

Browse files
authored
Helm: chart fixes and improvements (#259)
* fix: ServiceMonitor release label and selector Signed-off-by: crabique <crabique@users.noreply.github.com> * add: support for extraVolumes, extraVolumeMounts and annotations; restart pod upon SSH key change too Signed-off-by: crabique <crabique@users.noreply.github.com> * fix: serviceaccount blank line Signed-off-by: crabique <crabique@users.noreply.github.com> * bump: update chart version and bump exporter image Signed-off-by: crabique <crabique@users.noreply.github.com> * docs: update chart README with the new options, fix some typos Signed-off-by: crabique <crabique@users.noreply.github.com> --------- Signed-off-by: crabique <crabique@users.noreply.github.com>
1 parent 2802bce commit 47819ec

File tree

6 files changed

+52
-15
lines changed

6 files changed

+52
-15
lines changed

helm/README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
### Authentication
66

77
#### SSH key authentication
8-
Add your ssh-keyfile and config.yml to values.yml
8+
Add your SSH key and `configyml` to `values.yml`
99

10-
> sshkey is the base64 encoded id_rsa you want to use for authentication
10+
> sshkey is the base64 encoded id_rsa you want to use for authentication
1111
> generate sshkey with `cat $HOME/.ssh/id_rsa | base64 -w0 && echo`
1212
1313
`sshkey: QWRkIHlvdXIgb3duIGlkX3JzYSBoZXJl`
1414

15+
It is also possible to use the existing-secret pattern (e.g. with ExternalSecrets operator),
16+
the secret with the SSH key should be mounted via `extraVolumes` and `extraVolumeMounts`.
17+
1518
#### Password authentication
1619
To use password authentication the following values.yaml configuration could
1720
be used with a `junos-exporter-ssh` secret object storing SSH secrets:
@@ -51,8 +54,20 @@ data:
5154
```
5255
5356
### Devices configuration
54-
Add your devices to the devices in configyml in values.yml
57+
Add your devices to the devices in `configyml` in `values.yaml`
58+
59+
### Handling configuration/authorization changes
60+
To force reload of the exporter pods upon `configyml` or `sshkey` configuration changes,
61+
enable the `rollOutJunosExporterPods` option in `values.yaml`.
62+
63+
If Reloader controller is installed in the cluster, for `extraEnv` passwords or `extraVolumes` keys
64+
the `annotations` map in `values.yaml` can be used to specify a policy to handle the updates:
65+
66+
```yaml
67+
annotations:
68+
reloader.stakater.com/auto: "true"
69+
```
5570

5671
### Installation
57-
> cd helm
58-
> helm install junosexporter ./junosexporter
72+
> cd helm
73+
> helm install junosexporter ./junosexporter

helm/junosexporter/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ type: application
1414

1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
17-
version: 0.2.0
17+
version: 0.3.0
1818

1919
# This is the version number of the application being deployed. This version number should be
2020
# incremented each time you make changes to the application.
21-
appVersion: v0.12.2
21+
appVersion: v0.12.4
2222

2323
# dependencies:
2424
# - name: prometheus-operator

helm/junosexporter/templates/deployment.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ metadata:
44
name: {{ include "junos_exporter.fullname" . }}
55
labels:
66
{{- include "junos_exporter.labels" . | nindent 4 }}
7+
{{- with .Values.annotations }}
8+
annotations:
9+
{{- toYaml . | trim | nindent 4 }}
10+
{{- end }}
711
spec:
812
replicas: {{ .Values.replicaCount }}
913
selector:
@@ -16,6 +20,10 @@ spec:
1620
{{- if .Values.rollOutJunosExporterPods }}
1721
# ensure pods roll when configmap updates
1822
junos-exporter.github.io/junos-exporter-configmap-checksum: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum | quote }}
23+
{{- with .Values.sshkey }}
24+
# same but for the SSH key (hash salted with the release and truncated just in case)
25+
junos-exporter.github.io/junos-exporter-key-checksum: {{ cat $.Release.Name . | sha256sum | trunc 12 | quote }}
26+
{{- end }}
1927
{{- end }}
2028
{{- end }}
2129
labels:
@@ -57,7 +65,7 @@ spec:
5765
{{- with .Values.extraEnv }}
5866
{{- toYaml . | trim | nindent 10 }}
5967
{{- end }}
60-
{{- if or .Values.configyml .Values.sshkey }}
68+
{{- if or .Values.configyml .Values.sshkey .Values.extraVolumeMounts }}
6169
volumeMounts:
6270
{{- if .Values.configyml }}
6371
- mountPath: /config
@@ -67,10 +75,13 @@ spec:
6775
- mountPath: /ssh
6876
name: {{ .Release.Name }}-sshkey
6977
{{- end }}
78+
{{- with .Values.extraVolumeMounts }}
79+
{{- toYaml . | trim | nindent 10 }}
80+
{{- end }}
7081
{{- end }}
7182
resources:
7283
{{- toYaml .Values.resources | nindent 12 }}
73-
{{- if or .Values.configyml .Values.sshkey }}
84+
{{- if or .Values.configyml .Values.sshkey .Values.extraVolumes }}
7485
volumes:
7586
{{- if .Values.configyml }}
7687
- name: {{ .Release.Name }}-configmap
@@ -82,6 +93,9 @@ spec:
8293
secret:
8394
secretName: {{ .Release.Name }}-sshkey
8495
{{- end }}
96+
{{- with .Values.extraVolumes }}
97+
{{- toYaml . | trim | nindent 8 }}
98+
{{- end }}
8599
{{- end }}
86100
{{- with .Values.nodeSelector }}
87101
nodeSelector:

helm/junosexporter/templates/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ kind: ServiceAccount
44
metadata:
55
name: {{ include "junos_exporter.serviceAccountName" . }}
66
labels:
7-
{{ include "junos_exporter.labels" . | nindent 4 }}
7+
{{- include "junos_exporter.labels" . | nindent 4 }}
88
{{- end -}}

helm/junosexporter/templates/servicemonitor.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ kind: ServiceMonitor
44
metadata:
55
name: {{ .Release.Name }}-servicemonitor
66
namespace: {{ .Values.namespace }}
7-
release: {{ .Values.prometheusOperator }}
87
labels:
8+
release: {{ .Values.prometheusOperator }}
99
{{- include "junos_exporter.labels" . | nindent 4 }}
1010
spec:
1111
endpoints:
@@ -14,5 +14,6 @@ spec:
1414
interval: {{ default "120s" .Values.serviceMonitor.interval }}
1515
jobLabel: {{ default "jobLabel" .Values.serviceMonitor.jobLabel }}
1616
selector:
17-
{{- include "junos_exporter.selectorLabels" . | nindent 4 }}
17+
matchLabels:
18+
{{- include "junos_exporter.selectorLabels" . | nindent 6 }}
1819
{{- end }}

helm/junosexporter/values.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
replicaCount: 1
66

7-
# prometheusOperator is the relase label for prometheus-operator to look at the servicemonitor
7+
# prometheusOperator is the release label for prometheus-operator to look at the servicemonitor
88
prometheusOperator: prometheus-operator
99

1010
image:
@@ -25,6 +25,10 @@ extraEnv: []
2525
# Additional junos_exporter container arguments.
2626
extraArgs: []
2727

28+
# Additional volumes and mounts to add to the container.
29+
extraVolumes: []
30+
extraVolumeMounts: []
31+
2832
# configyml is the configfile for the exporter
2933
# configyml:
3034
# devices:
@@ -57,7 +61,7 @@ serviceAccount:
5761
create: true
5862
# The name of the service account to use.
5963
# If not set and create is true, a name is generated using the fullname template
60-
name:
64+
name: ""
6165

6266
podSecurityContext: {}
6367
# fsGroup: 2000
@@ -92,5 +96,8 @@ tolerations: []
9296

9397
affinity: {}
9498

95-
# Roll out junos-exporter pods automatically when configmap is updated.
99+
# Annotations to add to the Deployment
100+
annotations: {}
101+
102+
# Roll out junos-exporter pods automatically when configyml or sshkey is updated
96103
rollOutJunosExporterPods: false

0 commit comments

Comments
 (0)