Skip to content

Commit 86c216a

Browse files
committed
tweak helm chart
Signed-off-by: Alexander Trost <[email protected]>
1 parent 13883ac commit 86c216a

File tree

9 files changed

+172
-37
lines changed

9 files changed

+172
-37
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ ARG REVISION="N/A"
55

66
LABEL org.opencontainers.image.authors="Alexander Trost <[email protected]>" \
77
org.opencontainers.image.created="${BUILD_DATE}" \
8-
org.opencontainers.image.title="galexrt/container-node_exporter-smartmon" \
8+
org.opencontainers.image.title="galexrt/container-node_exporter-textfiles" \
99
org.opencontainers.image.description="Container Image with the Prometheus Community's node-exporter-textfile-collector-scripts Repository checked out, with some utilities installed." \
10-
org.opencontainers.image.documentation="https://github.com/galexrt/container-node_exporter-smartmon/blob/main/README.md" \
11-
org.opencontainers.image.url="https://github.com/galexrt/container-node_exporter-smartmon" \
12-
org.opencontainers.image.source="https://github.com/galexrt/container-node_exporter-smartmon" \
10+
org.opencontainers.image.documentation="https://github.com/galexrt/container-node_exporter-textfiles/blob/main/README.md" \
11+
org.opencontainers.image.url="https://github.com/galexrt/container-node_exporter-textfiles" \
12+
org.opencontainers.image.source="https://github.com/galexrt/container-node_exporter-textfiles" \
1313
org.opencontainers.image.revision="${REVISION}" \
1414
org.opencontainers.image.vendor="galexrt" \
1515
org.opencontainers.image.version="N/A"

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ container-build:
1818
docker build \
1919
--build-arg BUILD_DATE="$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')" \
2020
--build-arg VCS_REF="$(shell git rev-parse HEAD)" \
21-
-t ghcr.io/galexrt/node-exporter-smartmon:$(VERSION) \
21+
-t ghcr.io/galexrt/node-exporter-textfiles:$(VERSION) \
2222
.
23-
docker tag ghcr.io/galexrt/node-exporter-smartmon:$(VERSION) quay.io/galexrt/node-exporter-smartmon:$(VERSION)
23+
docker tag ghcr.io/galexrt/node-exporter-textfiles:$(VERSION) quay.io/galexrt/node-exporter-textfiles:$(VERSION)
2424

2525
if [ "$(VERSION)" != "$(VERSION_SHORT)" ]; then \
26-
docker tag ghcr.io/galexrt/node-exporter-smartmon:$(VERSION) ghcr.io/galexrt/node-exporter-smartmon:$(VERSION_SHORT); \
27-
docker tag ghcr.io/galexrt/node-exporter-smartmon:$(VERSION) quay.io/galexrt/node-exporter-smartmon:$(VERSION_SHORT); \
26+
docker tag ghcr.io/galexrt/node-exporter-textfiles:$(VERSION) ghcr.io/galexrt/node-exporter-textfiles:$(VERSION_SHORT); \
27+
docker tag ghcr.io/galexrt/node-exporter-textfiles:$(VERSION) quay.io/galexrt/node-exporter-textfiles:$(VERSION_SHORT); \
2828
fi
2929

3030
container-push:
31-
docker push ghcr.io/galexrt/node-exporter-smartmon:$(VERSION)
32-
docker push quay.io/galexrt/node-exporter-smartmon:$(VERSION)
31+
docker push ghcr.io/galexrt/node-exporter-textfiles:$(VERSION)
32+
docker push quay.io/galexrt/node-exporter-textfiles:$(VERSION)
3333

3434
if [ "$(VERSION)" != "$(VERSION_SHORT)" ]; then \
35-
docker push ghcr.io/galexrt/node-exporter-smartmon:$(VERSION_SHORT); \
36-
docker push quay.io/galexrt/node-exporter-smartmon:$(VERSION_SHORT); \
35+
docker push ghcr.io/galexrt/node-exporter-textfiles:$(VERSION_SHORT); \
36+
docker push quay.io/galexrt/node-exporter-textfiles:$(VERSION_SHORT); \
3737
fi

README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
# container-node_exporter-smartmon
1+
# container-node_exporter-textfiles
22

