Skip to content
Permalink
Browse files

feat: add netdata module using helm

  • Loading branch information...
etienne-napoleone committed May 13, 2019
1 parent c787ab9 commit 0c3388f74ab98d73a4b00bb4143c0ad0c4a4fd63
@@ -0,0 +1,5 @@
# IntelliJ project files
.idea
*.iml
out
gen
@@ -0,0 +1,10 @@
name: netdata
home: https://github.com/netdata/netdata
version: 0.0.11
appVersion: v1.14.0
description: Real-time performance monitoring, done right! https://my-netdata.io/
maintainer:
name: Chris Akritidis
email: chris@netdata.cloud
name: Vladimir Ryumin
email: vryumin@gmail.com

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,157 @@
# netdata Helm chart for kubernetes deployments

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

**This Helm chart is in Beta**.
Please validate that the settings are suitable for your cluster, before using
them in production

## Introduction

This chart bootstraps a [netdata](https://github.com/netdata/netdata) deployment
on a [Kubernetes](http://kubernetes.io) cluster using the
[Helm](https://helm.sh) package manager.

The chart installs a netdata slave pod on each node of a cluster, using a
`Daemonset` and a netdata master pod on one node, using a `Statefulset`. The
slaves function as headless collectors that simply collect and forward all the
metrics to the master netdata. The master uses persistent volumes to store
metrics and alarms, handles alarm notifications and provides the netdata UI to
view the metrics, using an nginx ingress controller.

## Prerequisites
- Kubernetes 1.8+

## Installing the Chart

Clone the repository locally

```console
$ git clone https://github.com/netdata/helmchart.git netdata
```

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

```console
$ helm install --name my-release ./netdata
```

The command deploys nginx-ingress on the Kubernetes cluster in the default
configuration. The [configuration](#configuration) section lists the parameters
that can be configured during installation.

> **Tip**: List all releases using `helm list`
## 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 table lists the configurable parameters of the nginx-ingress
chart and their default values.

Parameter | Description | Default
--- | --- | ---
`replicaCount` | Number of `replicas` for the master netdata `Statefulset` | `1`
`image.repository` | Container image repo | `netdata/netdata`
`image.tag` | Container image tag | `v1.12.2`
`image.pullPolicy` | Container image pull policy | `Always`
`service.type` | netdata master service type | `ClusterIP`
`service.port` | netdata master service port | `19999`
`ingress.enabled` | Create Ingress to access the netdata web UI | `true`
`ingress.annotations` | Associate annotations to the Ingress | `kubernetes.io/ingress.class: nginx` and `kubernetes.io/tls-acme: "true"`
`ingress.path` | URL path for the ingress | `/`
`ingress.hosts` | URL hostnames for the ingress (they need to resolve to the external IP of the ingress controller) | `netdata.k8s.local`
`rbac.create` | if true, create & use RBAC resources | `true`
`serviceAccount.create` |if true, create a service account | `true`
`serviceAccount.name` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template. | `netdata`
`clusterrole.name` | Name of the cluster role linked with the service account | `netdata`
`APIKEY` | The key shared between the master and the slave netdata for streaming | `11111111-2222-3333-4444-555555555555`
`master.resources` | Resources for the master statefulset | `{}`
`master.nodeSelector` | Node selector for the master statefulset | `{}`
`master.tolerations` | Tolerations settings for the master statefulset | `[]`
`master.affinity` | Affinity settings for the master statefulset | `{}`
`master.database.storageclass` | The storage class for the persistent volume claim of the master's database store, mounted to `/var/cache/netdata` | `standard`
`master.database.volumesize` | The storage space for the PVC of the master database | `2Gi`
`master.alarms.storageclass` | The storage class for the persistent volume claim of the master's alarm log, mounted to `/var/lib/netdata` | `standard`
`master.database.volumesize` | The storage space for the PVC of the master alarm log | `100Mi`
`master.env` | Set environment parameters for the master statefulset | `{}`
`master.stream_config` | Contents of the master's `stream.conf` | Store slave data, accept all connections, and issue alarms for slave data.
`master.netdata_config` | Contents of the master's `netdata.conf` | `memory mode = save` and `bind to = 0.0.0.0:19999`
`master.health_config` | Contents of `health_alarm_notify.conf` | Email disabled, a sample of the required settings for Slack notifications
`slave.resources` | Resources for the slave daemonsets | `{}`
`slave.nodeSelector` | Node selector for the slave daemonsets | `{}`
`slave.tolerations` | Tolerations settings for the slave daemonsets | `- operator: Exists` with `effect: NoSchedule`
`slave.affinity` | Affinity settings for the slave daemonsets | `{}`
`slave.env` | Set environment parameters for the slave daemonset | `{}`
`slave.stream_config` | Contents of the slave `stream.conf` | Send metrics to the master at netdata:19999
`master.netdata_config` | Contents of the slave's `netdata.conf` | No persistent storage, no alarms, no UI
`notifications.slackurl` | URL for slack notifications | `""`
`notifications.slackrecipient` | Slack recipient list | `""`
`sysctlImage.enabled` | Enable an init container to modify Kernel settings | `false` |
`sysctlImage.command` | sysctlImage command to execute | [] |
`sysctlImage.repository`| sysctlImage Init container name | `alpine` |
`sysctlImage.tag` | sysctlImage Init container tag | `latest` |
`sysctlImage.pullPolicy` | sysctlImage Init container pull policy | `Always` |
`sysctlImage.resources` | sysctlImage Init container CPU/Memory resource requests/limits | {} |

Example to set the parameters from the command line:
```console
$ helm install ./netdata --name my-release \
--set notifications.slackurl=MySlackAPIURL \
--set notifications.slackrecipiet="@MyUser MyChannel"
```

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

```console
$ helm install ./netdata --name my-release -f values.yaml
```

> **Tip**: You can use the default [values.yaml](values.yaml)
### Additional netdata configurations

To deploy additional netdata user configuration files, you will need to modify the helm chart configuration files as explained below.

#### Adding a configuration file to the master

To provide a new user configuration file to the master, you need to edit the following:
- In `templates/statefulset.yaml` : `spec.template.spec.volumes` and `spec.template.spec.containers.volumeMounts`.
- In `templates/configmap.yaml` : In the second `ConfigMap` with `metadata.name=netdata-conf-master`, update `metadata.data`.

Note that with the default configuration of this chart, the master does the health checks and triggers alams, but does not collect much data. As a result, the only other
configuration files that might make sense to add are the alarm and alarm template definitions, under `/etc/netdata/health.d`.

#### Adding a configuration file to the slaves

To provide a new user configuration file to the slave pods, you need to edit the following:
- In `templates/daemonset.yaml` : `spec.template.spec.volumes` and `spec.template.spec.containers.volumeMounts`.
- In `templates/configmap.yaml` : In the first `ConfigMap` with `metadata.name=netdata-conf-slave`, update `metadata.data`.

Regardless of whether you add config files that reside directly under `/etc/netdata` or in a subdirectory
such as `/etc/netdata/go.d`, you can use the already provided configurations as reference.

#### Example

For reference, the `yaml` templates of the master mentioned above include an `example` alarm that would get triggered if the python.d `example` module was enabled.
You will see in this case that we chose not to add a value for the contents of the configuration file in `values.yaml`. We use the multi-line syntax `var: |-` and enter
the contents of the config file underneath.

> **Tip**: Do pay attention to the indentation of the config file contents, as it matters for the parsing of the `yaml` file. Note that the first line under `var: |-`
must be indented with two more spaces relative to the preceding line:
```
myconfigfilecontents: |-
config line 1 #Need those two spaces
config line 2 #No problem indenting more here
```
@@ -0,0 +1,33 @@
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
1. netdata will be available on http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}, on the exposed port of your ingress controller

In a production environment, you
You can get that port via `kubectl get services`. e.g. in the following example, the http exposed port is 31737, the https one is 30069.
The hostname {{ . }} will need to be added to /etc/hosts, so that it resolves to the exposed IP. That IP depends on how your cluster is set up:
- When no load balancer is available (e.g. with minikube), you get the IP shown on `kubectl cluster-info`
- In a production environment, the command `kubectl get services` will show the IP under the EXTERNAL-IP column

The port can be retrieved in both cases from `kubectl get services`

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
exiled-tapir-nginx-ingress-controller LoadBalancer 10.98.132.169 <pending> 80:31737/TCP,443:30069/TCP 11h


{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
1. Get the application URL by running these commands:
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "netdata.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 }}
1. 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 "netdata.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "netdata.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 "netdata.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 }}
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "netdata.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 "netdata.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 "netdata.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
@@ -0,0 +1,26 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "netdata.fullname" . }}
labels:
app: {{ template "netdata.name" . }}
chart: {{ template "netdata.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
rules:
- apiGroups: [""]
resources: ["services", "events", "endpoints", "pods", "nodes", "componentstatuses", "nodes/proxy" ]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["resourcequotas"]
verbs: ["get", "list"]
- apiGroups: ["extensions"]
resources: ["ingresses"]
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/version", "/healthz", "/metrics"]
verbs: ["get"]
- apiGroups: [""]
resources: ["nodes/metrics", "nodes/spec"]
verbs: ["get"]
{{- end -}}
@@ -0,0 +1,19 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "netdata.fullname" . }}
labels:
app: {{ template "netdata.name" . }}
chart: {{ template "netdata.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "netdata.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccount.name }}
namespace: {{ .Release.Namespace }}
{{- end -}}
@@ -0,0 +1,38 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: netdata-conf-slave
labels:
app: {{ template "netdata.name" . }}
chart: {{ template "netdata.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
netdata.conf: {{ toYaml .Values.slave.netdata_config | indent 4 }}
stream.conf: {{ toYaml .Values.slave.stream_config | indent 4 }}

---

apiVersion: v1
kind: ConfigMap
metadata:
name: netdata-conf-master
labels:
app: {{ template "netdata.name" . }}
chart: {{ template "netdata.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
netdata.conf: {{ toYaml .Values.master.netdata_config | indent 4 }}
stream.conf: {{ toYaml .Values.master.stream_config | indent 4 }}
health_alarm_notify.conf: {{ toYaml .Values.master.health_config | indent 4 }}
example.conf: |-
alarm: example_alarm1
on: example.random
every: 2s
warn: $random1 > (($status >= $WARNING) ? (70) : (80))
crit: $random1 > (($status == $CRITICAL) ? (80) : (90))
info: random
to: sysadmin
Oops, something went wrong.

0 comments on commit 0c3388f

Please sign in to comment.
You can’t perform that action at this time.