Fork of external-dns but only Hetzner provider included to speed up provider development
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Vladimir Smagin 406f3b683e + 1 month ago
controller dependencies: Upgrade all k8s client-go dependent sources to v1.18.X 3 months ago
docs some cleanup 1 month ago
endpoint *: fix goreportcard golint warnings 5 months ago
img Add Logo for ExternalDNS (#313) 3 years ago
internal add license header check to the CI 2 months ago
kustomize chore(kustomize): move image tag to kustomization.yaml 1 month ago
pkg Merge pull request #1704 from DataDog/aws-cache-zones-list 1 month ago
plan Remove unnecessary import 4 months ago
provider + 1 month ago
registry Fix index out of range when hostname has no dots 2 months ago
scripts adding kubernetes adder 1 year ago
source Merge pull request #1628 from josephglanville/jpg/contour-httpproxy 1 month ago
vendor vendor 1 month ago
.gitignore vendor 1 month ago
Dockerfile add pipeline 1 month ago
Dockerfile.mini Update go versions to 1.14.x that were missed in commit 99cebfcf from PR #1476 5 months ago
Jenkinsfile + 1 month ago
LICENSE Initial commit 3 years ago
Makefile Moved coverprofile creation into Makefile 1 month ago
README.md + 1 month ago
code-of-conduct.md some cleanup 1 month ago
go.mod add pipeline 1 month ago
go.sum add pipeline 1 month ago
main.go + 1 month ago

README.md

What It Does

This is a fork of original external-dns 0.7.3 but only Hetzner provider included to make development of provider a little bit faster (for a months actually). Tutorial below describes how to setup hetzner-dns for usage within a Kubernetes cluster.

Make sure to use >=hetzner-dns 0.1.

Creating a Hetzner DNS zone

If you want to learn about how to use Hetzner’s DNS service read the following tutorial series:

An Introduction to Managing DNS, and Add a new DNS zone.

Create a new DNS zone where you want to create your records in. Let’s use example.com as an example here.

Creating Hetzner Credentials

Generate a new personal token by going to the API settings or follow Generating an API access token if you need more information. Give the token a name and choose read and write access. The token needs to be passed to ExternalDNS so make a note of it for later use.

The environment variable HETZNER_TOKEN will be needed to run ExternalDNS with Hetzner.

Deploy ExternalDNS

Connect your kubectl client to the cluster you want to test ExternalDNS with. Then apply one of the following manifests file to deploy ExternalDNS.

Manifest (for clusters without RBAC enabled)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: external-dns
spec:
  replicas: 1
  selector:
    matchLabels:
      app: external-dns
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: external-dns
    spec:
      containers:
      - name: external-dns
        image: registry.blindage.org/hetzner-dns:v0.1
        args:
        - --source=service # ingress is also possible
        - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above.
        - --provider=hetzner
        env:
        - name: HETZNER_TOKEN
          value: "YOUR_HETZNER_DNS_API_KEY"

Manifest (for clusters with RBAC enabled)

apiVersion: v1
kind: ServiceAccount
metadata:
  name: external-dns
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: external-dns
rules:
- apiGroups: [""]
  resources: ["services","endpoints","pods"]
  verbs: ["get","watch","list"]
- apiGroups: ["extensions","networking.k8s.io"]
  resources: ["ingresses"] 
  verbs: ["get","watch","list"]
- apiGroups: [""]
  resources: ["nodes"]
  verbs: ["list","watch"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: external-dns-viewer
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: external-dns
subjects:
- kind: ServiceAccount
  name: external-dns
  namespace: default
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: external-dns
spec:
  replicas: 1
  selector:
    matchLabels:
      app: external-dns
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: external-dns
    spec:
      serviceAccountName: external-dns
      containers:
      - name: external-dns
        image: registry.blindage.org/hetzner-dns:v0.1
        args:
        - --source=service # ingress is also possible
        - --domain-filter=example.com # (optional) limit to only example.com domains; change to match the zone created above.
        - --provider=hetzner
        env:
        - name: HETZNER_TOKEN
          value: "YOUR_HETZNER_DNS_API_KEY"

Deploying an Nginx Service

Create a service file called ‘nginx.yaml’ with the following contents:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
  annotations:
    external-dns.alpha.kubernetes.io/hostname: my-app.example.com
spec:
  selector:
    app: nginx
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

Note the annotation on the service; use the same hostname as the Hetzner DNS zone created above.

ExternalDNS uses this annotation to determine what services should be registered with DNS. Removing the annotation will cause ExternalDNS to remove the corresponding DNS records.

Create the deployment and service:

$ kubectl create -f nginx.yaml

Depending where you run your service it can take a little while for your cloud provider to create an external IP for the service.

Once the service has an external IP assigned, ExternalDNS will notice the new service IP address and synchronize the Hetzner DNS records.

Verifying Hetzner DNS records

Check your Hetzner DNS UI to view the records for your Hetzner DNS zone.

Click on the zone for the one created above if a different domain was used.

This should show the external IP address of the service as the A record for your domain.

Cleanup

Now that we have verified that ExternalDNS will automatically manage Hetzner DNS records, we can delete the tutorial’s example:

$ kubectl delete service -f nginx.yaml
$ kubectl delete service -f externaldns.yaml