Skip to content

Commit

Permalink
cherry-pick c14a3c962b93f00c188203d4a801fb28c73cac9e
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpedrosaSnoo authored and platinummonkey committed May 6, 2024
0 parents commit f436d65
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: helm-docs
helm-docs:
go run github.com/norwoodj/helm-docs/cmd/helm-docs@latest
23 changes: 23 additions & 0 deletions charts/unpoller/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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/
17 changes: 17 additions & 0 deletions charts/unpoller/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v2
name: unpoller
description: A Helm chart for unpoller, a unifi prometheus exporter
type: application
version: "2.11.2"
appVersion: "v2.11.2"
keywords:
- esp32
- home-assistant
home: https://github.com/unpoller/unpoller
icon: XXX?
sources:
- https://github.com/unpoller/unpoller
maintainers:
- name: XXXX?
email: XXXX?

54 changes: 54 additions & 0 deletions charts/unpoller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# unpoller

![Version: 2.11.2](https://img.shields.io/badge/Version-2.11.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.11.2](https://img.shields.io/badge/AppVersion-v2.11.2-informational?style=flat-square)

A Helm chart for unpoller, a unifi prometheus exporter

**Homepage:** <https://github.com/unpoller/unpoller>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| XXXX? | <XXXX?> | |

## Source Code

* <https://github.com/unpoller/unpoller>

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| dashboards.create | bool | `true` | |
| dashboards.grafana.create | bool | `true` | |
| dashboards.grafana.secret.existingSecretName | string | `""` | |
| dashboards.grafana.secret.password | string | `"prom-operator"` | |
| dashboards.grafana.secret.username | string | `"prom"` | |
| dashboards.grafana.selectorLabels | object | `{}` | |
| dashboards.grafana.url | string | `""` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"ghcr.io/unpoller/unpoller"` | |
| image.tag | string | `"v2.11.2"` | |
| imagePullSecrets | list | `[]` | |
| livenessProbe.httpGet.path | string | `"/"` | |
| livenessProbe.httpGet.port | string | `"http"` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podLabels | object | `{}` | |
| podSecurityContext | object | `{}` | |
| readinessProbe.httpGet.path | string | `"/"` | |
| readinessProbe.httpGet.port | string | `"http"` | |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
| securityContext | object | `{}` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.automount | bool | `true` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| tolerations | list | `[]` | |
| upConfig | string | `"[poller]\n debug = false\n quiet = false\n plugins = []\n[prometheus]\n disable = false\n http_listen = \"0.0.0.0:9130\"\n report_errors = false\n[influxdb]\n disable = true\n[unifi]\n dynamic = false\n[loki]\n disable = true\n[[unifi.controller]] \n url = \"https://unifi.home:8443\"\n user = \"unifi\"\n pass = \"unifi\"\n sites = [\"all\"]\n save_ids = true\n save_dpi = true\n save_sites = true\n hash_pii = false\n verify_ssl = false\n"` | |

81 changes: 81 additions & 0 deletions charts/unpoller/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "unpoller.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 "unpoller.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 }}

{{/*
Name for the grafana CR secret.
*/}}
{{- define "unpoller.grafana-secret" -}}
{{- printf "%s-%s" "grafana-secret" (include "unpoller.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}


{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "unpoller.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "unpoller.labels" -}}
helm.sh/chart: {{ include "unpoller.chart" . }}
{{ include "unpoller.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "unpoller.selectorLabels" -}}
app.kubernetes.io/name: {{ include "unpoller.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "unpoller.dashboadSelectorLabels" -}}
{{- if .Values.dashboards.grafana.create -}}
app.kubernetes.io/name: {{ include "unpoller.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- else -}}
{{- with .Values.dashboards.grafana.selectorLabels }}
{{- toYaml . }}
{{- end }}
{{- end -}}
{{- end}}

{{/*
Create the name of the service account to use
*/}}
{{- define "unpoller.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "unpoller.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
78 changes: 78 additions & 0 deletions charts/unpoller/templates/dashboards.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{{- if .Values.dashboards.create }}
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: unpoller-uap-insights
labels:
{{- include "unpoller.labels" . | nindent 4 }}
spec:
instanceSelector:
matchLabels:
{{- include "unpoller.dashboadSelectorLabels" . | nindent 6 }}
url: "https://grafana.com/api/dashboards/11314/revisions/10/download"
datasources:
- inputName: "DS_PROMETHEUS"
datasourceName: "Prometheus"
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: unpoller-client-insights
labels:
{{- include "unpoller.labels" . | nindent 4 }}
spec:
instanceSelector:
matchLabels:
{{- include "unpoller.dashboadSelectorLabels" . | nindent 6 }}
url: "https://grafana.com/api/dashboards/11315/revisions/9/download"
datasources:
- inputName: "DS_PROMETHEUS"
datasourceName: "Prometheus"
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: unpoller-usw-insights
labels:
{{- include "unpoller.labels" . | nindent 4 }}
spec:
instanceSelector:
matchLabels:
{{- include "unpoller.dashboadSelectorLabels" . | nindent 6 }}
url: "https://grafana.com/api/dashboards/11312/revisions/9/download"
datasources:
- inputName: "DS_PROMETHEUS"
datasourceName: "Prometheus"

---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: unpoller-network-sites
labels:
{{- include "unpoller.labels" . | nindent 4 }}
spec:
instanceSelector:
matchLabels:
{{- include "unpoller.dashboadSelectorLabels" . | nindent 6 }}
url: "https://grafana.com/api/dashboards/11311/revisions/5/download"
datasources:
- inputName: "DS_PROMETHEUS"
datasourceName: "Prometheus"

---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: unpoller-usg-insights
labels:
{{- include "unpoller.labels" . | nindent 4 }}
spec:
instanceSelector:
matchLabels:
{{- include "unpoller.dashboadSelectorLabels" . | nindent 6 }}
url: "https://grafana.com/api/dashboards/11313/revisions/9/download"
datasources:
- inputName: "DS_PROMETHEUS"
datasourceName: "Prometheus"
{{- end }}
69 changes: 69 additions & 0 deletions charts/unpoller/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "unpoller.fullname" . }}
labels:
{{- include "unpoller.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "unpoller.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "unpoller.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "unpoller.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 9130
name: tcp
protocol: TCP
- containerPort: 9130
name: udp
protocol: UDP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config-volume
mountPath: /etc/unpoller/up.conf
subPath: up.conf
volumes:
- name: config-volume
secret:
secretName: unifi-poller
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/unpoller/templates/grafana-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if and .Values.dashboards.grafana.create (not .Values.dashboards.grafana.secret.existingSecretName)}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "unpoller.grafana-secret" . }}
labels:
{{- include "unpoller.labels" . | nindent 4 }}
stringData:
GF_SECURITY_ADMIN_PASSWORD: {{ .Values.dashboards.grafana.secret.password }}
GF_SECURITY_ADMIN_USER: {{ .Values.dashboards.grafana.secret.username }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/unpoller/templates/grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.dashboards.grafana.create }}
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: {{ include "unpoller.fullname" . }}
labels:
{{- include "unpoller.labels" . | nindent 4 }}
spec:
external:
url: http://monitoring-promstack-grafana #Grafana URL
adminPassword:
name: grafana-admin-credentials
key: GF_SECURITY_ADMIN_PASSWORD
adminUser:
name: grafana-admin-credentials
key: GF_SECURITY_ADMIN_USER
{{- end }}
12 changes: 12 additions & 0 deletions charts/unpoller/templates/pod-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: unifi-poller
labels:
{{- include "unpoller.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "unpoller.selectorLabels" . | nindent 6 }}
podMetricsEndpoints:
- port: tcp
13 changes: 13 additions & 0 deletions charts/unpoller/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "unpoller.serviceAccountName" . }}
labels:
{{- include "unpoller.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
Loading

0 comments on commit f436d65

Please sign in to comment.