Unifi Poller charm for k8s

I have been working on a k8s charm for Unifi Poller and I have something ready for public consumption.

This charm allows deploying a poller to retrieve metrics from a running Unifi Network Controller for wireless, switch and routing data for a Unifi based network. The charm supports pull from a remote Prometheus server, or can be configured to push data into InfluxDB. From there it can be visualised in Grafana, with a comprehensive set of dashboards available. Further information on the Unifi Poller itself can be found in the upstream project documentation.

The charm is published to the charmstore and the code available on Launchpad. The charm has unit tests that verify functionality and has been deployed and tested on MicroK8s.

We publish a suitable image, built by Launchpad, on dockerhub which is set as the default image for deployment to a Juju Kubernetes model:

juju deploy cs:~unifi-poller-charmers/unifi-poller unifi-poller

The charm will not function without connection details for a Unifi Network Controller. You will need to create a read-only admin user on the controller with access to all sites by following prerequisite steps from the wiki, then:

juju config unifi_poller controller_url="https://<ip_address>:8443"
juju config unifi_poller controller_username=<username>
juju config unifi_poller controller_password=<password>

Optionally we can also enable DPI (Deep Packet Inspection) data collection from the Controller. To utilise this there must be at least one site using a Unifi Security Gateway product such as the USG or UDM devices or their Pro variants, and such a site must also have DPI enabled in site configuration, then:

juju config unifi_poller controller_dpi=true

Configuring the controller URL, and credentials is sufficient config to configure polling and to enable the prometheus endpoint on http://pod_cluster_IP:9130/metrics

To expose that endpoint outside the k8s cluster via the ingress eg:

juju config unifi-poller juju-external-hostname="unifi-poller.example.domain"
juju expose unifi-poller

This will expose the service via the kubernetes nginx ingress via a virtual host, eg http://unifi-poller.example.com/metrics

The charm optionally supports an externally deployed InfluxDB instance which may be preferred for longer term data storage. This could be deployed outside the cluster in a suitable juju model using juju deploy cs:influxdb. The Unifi Poller charm supports authentication to the InfluxDB instance, if required:

juju config unifi-poller influxdb_url="https://<ip_address>:8086"
juju config unifi-poller influxdb_dbname=<dbname>
juju config unifi-poller influxdb_username=<db_username>
juju config unifi=poller influxdb_password=<db_password>

The Unifi Poller charm supports configuring additional controllers and additional options, which can be added via the extra_configs charm option. See config.yaml and the full list of support env vars for details.

Should you need a specific version of the upstream poller, the Dockerfile and a Makefile target for image building are available from the charm code repository on Launchpad. Once built and pushed to your local docker registry you can deploy by setting the image_path charm option.

We would be interested in any feedback on the code or charm itself. Please feel free to file bugs against the project on Launchpad.

Special thank you to both John Lenton (@chipaca) and Facundo Batista (@facundo) for their feedback and help during development of this charm.

2 Likes