Fix plugin tree for CoreDNS

First request should go to kubernetes zone, then fallthrough to
etcd in case of ExternalDNS or federation.

Change-Id: Idd20c60cda4fdb551e0dab93c5f221ec3a644271
Related-PROD: PROD-24344
diff --git a/kubernetes/files/kube-addons/coredns/coredns-cm.yml b/kubernetes/files/kube-addons/coredns/coredns-cm.yml
index a9b8da6..c9ce8a5 100644
--- a/kubernetes/files/kube-addons/coredns/coredns-cm.yml
+++ b/kubernetes/files/kube-addons/coredns/coredns-cm.yml
@@ -11,25 +11,9 @@
 data:
   Corefile: |
     .:53 {
-{% if master.federation.enabled %}
-        etcd {{ master.federation.name }} {
-          stubzones
-          path /skydns
-          endpoint http://{{ common.addons.coredns.etcd.client_address }}:2379
-        }
-{% endif %}
-{% if common.addons.externaldns.enabled %}
-        etcd {{ common.addons.externaldns.domain }} {
-          stubzones
-          path /skydns
-          endpoint http://{{ common.addons.coredns.etcd.client_address }}:2379
-        }
-{% endif %}
         errors
         log stdout
         health
-        proxy . /etc/resolv.conf
-        cache 30
         reload
         loadbalance
 {%- if common.addons.coredns.domain == "cluster.local"  %}
@@ -39,6 +23,26 @@
 {%- endif %}
           pods insecure
           upstream
+{%- if common.addons.externaldns.enabled and common.addons.externaldns.domain == common.addons.coredns.domain %}
+          fallthrough {{ common.addons.coredns.domain }} in-addr.arpa ip6.arpa
+{%- else %}
           fallthrough in-addr.arpa ip6.arpa
+{%- endif %}
         }
+{%- if master.federation.enabled %}
+        etcd {{ master.federation.name }} {
+          stubzones
+          path /skydns
+          endpoint http://{{ common.addons.coredns.etcd.client_address }}:2379
+        }
+{%- endif %}
+{%- if common.addons.externaldns.enabled %}
+        etcd {{ common.addons.externaldns.domain }} {
+          stubzones
+          path /skydns
+          endpoint http://{{ common.addons.coredns.etcd.client_address }}:2379
+        }
+{%- endif %}
+        proxy . /etc/resolv.conf
+        cache 30
     }