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

Set ingress DNSRecord component values even if the addon is disabled #5482

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/operation/botanist/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ func (b *Botanist) DefaultIngressDNSRecord() extensionsdnsrecord.Interface {
Namespace: b.Shoot.SeedNamespace,
TTL: b.Config.Controllers.Shoot.DNSEntryTTLSeconds,
}
if b.NeedsIngressDNS() {
// Set component values even if the nginx-ingress addons is not enabled.
if b.NeedsExternalDNS() {
values.Type = b.Shoot.ExternalDomain.Provider
if b.Shoot.ExternalDomain.Zone != "" {
values.Zone = &b.Shoot.ExternalDomain.Zone
Expand Down
46 changes: 46 additions & 0 deletions pkg/operation/botanist/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,52 @@ var _ = Describe("addons", func() {
})

Context("DefaultIngressDNSRecord", func() {
It("should create a component with correct values when nginx-ingress addon is enabled", func() {
c := b.DefaultIngressDNSRecord()
c.SetRecordType(extensionsv1alpha1.DNSRecordTypeA)
c.SetValues([]string{address})

actual := c.GetValues()
Expect(actual).To(DeepEqual(&dnsrecord.Values{
Name: b.Shoot.GetInfo().Name + "-" + common.ShootDNSIngressName,
SecretName: DNSRecordSecretPrefix + "-" + b.Shoot.GetInfo().Name + "-" + v1beta1constants.DNSRecordExternalName,
Namespace: seedNamespace,
TTL: pointer.Int64(ttl),
Type: externalProvider,
Zone: pointer.String(externalZone),
SecretData: map[string][]byte{
"external-foo": []byte("external-bar"),
},
DNSName: "*.ingress." + externalDomain,
RecordType: extensionsv1alpha1.DNSRecordTypeA,
Values: []string{address},
}))
})

It("should create a component with correct values when nginx-ingress addon is disabled", func() {
b.Shoot.GetInfo().Spec.Addons.NginxIngress.Enabled = false

c := b.DefaultIngressDNSRecord()
c.SetRecordType(extensionsv1alpha1.DNSRecordTypeA)
c.SetValues([]string{address})

actual := c.GetValues()
Expect(actual).To(DeepEqual(&dnsrecord.Values{
Name: b.Shoot.GetInfo().Name + "-" + common.ShootDNSIngressName,
SecretName: DNSRecordSecretPrefix + "-" + b.Shoot.GetInfo().Name + "-" + v1beta1constants.DNSRecordExternalName,
Namespace: seedNamespace,
TTL: pointer.Int64(ttl),
Type: externalProvider,
Zone: pointer.String(externalZone),
SecretData: map[string][]byte{
"external-foo": []byte("external-bar"),
},
DNSName: "*.ingress." + externalDomain,
RecordType: extensionsv1alpha1.DNSRecordTypeA,
Values: []string{address},
}))
})

It("should create a component that creates the DNSRecord and its secret on Deploy", func() {
c := b.DefaultIngressDNSRecord()
c.SetRecordType(extensionsv1alpha1.DNSRecordTypeA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var TimeNow = time.Now
// Interface is an interface for managing DNSRecords
type Interface interface {
component.DeployMigrateWaiter
GetValues() *Values
SetRecordType(extensionsv1alpha1.DNSRecordType)
SetValues([]string)
}
Expand Down Expand Up @@ -279,6 +280,11 @@ func (c *dnsRecord) WaitCleanup(ctx context.Context) error {
)
}

// GetValues returns the current configuration values of the deployer.
func (c *dnsRecord) GetValues() *Values {
return c.values
}

// SetRecordType sets the record type in the values.
func (c *dnsRecord) SetRecordType(recordType extensionsv1alpha1.DNSRecordType) {
c.values.RecordType = recordType
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions pkg/operation/botanist/dnsrecord_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,28 @@ var _ = Describe("dnsrecord", func() {
})

Context("DefaultExternalDNSRecord", func() {
It("should create a component with correct values", func() {
r := b.DefaultExternalDNSRecord()
r.SetRecordType(extensionsv1alpha1.DNSRecordTypeA)
r.SetValues([]string{address})

actual := r.GetValues()
Expect(actual).To(DeepEqual(&dnsrecord.Values{
Name: b.Shoot.GetInfo().Name + "-" + v1beta1constants.DNSRecordExternalName,
SecretName: DNSRecordSecretPrefix + "-" + b.Shoot.GetInfo().Name + "-" + v1beta1constants.DNSRecordExternalName,
Namespace: seedNamespace,
TTL: pointer.Int64(ttl),
Type: externalProvider,
Zone: pointer.String(externalZone),
SecretData: map[string][]byte{
"external-foo": []byte("external-bar"),
},
DNSName: "api." + externalDomain,
RecordType: extensionsv1alpha1.DNSRecordTypeA,
Values: []string{address},
}))
})

It("should create a component that creates the DNSRecord and its secret on Deploy", func() {
r := b.DefaultExternalDNSRecord()
r.SetRecordType(extensionsv1alpha1.DNSRecordTypeA)
Expand Down Expand Up @@ -236,6 +258,28 @@ var _ = Describe("dnsrecord", func() {
})

Context("DefaultInternalDNSRecord", func() {
It("should create a component with correct values", func() {
c := b.DefaultInternalDNSRecord()
c.SetRecordType(extensionsv1alpha1.DNSRecordTypeA)
c.SetValues([]string{address})

actual := c.GetValues()
Expect(actual).To(DeepEqual(&dnsrecord.Values{
Name: b.Shoot.GetInfo().Name + "-" + v1beta1constants.DNSRecordInternalName,
SecretName: DNSRecordSecretPrefix + "-" + b.Shoot.GetInfo().Name + "-" + v1beta1constants.DNSRecordInternalName,
Namespace: seedNamespace,
TTL: pointer.Int64(ttl),
Type: internalProvider,
Zone: pointer.String(internalZone),
SecretData: map[string][]byte{
"internal-foo": []byte("internal-bar"),
},
DNSName: "api." + internalDomain,
RecordType: extensionsv1alpha1.DNSRecordTypeA,
Values: []string{address},
}))
})

It("should create a component that creates the DNSRecord and its secret on Deploy", func() {
r := b.DefaultInternalDNSRecord()
r.SetRecordType(extensionsv1alpha1.DNSRecordTypeA)
Expand Down