Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add txt prefix for CNAME only providers #39

Merged
merged 1 commit into from
Oct 12, 2021
Merged
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
6 changes: 6 additions & 0 deletions pkg/operator/controller/externaldns/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func TestDesiredExternalDNSDeployment(t *testing.T) {
"--publish-internal-services",
"--ignore-hostname-annotation",
"--fqdn-template={{.Name}}.test.com",
"--txt-prefix=external-dns-",
"--azure-config-file=/etc/kubernetes/azure.json",
},
VolumeMounts: []corev1.VolumeMount{
Expand Down Expand Up @@ -274,6 +275,7 @@ func TestDesiredExternalDNSDeployment(t *testing.T) {
"--publish-internal-services",
"--ignore-hostname-annotation",
"--fqdn-template={{.Name}}.test.com",
"--txt-prefix=external-dns-",
},
},
},
Expand Down Expand Up @@ -333,6 +335,7 @@ func TestDesiredExternalDNSDeployment(t *testing.T) {
"--publish-internal-services",
"--ignore-hostname-annotation",
"--fqdn-template={{.Name}}.test.com",
"--txt-prefix=external-dns-",
"--google-project=external-dns-gcp-project",
},
Env: []corev1.EnvVar{
Expand Down Expand Up @@ -389,6 +392,7 @@ func TestDesiredExternalDNSDeployment(t *testing.T) {
"--publish-internal-services",
"--ignore-hostname-annotation",
"--fqdn-template={{.Name}}.test.com",
"--txt-prefix=external-dns-",
},
},
},
Expand Down Expand Up @@ -448,6 +452,7 @@ func TestDesiredExternalDNSDeployment(t *testing.T) {
"--publish-internal-services",
"--ignore-hostname-annotation",
"--fqdn-template={{.Name}}.test.com",
"--txt-prefix=external-dns-",
"--bluecat-config-file=/etc/kubernetes/bluecat.json",
},
VolumeMounts: []corev1.VolumeMount{
Expand Down Expand Up @@ -497,6 +502,7 @@ func TestDesiredExternalDNSDeployment(t *testing.T) {
"--service-type-filter=ExternalName",
"--publish-internal-services",
"--ignore-hostname-annotation",
"--txt-prefix=external-dns-",
"--fqdn-template={{.Name}}.test.com",
},
},
Expand Down
21 changes: 18 additions & 3 deletions pkg/operator/controller/externaldns/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
defaultOwnerPrefix = "external-dns"
defaultMetricsStartPort = 7979
defaultConfigMountPath = "/etc/kubernetes"
defaultTXTRecordPrefix = "external-dns-"
//
// AWS
//
Expand Down Expand Up @@ -177,8 +178,6 @@ func (b *externalDNSContainerBuilder) fillProviderAgnosticFields(seq int, zone s
args = append(args, fmt.Sprintf("--fqdn-template=%s", strings.Join(b.externalDNS.Spec.Source.FQDNTemplate, ",")))
}

//TODO: Add logic for the CRD source.

filterArgs, err := b.domainFilters()
if err != nil {
return err
Expand Down Expand Up @@ -305,6 +304,9 @@ func (b *externalDNSContainerBuilder) fillAWSFields(container *corev1.Container)

// fillAzureFields fills the given container with the data specific to Azure provider
func (b *externalDNSContainerBuilder) fillAzureFields(container *corev1.Container) {
// https://github.com/kubernetes-sigs/external-dns/issues/2082
container.Args = addTXTPrefixFlag(container.Args)

// no volume mounts will be added if there is no config volume added before
for _, v := range b.volumes {
// config volume
Expand All @@ -321,7 +323,10 @@ func (b *externalDNSContainerBuilder) fillAzureFields(container *corev1.Containe

// fillGCPFields fills the given container with the data specific to Google provider
func (b *externalDNSContainerBuilder) fillGCPFields(container *corev1.Container) {
// don't add empty args GCP provider is not given
// https://github.com/kubernetes-sigs/external-dns/issues/262
container.Args = addTXTPrefixFlag(container.Args)

// don't add empty args if GCP provider is not given
if b.externalDNS.Spec.Provider.GCP == nil {
return
}
Expand All @@ -345,6 +350,10 @@ func (b *externalDNSContainerBuilder) fillGCPFields(container *corev1.Container)

// fillBlueCatFields fills the given container with the data specific to BlueCat provider
func (b *externalDNSContainerBuilder) fillBlueCatFields(container *corev1.Container) {
// only standard CNAME records are supported
// https://docs.bluecatnetworks.com/r/Address-Manager-API-Guide/ENUM-number-generic-methods/9.2.0
container.Args = addTXTPrefixFlag(container.Args)

// no volume mounts will be added if there is no config volume added before
for _, v := range b.volumes {
// config volume
Expand Down Expand Up @@ -510,3 +519,9 @@ func (b *externalDNSVolumeBuilder) bluecatVolumes() []corev1.Volume {
},
}
}

// addTXTPrefixFlag adds the txt prefix flag with default value
// needed if CNAME records are used: https://github.com/kubernetes-sigs/external-dns#note
func addTXTPrefixFlag(args []string) []string {
return append(args, fmt.Sprintf("--txt-prefix=%s", defaultTXTRecordPrefix))
}