Skip to content

Commit

Permalink
Add prometheus-snmp-exporter chart (helm#10734)
Browse files Browse the repository at this point in the history
* Add prometheus-snmp-exporter chart

Signed-off-by: Maxime Guyot <[email protected]>

* Add RBAC and service accounts best practices

Signed-off-by: Maxime Guyot <[email protected]>

* Use the new labels

Signed-off-by: Maxime Guyot <[email protected]>

* Add documentation of the Prometheus configuration

Signed-off-by: Maxime Guyot <[email protected]>
  • Loading branch information
Miouge1 authored and k8s-ci-robot committed Jan 20, 2019
1 parent d26f5d4 commit 1511ad9
Show file tree
Hide file tree
Showing 13 changed files with 472 additions and 0 deletions.
15 changes: 15 additions & 0 deletions stable/prometheus-snmp-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
description: Prometheus SNMP Exporter
name: prometheus-snmp-exporter
version: 0.0.1
appVersion: 0.14.0
home: https://github.com/prometheus/snmp_exporter
sources:
- https://github.com/prometheus/snmp_exporter
keywords:
- prometheus
- snmp
- monitoring
maintainers:
- name: miouge1
email: [email protected]
4 changes: 4 additions & 0 deletions stable/prometheus-snmp-exporter/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
approvers:
- miouge1
reviewers:
- miouge1
119 changes: 119 additions & 0 deletions stable/prometheus-snmp-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Prometheus SNMP Exporter

Prometheus exporter for snmp monitoring

Learn more: [https://github.com/prometheus/snmp_exporter](https://github.com/prometheus/snmp_exporter)

## TL;DR;

```bash
$ helm install stable/prometheus-snmp-exporter
```

## Introduction

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

## Prerequisites

- Kubernetes 1.8+ with Beta APIs enabled

## Installing the Chart

To install the chart with the release name `my-release`:

```bash
$ helm install --name my-release stable/prometheus-snmp-exporter
```

The command deploys SNMP Exporter on the Kubernetes cluster using the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```bash
$ helm delete --purge my-release
```
The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following table lists the configurable parameters of the SNMP-Exporter chart and their default values.

| Parameter | Description | Default |
| -------------------------------------- | ----------------------------------------------- | ----------------------------- |
| `config` | Prometheus SNMP configuration | {} |
| `configmapReload.name` | configmap-reload container name | `configmap-reload` |
| `configmapReload.image.repository` | configmap-reload container image repository | `jimmidyson/configmap-reload` |
| `configmapReload.image.tag` | configmap-reload container image tag | `v0.2.2` |
| `configmapReload.image.pullPolicy` | configmap-reload container image pull policy | `IfNotPresent` |
| `configmapReload.extraArgs` | Additional configmap-reload container arguments | `{}` |
| `configmapReload.extraConfigmapMounts` | Additional configmap-reload configMap mounts | `[]` |
| `configmapReload.resources` | configmap-reload pod resource requests & limits | `{}` |
| `extraArgs` | Optional flags for exporter | `[]` |
| `image.repository` | container image repository | `prom/snmp-exporter` |
| `image.tag` | container image tag | `v0.12.0` |
| `image.pullPolicy` | container image pull policy | `IfNotPresent` |
| `ingress.annotations` | Ingress annotations | None |
| `ingress.enabled` | Enables Ingress | `false` |
| `ingress.hosts` | Ingress accepted hostnames | None |
| `ingress.tls` | Ingress TLS configuration | None |
| `nodeSelector` | node labels for pod assignment | `{}` |
| `tolerations` | node tolerations for pod assignment | `[]` |
| `affinity` | node affinity for pod assignment | `{}` |
| `podAnnotations` | annotations to add to each pod | `{}` |
| `resources` | pod resource requests & limits | `{}` |
| `restartPolicy` | container restart policy | `Always` |
| `service.annotations` | annotations for the service | `{}` |
| `service.labels` | additional labels for the service | None |
| `service.type` | type of service to create | `ClusterIP` |
| `service.port` | port for the snmp http service | `9116` |
| `service.externalIPs` | list of external ips | [] |
| `rbac.create` | Use Role-based Access Control | `true` |
| `serviceAccount.create` | Should we create a ServiceAccount | `true` |
| `serviceAccount.name` | Name of the ServiceAccount to use | `null` |

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```bash
$ helm install --name my-release \
--set key_1=value_1,key_2=value_2 \
stable/prometheus-snmp-exporter
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

```bash
# example for staging
$ helm install --name my-release -f values.yaml stable/prometheus-snmp-exporter
```

> **Tip**: You can use the default [values.yaml](values.yaml)
## Prometheus Configuration


The snmp exporter needs to be passed the address as a parameter, this can be done with relabelling.

Example config:

```
scrape_configs:
- job_name: 'snmp'
static_configs:
- targets:
- 192.168.1.2 # SNMP device.
metrics_path: /snmp
params:
module: [if_mib]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: my-service-name:9116 # The SNMP exporter's Service name and port.
```

See [prometheus/snmp_exporter/README.md](https://github.com/prometheus/snmp_exporter/) for further information.
1 change: 1 addition & 0 deletions stable/prometheus-snmp-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/prometheus/snmp_exporter/ for how to configure Prometheus and the SNMP Exporter.
42 changes: 42 additions & 0 deletions stable/prometheus-snmp-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "prometheus-snmp-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "prometheus-snmp-exporter.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "prometheus-snmp-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "prometheus-snmp-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "prometheus-snmp-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
14 changes: 14 additions & 0 deletions stable/prometheus-snmp-exporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.config }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "prometheus-snmp-exporter.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "prometheus-snmp-exporter.chart" . }}
data:
snmp.yaml: |
{{ toYaml .Values.config | indent 4 }}
{{- end }}
95 changes: 95 additions & 0 deletions stable/prometheus-snmp-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "prometheus-snmp-exporter.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "prometheus-snmp-exporter.chart" . }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "prometheus-snmp-exporter.chart" . }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
spec:
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 6 }}
{{- end }}

restartPolicy: {{ .Values.restartPolicy }}
serviceAccountName: {{ template "prometheus-snmp-exporter.serviceAccountName" . }}
containers:
- name: snmp-exporter
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
runAsNonRoot: true
runAsUser: 1000
args:
{{- if .Values.config }}
- "--config.file=/config/snmp.yaml"
{{- end }}
{{- if .Values.extraArgs }}
{{ toYaml .Values.extraArgs | indent 12 }}
{{- end }}
securityContext:
readOnlyRootFilesystem: true
resources:
{{ toYaml .Values.resources | indent 12 }}
ports:
- containerPort: {{ .Values.service.port }}
name: http
livenessProbe:
httpGet:
path: /health
port: http
readinessProbe:
httpGet:
path: /health
port: http
{{- if .Values.config }}
volumeMounts:
- mountPath: /config
name: config
- name: configmap-reload
image: "{{ .Values.configmapReload.image.repository }}:{{ .Values.configmapReload.image.tag }}"
imagePullPolicy: "{{ .Values.configmapReload.image.pullPolicy }}"
args:
- --volume-dir=/etc/config
- --webhook-url=http://localhost:{{ .Values.service.port }}/-/reload
resources:
{{ toYaml .Values.configmapReload.resources | indent 12 }}
volumeMounts:
- mountPath: /etc/config
name: config
readOnly: true
volumes:
- name: config
configMap:
name: {{ template "prometheus-snmp-exporter.fullname" . }}
{{- end }}
30 changes: 30 additions & 0 deletions stable/prometheus-snmp-exporter/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.ingress.enabled -}}
{{- $serviceName := include "prometheus-snmp-exporter.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "prometheus-snmp-exporter.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "prometheus-snmp-exporter.chart" . }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
spec:
rules:
{{- range $host := .Values.ingress.hosts }}
- host: {{ $host }}
http:
paths:
- path: /
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}
15 changes: 15 additions & 0 deletions stable/prometheus-snmp-exporter/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.rbac.create }}
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "prometheus-snmp-exporter.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "prometheus-snmp-exporter.chart" . }}
rules:
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get"]
{{- end }}
18 changes: 18 additions & 0 deletions stable/prometheus-snmp-exporter/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.rbac.create }}
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "prometheus-snmp-exporter.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "prometheus-snmp-exporter.chart" . }}
subjects:
- kind: ServiceAccount
name: {{ template "prometheus-snmp-exporter.serviceAccountName" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "prometheus-snmp-exporter.fullname" . }}
{{- end }}
29 changes: 29 additions & 0 deletions stable/prometheus-snmp-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
kind: Service
apiVersion: v1
metadata:
name: {{ template "prometheus-snmp-exporter.fullname" . }}
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "prometheus-snmp-exporter.chart" . }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- name: http
port: {{ .Values.service.port }}
protocol: TCP
{{- if .Values.service.externalIPs }}
externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
Loading

0 comments on commit 1511ad9

Please sign in to comment.