Home

Awesome

external-dns-routeros-provider

<p align="center"> <em>A RouterOS provider for external-dns</em> </p>

This repo provides an external-dns webhook provider capable of integrating with devices running Mikrotik's RouterOS.


Usage

The docker image can be pulled from docker.io/benfiola/external-dns-routeros-provider:latest.

This webhook server is intended to be run as a sidecar alongside external-dns - such that the webhook is connectable via localhost:8888. An example deployment can be found here.

Configuration

Configuring the webhook can be done via the environment or via CLI arguments.

CLIEnvironment VariableDescription
--filter-excludeEXTERNAL_DNS_ROUTEROS_PROVIDER_FILTER_EXCLUDE(Optional) domain name to exclude from webhook processing - can be used multiple times
--filter-includeEXTERNAL_DNS_ROUTEROS_PROVIDER_FILTER_INCLUDE(Optional) domain name to include in webhook processing - can be used multiple times
--filter-regex-excludeEXTERNAL_DNS_ROUTEROS_PROVIDER_FILTER_REGEX_EXCLUDE(Optional) domain name regex to exclude from webhook processing
--filter-regex-includeEXTERNAL_DNS_ROUTEROS_PROVIDER_FILTER_REGEX_INCLUDE(Optional) domain name regex to include in webhook processing
--log-levelEXTERNAL_DNS_ROUTEROS_PROVIDER_LOG_LEVEL(Optional) log level (error, warning, info, debug), default: info
--routeros-addressEXTERNAL_DNS_ROUTEROS_PROVIDER_ROUTEROS_ADDRESSrouteros device <host>:<port>
--routeros-passwordEXTERNAL_DNS_ROUTEROS_PROVIDER_ROUTEROS_PASSWORDrouteros password
--routeros-usernameEXTERNAL_DNS_ROUTEROS_PROVIDER_ROUTEROS_USERNAMErouteros username
--server-hostEXTERNAL_DNS_ROUTEROS_PROVIDER_SERVER_HOST(Optional) server host to listen on, default: 127.0.0.1
--server-portEXTERNAL_DNS_ROUTEROS_PROVIDER_SERVER_PORT(Optional) server port to listen on, default: 8888

Development

I personally use vscode as an IDE. For a consistent development experience, this project is also configured to utilize devcontainers. If you're using both - and you have the Dev Containers extension installed - you can follow the introductory docs to quickly get started.

NOTE: Helper scripts are written under the assumption that they're being executed within a dev container.

Creating a dev environment

From the project root, run the following to create a development cluster to test the webhook with:

cd /workspaces/external-dns-routeros-provider
./dev/create.sh

This will:

Re-running this script will re-create all of the above.

Creating a launch script

Copy the ./dev/dev.go.template script to ./dev/dev.go, then run it to start both the external-dns controller and this provider. ./dev/dev.go is ignored by git and can be modified as needed to help facilitate local development.

Additionally, the devcontainer is configured with a vscode launch configuration that points to ./dev/dev.go. You should be able to launch (and attach a debugger to) the webhook via this vscode launch configuration.