Add helm chart

This commit is contained in:
Jochem
2024-07-03 21:29:02 +02:00
parent b0e7eaa3d1
commit 614feeee46
19 changed files with 1281 additions and 0 deletions

1
charts/librenms/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
charts

View File

@@ -0,0 +1,25 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
# custom
repository

View File

@@ -0,0 +1,9 @@
dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 19.5.5
- name: mysql
repository: https://charts.bitnami.com/bitnami
version: 10.3.0
digest: sha256:e3cdff9ae055655aacaa8e64187b42cc1834bd5ddbbc6f9dbb01fa214586cf68
generated: "2024-06-20T07:46:30.599412737Z"

View File

@@ -0,0 +1,18 @@
apiVersion: v2
name: librenms
description: LibreNMS is an autodiscovering PHP/MySQL-based network monitoring system.
type: application
version: 3.8.0
appVersion: "24.5.0"
dependencies:
- name: redis
version: "~19.5.0"
repository: "https://charts.bitnami.com/bitnami"
when: redis.enabled == true
- name: mysql
version: "~10.3.0"
repository: "https://charts.bitnami.com/bitnami"
when: mysql.enabled == true

56
charts/librenms/README.md Normal file
View File

@@ -0,0 +1,56 @@
# LibreNMS
[LibreNMS](https://docs.librenms.org/) is an IP address management (IPAM) and
data center infrastructure management (DCIM) tool.
## TL;DR
```shell
$ helm repo add thechef23 https://thechef23.github.io/helm-librenms
$ helm install my-release thechef23-librenms/librenms
```
## Prerequisites
- This chart has only been tested on Kubernetes 1.18+, but should work on 1.14+
- Recent versions of Helm 3 are supported
## Installing the Chart
To install the chart with the release name `my-release` and default configuration:
```shell
$ helm repo add thechef23 https://thechef23.github.io/helm-librenms
$ helm install my-release thechef23-librenms/librenms
```
## Values
Check the [values.yml](/TheChef23/helm-librenms/blob/main/values.yaml) file for the available settings for this chart and its
dependencies.
## Uninstalling the Chart
To delete the chart:
```shell
$ helm delete my-release
```
## License
> The following notice applies to all files contained within this Helm Chart and
> the Git repository which contains it:
>
> Copyright 2022 Jochem Bruijns
>
> Licensed under the Apache License, Version 2.0 (the "License");
> you may not use this file except in compliance with the License.
> You may obtain a copy of the License at
>
> http://www.apache.org/licenses/LICENSE-2.0
>
> Unless required by applicable law or agreed to in writing, software
> distributed under the License is distributed on an "AS IS" BASIS,
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> See the License for the specific language governing permissions and
> limitations under the License.

View File

@@ -0,0 +1,2 @@
<?php
{{.Values.librenms.configuration}}

View File

@@ -0,0 +1 @@
APP_KEY={{.Values.librenms.appkey}}

View File

@@ -0,0 +1,7 @@
#!/bin/sh
TARGET="/data/env-volume/env"
echo "Target: $TARGET"
cp /data/files/env $TARGET
echo -e "\nNODE_ID=`hostname`" >> $TARGET
cat $TARGET

View File

@@ -0,0 +1,3 @@
{{- define "librenms.configChecksum" -}}
{{- include (print $.Template.BasePath "/librenms-configmap.yml") . | sha256sum -}}
{{- end -}}

View File

@@ -0,0 +1,29 @@
---
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ .Release.Name }}
data:
TZ: {{ .Values.librenms.timezone}}
DB_TIMEOUT: "60"
REDIS_HOST: {{ .Release.Name }}-redis-master
REDIS_PORT: "6379"
REDIS_DB: "0"
RRDCACHED_SERVER: "{{ .Release.Name }}-rrdcached:42217"
CACHE_DRIVER: redis
SESSION_DRIVER: redis
DB_HOST: {{ .Release.Name }}-mysql
DB_USERNAME: {{.Values.mysql.auth.username}}
DB_DATABASE: {{.Values.mysql.auth.database}}
---
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ .Release.Name }}-files
data:
custom.php: |-
{{ tpl (.Files.Get "files/custom.php") . | indent 4 }}
env: |-
{{ tpl (.Files.Get "files/env") . | indent 4 }}
init.sh: |-
{{ tpl (.Files.Get "files/init.sh") . | indent 4 }}

View File

