title: Alias for Kubernetes service
body: <p>I have Minikube running Kubernetes version 1.18.2. The Minikube is running stock CoreDNS as well. I need to introduce a DNS alias for my sevice coolservice. The service is available under standard coolservice, coolservice.default and coolservice.default.svc.cluster.local DNS names. I would like my service to be also available under the domain coolservice.foo.bar.</p>
  <p>I'm trying to use the DNS rewrite plugin for that purpose. This is my Corefile configuration:</p>
  <pre><code>apiVersion: v1
  data:
    Corefile: |
      .:53 {
        [... unchanged ...]
      }
      foo.bar {
        rewrite name exact coolservice.foo.bar coolservice.default.svc.cluster.local
      }
  kind: ConfigMap
  metadata:
    [... unchanged ...]
  </code></pre>
  <p>After I apply the Corefile with kubectl, I'm stating shell in another pod, and I'm trying to resolve the domain with <code>host</code> and <code>curl</code>. Unfortunately, if fails with error <code>Question section mismatch</code>:</p>
  <pre><code>root@aks-ssh:/# host coolservice.default.svc.cluster.local
  coolservice.default.svc.cluster.local has address 10.108.195.164
  
  root@aks-ssh:/# host coolservice.foo.bar
  ;; Question section mismatch: got coolservice.default.svc.cluster.local/A/IN
   
  ;; Question section mismatch: got coolservice.default.svc.cluster.local/A/IN
  ;; connection timed out; no servers could be reached
  
  root@aks-ssh:/# curl -X GET coolservice.default.svc.cluster.local:8100/health
  {&quot;results&quot;:[],&quot;compositeStatus&quot;:&quot;Healthy&quot;}
  
  root@aks-ssh:/# curl -X GET coolservice.foo.bar:8100/health
  curl: (6) Could not resolve host: coolservice.foo.bar
  </code></pre>
  <p>In this <a href="https://coredns.io/plugins/rewrite/#response-rewrites" rel="nofollow noreferrer">documentation section</a> it's written that  when using <code>exact</code> name rewrite rules, the answer gets rewritten automatically. I've tried regex rules as well. Any idea what can be wrong here? (I've tried to configure it on AKS cluster as well, the same problem.).</p>