Merge pull request #123 from aledbf/fix-resolver
Add resolver configuration to nginx
This commit is contained in:
commit
c49b03facc
2 changed files with 15 additions and 0 deletions
|
@ -26,6 +26,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/api"
|
||||
|
||||
"k8s.io/ingress/controllers/nginx/pkg/config"
|
||||
"k8s.io/ingress/core/pkg/net/dns"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -69,6 +70,13 @@ func ReadConfig(conf *api.ConfigMap) config.Configuration {
|
|||
to.SkipAccessLogURLs = skipUrls
|
||||
to.WhitelistSourceRange = whitelist
|
||||
|
||||
h, err := dns.GetSystemNameServers()
|
||||
if err != nil {
|
||||
glog.Warningf("unexpected error reading system nameservers: %v", err)
|
||||
} else {
|
||||
to.Resolver = h
|
||||
}
|
||||
|
||||
config := &mapstructure.DecoderConfig{
|
||||
Metadata: nil,
|
||||
WeaklyTypedInput: true,
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"k8s.io/ingress/controllers/nginx/pkg/config"
|
||||
"k8s.io/ingress/core/pkg/net/dns"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
)
|
||||
|
||||
|
@ -53,6 +54,12 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
|||
def.UseProxyProtocol = true
|
||||
def.GzipTypes = "text/html"
|
||||
|
||||
h, err := dns.GetSystemNameServers()
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
def.Resolver = h
|
||||
|
||||
to := ReadConfig(conf)
|
||||
if !reflect.DeepEqual(def, to) {
|
||||
t.Errorf("expected %v but retuned %v", def, to)
|
||||
|
|
Loading…
Reference in a new issue