@@ -0,0 +1,42 @@
{{- if .Values.librenms.snmp_scanner.enabled }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ .Release.Name }}-snmp-scanner
spec:
schedule: "{{.Values.librenms.snmp_scanner.cron }}"
jobTemplate:
spec:
template:
metadata:
annotations:
checksum/config: {{ include "librenms.configChecksum" . }}
spec:
volumes:
- name: files
configMap:
name: {{ .Release.Name }}-files
containers:
- name: snmp-scanner
image: '{{ .Values.librenms.image.repository }}:{{ .Values.librenms.image.tag }}'
imagePullPolicy: Always
envFrom:
- configMapRef:
name: {{ .Release.Name }}
volumeMounts:
- name: files
mountPath: /opt/librenms/config.d/custom.php
subPath: custom.php
readOnly: true
command:
- '/opt/librenms/snmp-scan.py'
- '-v'
{{- if .Values.librenms.snmp_scanner.resources }}
resources: {{ toYaml .Values.librenms.snmp_scanner.resources | nindent 14 }}
{{- end }}
{{- with .Values.librenms.snmp_scanner.extraEnvs }}
env:
{{- toYaml . | nindent 8 }}
{{- end }}
restartPolicy: OnFailure
{{ end }}

View File

@@ -0,0 +1,74 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-frontend
spec:
replicas: {{ .Values.librenms.frontend.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: frontend
template:
metadata:
annotations:
checksum/config: {{ include "librenms.configChecksum" . }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: frontend
spec:
volumes:
- name: env-volume
emptyDir: {}
- name: files
configMap:
name: {{ .Release.Name }}-files
- name: mysql
secret:
secretName: {{ .Release.Name }}-mysql
optional: false
initContainers:
- name: init
image: busybox:1.28
command: ["/bin/sh","/data/files/init.sh"]
volumeMounts:
- name: env-volume
mountPath: /data/env-volume
- name: files
mountPath: /data/files
containers:
- name: librenms
image: '{{ .Values.librenms.image.repository }}:{{ .Values.librenms.image.tag }}'
imagePullPolicy: Always
envFrom:
- configMapRef:
name: {{ .Release.Name }}
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-mysql
key: mysql-password
{{- with .Values.librenms.extraEnvs }}
{{- toYaml . | nindent 8 }}
{{- end }}
volumeMounts:
- name: files
mountPath: /data/files
- name: files
mountPath: /data/config/custom.php
subPath: custom.php
readOnly: true
- name: mysql
mountPath: "/opt/secrets/mysql/"
- name: env-volume
mountPath: /data/.env
subPath: env
{{- if .Values.librenms.frontend.resources }}
resources: {{ toYaml .Values.librenms.frontend.resources | nindent 10 }}
{{- end }}
{{- if .Values.librenms.frontend.readinessProbe }}
readinessProbe: {{ toYaml .Values.librenms.frontend.readinessProbe | nindent 10 }}
{{- end }}
ports:
- name: http
containerPort: 8000

View File

@@ -0,0 +1,75 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-poller
spec:
replicas: {{ .Values.librenms.poller.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
serviceName: "poller"
template:
metadata:
annotations:
checksum/config: {{ include "librenms.configChecksum" . }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
volumes:
- name: env-volume
emptyDir: {}
- name: files
configMap:
name: {{ .Release.Name }}-files
- name: mysql
secret:
secretName: {{ .Release.Name }}-mysql
initContainers:
- name: init
image: busybox:1.28
command: ["/bin/sh","/data/files/init.sh"]
volumeMounts:
- name: env-volume
mountPath: /data/env-volume
- name: files
mountPath: /data/files
containers:
- name: poller
image: '{{ .Values.librenms.image.repository }}:{{ .Values.librenms.image.tag }}'
imagePullPolicy: Always
env:
- name: SIDECAR_DISPATCHER
value: "1"
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-mysql
key: mysql-password
{{- with .Values.librenms.poller.extraEnvs }}
{{- toYaml . | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}
volumeMounts:
- name: files
mountPath: /data/config/custom.php
subPath: custom.php
readOnly: true
- name: env-volume
mountPath: /data/.env
subPath: env
- name: mysql
mountPath: "/opt/secrets/mysql/"
readOnly: true
{{- if .Values.librenms.poller.resources }}
resources: {{ toYaml .Values.librenms.poller.resources | nindent 10 }}
{{- end }}
readinessProbe:
exec:
command: ["nc", "-z", "-v", "-w1", "{{ .Release.Name }}-mysql", "3306"]
initialDelaySeconds: 0
periodSeconds: 1
failureThreshold: 3

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}
spec:
selector:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: frontend
ports:
- name: {{ .Release.Name }}
protocol: TCP
port: 8000
targetPort: 8000

View File

@@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-rrdcached
spec:
strategy:
type: Recreate
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: rrdcached
template:
metadata:
labels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: rrdcached
spec:
securityContext:
fsGroup: 1000
volumes:
{{- if .Values.librenms.rrdcached.persistence.enabled }}
- name: db
persistentVolumeClaim:
claimName: {{ .Release.Name }}-rrdcached
- name: journal
persistentVolumeClaim:
claimName: {{ .Release.Name }}-rrdcached-journal
{{end}}
- name: mysql
secret:
secretName: {{ .Release.Name }}-mysql
optional: false # default setting; "mysecret" must exist
containers:
- name: rrdcached
image: '{{ .Values.librenms.rrdcached.image.repository }}:{{ .Values.librenms.rrdcached.image.tag }}'
imagePullPolicy: Always
{{- if .Values.librenms.rrdcached.persistence.enabled }}
volumeMounts:
- name: db
mountPath: /data/db
- name: journal
mountPath: /data/journal
- name: mysql
mountPath: "/opt/mysql/"
readOnly: true
{{end}}
env:
{{- with .Values.librenms.rrdcached.envs }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.librenms.rrdcached.extraEnvs }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.librenms.rrdcached.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- if .Values.librenms.rrdcached.resources }}
resources: {{ toYaml .Values.librenms.rrdcached.resources | nindent 10 }}
{{- end }}

View File

@@ -0,0 +1,31 @@
{{- if .Values.librenms.rrdcached.persistence.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-rrdcached
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.librenms.rrdcached.persistence.rrdcached.size }}
{{- if .Values.librenms.rrdcached.persistence.rrdcached.storageClassName }}
storageClassName: {{.Values.librenms.rrdcached.persistence.rrdcached.storageClassName}}
{{end}}
volumeMode: Filesystem
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-rrdcached-journal
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.librenms.rrdcached.persistence.journal.size }}
{{- if .Values.librenms.rrdcached.persistence.journal.storageClassName }}
storageClassName: {{.Values.librenms.rrdcached.persistence.journal.storageClassName}}
{{end}}
volumeMode: Filesystem
{{end}}

View File

@@ -0,0 +1,28 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-rrdcached
spec:
selector:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: rrdcached
ports:
- name: rrdcached
protocol: TCP
port: 42217
targetPort: 42217
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-rrdcached-headless
spec:
selector:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: rrdcached
ports:
- name: rrdcached
protocol: TCP
port: 42217
targetPort: 42217
clusterIP: None

121
charts/librenms/values.yaml Normal file
View File

@@ -0,0 +1,121 @@
# Default values for librenms.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
librenms:
image:
repository: librenms/librenms
tag: 24.5.0
# Timezone used by librenms for communication with RRD cached
timezone: UTC
# Custom configuration options for LibreNMS. Fore more infomation on options
# in this file check the following link:
# https://docs.librenms.org/Support/Configuration/
configuration: |-
$config['distributed_poller_group'] = '0';
$config['distributed_poller'] = true;
# Laravel appkey used by LibreNMS, a default is set for useability it is
# recommended to replace this with your own key
appkey: base64:Qh1eBwRfpgNHWByDDqhaX0I/0hnE/VDRiLHLnjwrZRw=
# Frontend container configurations options
frontend:
replicas: 1
readinessProbe:
httpGet:
path: /login
port: 8000
initialDelaySeconds: 30
periodSeconds: 60
timeoutSeconds: 10
resources:
requests:
cpu: 50m
memory: 150M
# Distributed poller container configurations options
poller:
replicas: 2
resources:
requests:
cpu: 500m
memory: 200M
# SNMP network discovery scanner cron job. This job is optional and only use
# when having snmp network discovery enabled. For this to work either set the
# 'nets' confifuration in the custom config on in the admin interface
# See the following link for more information:
# https://docs.librenms.org/Extensions/Auto-Discovery/
snmp_scanner:
enabled: false
cron: 15 * * * *
resources:
requests:
cpu: 500m
memory: 200M
# Extra environment variable for LibreNMS SNMP scanner container
extraEnvs: {}
# Extra environment variable for LibreNMS container
extraEnvs: {}
# RRD cached is the tool that allows for distributed polling and is mandatory
# in this LibreNMS helm chart. See the rrdcached documentation for more
# information: https://oss.oetiker.ch/rrdtool/doc/rrdcached.en.html
rrdcached:
image:
repository: crazymax/rrdcached
tag: 1.8.0
persistence:
enabled: true
journal:
size: 20Gi
rrdcached:
size: 100Gi
resources:
requests:
cpu: 100m
memory: 500M
livenessProbe:
tcpSocket:
port: 42217
initialDelaySeconds: 15
periodSeconds: 20
envs:
- name: TZ
value: "Europe/Amsterdam"
- name: WRITE_JITTER
value: '1800'
- name: WRITE_TIMEOUT
value: '1800'
# Extra environment variable for RRDCACHED container
extraEnvs: {}
# Configuration for MySQL dependency chart by Bitnami. See their chart for
# more information: https://github.com/bitnami/charts/tree/master/bitnami/mysql
mysql:
enabled: true
auth:
username: librenms
database: librenms
# Configuration for redis dependency chart by Bitnami. See their chart for
# more information: https://github.com/bitnami/charts/tree/master/bitnami/redis
redis:
enabled: true
auth:
enabled: false
sentinel: false
sentinel:
enabled: false
master:
disableCommands: []
architecture: standalone