ExternalDNS is a Kubernetes add-on for automatically managing DNS records for Kubernetes ingresses and services by using different DNS providers. This webhook provider allows you to automate DNS records from your Kubernetes clusters into your UniFi Network controller.
- ExternalDNS >= v0.14.0
- UniFi OS >= 3.x
- UniFi Network >= 8.2.93
- Wildcard CNAME Records are not supported by UniFi.
UniFi Api Key - Network v9.0.0+
-
Open your UniFi Console's Network Settings and go to
Settings > Control Plane > Admins & Users
. -
Selecting your user to operate under. Whenever we modify the DNS Records, this user will show up under
System Log > Admin Activity
-
Go under
Control Plane API Key
and clickCreate New
. You can set the name to whatever you want, and the expiration to whatever you feel like. -
Create a Kubernetes secret called
external-dns-unifi-secret
that will hold yourUNIFI_API_KEY
with their respected values from Step 3.
---
apiVersion: v1
kind: Secret
metadata:
name: external-dns-unifi-secret
data:
api-key: <your-api-key>
Username & Password (Deprecated)
-
Open your UniFi Console's Network Settings and go to
Settings > Control Plane > Admins & Users
. -
Select
Create New Admin
. -
In the menu that appears, enable
Restrict to Local Access Only
. DeselectUse a Predefined Role
. SetNetwork: Site Admin
. All other selections can be set toNone
. ClickCreate
. -
Create a Kubernetes secret called
external-dns-unifi-secret
that holds theusername
andpassword
with their respected values from Step 3.
---
apiVersion: v1
kind: Secret
metadata:
name: external-dns-unifi-secret
data:
username: <your-username>
password: <your-password>
-
Add the ExternalDNS Helm repository to your cluster.
helm repo add external-dns https://kubernetes-sigs.github.io/external-dns/
-
Deploy your
external-dns-unifi-secret
secret that holds your authentication credentials from either of the credential types above. -
Create the helm values file, for example
external-dns-unifi-values.yaml
:fullnameOverride: external-dns-unifi logLevel: &logLevel debug provider: name: webhook webhook: image: repository: ghcr.io/kashalls/external-dns-unifi-webhook tag: main # replace with a versioned release tag env: - name: UNIFI_HOST value: https://192.168.1.1 # replace with the address to your UniFi router/controller - name: UNIFI_EXTERNAL_CONTROLLER value: "false" - name: UNIFI_API_KEY valueFrom: secretKeyRef: name: external-dns-unifi-secret key: api-key - name: LOG_LEVEL value: *logLevel livenessProbe: httpGet: path: /healthz port: http-webhook initialDelaySeconds: 10 timeoutSeconds: 5 readinessProbe: httpGet: path: /readyz port: http-webhook initialDelaySeconds: 10 timeoutSeconds: 5 extraArgs: - --ignore-ingress-tls-spec policy: sync sources: ["ingress", "service"] txtOwnerId: default txtPrefix: k8s. domainFilters: ["example.com"] # replace with your domain
-
Install the Helm chart
helm install external-dns-unifi external-dns/external-dns -f external-dns-unifi-values.yaml --version 1.15.0 -n external-dns
Environment Variable | Description | Default Value |
---|---|---|
UNIFI_API_KEY |
The local api key provided for your user | N/A |
UNIFI_USER |
Username for the Unifi Controller (deprecated use UNIFI_API_KEY ). |
N/A |
UNIFI_PASS |
Password for the Unifi Controller (deprecated use UNIFI_API_KEY ). |
N/A |
UNIFI_SKIP_TLS_VERIFY |
Whether to skip TLS verification (true or false). | true |
UNIFI_SITE |
Unifi Site Identifier (used in multi-site installations) | default |
UNIFI_HOST |
Host of the Unifi Controller (must be provided). | N/A |
UNIFI_EXTERNAL_CONTROLLER * |
Toggles support for non-UniFi Hardware | false |
LOG_LEVEL |
Change the verbosity of logs (used when making a bug report) | info |
*UNIFI_EXTERNAL_CONTROLLER
is used to toggle between two versions of the Network Controller API. If you are running the UniFi software outside of UniFi's official hardware (e.g., Cloud Key or Dream Machine), you'll need to set UNIFI_EXTERNAL_CONTROLLER
to true
Environment Variable | Description | Default Value |
---|---|---|
SERVER_HOST |
The host address where the server listens. | localhost |
SERVER_PORT |
The port where the server listens. | 8888 |
SERVER_READ_TIMEOUT |
Duration the server waits before timing out on read operations. | N/A |
SERVER_WRITE_TIMEOUT |
Duration the server waits before timing out on write operations. | N/A |
DOMAIN_FILTER |
List of domains to include in the filter. | Empty |
EXCLUDE_DOMAIN_FILTER |
List of domains to exclude from filtering. | Empty |
REGEXP_DOMAIN_FILTER |
Regular expression for filtering domains. | Empty |
REGEXP_DOMAIN_FILTER_EXCLUSION |
Regular expression for excluding domains from the filter. | Empty |
Thanks to all the people who donate their time to the Home Operations Discord community.