Skip to content

Commit

Permalink
fix: use UDP for upstream DNS by default (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
domdom82 authored Dec 12, 2024
1 parent 4a50b69 commit 9fbf9ae
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/admission/mutator/shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
gardencorev1beta1helper "github.com/gardener/gardener/pkg/apis/core/v1beta1/helper"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
)
Expand Down Expand Up @@ -108,6 +109,18 @@ func (s *shoot) Mutate(_ context.Context, newObj, oldObj client.Object) error {
Raw: modifiedJSON,
}
}

// Disable TCP to upstream DNS queries by default on Azure. DNS over TCP may cause performance issues on larger clusters.
if shoot.Spec.SystemComponents != nil {
if shoot.Spec.SystemComponents.NodeLocalDNS != nil {
if shoot.Spec.SystemComponents.NodeLocalDNS.Enabled {
if shoot.Spec.SystemComponents.NodeLocalDNS.ForceTCPToUpstreamDNS == nil {
shoot.Spec.SystemComponents.NodeLocalDNS.ForceTCPToUpstreamDNS = ptr.To(false)
}
}
}
}

return nil
}

Expand Down
32 changes: 32 additions & 0 deletions pkg/admission/mutator/shoot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,37 @@ var _ = Describe("Shoot mutator", func() {
}))
})
})

Context("Mutate shoot NodeLocalDNS default for ForceTCPToUpstreamDNS property", func() {
BeforeEach(func() {
shoot.Spec.SystemComponents = &gardencorev1beta1.SystemComponents{
NodeLocalDNS: &gardencorev1beta1.NodeLocalDNS{
Enabled: true,
},
}
})

It("should not touch the ForceTCPToUpstreamDNS property if NodeLocalDNS is disabled", func() {
shoot.Spec.SystemComponents.NodeLocalDNS.Enabled = false
err := shootMutator.Mutate(ctx, shoot, nil)
Expect(err).NotTo(HaveOccurred())
Expect(shoot.Spec.SystemComponents.NodeLocalDNS.ForceTCPToUpstreamDNS).To(BeNil())
})

It("should not touch the ForceTCPToUpstreamDNS property if it is already set", func() {
shoot.Spec.SystemComponents.NodeLocalDNS.ForceTCPToUpstreamDNS = ptr.To(true)
err := shootMutator.Mutate(ctx, shoot, nil)
Expect(err).NotTo(HaveOccurred())
Expect(shoot.Spec.SystemComponents.NodeLocalDNS.ForceTCPToUpstreamDNS).ToNot(BeNil())
Expect(*shoot.Spec.SystemComponents.NodeLocalDNS.ForceTCPToUpstreamDNS).To(BeTrue())
})

It("should set the ForceTCPToUpstreamDNS property to false by default", func() {
err := shootMutator.Mutate(ctx, shoot, nil)
Expect(err).NotTo(HaveOccurred())
Expect(shoot.Spec.SystemComponents.NodeLocalDNS.ForceTCPToUpstreamDNS).ToNot(BeNil())
Expect(*shoot.Spec.SystemComponents.NodeLocalDNS.ForceTCPToUpstreamDNS).To(BeFalse())
})
})
})
})

0 comments on commit 9fbf9ae

Please sign in to comment.