Skip to content

Commit

Permalink
persist netdata's child /var/lib/netdata on the host node (#193)
Browse files Browse the repository at this point in the history
* templates/daemonset: persist /var/lib/netdata

* templates/daemonset: rework persistence

* templates/daemonset: minor

* templates/daemonset: minor

* update readme

* remove persistUniqueID

* bump version

* add namespaceAware option

* change default rootDir value

* minor

* rename rootDir to path

* simplify

* simplify
  • Loading branch information
ilyam8 authored Feb 18, 2021
1 parent 50f7173 commit e58a633
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion charts/netdata/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: netdata
version: 3.5.1
version: 3.6.1
description: Real-time performance monitoring, done right!
type: application
keywords:
Expand Down
5 changes: 3 additions & 2 deletions charts/netdata/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Netdata Helm chart for Kubernetes deployments

[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/netdata)](https://artifacthub.io/packages/search?repo=netdata) ![Version: 3.5.1](https://img.shields.io/badge/Version-3.5.1-informational) ![AppVersion: v1.29.1](https://img.shields.io/badge/AppVersion-v1.29.1-informational)
[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/netdata)](https://artifacthub.io/packages/search?repo=netdata) ![Version: 3.6.1](https://img.shields.io/badge/Version-3.6.1-informational) ![AppVersion: v1.29.1](https://img.shields.io/badge/AppVersion-v1.29.1-informational)

_Based on the work of varyumin (https://github.com/varyumin/netdata)_.

Expand Down Expand Up @@ -153,7 +153,8 @@ The following table lists the configurable parameters of the netdata chart and t
| `child.podLabels` | Additional labels to add to the child pods | `{}` |
| `child.podAnnotations` | Additional annotations to add to the child pods | `{}` |
| `child.podAnnotationAppArmor.enabled` | Whether or not to include the AppArmor security annotation | `true` |
| `child.persistUniqueID` | Whether or not to persist `netdata.public.unique.id` across restarts | `true` |
| `child.persistence.hostPath` | Host node directory for storing child instance data | `/var/lib/netdata-k8s-child` |
| `child.persistence.enabled` | Whether or not to persist `/var/lib/netdata` in the `child.persistence.hostPath`. | `true` |
| `child.configs` | Manage custom child's configs | See [Configuration files](#configuration-files). |
| `child.claiming.enabled` | Enable child claiming for netdata cloud | `false` |
| `child.claiming.token` | Claim token | `""` |
Expand Down
41 changes: 15 additions & 26 deletions charts/netdata/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,22 @@ spec:
resources:
{{ toYaml .Values.sysctlImage.resources | indent 12 }}
{{- end }}
{{- if .Values.child.persistUniqueID }}
- name: init-nodeuid
{{- if and .Values.child.persistence.enabled .Values.child.persistence.hostPath }}
- name: init-persistence
image: "{{ .Values.wgetImage.repository }}:{{ .Values.wgetImage.tag }}"
resources:
requests:
cpu: 10m
imagePullPolicy: {{ .Values.wgetImage.pullPolicy }}
volumeMounts:
- name: nodeuid
mountPath: "/nodeuid"
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: persistencevarlibdir
mountPath: "/persistencevarlibdir"
command:
- "/bin/sh"
args:
- "-c"
- '
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token);
URL="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}/api/v1/nodes/${MY_NODE_NAME}";
HEADER="Authorization: Bearer ${TOKEN}";
DATA=$(wget -q -T 5 --no-check-certificate --header "${HEADER}" -O - "${URL}");
[ -z "${DATA}" ] && exit 1;
UID=$(echo "${DATA}" | grep -m 1 uid | grep -o ":.*" | tr -d ": \",");
[ -z "${UID}" ] && exit 1;
echo -n "${UID}" > /nodeuid/netdata.public.unique.id;
chmod 777 /persistencevarlibdir;
'
{{- end }}
containers:
Expand Down Expand Up @@ -164,9 +149,9 @@ spec:
subPath: {{ $name }}
{{- end }}
{{- end }}
{{- if .Values.child.persistUniqueID }}
- name: nodeuid
mountPath: "/var/lib/netdata/registry/"
{{- if and .Values.child.persistence.enabled .Values.child.persistence.hostPath }}
- name: persistencevarlibdir
mountPath: /var/lib/netdata
{{- end }}
{{- if .Values.sd.child.enabled }}
- name: sd-shared
Expand Down Expand Up @@ -226,9 +211,13 @@ spec:
- name: config
configMap:
name: netdata-conf-child
{{- if .Values.child.persistUniqueID }}
- name: nodeuid
emptyDir: {}
{{- with .Values.child.persistence }}
{{- if and .enabled .hostPath }}
- name: persistencevarlibdir
hostPath:
path: {{ .hostPath }}/var/lib/netdata
type: DirectoryOrCreate
{{- end }}
{{- end }}
{{- if .Values.sd.child.enabled }}
- name: sd-shared
Expand Down
4 changes: 3 additions & 1 deletion charts/netdata/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ child:

podAnnotations: {}

persistUniqueID: true
persistence:
enabled: true
hostPath: /var/lib/netdata-k8s-child

configs:
netdata:
Expand Down

0 comments on commit e58a633

Please sign in to comment.