You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/flags.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@
25
25
|`--crd-source-apiversion="externaldns.k8s.io/v1alpha1"`| API version of the CRD for crd source, e.g. `externaldns.k8s.io/v1alpha1`, valid only when using crd source |
26
26
|`--crd-source-kind="DNSEndpoint"`| Kind of the CRD for the crd source in API group and version specified by crd-source-apiversion |
27
27
|`--default-targets=DEFAULT-TARGETS`| Set globally default host/IP that will apply as a target instead of source addresses. Specify multiple times for multiple targets (optional) |
28
+
|`--[no-]force-default-targets`| Force the application of --default-targets, overriding any targets provided by the source (DEPRECATED: This reverts to (improved) legacy behavior which allows empty CRD targets for migration to new state) |
28
29
|`--exclude-record-types=EXCLUDE-RECORD-TYPES`| Record types to exclude from management; specify multiple times to exclude many; (optional) |
This tutorial describes how to use the CRD source with ExternalDNS to manage DNS records. The CRD source allows you to define your desired DNS records declaratively using `DNSEndpoint` custom resources.
4
+
5
+
## Default Targets and CRD Targets
6
+
7
+
ExternalDNS has a `--default-targets` flag that can be used to specify a default set of targets for all created DNS records. The behavior of how these default targets interact with targets specified in a `DNSEndpoint` CRD has been refined.
8
+
9
+
### New Behavior (default)
10
+
11
+
By default, ExternalDNS now has the following behavior:
12
+
13
+
- If a `DNSEndpoint` resource has targets specified in its `spec.endpoints[].targets` field, these targets will be used for the DNS record, **overriding** any targets specified via the `--default-targets` flag.
14
+
- If a `DNSEndpoint` resource has an **empty**`targets` field, the targets from the `--default-targets` flag will be used. This allows for creating records that point to default load balancers or IPs without explicitly listing them in every `DNSEndpoint` resource.
15
+
16
+
### Legacy Behavior (`--force-default-targets`)
17
+
18
+
To maintain backward compatibility and support certain migration scenarios, the `--force-default-targets` flag is available.
19
+
20
+
- When `--force-default-targets` is used, ExternalDNS will **always** use the targets from `--default-targets`, regardless of whether the `DNSEndpoint` resource has targets specified or not.
21
+
This flag allows for a smooth migration path to the new behavior. It allow keeping old CRD resources, allows to start removing targets from one by one resource and then remove the flag.
22
+
23
+
## Examples
24
+
25
+
Let's look at how this works in practice. Assume ExternalDNS is running with `--default-targets=1.2.3.4`.
26
+
27
+
### DNSEndpoint with Targets
28
+
29
+
Here is a `DNSEndpoint` with a target specified.
30
+
31
+
```yaml
32
+
---
33
+
apiVersion: externaldns.k8s.io/v1alpha1
34
+
kind: DNSEndpoint
35
+
metadata:
36
+
name: targets
37
+
namespace: default
38
+
spec:
39
+
endpoints:
40
+
- dnsName: smoke-t.example.com
41
+
recordTTL: 300
42
+
recordType: CNAME
43
+
targets:
44
+
- placeholder
45
+
```
46
+
47
+
- **Without `--force-default-targets` (New Behavior):** A CNAME record for `smoke-t.example.com` will be created pointing to `placeholder`.
48
+
- **With `--force-default-targets` (Legacy Behavior):** A CNAME record for `smoke-t.example.com` will be created pointing to `1.2.3.4`. The `placeholder` target will be ignored.
49
+
50
+
### DNSEndpoint with Empty/No Targets
51
+
52
+
Here is a `DNSEndpoint` without any targets specified.
53
+
54
+
```yaml
55
+
---
56
+
apiVersion: externaldns.k8s.io/v1alpha1
57
+
kind: DNSEndpoint
58
+
metadata:
59
+
name: no-targets
60
+
namespace: default
61
+
spec:
62
+
endpoints:
63
+
- dnsName: smoke-nt.example.com
64
+
recordTTL: 300
65
+
recordType: CNAME
66
+
```
67
+
68
+
- **Without `--force-default-targets` (New Behavior):** A CNAME record for `smoke-nt.example.com` will be created pointing to `1.2.3.4`.
69
+
- **With `--force-default-targets` (Legacy Behavior):** A CNAME record for `smoke-nt.example.com` will be created pointing to `1.2.3.4`.
70
+
71
+
`--force-default-targets`allows migration path to clean CRD resources.
app.Flag("crd-source-apiversion", "API version of the CRD for crd source, e.g. `externaldns.k8s.io/v1alpha1`, valid only when using crd source").Default(defaultConfig.CRDSourceAPIVersion).StringVar(&cfg.CRDSourceAPIVersion)
459
461
app.Flag("crd-source-kind", "Kind of the CRD for the crd source in API group and version specified by crd-source-apiversion").Default(defaultConfig.CRDSourceKind).StringVar(&cfg.CRDSourceKind)
460
462
app.Flag("default-targets", "Set globally default host/IP that will apply as a target instead of source addresses. Specify multiple times for multiple targets (optional)").StringsVar(&cfg.DefaultTargets)
463
+
app.Flag("force-default-targets", "Force the application of --default-targets, overriding any targets provided by the source (DEPRECATED: This reverts to (improved) legacy behavior which allows empty CRD targets for migration to new state)").Default(strconv.FormatBool(defaultConfig.ForceDefaultTargets)).BoolVar(&cfg.ForceDefaultTargets)
461
464
app.Flag("exclude-record-types", "Record types to exclude from management; specify multiple times to exclude many; (optional)").Default().StringsVar(&cfg.ExcludeDNSRecordTypes)
app.Flag("exclude-unschedulable", "Exclude nodes that are considered unschedulable (default: true)").Default(strconv.FormatBool(defaultConfig.ExcludeUnschedulable)).BoolVar(&cfg.ExcludeUnschedulable)
// Make sure that all endpoints have targets for A or CNAME type
186
185
varcrdEndpoints []*endpoint.Endpoint
187
186
for_, ep:=rangednsEndpoint.Spec.Endpoints {
188
187
if (ep.RecordType==endpoint.RecordTypeCNAME||ep.RecordType==endpoint.RecordTypeA||ep.RecordType==endpoint.RecordTypeAAAA) &&len(ep.Targets) <1 {
189
-
log.Warnf("Endpoint %s with DNSName %s has an empty list of targets", dnsEndpoint.Name, ep.DNSName)
190
-
continue
188
+
log.Debugf("Endpoint %s with DNSName %s has an empty list of targets, allowing it to pass through for default-targets processing", dnsEndpoint.Name, ep.DNSName)
log.Warnf("Endpoint %s with DNSName %s has an illegal target. The subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com')", dnsEndpoint.Name, ep.DNSName)
203
+
log.Warnf("Endpoint %s/%s with DNSName %s has an illegal target format.", dnsEndpoint.Namespace, dnsEndpoint.Name, ep.DNSName)
log.Warnf("Source provided targets for %q (%s), ignoring default targets [%s] due to new behavior. Use --force-default-targets to revert to old behavior.", endpoints[i].DNSName, endpoints[i].RecordType, strings.Join(ms.defaultTargets, ", "))
0 commit comments