diff --git a/cmd/node-cache/app/cache_app.go b/cmd/node-cache/app/cache_app.go index 586ec2c8c..fe82727af 100644 --- a/cmd/node-cache/app/cache_app.go +++ b/cmd/node-cache/app/cache_app.go @@ -21,6 +21,7 @@ import ( "time" "github.com/coredns/coredns/coremain" + "github.com/coredns/coredns/core/dnsserver" clog "github.com/coredns/coredns/plugin/pkg/log" "k8s.io/dns/cmd/kube-dns/app/options" @@ -35,6 +36,33 @@ var ( iptablesCommentAllowTraffic = "NodeLocal DNS Cache: allow DNS traffic" ) +// List should match the included plugins in ../main.go, +// and must also be in the correct order as per +// https://github.com/coredns/coredns/blob/master/plugin.cfg +// Source: https://coredns.io/2017/07/25/compile-time-enabling-or-disabling-plugins/#build-with-external-golang-source-code +var directives = []string{ + "timeouts", + "reload", + "bufsize", + "bind", + "debug", + "trace", + "health", + "pprof", + "prometheus", + "errors", + "log", + "dns64", + "loadbalance", + "cache", + "rewrite", + "template", + "hosts", + "loop", + "forward", + "whoami", +} + // ConfigParams lists the configuration options that can be provided to node-cache type ConfigParams struct { LocalIPStr string // comma separated listen ips for the local cache agent @@ -269,6 +297,12 @@ func (c *CacheApp) runPeriodic() { // RunApp invokes the background checks and runs coreDNS as a cache func (c *CacheApp) RunApp() { go c.runPeriodic() + + // Specify plugin order. Required when adding additional/external + // plugins, as the list in plugin.cfg from coredns/coredns is used + // if dnsServer.Directives isn't provided. + dnsserver.Directives = directives + coremain.Run() // Unlikely to reach here, if we did it is because coremain exited and the signal was not trapped. clog.Errorf("Untrapped signal, tearing down") @@ -306,4 +340,4 @@ func isFileExists(path string) bool { return false } return !f.IsDir() -} +} \ No newline at end of file