Add ingress object (#16) (#17)

* Add ingress object (#16)

* Add ingress and testing values

* Bump version

* Fix CI values
This commit is contained in:
Jochem 2024-07-12 11:29:09 +02:00 committed by GitHub
parent cd178d3a0a
commit 62b40e4657
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 157 additions and 4 deletions

View File

@ -2,7 +2,7 @@ apiVersion: v2
name: librenms name: librenms
description: LibreNMS is an autodiscovering PHP/MySQL-based network monitoring system. description: LibreNMS is an autodiscovering PHP/MySQL-based network monitoring system.
type: application type: application
version: 3.11.1 version: 3.12.0
appVersion: "24.5.0" appVersion: "24.5.0"
maintainers: maintainers:
- name: TheChef23 - name: TheChef23

View File

@ -1,5 +1,5 @@
# LibreNMS # LibreNMS
![Version: 3.11.0](https://img.shields.io/badge/Version-3.11.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 24.5.0](https://img.shields.io/badge/AppVersion-24.5.0-informational?style=flat-square) ![Version: 3.12.0](https://img.shields.io/badge/Version-3.12.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 24.5.0](https://img.shields.io/badge/AppVersion-24.5.0-informational?style=flat-square)
## TL;DR ## TL;DR
@ -47,12 +47,17 @@ librenms:
### Available values ### Available values
The following table lists the main configurable parameters of the librenms chart v3.11.0 and their default values. Please, refer to [values.yaml](./values.yaml) for the full list of configurable parameters. The following table lists the main configurable parameters of the librenms chart v3.12.0 and their default values. Please, refer to [values.yaml](./values.yaml) for the full list of configurable parameters.
## Values ## Values
| Key | Type | Default | Description | | Key | Type | Default | Description |
|-----|------|---------|-------------| |-----|------|---------|-------------|
| ingress | object | `{"annotations":{},"className":"","enabled":false,"hosts":[{"host":"chart-example.local","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}],"tls":[]}` | LibreNMS ingress configuration |
| ingress.annotations | object | `{}` | Ingress annotations |
| ingress.className | string | `""` | Ingress class name |
| ingress.enabled | bool | `false` | Enable or disable ingress |
| ingress.hosts | list | `[{"host":"chart-example.local","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}]` | Ingress ingress rules |
| librenms.appkey | string | `nil` | Laravel appkey used by LibreNMS, this should be generated by you and is a required setting. See the README for more information | | librenms.appkey | string | `nil` | Laravel appkey used by LibreNMS, this should be generated by you and is a required setting. See the README for more information |
| librenms.configuration | string | `"$config['distributed_poller_group'] = '0';\n$config['distributed_poller'] = true;\n"` | Custom configuration options for LibreNMS. Fore more infomation on options in this file check the following link: https://docs.librenms.org/Support/Configuration/ | | librenms.configuration | string | `"$config['distributed_poller_group'] = '0';\n$config['distributed_poller'] = true;\n"` | Custom configuration options for LibreNMS. Fore more infomation on options in this file check the following link: https://docs.librenms.org/Support/Configuration/ |
| librenms.extraEnvs | object | `{}` | LibreNMS frontend extra envs | | librenms.extraEnvs | object | `{}` | LibreNMS frontend extra envs |

View File

@ -1,2 +1,4 @@
librenms: librenms:
appkey: base64:RTMmh+i10E2RMcDxookMu47BTzJQy87hOU+k/zcuPnA= appkey: base64:RTMmh+i10E2RMcDxookMu47BTzJQy87hOU+k/zcuPnA=
ingress:
enabled: true

View File

@ -1,3 +1,66 @@
{{- define "librenms.configChecksum" -}} {{- define "librenms.configChecksum" -}}
{{- include (print $.Template.BasePath "/librenms-configmap.yml") . | sha256sum -}} {{- include (print $.Template.BasePath "/librenms-configmap.yml") . | sha256sum -}}
{{- end -}} {{- end -}}
{{/*
Expand the name of the chart.
*/}}
{{- define "librenms.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 "librenms.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 "librenms.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "librenms.labels" -}}
helm.sh/chart: {{ include "librenms.chart" . }}
{{ include "librenms.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "librenms.selectorLabels" -}}
app.kubernetes.io/name: {{ include "librenms.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "librenms.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "librenms.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,62 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := .Release.Name -}}
{{- $svcPort := 8000 -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Release.Name }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/instance: frontend
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -123,6 +123,27 @@ librenms:
# -- Extra environment variable for RRDCACHED container # -- Extra environment variable for RRDCACHED container
extraEnvs: {} extraEnvs: {}
# -- LibreNMS ingress configuration
ingress:
# -- Enable or disable ingress
enabled: false
# -- Ingress class name
className: ""
# -- Ingress annotations
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
# -- Ingress ingress rules
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
# -- Configuration for MySQL dependency chart by Bitnami. See their chart for # -- Configuration for MySQL dependency chart by Bitnami. See their chart for
# more information: https://github.com/bitnami/charts/tree/master/bitnami/mysql # more information: https://github.com/bitnami/charts/tree/master/bitnami/mysql
mysql: mysql: