Skip to content

Commit

Permalink
Merge pull request #234 from wigust/helm
Browse files Browse the repository at this point in the history
Update Helm Chart patch series
  • Loading branch information
czerwonk authored Nov 14, 2023
2 parents 44580ae + 60b8c1b commit 2d3c6d4
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 28 deletions.
44 changes: 44 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,58 @@
# Helm chart for helm v3

## How to use

### Authentication

#### SSH key authentication
Add your ssh-keyfile and config.yml to values.yml

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

#### Password authentication
To use password authentication the following values.yaml configuration could
be used with a `junos-exporter-ssh` secret object storing SSH secrets:

``` yaml
extraArgs:
- "-ssh.targets=$(JUNOS_EXPORTER_SSH_TARGETS)"
- "-ssh.user=$(JUNOS_EXPORTER_SSH_USER)"
- "-ssh.password=$(JUNOS_EXPORTER_SSH_PASSWORD)"

extraEnv:
- name: JUNOS_EXPORTER_SSH_TARGETS
valueFrom:
secretKeyRef:
name: junos-exporter-ssh
key: targets
- name: JUNOS_EXPORTER_SSH_USER
valueFrom:
secretKeyRef:
name: junos-exporter-ssh
key: username
- name: JUNOS_EXPORTER_SSH_PASSWORD
valueFrom:
secretKeyRef:
name: junos-exporter-ssh
key: password
```
``` yaml
apiVersion: v1
kind: Secret
type: Opaque
data:
password: BASE64_ENCODED_SSH_PASSWORD
targets: BASE64_ENCODED_SSH_TARGETS
username: BASE64_ENCODED_SSH_USERNAME
```
### Devices configuration
Add your devices to the devices in configyml in values.yml
### Installation
> cd helm
> helm install junosexporter ./junosexporter
6 changes: 3 additions & 3 deletions helm/junosexporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: junos_exporter
name: junos-exporter
description: junos_exporter deployment for prometheus-operator

# A chart can be either an 'application' or a 'library' chart.
Expand All @@ -14,11 +14,11 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: v0.9.5.7
appVersion: v0.12.2

# dependencies:
# - name: prometheus-operator
Expand Down
7 changes: 4 additions & 3 deletions helm/junosexporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{{- if .Values.configyml }}
apiVersion: v1
kind: ConfigMap
data:
config.yml: {{ toYaml .Values.configyml | indent 2 }}
config.yml: |
{{- toYaml .Values.configyml | nindent 4 }}
metadata:
name: {{ .Release.Name }}-configmap
namespace: {{ .Values.namespace }}
labels:
{{- include "junos_exporter.labels" . | nindent 4 }}
{{- end }}
44 changes: 42 additions & 2 deletions helm/junosexporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ spec:
{{- include "junos_exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- if .Values.rollOutJunosExporterPods }}
annotations:
{{- if .Values.rollOutJunosExporterPods }}
# ensure pods roll when configmap updates
junos-exporter.github.io/junos-exporter-configmap-checksum: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum | quote }}
{{- end }}
{{- end }}
labels:
{{- include "junos_exporter.selectorLabels" . | nindent 8 }}
spec:
Expand All @@ -27,22 +34,55 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /app/junos_exporter
{{- if .Values.extraArgs }}
args:
{{- if .Values.configyml }}
- -config.file=/config/config.yml
{{- end }}
{{- with .Values.extraArgs }}
{{- toYaml . | trim | nindent 10 }}
{{- end }}
{{- end }}
ports:
- name: metrics
containerPort: 9326
protocol: TCP
env:
{{- if .Values.sshkey }}
- name: SSH_KEYFILE
value: "/ssh/ssh-keyfile"
- name: CONFIG_FILE
value: "/config/config.yml"
{{- end }}
{{- with .Values.extraEnv }}
{{- toYaml . | trim | nindent 10 }}
{{- end }}
{{- if or .Values.configyml .Values.sshkey }}
volumeMounts:
{{- if .Values.configyml }}
- mountPath: /config
name: {{ .Release.Name }}-configmap
{{- end }}
{{- if .Values.sshkey }}
- mountPath: /ssh
name: {{ .Release.Name }}-sshkey
{{- end }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if or .Values.configyml .Values.sshkey }}
volumes:
{{- if .Values.configyml }}
- name: {{ .Release.Name }}-configmap
configMap:
name: {{ .Release.Name }}-configmap
{{- end }}
{{- if .Values.sshkey }}
- name: {{ .Release.Name }}-sshkey
secret:
secretName: {{ .Release.Name }}-sshkey
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
2 changes: 2 additions & 0 deletions helm/junosexporter/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.sshkey }}
apiVersion: v1
kind: Secret
data:
Expand All @@ -8,3 +9,4 @@ metadata:
labels:
{{- include "junos_exporter.labels" . | nindent 4 }}
type: Opaque
{{- end }}
4 changes: 3 additions & 1 deletion helm/junosexporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{{- if and .Values.prometheusOperator .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ .Release.Name }}-serviceMonitor
name: {{ .Release.Name }}-servicemonitor
namespace: {{ .Values.namespace }}
release: {{ .Values.prometheusOperator }}
labels:
Expand All @@ -14,3 +15,4 @@ spec:
jobLabel: {{ default "jobLabel" .Values.serviceMonitor.jobLabel }}
selector:
{{- include "junos_exporter.selectorLabels" . | nindent 4 }}
{{- end }}
46 changes: 27 additions & 19 deletions helm/junosexporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

replicaCount: 1

namespace: monitoring

# prometheusOperator is the relase label for prometheus-operator to look at the servicemonitor
prometheusOperator: prometheus-operator

Expand All @@ -19,29 +17,36 @@ fullnameOverride: ""

# sshkey is the base64 encoded id_rsa you want to use for authentication
# generate sshkey with `cat $HOME/.ssh/id_rsa | base64 -w0 && echo`
sshkey: QWRkIHlvdXIgb3duIGlkX3JzYSBoZXJl
# sshkey: "QWRkIHlvdXIgb3duIGlkX3JzYSBoZXJl"

# Additional junos_exporter container environment variables.
extraEnv: []

# Additional junos_exporter container arguments.
extraArgs: []

# configyml is the configfile for the exporter
configyml: |-
devices:
- host: srx.example.com
username: junos_exporter
keyfile: /config/ssh-keyfile
features:
bgp: false
ospf: false
isis: false
l2circuit: false
environment: true
routes: true
routing_engine: true
interface_diagnostic: true
power: true
# configyml:
# devices:
# - host: srx.example.com
# username: junos_exporter
# keyfile: /config/ssh-keyfile
#
# features:
# bgp: false
# ospf: false
# isis: false
# l2circuit: false
# environment: true
# routes: true
# routing_engine: true
# interface_diagnostic: true
# power: true

#serviceMonitor.scapeTimeout needs to be high since junos_exporter uses ssh
#serviceMonitor.interval needs to be higher than scrapeTimeout
serviceMonitor:
enabled: true
scrapeTimeout: 60s
interval: 120s
jobLabel: jobLabel
Expand Down Expand Up @@ -85,3 +90,6 @@ nodeSelector: {}
tolerations: []

affinity: {}

# Roll out junos-exporter pods automatically when configmap is updated.
rollOutJunosExporterPods: false

0 comments on commit 2d3c6d4

Please sign in to comment.