From 842551bf4264f1bc04fe7be9213708bcc5029e4f Mon Sep 17 00:00:00 2001 From: Grant Spence Date: Mon, 26 Jun 2023 14:21:37 -0400 Subject: [PATCH] WIP: Proof of concept for Shared VPC support --- api/v1beta1/externaldns_types.go | 5 +++++ api/v1beta1/zz_generated.deepcopy.go | 5 +++++ .../bases/externaldns.olm.openshift.io_externaldnses.yaml | 3 +++ pkg/operator/controller/externaldns/pod.go | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/api/v1beta1/externaldns_types.go b/api/v1beta1/externaldns_types.go index bcc67cd0..322de4bd 100644 --- a/api/v1beta1/externaldns_types.go +++ b/api/v1beta1/externaldns_types.go @@ -101,6 +101,11 @@ type ExternalDNSSpec struct { // +kubebuilder:validation:Optional // +optional Zones []string `json:"zones,omitempty"` + + // AWSRoleARN is a string + // +kubebuilder:validation:Optional + // +optional + AWSRoleARN *string `json:"awsRoleARN,omitempty"` } // ExternalDNSDomain describes how sets of included diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 22383946..da1010f4 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -375,6 +375,11 @@ func (in *ExternalDNSSpec) DeepCopyInto(out *ExternalDNSSpec) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.AWSRoleARN != nil { + in, out := &in.AWSRoleARN, &out.AWSRoleARN + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalDNSSpec. diff --git a/config/crd/bases/externaldns.olm.openshift.io_externaldnses.yaml b/config/crd/bases/externaldns.olm.openshift.io_externaldnses.yaml index 4c46596d..a7dba5d6 100644 --- a/config/crd/bases/externaldns.olm.openshift.io_externaldnses.yaml +++ b/config/crd/bases/externaldns.olm.openshift.io_externaldnses.yaml @@ -507,6 +507,9 @@ spec: description: spec is the specification of the desired behavior of the ExternalDNS. properties: + awsRoleARN: + description: AWSRoleARN is a string + type: string domains: description: "Domains specifies which domains that ExternalDNS should create DNS records for. Multiple domain values can be specified diff --git a/pkg/operator/controller/externaldns/pod.go b/pkg/operator/controller/externaldns/pod.go index 237eeec5..7ff5c339 100644 --- a/pkg/operator/controller/externaldns/pod.go +++ b/pkg/operator/controller/externaldns/pod.go @@ -194,6 +194,10 @@ func (b *externalDNSContainerBuilder) fillProviderAgnosticFields(seq int, zone s args = append(args, "--ignore-hostname-annotation") } + if b.externalDNS.Spec.AWSRoleARN != nil { + args = append(args, fmt.Sprintf("--aws-assume-role=%s", *b.externalDNS.Spec.AWSRoleARN)) + } + if len(b.externalDNS.Spec.Source.FQDNTemplate) > 0 { args = append(args, fmt.Sprintf("--fqdn-template=%s", strings.Join(b.externalDNS.Spec.Source.FQDNTemplate, ","))) } else {