How to set up external-dns

Installing external-dns on Kubernetes

Install external-dns via helm chart

1
2
3
4
5
NS=dns
REPO=bitnami/external-dns
NAME=cf

helm --namespace=${NS} upgrade --install ${NAME} ${REPO} -f values.yaml

Configure values

詳細可以參考官方文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## DNS provider where the DNS records will be created. Available providers are:
## - alibabacloud, aws, azure, azure-private-dns, cloudflare, coredns, designate, digitalocean, google, infoblox, rfc2136, transip
##
provider: cloudflare

## Cloudflare configuration to be set via arguments/env. variables
##
cloudflare:
## `CF_API_TOKEN` to set in the environment
##
apiToken: ${YOUR_TOKEN}
## `CF_API_KEY` to set in the environment
##
apiKey:
## Use an existing secret with keys "cloudflare_api_token" or "cloudflare_api_key" defined.
## This ignores cloudflare.apiToken, and cloudflare.apiKey
##
# secretName:
## `CF_API_EMAIL` to set in the environment
##
email:
## Enable the proxy feature of Cloudflare
##
proxied: true

## Modify how DNS records are sychronized between sources and providers (options: sync, upsert-only)
##
policy: sync

How to use

ingress 中設定 annotation

1
2
3
4
5
6
annotations:
kubernetes.io/ingress.class: nginx
# 設定你想要的 host
external-dns.alpha.kubernetes.io/hostname: ${YOUR_HOST}
# 如果有設定 target 的話會自動使用 CNAME
external-dns.alpha.kubernetes.io/target: ${YOUR_TARGET}

Conclusion