Skip to content

Commit

Permalink
address Ashwin's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ishustava committed Oct 25, 2022
1 parent 9437b2c commit 267355b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions control-plane/connect-inject/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ const (
defaultDNSOptionNdots = 1
defaultDNSOptionTimeout = 5
defaultDNSOptionAttempts = 2

// defaultEtcResolvConfFile is the default location of the /etc/resolv.conf file.
defaultEtcResolvConfFile = "/etc/resolv.conf"
consulDatataplaneAddress = "127.0.0.1"
)

func (w *MeshWebhook) configureDNS(pod *corev1.Pod, k8sNS string) error {
// First, we need to determine the nameservers configured in this cluster from /etc/resolv.conf.
etcResolvConf := "/etc/resolv.conf"
etcResolvConf := defaultEtcResolvConfFile
if w.etcResolvFile != "" {
etcResolvConf = w.etcResolvFile
}
Expand All @@ -36,8 +40,7 @@ func (w *MeshWebhook) configureDNS(pod *corev1.Pod, k8sNS string) error {
// configured in our /etc/resolv.conf. It's important to add Consul DNS as the first nameserver because
// if we put kube DNS first, it will return NXDOMAIN response and a DNS client will not fall back to other nameservers.
if pod.Spec.DNSConfig == nil {
consulDPAddress := "127.0.0.1"
nameservers := []string{consulDPAddress}
nameservers := []string{consulDatataplaneAddress}
nameservers = append(nameservers, cfg.Servers...)
var options []corev1.PodDNSConfigOption
if cfg.Ndots != defaultDNSOptionNdots {
Expand Down

0 comments on commit 267355b

Please sign in to comment.