Skip to content
Draft
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
8 changes: 5 additions & 3 deletions controller/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"net/http"
"os"
"os/signal"
"slices"
"strings"
"syscall"
"time"

Expand Down Expand Up @@ -63,9 +65,9 @@ func execute(ctx context.Context) {
}

// Set annotation prefix (required since init() was removed)
annotations.SetAnnotationPrefix(cfg.AnnotationPrefix)
if cfg.AnnotationPrefix != annotations.DefaultAnnotationPrefix {
log.Infof("Using custom annotation prefix: %s", cfg.AnnotationPrefix)
annotations.SetAnnotationPrefixes(cfg.AnnotationPrefixes...)
if !slices.Equal(cfg.AnnotationPrefixes, []string{annotations.DefaultAnnotationPrefix, annotations.AlphaAnnotationPrefix}) {
log.Infof("Using custom annotation prefixes: %s", strings.Join(cfg.AnnotationPrefixes, ","))
}

if err := configureLogger(cfg); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions docs/annotations/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ The following table documents which sources support which annotations:
[^4]: For Gateway API sources, annotation placement differs by type. See [Gateway API Annotation Placement](#gateway-api-annotation-placement) for details.
[^5]: The annotation must be on the listener's `VirtualService`.

Annotation prefixes can be configured with the `--annotation-prefix` flag, the default prefixes are `external-dns.kubernetes.io/` and `external-dns.alpha.kubernetes.io/` (for backward compatibility).

!!!note "Annotation prefix deprecation"
The `external-dns.alpha.kubernetes.io/` prefix is deprecated and will eventually be removed. It is recommended to use the `external-dns.kubernetes.io/` prefix for all annotations.
For example, `external-dns.alpha.kubernetes.io/hostname` should be updated to `external-dns.kubernetes.io/hostname`.

## external-dns.kubernetes.io/access

Specifies which set of node IP addresses to use for a `Service` of type `NodePort`.
Expand Down
2 changes: 1 addition & 1 deletion docs/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tags:
| `--skipper-routegroup-groupversion="zalando.org/v1"` | The resource version for skipper routegroup |
| `--[no-]always-publish-not-ready-addresses` | Always publish also not ready addresses for headless services (optional) |
| `--annotation-filter=""` | Filter resources queried for endpoints by annotation, using label selector semantics |
| `--annotation-prefix="external-dns.kubernetes.io/"` | Annotation prefix for external-dns annotations (default: external-dns.kubernetes.io/) |
| `--annotation-prefix=external-dns.kubernetes.io/...` | Annotation prefix for external-dns annotations (default: external-dns.kubernetes.io/, ); specify multiple times to support additional prefixes |
| `--compatibility=` | Process annotation semantics from legacy implementations (optional, options: mate, molecule, kops-dns-controller) |
| `--connector-source-server="localhost:8080"` | The server to connect for connector source, valid only when using connector source |
| `--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 |
Expand Down
1 change: 1 addition & 0 deletions internal/flags/binders.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (b *KingpinBinder) Int64Var(name, help string, def int64, target *int64) {
}

func (b *KingpinBinder) StringsVar(name, help string, def []string, target *[]string) {
*target = nil
if len(def) > 0 {
b.App.Flag(name, help).Default(def...).StringsVar(target)
return
Expand Down
10 changes: 5 additions & 5 deletions pkg/apis/externaldns/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Config struct {
Sources []string
Namespace string
AnnotationFilter string
AnnotationPrefix string
AnnotationPrefixes []string
LabelFilter string
IngressClassNames []string
FQDNTemplate []string
Expand Down Expand Up @@ -241,7 +241,7 @@ var defaultConfig = &Config{
AkamaiServiceConsumerDomain: "",
AlibabaCloudConfigFile: "/etc/kubernetes/alibaba-cloud.json",
AnnotationFilter: "",
AnnotationPrefix: annotations.DefaultAnnotationPrefix,
AnnotationPrefixes: []string{annotations.DefaultAnnotationPrefix, annotations.AlphaAnnotationPrefix},
APIServerURL: "",
AWSAPIRetries: 3,
AWSAssumeRole: "",
Expand Down Expand Up @@ -468,8 +468,8 @@ var allowedSources = []string{
// NewConfig returns new Config object
func NewConfig() *Config {
return &Config{
AnnotationPrefix: annotations.DefaultAnnotationPrefix,
AWSSDCreateTag: map[string]string{},
AnnotationPrefixes: []string{annotations.DefaultAnnotationPrefix, annotations.AlphaAnnotationPrefix},
AWSSDCreateTag: map[string]string{},
}
}

Expand Down Expand Up @@ -540,7 +540,7 @@ func bindFlags(b flags.FlagBinder, cfg *Config) {
// Flags related to processing source
b.BoolVar("always-publish-not-ready-addresses", "Always publish also not ready addresses for headless services (optional)", false, &cfg.AlwaysPublishNotReadyAddresses)
b.StringVar("annotation-filter", "Filter resources queried for endpoints by annotation, using label selector semantics", defaultConfig.AnnotationFilter, &cfg.AnnotationFilter)
b.StringVar("annotation-prefix", "Annotation prefix for external-dns annotations (default: external-dns.kubernetes.io/)", defaultConfig.AnnotationPrefix, &cfg.AnnotationPrefix)
b.StringsVar("annotation-prefix", "Annotation prefix for external-dns annotations (default: external-dns.kubernetes.io/, ); specify multiple times to support additional prefixes", defaultConfig.AnnotationPrefixes, &cfg.AnnotationPrefixes)
b.EnumVar("compatibility", "Process annotation semantics from legacy implementations (optional, options: mate, molecule, kops-dns-controller)", defaultConfig.Compatibility, &cfg.Compatibility, "", "mate", "molecule", "kops-dns-controller")
b.StringVar("connector-source-server", "The server to connect for connector source, valid only when using connector source", defaultConfig.ConnectorSourceServer, &cfg.ConnectorSourceServer)
b.StringVar("crd-source-apiversion", "API version of the CRD for crd source, e.g. `externaldns.k8s.io/v1alpha1`, valid only when using crd source", defaultConfig.CRDSourceAPIVersion, &cfg.CRDSourceAPIVersion)
Expand Down
7 changes: 5 additions & 2 deletions pkg/apis/externaldns/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
SkipperRouteGroupVersion: "zalando.org/v1",
Sources: []string{"service"},
Namespace: "",
AnnotationPrefix: "external-dns.kubernetes.io/",
AnnotationPrefixes: []string{"external-dns.kubernetes.io/", "external-dns.alpha.kubernetes.io/"},
FQDNTemplate: nil,
Compatibility: "",
Provider: ProviderGoogle,
Expand Down Expand Up @@ -150,7 +150,7 @@ var (
SkipperRouteGroupVersion: "zalando.org/v2",
Sources: []string{"service", "ingress", "connector"},
Namespace: "namespace",
AnnotationPrefix: "external-dns.kubernetes.io/",
AnnotationPrefixes: []string{"external-dns.example.com/", "external-dns.alpha.example.com/"},
IgnoreHostnameAnnotation: true,
IgnoreNonHostNetworkPods: true,
IgnoreIngressTLSSpec: true,
Expand Down Expand Up @@ -312,6 +312,8 @@ func TestParseFlags(t *testing.T) {
"--server=http://127.0.0.1:8080",
"--kubeconfig=/some/path",
"--request-timeout=77s",
"--annotation-prefix=external-dns.example.com/",
"--annotation-prefix=external-dns.alpha.example.com/",
"--gloo-namespace=gloo-not-system",
"--gloo-namespace=gloo-second-system",
"--skipper-routegroup-groupversion=zalando.org/v2",
Expand Down Expand Up @@ -445,6 +447,7 @@ func TestParseFlags(t *testing.T) {
"EXTERNAL_DNS_SERVER": "http://127.0.0.1:8080",
"EXTERNAL_DNS_KUBECONFIG": "/some/path",
"EXTERNAL_DNS_REQUEST_TIMEOUT": "77s",
"EXTERNAL_DNS_ANNOTATION_PREFIX": "external-dns.example.com/\nexternal-dns.alpha.example.com/",
"EXTERNAL_DNS_CONTOUR_LOAD_BALANCER": "heptio-contour-other/contour-other",
"EXTERNAL_DNS_GLOO_NAMESPACE": "gloo-not-system\ngloo-second-system",
"EXTERNAL_DNS_SKIPPER_ROUTEGROUP_GROUPVERSION": "zalando.org/v2",
Expand Down
11 changes: 8 additions & 3 deletions pkg/apis/externaldns/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ func ValidateConfig(cfg *externaldns.Config) error {
return errors.New("--annotation-filter does not specify a valid label selector")
}

if cfg.AnnotationPrefix == "" {
if len(cfg.AnnotationPrefixes) == 0 {
return errors.New("--annotation-prefix cannot be empty")
}
if !strings.HasSuffix(cfg.AnnotationPrefix, "/") {
return errors.New("--annotation-prefix must end with '/'")
for _, prefix := range cfg.AnnotationPrefixes {
if len(prefix) == 0 {
return errors.New("--annotation-prefix cannot be empty")
}
if !strings.HasSuffix(prefix, "/") {
return errors.New("--annotation-prefix must end with '/'")
}
}

if cfg.KubeAPIQPS <= 0 {
Expand Down
Loading