[unifi-poller] new chart (#331)

* add unifi-poller

* fix lint

* fix lint
This commit is contained in:
Devin Buhl 2020-08-18 13:58:15 -04:00 committed by GitHub
parent cfd9708cf4
commit 81e0519f1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 501 additions and 0 deletions

22
charts/unifi-poller/.helmignore Executable file
View File

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

16
charts/unifi-poller/Chart.yaml Executable file
View File

@ -0,0 +1,16 @@
apiVersion: v1
appVersion: "2.0.1"
description: Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus
name: unifi-poller
version: 1.0.0
keywords:
- unifi
- unifi-poller
home: https://github.com/billimek/billimek-charts/tree/master/charts/unifi-poller
icon: https://raw.githubusercontent.com/wiki/unifi-poller/unifi-poller/images/unifi-poller-logo.png
sources:
- https://github.com/unifi-poller/unifi-poller
- https://hub.docker.com/r/golift/unifi-poller
maintainers:
- name: billimek
email: jeff@billimek.com

View File

@ -0,0 +1,4 @@
approvers:
- billimek
reviewers:
- billimek

49
charts/unifi-poller/README.md Executable file
View File

@ -0,0 +1,49 @@
# unifi-poller
This is an opinionated helm chart for [unifi-poller](https://github.com/unifi-poller/unifi-poller)
Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus
The default values and container images used in this chart will allow for running in a multi-arch cluster (amd64, arm, arm64)
## TL;DR;
```shell
$ helm repo add billimek https://billimek.com/billimek-charts/
$ helm install billimek/unifi-poller
```
## Installing the Chart
To install the chart with the release name `my-release`:
```console
helm install --name unifi-poller billimek/unifi-poller
```
## Uninstalling the Chart
To uninstall/delete the `unifi-poller` deployment:
```console
helm delete unifi-poller --purge
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
Read through the [values.yaml](https://github.com/billimek/billimek-charts/blob/master/charts/unifi-poller/values.yaml) file. It has several commented out suggested values.
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
helm install --name unifi-poller \
billimek/unifi-poller
```
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```console
helm install --name unifi-poller -f values.yaml stable/unifi-poller
```

View File

@ -0,0 +1,21 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "unifi-poller.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 }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "unifi-poller.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "unifi-poller.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
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.kubernetes.io/name={{ include "unifi-poller.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:9130 to use your application"
kubectl port-forward $POD_NAME 9130:80
{{- end }}

View File

@ -0,0 +1,56 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "unifi-poller.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 "unifi-poller.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 "unifi-poller.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "unifi-poller.labels" -}}
app.kubernetes.io/name: {{ include "unifi-poller.name" . }}
helm.sh/chart: {{ include "unifi-poller.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "unifi-poller.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "unifi-poller.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

View File

@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "unifi-poller.fullname" . }}
labels:
{{ include "unifi-poller.labels" . | indent 4 }}
data:
up.yaml: {{ .Values.config | toYaml | quote }}

View File

@ -0,0 +1,70 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "unifi-poller.fullname" . }}
labels:
{{ include "unifi-poller.labels" . | indent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
revisionHistoryLimit: 3
selector:
matchLabels:
app.kubernetes.io/name: {{ include "unifi-poller.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
annotations:
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
app.kubernetes.io/name: {{ include "unifi-poller.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "unifi-poller.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-c"
- "/etc/unifi-poller/up.yaml"
ports:
- name: http
containerPort: 9130
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
volumeMounts:
- name: config
mountPath: /etc/unifi-poller
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ template "unifi-poller.fullname" . }}

View File

@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "unifi-poller.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app.kubernetes.io/name: {{ include "unifi-poller.name" . }}
helm.sh/chart: {{ include "unifi-poller.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}

View File

@ -0,0 +1,27 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "unifi-poller.fullname" . }}
labels:
{{ include "unifi-poller.labels" . | indent 4 }}
{{- if or (not .Values.config.prometheus.disable) (.Values.service.annotations) }}
annotations:
{{- if not .Values.config.prometheus.disable }}
prometheus.io/path: /metrics
prometheus.io/port: "9130"
prometheus.io/scrape: "true"
{{- end }}
{{- if .Values.service.annotations }}
{{ toYaml .Values.service.annotations | nindent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "unifi-poller.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

View File

@ -0,0 +1,8 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "unifi-poller.serviceAccountName" . }}
labels:
{{ include "unifi-poller.labels" . | indent 4 }}
{{- end -}}

View File

@ -0,0 +1,18 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "unifi-poller.fullname" . }}-test-connection"
labels:
app.kubernetes.io/name: {{ include "unifi-poller.name" . }}
helm.sh/chart: {{ include "unifi-poller.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "unifi-poller.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

163
charts/unifi-poller/values.yaml Executable file
View File

@ -0,0 +1,163 @@
# Default values for unifi-poller.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: golift/unifi-poller
tag: 2.0.0
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 9130
annotations: {}
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
config:
poller:
# config.poller.debug -- Turns on line numbers, microsecond logging, and a per-device log.
# The default is false, but I personally leave this on at home (four devices).
# This may be noisy if you have a lot of devices. It adds one line per device.
debug: false
# config.poller.quiet -- Turns off per-interval logs. Only startup and error logs will be emitted.
# Recommend enabling debug with this setting for better error logging.
quiet: false
# config.poller.plugins -- Load dynamic plugins. Advanced use; only sample mysql plugin provided by default.
plugins: []
#### OUTPUTS
prometheus:
# config.prometheus.disable -- Disable prometheus output
disable: false
# config.prometheus.http_listen -- This controls on which ip and port /metrics is exported when mode is "prometheus".
# This has no effect in other modes. Must contain a colon and port.
http_listen: "0.0.0.0:9130"
# config.prometheus.requests --
report_errors: false
influxdb:
# config.influxdb.disable -- Disable prometheus output
disable: false
# config.influxdb.interval --
interval: "30s"
# config.influxdb.url -- InfluxDB does not require auth by default, so the user/password are probably unimportant.
url: "http://127.0.0.1:8086"
# config.influxdb.user --
user: "unifipoller"
# config.influxdb.pass --
pass: "unifipoller"
# config.influxdb.pass -- Be sure to create this database.
db: "unifi"
# config.influxdb.verify_ssl -- The UniFi Controller only updates traffic stats about every 30 seconds.
# Setting this to something lower may lead to "zeros" in your data.
# If you're getting zeros now, set this to "1m"
verify_ssl: false
#### Inputs
unifi:
# config.unifi.dynamic -- Setting this to true and providing default credentials allows you to skip
# configuring controllers in this config file. Instead you configure them in
# your prometheus.yml config. Prometheus then sends the controller URL to
# unifi-poller when it performs the scrape. This is useful if you have many,
# or changing controllers. Most people can leave this off. See wiki for more.
dynamic: false
# config.unifi.defaults -- The following section contains the default credentials/configuration for any
# dynamic controller (see above section), or the primary controller if you do not
# provide one and dynamic is disabled. In other words, you can just add your
# controller here and delete the following section.
defaults:
# config.unifi.defaults.role -- Friendly name used in dashboards. Uses URL if left empty; which is fine.
# Avoid changing this later because it will live forever in your database.
# Multiple controllers may share a role. This allows grouping during scrapes.
role: "main controller"
# config.unifi.defaults.role -- Username to talk to unifi
user: "unifipoller"
# config.unifi.defaults.pass -- Password to talk to unifi
pass: "unifipoller"
# config.unifi.defaults.url -- Url to talk to unifi
url: "https://127.0.0.1:8443"
# config.unifi.defaults.sites -- If the controller has more than one site, specify which sites to poll here.
# Set this to ["default"] to poll only the first site on the controller.
# A setting of ["all"] will poll all sites; this works if you only have 1 site too.
sites:
- all
# config.unifi.defaults.verify_ssl -- If your UniFi controller has a valid SSL certificate (like lets encrypt),
# you can enable this option to validate it. Otherwise, any SSL certificate is
# valid. If you don't know if you have a valid SSL cert, then you don't have one
verify_ssl: false
# config.unifi.defaults.save_ids -- Enable collection of Intrusion Detection System Data (InfluxDB only).
# Only useful if IDS or IPS are enabled on one of the sites.
save_ids: false
# config.unifi.defaults.save_dpi -- Enable collection of Deep Packet Inspection data. This data breaks down traffic
# types for each client and site, it powers a dedicated DPI dashboard.
# Enabling this adds roughly 150 data points per client. That's 6000 metrics for
# 40 clients. This adds a little bit of poller run time per interval and causes
# more API requests to your controller(s). Don't let these "cons" sway you:
# it's cool data. Please provide feedback on your experience with this feature.
save_dpi: false
# config.unifi.defaults.save_sites -- Enable collection of site data. This data powers the Network Sites dashboard.
# It's not valuable to everyone and setting this to false will save resources.
save_sites: true
# config.unifi.controllers -- Repeat any controllers like default above
controllers: []