From fb65df5bd017e9cc647ff5b9a313033553707127 Mon Sep 17 00:00:00 2001 From: Giancarlo Rubio Date: Fri, 30 Mar 2018 18:18:02 +0200 Subject: [PATCH] add prometheus node exporter chart (#4260) * add prometheus node exporter chart * Add owners file * Addedd home tag * Review README table, remove rbac from values --- stable/prometheus-node-exporter/.helmignore | 21 ++++++ stable/prometheus-node-exporter/Chart.yaml | 15 +++++ stable/prometheus-node-exporter/OWNERS | 4 ++ stable/prometheus-node-exporter/README.md | 64 ++++++++++++++++++ .../templates/NOTES.txt | 15 +++++ .../templates/_helpers.tpl | 44 +++++++++++++ .../templates/daemonset.yaml | 66 +++++++++++++++++++ .../templates/service.yaml | 19 ++++++ .../templates/serviceaccount.yaml | 11 ++++ stable/prometheus-node-exporter/values.yaml | 35 ++++++++++ 10 files changed, 294 insertions(+) create mode 100644 stable/prometheus-node-exporter/.helmignore create mode 100644 stable/prometheus-node-exporter/Chart.yaml create mode 100644 stable/prometheus-node-exporter/OWNERS create mode 100644 stable/prometheus-node-exporter/README.md create mode 100644 stable/prometheus-node-exporter/templates/NOTES.txt create mode 100644 stable/prometheus-node-exporter/templates/_helpers.tpl create mode 100644 stable/prometheus-node-exporter/templates/daemonset.yaml create mode 100644 stable/prometheus-node-exporter/templates/service.yaml create mode 100644 stable/prometheus-node-exporter/templates/serviceaccount.yaml create mode 100644 stable/prometheus-node-exporter/values.yaml diff --git a/stable/prometheus-node-exporter/.helmignore b/stable/prometheus-node-exporter/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/prometheus-node-exporter/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/stable/prometheus-node-exporter/Chart.yaml b/stable/prometheus-node-exporter/Chart.yaml new file mode 100644 index 0000000000..fa424161b9 --- /dev/null +++ b/stable/prometheus-node-exporter/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +appVersion: "0.15.2" +description: A Helm chart for prometheus node-exporter +name: prometheus-node-exporter +version: 0.1.0 +home: https://github.com/prometheus/node_exporter/ +sources: +- https://github.com/prometheus/node_exporter/ +keywords: +- node-exporter +- prometheus +- exporter +maintainers: +- email: gianrubio@gmail.com + name: gianrubio diff --git a/stable/prometheus-node-exporter/OWNERS b/stable/prometheus-node-exporter/OWNERS new file mode 100644 index 0000000000..fe9b2c3d33 --- /dev/null +++ b/stable/prometheus-node-exporter/OWNERS @@ -0,0 +1,4 @@ +approvers: +- gianrubio +reviewers: +- gianrubio \ No newline at end of file diff --git a/stable/prometheus-node-exporter/README.md b/stable/prometheus-node-exporter/README.md new file mode 100644 index 0000000000..87ab333232 --- /dev/null +++ b/stable/prometheus-node-exporter/README.md @@ -0,0 +1,64 @@ +# Prometheus Node Exporter + +* Installs prometheus [node exporter](https://github.com/prometheus/node_exporter) + +## TL;DR; + +```console +$ helm install stable/prometheus-node-exporter +``` + +## Introduction + +This chart bootstraps a prometheus [node exporter](http://github.com/prometheus/node_exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release stable/prometheus-node-exporter +``` + +The command deploys node exporter on the Kubernetes cluster in 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: + +```console +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the Node Exporter chart and their default values. + +| Parameter | Description | Default | +| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | +| `image.repository` | Image repository | `quay.io/prometheus/node-exporter` | +| `image.tag` | Image tag | `v0.15.2` | +| `image.pullPolicy` | Image pull policy | `IfNotPresent` | +| `resources` | CPU/Memory resource requests/limits | `{}` | +| `service.type` | Service type | `ClusterIP` | +| `service.port` | The service port | `9100` | +| `service.targetPort` | The target port of the container | `9100` | +| `serviceAccount.create` | Specifies whether a service account should be created. | `true` | +| `serviceAccount.name` | Service account to be used. If not set and `serviceAccount.create` is `true`, a name is generated using the fullname template | | +| `tolerations` | List of node taints to tolerate | `- effect: NoSchedule operator: Exists` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm install --name my-release \ + --set serviceAccount.name=node-exporter \ + stable/prometheus-node-exporter +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm install --name my-release -f values.yaml stable/prometheus-node-exporter +``` diff --git a/stable/prometheus-node-exporter/templates/NOTES.txt b/stable/prometheus-node-exporter/templates/NOTES.txt new file mode 100644 index 0000000000..4902798ff1 --- /dev/null +++ b/stable/prometheus-node-exporter/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "prometheus-node-exporter.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "prometheus-node-exporter.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "prometheus-node-exporter.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "prometheus-node-exporter.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/stable/prometheus-node-exporter/templates/_helpers.tpl b/stable/prometheus-node-exporter/templates/_helpers.tpl new file mode 100644 index 0000000000..be079fd0da --- /dev/null +++ b/stable/prometheus-node-exporter/templates/_helpers.tpl @@ -0,0 +1,44 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "prometheus-node-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). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "prometheus-node-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-node-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-node-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "prometheus-node-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/stable/prometheus-node-exporter/templates/daemonset.yaml b/stable/prometheus-node-exporter/templates/daemonset.yaml new file mode 100644 index 0000000000..b4345fe481 --- /dev/null +++ b/stable/prometheus-node-exporter/templates/daemonset.yaml @@ -0,0 +1,66 @@ +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: {{ template "prometheus-node-exporter.fullname" . }} + labels: + app: {{ template "prometheus-node-exporter.name" . }} + chart: {{ template "prometheus-node-exporter.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + selector: + matchLabels: + app: {{ template "prometheus-node-exporter.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "prometheus-node-exporter.name" . }} + release: {{ .Release.Name }} + spec: + serviceAccountName: {{ template "prometheus-node-exporter.serviceAccountName" . }} + securityContext: + runAsNonRoot: true + runAsUser: 65534 + containers: + - name: node-exporter + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - --path.procfs=/host/proc + - --path.sysfs=/host/sys + - --web.listen-address=0.0.0.0:{{ .Values.service.port }} + ports: + - name: metrics + containerPort: {{ .Values.service.targetPort }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: +{{ toYaml .Values.resources | indent 12 }} + volumeMounts: + - name: proc + mountPath: /host/proc + readOnly: true + - name: sys + mountPath: /host/sys + readOnly: true + hostNetwork: true + hostPID: true + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + volumes: + - name: proc + hostPath: + path: /proc + - name: sys + hostPath: + path: /sys \ No newline at end of file diff --git a/stable/prometheus-node-exporter/templates/service.yaml b/stable/prometheus-node-exporter/templates/service.yaml new file mode 100644 index 0000000000..dfa5bf33ce --- /dev/null +++ b/stable/prometheus-node-exporter/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "prometheus-node-exporter.fullname" . }} + labels: + app: {{ template "prometheus-node-exporter.name" . }} + chart: {{ template "prometheus-node-exporter.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + protocol: TCP + name: metrics + selector: + app: {{ template "prometheus-node-exporter.name" . }} + release: {{ .Release.Name }} diff --git a/stable/prometheus-node-exporter/templates/serviceaccount.yaml b/stable/prometheus-node-exporter/templates/serviceaccount.yaml new file mode 100644 index 0000000000..d538b99c95 --- /dev/null +++ b/stable/prometheus-node-exporter/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "prometheus-node-exporter.serviceAccountName" . }} + labels: + app: {{ template "prometheus-node-exporter.name" . }} + chart: {{ template "prometheus-node-exporter.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +{{- end -}} diff --git a/stable/prometheus-node-exporter/values.yaml b/stable/prometheus-node-exporter/values.yaml new file mode 100644 index 0000000000..0a635369b0 --- /dev/null +++ b/stable/prometheus-node-exporter/values.yaml @@ -0,0 +1,35 @@ +# Default values for prometheus-node-exporter. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +image: + repository: quay.io/prometheus/node-exporter + tag: v0.15.2 + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 9100 + targetPort: 9100 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 200m + # memory: 50Mi + # requests: + # cpu: 100m + # memory: 30Mi + +serviceAccount: + # Specifies whether a ServiceAccount should be created + create: true + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: + +tolerations: + - effect: NoSchedule + operator: Exists