Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Release Cleanup #99

Merged
merged 11 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
MIKROTIK_BASEURL = "192.168.88.1:443"

MIKROTIK_USERNAME = ""
MIKROTIK_PASSWORD = ""

MIKROTIK_SKIP_TLS_VERIFY = false
MIKROTIK_BASEURL=https://192.168.88.1:443
MIKROTIK_USERNAME=external-dns
MIKROTIK_PASSWORD=external-dns
MIKROTIK_SKIP_TLS_VERIFY=true
97 changes: 94 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,105 @@
# ExternalDNS Webhook Provider for Mikrotik

> [!WARNING]
> This software is experimental and **NOT FIT FOR PRODUCTION USE!**
> [!IMPORTANT]
> While this software has reached version `v1.0.0`, it has not yet undergone extensive testing in large-scale, real-world environments. As such, it may still have bugs and may not yet be fully suitable for production use.
>
> I encourage users to report any issues or suggest improvements, as this project remains under active development. Thank you for contributing!

[ExternalDNS](https://github.com/kubernetes-sigs/external-dns) 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 MikroTik router.

Supported DNS record types:

- A
- AAAA
- CNAME
- MX
- NS
- SRV
- TXT

## 🎯 Requirements

- ExternalDNS >= v0.14.0
- Mikrotik RouterOS (tested on 7.14.3 stable )
- Mikrotik RouterOS (tested on 7.14.3 stable)

## 🚫 Limitations

- Currently, `DNSEndpoints` with multiple `targets` are *technically* not supported. Only one record will be created with the first target from the list, but eDNS will keep trying to update your DNS record in RouterOS, constantly sending `PUT` requests.
- The `Disabled` option on DNS records is currently ignored
- Support for `providerSpecific` annotations on `Ingress` objects is not **yet** supported.

## ⚙️ Configuration Options

### MikroTik Configuration

| Environment Variable | Description | Default Value |
|-----------------------------|---------------------------------------------------------------------|---------------|
| `MIKROTIK_BASEURL` | URL at which the RouterOS API is available. (ex. `https://192.168.88.1:443`) | N/A |
| `MIKROTIK_USERNAME` | Username for the RouterOS API authentication. | N/A |
| `MIKROTIK_PASSWORD` | Password for the RouterOS API authentication. | N/A |
| `MIKROTIK_SKIP_TLS_VERIFY` | Whether to skip TLS verification (true or false). | `false` |
| `LOG_FORMAT` | The format in which logs will be printed. (`text` or `json`) | `json` |
| `LOG_LEVEL` | The verbosity at which logs are printed logs. (`debug`, `info`, `warn` or `error`) | `info` |

### Webhook Server Configuration

| 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 |

## 🚀 Deployment

1. Create a service account in RouterOS. This local user needs read and write access to manage static DNS.
2. Create a Kubernetes namespace for your External DNS deployment

```yaml
---
apiVersion: v1
kind: Namespace
metadata:
name: external-dns
```

3. Create a Kubernetes secret with the connection details for your RouterOS instance:

```yaml
---
apiVersion: v1
kind: Secret
metadata:
name: mikrotik-credentials
namespace: external-dns
stringData:
MIKROTIK_BASEURL: "https://192.168.88.1:443"
MIKROTIK_USERNAME: "external-dns"
MIKROTIK_PASSWORD: "external-dns"
MIKROTIK_SKIP_TLS_VERIFY: "true"
```

4. Add the External DNS helm repository and update your local cache

```bash
helm repo add external-dns https://kubernetes-sigs.github.io/external-dns/
helm repo update
```

5. Configure your helm values. Take a look at the [example values.yaml](./example/values.yaml)
6. Install the External DNS helm chart

```bash
helm upgrade --install --namespace external-dns external-dns external-dns/external-dns -f values.yaml
```

> [!TIP]
> By default, support for MX, NS and SRV records is disabled and needs to be enabled via the `--managed-record-types` argument.
> Make sure to set `--managed-record-types=SRV` if you want to enable SRV records, and so on.

## ⭐ Stargazers

Expand Down
6 changes: 3 additions & 3 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tasks:
- kubectl delete secret --namespace external-dns mikrotik-credentials || true
- kubectl create secret generic --namespace external-dns --from-env-file=.env mikrotik-credentials || true
- helm repo add external-dns https://kubernetes-sigs.github.io/external-dns && helm repo update
- helm upgrade --install --namespace external-dns external-dns external-dns/external-dns -f deploy/values.yaml
- helm upgrade --install --namespace external-dns external-dns external-dns/external-dns -f example/values.yaml

kube:logs:
desc: Fetch the logs from the external-dns-mikrotik webhook container to a local file.
Expand All @@ -31,8 +31,8 @@ tasks:
desc: Remove the external-dns-mikrotik webhook from the test cluster.
cmds:
- kubectl delete ns external-dns || true
- kubectl delete -f deploy/records || true
- kubectl delete -f deploy/ingress || true
- kubectl delete -f example/records || true
- kubectl delete -f example/ingress || true

go:release:
desc: Run goreleaser in snapshot mode.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions deploy/values.yaml → example/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ provider:
webhook:
image:
repository: ghcr.io/mirceanton/external-dns-provider-mikrotik
tag: pr-98
pullPolicy: Always
tag: v1.0.0
pullPolicy: IfNotPresent
env:
- name: LOG_FORMAT
value: json
Expand Down