3-
Container Image with the Prometheus Community's node-exporter-textfile-collector-scripts Repository checked out, with some utilities installed.
3+
<details>
4+
<summary>
5+
<b>NOTICE The repository and image have been renamed on 18.02.2022! For more information click this spoiler</b>
6+
</summary>
7+
8+
The container images name has been changed from `galexrt/node-exporter-smartmon` to **`galexrt/node-exporter-textfiles`**.
9+
E.g., the image on quay.io is now available at `quay.io/galexrt/node-exporter-smartmon`.
10+
11+
The repository name has been changed from `container-node_exporter-smartmon` to **`container-node_exporter-textfiles`**.
12+
13+
This has been done as the image in this repository is not just for running the `smartmon` textfile collector script(s) anymore.
14+
</details>
15+
16+
Container Image for easily running textfile exporter scripts from the Prometheus Community to be collected by the prometheus/node_exporter.
417

518
Container Image available from:
619

7-
* [Quay.io](https://quay.io/repository/galexrt/node-exporter-smartmon)
8-
* [GHCR.io](https://github.com/users/galexrt/packages/container/package/node-exporter-smartmon)
20+
* [Quay.io](https://quay.io/repository/galexrt/node-exporter-textfiles)
21+
* [GHCR.io](https://github.com/users/galexrt/packages/container/package/node-exporter-textfiles)
922

1023
Container Image Tags:
1124

@@ -24,11 +37,11 @@ The entrypoint script is putting the output into the directory `/var/lib/node_ex
2437

2538
### Variables
2639

27-
| Name | Default | Description |
28-
| ----------------- | ------------- | ------------------------------------------------------------- |
29-
| `SCRIPT` | `smartmon.sh` | Which of the node_exporter textfile collector scripts to run. |
30-
| `OUTPUT_FILENAME` | `smartmon` | Name of the output file (file ending is always `.prom`). |
31-
| `INTERVAL` | `300` | Interval at which to run the script at. |
40+
| Name | Default | Description |
41+
| ----------------- | ------------- | ---------------------------------------------------------------- |
42+
| `SCRIPT` | `smartmon.sh` | Which of the node_exporter textfile collector scripts to run. |
43+
| `OUTPUT_FILENAME` | `smartmon` | Name of the output file (file ending must not be added `.prom`). |
44+
| `INTERVAL` | `300` | Interval at which to run the script at. |
3245

3346
Any flags / args given to the container are passed to the `SCRIPT` that will be executed.
3447

charts/node-exporter-textfiles/templates/NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ The node-exporter-textfiles DaemonSet has been deployed!
22

33
Make sure to configure your node_exporter to pickup textfiles.
44
For more information see the documentation at:
5-
https://github.com/galexrt/container-node_exporter-smartmon/main/docs/node_exporter.md
5+
https://github.com/galexrt/container-node_exporter-textfiles/main/docs/node_exporter.md

charts/node-exporter-textfiles/templates/daemonset.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: apps/v1
2-
kind: Deployment
2+
kind: DaemonSet
33
metadata:
44
name: {{ include "node-exporter-textfiles.fullname" . }}
55
labels:
@@ -29,13 +29,26 @@ spec:
2929
- name: {{ .name }}
3030
securityContext:
3131
{{- toYaml $.Values.securityContext | nindent 12 }}
32-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
32+
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
3333
imagePullPolicy: {{ $.Values.image.pullPolicy }}
3434
resources:
3535
{{- toYaml .resources | nindent 12 }}
36+
env:
37+
- name: SCRIPT
38+
value: "{{ .script }}"
39+
- name: OUTPUT_FILENAME
40+
value: {{ .outputFilename | quote }}
41+
- name: INTERVAL
42+
value: "{{ .interval }}"
43+
{{- with .additionalEnv }}
44+
{{- toYaml . | nindent 12 }}
45+
{{- end}}
3646
volumeMounts:
3747
- mountPath: /var/lib/node_exporter
3848
name: textfile
49+
{{- with .additionalVolumeMounts }}
50+
{{ toYaml . | nindent 12 }}
51+
{{- end }}
3952
{{- end }}
4053
{{- with .Values.nodeSelector }}
4154
nodeSelector:
@@ -50,4 +63,4 @@ spec:
5063
{{- toYaml . | nindent 8 }}
5164
{{- end }}
5265
volumes:
53-
{{- toYaml .Values.textfileVolumes | nindent 8 }}
66+
{{- toYaml .Values.additionalVolumes | nindent 8 }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- if .Values.podSecurityPolicy.enabled }}
2+
apiVersion: extensions/v1beta1
3+
kind: PodSecurityPolicy
4+
metadata:
5+
name: {{ include "node-exporter-textfiles.fullname" . }}
6+
labels:
7+
{{- include "node-exporter-textfiles.labels" . | nindent 4 }}
8+
annotations:
9+
{{- if .Values.podSecurityPolicy.annotations }}
10+
{{ toYaml .Values.podSecurityPolicy.annotations | indent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- toYaml .Values.podSecurityPolicy.spec | nindent 2 }}
14+
---
15+
apiVersion: rbac.authorization.k8s.io/v1
16+
kind: ClusterRole
17+
metadata:
18+
name: {{ include "node-exporter-textfiles.fullname" . }}
19+
rules:
20+
- apiGroups: ['policy']
21+
resources: ['podsecuritypolicies']
22+
verbs: ['use']
23+
resourceNames:
24+
- {{ include "node-exporter-textfiles.fullname" . }}
25+
---
26+
apiVersion: rbac.authorization.k8s.io/v1
27+
kind: ClusterRoleBinding
28+
metadata:
29+
name: {{ include "node-exporter-textfiles.fullname" . }}
30+
roleRef:
31+
kind: ClusterRole
32+
name: {{ include "node-exporter-textfiles.fullname" . }}
33+
apiGroup: rbac.authorization.k8s.io
34+
subjects:
35+
- kind: ServiceAccount
36+
name: {{ include "node-exporter-textfiles.serviceAccountName" . }}
37+
namespace: {{ .Release.Namespace }}
38+
{{- end }}

charts/node-exporter-textfiles/values.yaml

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
replicaCount: 1
66

77
image:
8-
repository: quay.io/galexrt/node-exporter-smartmon
8+
repository: quay.io/galexrt/node-exporter-textfiles
99
pullPolicy: IfNotPresent
1010
# Overrides the image tag whose default is the chart appVersion.
1111
tag: ""
@@ -16,6 +16,7 @@ fullnameOverride: ""
1616

1717
serviceAccount:
1818
# Specifies whether a service account should be created
19+
# Must be true if `podSecurityPolicy.enabled` is `true` (default)
1920
create: true
2021
# Annotations to add to the service account
2122
annotations: {}
@@ -28,7 +29,9 @@ podAnnotations: {}
2829
podSecurityContext: {}
2930
# fsGroup: 2000
3031

31-
securityContext: {}
32+
securityContext:
33+
# Privileged is required for most of the textfile scripts
34+
privileged: true
3235
# capabilities:
3336
# drop:
3437
# - ALL
@@ -42,16 +45,28 @@ tolerations: []
4245

4346
affinity: {}
4447

45-
textfileVolumes:
48+
additionalVolumes:
4649
- name: textfile
4750
hostPath:
4851
path: /var/lib/node_exporter
4952
type: Directory
53+
- hostPath:
54+
path: /dev
55+
name: host-dev
5056

5157
textfiles:
5258
# List of textfiles script that should be run in the daemonset as separate containers
5359
- name: smartmon
5460
script: smartmon.py
61+
# If unset, will default to the `name`
62+
outputFilename: "smartmon"
63+
# Defaults to `300`
64+
interval: 900
65+
additionalEnv: []
66+
additionalVolumeMounts:
67+
- mountPath: /dev
68+
name: host-dev
69+
readOnly: true
5570
resources: {}
5671
# We usually recommend not to specify default resources and to leave this as a conscious
5772
# choice for the user. This also increases chances charts run on environments with little
@@ -63,3 +78,36 @@ textfiles:
6378
# requests:
6479
# cpu: 100m
6580
# memory: 128Mi
81+
82+
podSecurityPolicy:
83+
enabled: true
84+
annotations: {}
85+
spec:
86+
privileged: true
87+
allowPrivilegeEscalation: true
88+
volumes:
89+
- 'configMap'
90+
- 'emptyDir'
91+
- 'hostPath'
92+
- 'secret'
93+
allowedHostPaths:
94+
# This must be the same as for the `additionalVolumes` hostPath volume paths
95+
- pathPrefix: /var/lib/node_exporter
96+
readOnly: false
97+
- pathPrefix: /dev
98+
readOnly: true
99+
hostNetwork: false
100+
hostPID: false
101+
hostIPC: false
102+
runAsUser:
103+
rule: 'RunAsAny'
104+
runAsGroup:
105+
rule: 'RunAsAny'
106+
seLinux:
107+
rule: 'RunAsAny'
108+
supplementalGroups:
109+
rule: 'RunAsAny'
110+
fsGroup:
111+
rule: 'RunAsAny'
112+
readOnlyRootFilesystem: false
113+
hostPorts: []

docs/node_exporter.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,39 @@
22

33
## Configuration
44

5-
The `node_exporter` must have these flags set:
5+
The `node_exporter` must have this flag set:
66

77
```console
8-
--collector.textfile.directory=PATH
8+
--collector.textfile.directory=YOUR_TEXTFILE_OUTPUT_PATH
99
```
1010

11+
(Where `YOUR_TEXTFILE_OUTPUT_PATH` when using this repos default would be `/var/lib/node_exporter`)
12+
1113
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).
1214

1315
### Containerized
1416

1517
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.
1618

1719
The access from the node_exporter can be set to readOnly, but the textfiles container must read write to that directory.
20+
21+
When using the default values of the provided `node_exporter-textfiles` Helm Chart, you need to add a `hostPath` volume to your `node_exporter` to the path `/var/lib/node_exporter` and a `volumeMounts` entry.
22+
23+
Example YAML snippets for your `node_exporter` DaemonSet in Kubernetes:
24+
25+
```yaml
26+
additionalVolumes:
27+
- hostPath:
28+
path: /dev
29+
name: host-dev
30+
- hostPath:
31+
path: /var/lib/node_exporter
32+
name: host-textfile
33+
```
34+
35+
```yaml
36+
volumeMounts:
37+
- mountPath: /var/lib/node_exporter
38+
name: host-textfile
39+
readOnly: false
40+
```

kubernetes/daemonset.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
apiVersion: apps/v1
22
kind: DaemonSet
33
metadata:
4-
name: node-exporter-smartmon
4+
name: node-exporter-textfiles
55
labels:
6-
app.kubernetes.io/name: node-exporter-smartmon
6+
app.kubernetes.io/name: node-exporter-textfiles
77
spec:
88
updateStrategy:
99
rollingUpdate:
1010
maxUnavailable: 5
1111
type: RollingUpdate
1212
selector:
1313
matchLabels:
14-
app.kubernetes.io/name: node-exporter-smartmon
14+
app.kubernetes.io/name: node-exporter-textfiles
1515
template:
1616
metadata:
17-
name: node-exporter-smartmon
17+
name: node-exporter-textfiles
1818
labels:
19-
app.kubernetes.io/name: node-exporter-smartmon
19+
app.kubernetes.io/name: node-exporter-textfiles
2020
spec:
2121
tolerations:
2222
- key: node-role.kubernetes.io/master
@@ -26,7 +26,7 @@ spec:
2626
operator: "Exists"
2727
terminationGracePeriodSeconds: 5
2828
containers:
29-
- image: quay.io/galexrt/node-exporter-smartmon:v20220203-125335-155
29+
- image: quay.io/galexrt/node-exporter-textfiles:v20220203-125335-155
3030
name: smartmon
3131
env:
3232
- name: INTERVAL
@@ -49,7 +49,7 @@ spec:
4949
- mountPath: /var/lib/node_exporter
5050
name: host-textfile
5151
readOnly: false
52-
- image: quay.io/galexrt/node-exporter-smartmon:v20220203-125335-155
52+
- image: quay.io/galexrt/node-exporter-textfiles:v20220203-125335-155
5353
name: nvmemetrics
5454
env:
5555
- name: INTERVAL

0 commit comments

Comments
 (0)