Skip to content

Commit 13883ac

Browse files
committed
add more documentation and a basic helm chart
Signed-off-by: Alexander Trost <[email protected]>
1 parent 6cc1b69 commit 13883ac

File tree

11 files changed

+294
-2
lines changed

11 files changed

+294
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ Any flags / args given to the container are passed to the `SCRIPT` that will be
3434

3535
## Grafana Dashboard
3636

37-
A Grafana dashboard for viewing the exported metrics can be found on [Grafana.com - Smartmon Textfile by Galexrt](https://grafana.com/dashboards/3992) and in the [`grafana/`](grafana/) directory.
37+
A Grafana dashboard for viewing `smartmon` metrics can be found in the [`grafana/`](grafana/) directory and [Grafana.com - Smartmon Textfile Dashboard by Galexrt](https://grafana.com/dashboards/3992).
38+
39+
## Required node_exporter Configuration
40+
41+
See [node_exporter Configuration Prerequisites](docs/../node_exporter.md).
3842

3943
## Kubernetes
44+
Following deployments / installation methods are available:
4045

41-
The [`kubernetes/`](kubernetes/) directory contains an example DaemonSet for your Kubernetes cluster.
46+
* [`node-exporter-textfiles` Helm Chart](charts/node-exporter-textfiles) (Recommended)
47+
* [`kubernetes/`](kubernetes/) directory contains an example DaemonSet running the `smartmon.sh` and `nvme_metrics.sh` textfile scripts.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: node-exporter-textfiles
3+
description: A Helm chart for running the container-node-exporter-textfiles image easily in Kubernetes as a DaemonSet.
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "v20220203-125335-155"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# node-exporter-textfiles Helm Chart
2+
3+
## Prerequisites
4+
5+
Checkout the [node_exporter textfile Configuration documentation](../../docs/node_exporter.md) to ensure your node_exporter is configured to pickup the textfile exported metrics.
6+
7+
## Installation
8+
9+
You can customize the textfiles deployed by modifying the `values.yaml` to your needs.
10+
11+
```console
12+
$ helm upgrade --install RELEASE_NAME . --values values.yaml
13+
```
14+
15+
## Uninstall
16+
17+
Replace `RELEASE_NAME` with the Helm release name, to see your current Helm releases you can use `helm ls`.
18+
19+
```console
20+
$ helm uninstall RELEASE_NAME
21+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The node-exporter-textfiles DaemonSet has been deployed!
2+
3+
Make sure to configure your node_exporter to pickup textfiles.
4+
For more information see the documentation at:
5+
https://github.com/galexrt/container-node_exporter-smartmon/main/docs/node_exporter.md
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "node-exporter-textfiles.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "node-exporter-textfiles.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "node-exporter-textfiles.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "node-exporter-textfiles.labels" -}}
37+
helm.sh/chart: {{ include "node-exporter-textfiles.chart" . }}
38+
{{ include "node-exporter-textfiles.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "node-exporter-textfiles.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "node-exporter-textfiles.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "node-exporter-textfiles.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "node-exporter-textfiles.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "node-exporter-textfiles.fullname" . }}
5+
labels:
6+
{{- include "node-exporter-textfiles.labels" . | nindent 4 }}
7+
spec:
8+
selector:
9+
matchLabels:
10+
{{- include "node-exporter-textfiles.selectorLabels" . | nindent 6 }}
11+
template:
12+
metadata:
13+
{{- with .Values.podAnnotations }}
14+
annotations:
15+
{{- toYaml . | nindent 8 }}
16+
{{- end }}
17+
labels:
18+
{{- include "node-exporter-textfiles.selectorLabels" . | nindent 8 }}
19+
spec:
20+
{{- with .Values.imagePullSecrets }}
21+
imagePullSecrets:
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
serviceAccountName: {{ include "node-exporter-textfiles.serviceAccountName" . }}
25+
securityContext:
26+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
27+
containers:
28+
{{- range .Values.textfiles }}
29+
- name: {{ .name }}
30+
securityContext:
31+
{{- toYaml $.Values.securityContext | nindent 12 }}
32+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
33+
imagePullPolicy: {{ $.Values.image.pullPolicy }}
34+
resources:
35+
{{- toYaml .resources | nindent 12 }}
36+
volumeMounts:
37+
- mountPath: /var/lib/node_exporter
38+
name: textfile
39+
{{- end }}
40+
{{- with .Values.nodeSelector }}
41+
nodeSelector:
42+
{{- toYaml . | nindent 8 }}
43+
{{- end }}
44+
{{- with .Values.affinity }}
45+
affinity:
46+
{{- toYaml . | nindent 8 }}
47+
{{- end }}
48+
{{- with .Values.tolerations }}
49+
tolerations:
50+
{{- toYaml . | nindent 8 }}
51+
{{- end }}
52+
volumes:
53+
{{- toYaml .Values.textfileVolumes | nindent 8 }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "node-exporter-textfiles.serviceAccountName" . }}
6+
labels:
7+
{{- include "node-exporter-textfiles.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- end }}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Default values for node-exporter-textfiles.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 1
6+
7+
image:
8+
repository: quay.io/galexrt/node-exporter-smartmon
9+
pullPolicy: IfNotPresent
10+
# Overrides the image tag whose default is the chart appVersion.
11+
tag: ""
12+
13+
imagePullSecrets: []
14+
nameOverride: ""
15+
fullnameOverride: ""
16+
17+
serviceAccount:
18+
# Specifies whether a service account should be created
19+
create: true
20+
# Annotations to add to the service account
21+
annotations: {}
22+
# The name of the service account to use.
23+
# If not set and create is true, a name is generated using the fullname template
24+
name: ""
25+
26+
podAnnotations: {}
27+
28+
podSecurityContext: {}
29+
# fsGroup: 2000
30+
31+
securityContext: {}
32+
# capabilities:
33+
# drop:
34+
# - ALL
35+
# readOnlyRootFilesystem: true
36+
# runAsNonRoot: true
37+
# runAsUser: 1000
38+
39+
nodeSelector: {}
40+
41+
tolerations: []
42+
43+
affinity: {}
44+
45+
textfileVolumes:
46+
- name: textfile
47+
hostPath:
48+
path: /var/lib/node_exporter
49+
type: Directory
50+
51+
textfiles:
52+
# List of textfiles script that should be run in the daemonset as separate containers
53+
- name: smartmon
54+
script: smartmon.py
55+
resources: {}
56+
# We usually recommend not to specify default resources and to leave this as a conscious
57+
# choice for the user. This also increases chances charts run on environments with little
58+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
59+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
60+
# limits:
61+
# cpu: 100m
62+
# memory: 128Mi
63+
# requests:
64+
# cpu: 100m
65+
# memory: 128Mi

docs/node_exporter.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# node_exporter Prerequisites
2+
3+
## Configuration
4+
5+
The `node_exporter` must have these flags set:
6+
7+
```console
8+
--collector.textfile.directory=PATH
9+
```
10+
11+
Also ensure that you are not actively disabling the `textfile` exporter (it is enabled by default), for more information see: [GitHub prometheus/node_exporter - Collectors section](https://github.com/prometheus/node_exporter#collectors).
12+
13+
### Containerized
14+
15+
If you are running node_exporter in containers (e.g., through Kubernetes), you need to add the textfile output path on the host to your node_exporter volumes.
16+
17+
The access from the node_exporter can be set to readOnly, but the textfiles container must read write to that directory.

0 commit comments

Comments
 (0)