Webhook-provider for Domeneshop to be used by external-dns
Find a file
2025-03-16 06:49:14 +00:00
.forgejo chore: add version 2025-03-15 09:40:33 +01:00
ci chore: bump app version to v0.6.1 and enhance domain filtering logic with improved logging for better debugging 2025-03-15 20:12:57 +01:00
src chore(deps): update module sigs.k8s.io/external-dns to v0.16.1 2025-03-16 01:01:01 +00:00
.gitignore Feature/rename repository (#3) 2024-02-29 22:38:14 +01:00
Dockerfile chore(deps): update golang docker tag to v1.24.1 2025-03-16 01:00:48 +00:00
LICENSE Initial commit 2024-02-25 15:04:42 +01:00
README.md chore: update README and main application to use new environment variable names and port configuration 2025-03-15 17:44:25 +01:00
renovate.json chore: cleanup and add build workflow 2025-03-15 09:38:11 +01:00

Domeneshop Webhook for ExternalDNS

A lightweight webhook that integrates Domeneshop DNS with Kubernetes ExternalDNS, enabling automated DNS management.

🚀 Key Features

  • Automatic DNS record management for Kubernetes services
  • Support for multiple record types (A, AAAA, CNAME, TXT)
  • Simple deployment as a sidecar container
  • Health and readiness probes
  • Configurable TLS support
  • CORS support for API access

📋 Quick Start

Prerequisites

  • Kubernetes cluster with ExternalDNS
  • Domeneshop API credentials (get yours here)

Deployment

  1. Create a secret with your Domeneshop credentials:
kubectl create secret generic external-dns-domeneshop-webhook \
  --from-literal=DOMENESHOP_API_TOKEN=your_api_token \
  --from-literal=DOMENESHOP_API_SECRET=your_api_secret
  1. Create a values file for the ExternalDNS Helm chart:
# external-dns-domeneshop-values.yaml
fullnameOverride: external-dns-domeneshop
extraArgs:
- --gateway-label-filter=app.kubernetes.io/name in (gateway-external)
- --ignore-hostname-annotation
- --fqdn-template=external.example.com
- --webhook-provider-url=http://localhost:8080
provider:
  name: webhook
  webhook:
    image:
      repository: code.252.no/pub/external-dns-domeneshop-webhook
      tag: v0.1.0
    env:
    # - name: LOG_LEVEL
    #   value: debug
    - name: PORT
      value: "8080"
    - name: TOKEN
      valueFrom:
        secretKeyRef:
          name: external-dns-domeneshop-webhook
          key: DOMENESHOP_API_TOKEN
    - name: SECRET
      valueFrom:
        secretKeyRef:
          name: external-dns-domeneshop-webhook
          key: DOMENESHOP_API_SECRET
    ports:
    - containerPort: 8080
      name: http
    livenessProbe:
      httpGet:
        path: /healthz
        port: http
      initialDelaySeconds: 10
      timeoutSeconds: 5
    readinessProbe:
      httpGet:
        path: /readyz
        port: http
      initialDelaySeconds: 10
      timeoutSeconds: 5
triggerLoopOnEvent: true
policy: sync
sources:
- gateway-httproute
txtOwnerId: k8s
txtPrefix: kube.
domainFilters:
- "example.com"
  1. Install ExternalDNS with the webhook:
helm upgrade my-release external-dns/external-dns \
  -f external-dns-domeneshop-values.yaml

⚙️ Configuration

The webhook supports configuration via environment variables:

Variable Description Default
TOKEN Domeneshop API token Required
SECRET Domeneshop API secret Required
PORT Server port 8080
TLS_CERT_FILE Path to TLS certificate
TLS_KEY_FILE Path to TLS key
ALLOWED_ORIGINS CORS allowed origins (comma-separated) *

🔍 Implementation Details

Architecture

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│   ExternalDNS   │────▶│     Webhook     │────▶│  Domeneshop API │
└─────────────────┘     └─────────────────┘     └─────────────────┘

Components

  • main.go: Core application with HTTP server and route configuration
  • webhook: Implements HTTP endpoints required by ExternalDNS
  • internal/client: Domeneshop API client implementation
  • internal/provider: Methods for DNS record management

Note on CNAME Records

Domeneshop strictly enforces RFC compliance (RFC 1034, 1912) which prevents CNAME records from coexisting with any other records. Using the --txt-prefix option in ExternalDNS can help work around this limitation.

🧪 Development

For local development:

  1. Run the webhook locally
  2. Deploy ExternalDNS pointing to your local instance:
helm upgrade my-release external-dns/external-dns \
  --set provider=webhook \
  --set webhook.url=http://host.docker.internal:8080

Alternatively, use the Docker gateway IP (172.17.0.1):

--webhook-provider-url=http://172.17.0.1:8080

📚 Resources