coredns: plugin/rewrite Not working in k8s
Hi.
CoreDNS version: 1.6.0 Kubernetes version: v1.15.3 (Bare metal, installed via kubespray).
I try to use rewrite plugin. I add to ConfigMap core dns:
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
log
errors
health
rewrite stop {
name regex (.*)\.my\.domain\.$ {1}.navigator32-services-stage.svc.cluster.local
answer name (.*)\.navigator32-services-stage\.svc\.cluster\.local\.$ {1}.my.domain
}
ready
# rewrite name nats-stage-client.my.domain nats-stage-client.navigator32-services-stage.svc.cluster.local
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream /etc/resolv.conf
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
forward . /etc/resolv.conf {
prefer_udp
}
cache 30
loop
reload
loadbalance
}
I apply this manifest and restart coredns.
Then I try command (for example): host nats-stage-client.my.domain
and I see in logs:
.:53
2019-09-23T13:42:06.222Z [INFO] plugin/reload: Running configuration MD5 = daa664635e18fdc499460ac35f7d5650
2019-09-23T13:42:06.223Z [INFO] CoreDNS-1.6.0
2019-09-23T13:42:06.223Z [INFO] linux/amd64, go1.12.7, 0a218d3
CoreDNS-1.6.0
linux/amd64, go1.12.7, 0a218d3
2019-09-23T14:17:21.942Z [INFO] 10.233.122.0:37076 - 58005 "A IN nats-stage-client.my.domain.default.svc.cluster.local. tcp 71 false 65535" NXDOMAIN qr,aa,rd 164 0.000288025s
2019-09-23T14:17:21.947Z [INFO] 10.233.122.0:37076 - 23634 "A IN nats-stage-client.my.domain.svc.cluster.local. tcp 63 false 65535" NXDOMAIN qr,aa,rd 156 0.002472497s
2019-09-23T14:17:21.949Z [INFO] 10.233.122.0:37076 - 10253 "A IN nats-stage-client.my.domain.cluster.local. tcp 59 false 65535" NXDOMAIN qr,aa,rd 152 0.000340663s
I see that rewrite is not work. What could be the problem?
Thanks.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 29 (15 by maintainers)
I came up with the following solution: need to change configmap of nodelocaldns (
kubectl get configmap nodelocaldns -n kube-system -o yaml > nodelocaldns.yaml
and changeto
then apply it
kubectl apply -f nodelocaldns.yaml
,and after that the rewrite rules start to work.