<p>I'm trying to bring docker container to kubernetes. In docker you can ask the <em>dns</em> for : </p>

<pre><code>host tasks.containername 
</code></pre>

<p>The result are all internal IPs from running containers with this name. </p>

<p>I do the same on kubernetes, by using the headless-services. I can do </p>

<pre><code>host pod-name 
</code></pre>

<p>The result are also all internal IPs from the pods. </p>

<p>So far so good but there are a lot of "run.sh" scripts that uses the "task.XXX" query. Have someone a idea how to fix this without editing all run.sh scripts ? </p>

<p>Maybe something in the coredns, with mapping. </p>

<p>best and thank you</p>

mickmack
<p>I agree with editing the scripts is the wisest solution, but here is how you can edit coredns in kubernetes.</p>

<p><code>kubectl edit configmap coredns -n kube-system</code></p>

<p>and then add the rewrite config as below.</p>

<pre><code>rewrite name tasks.containername.default.svc.cluster.local containername.default.svc.cluster.local
</code></pre>

<p>for example</p>

<pre><code>.:53 {
    errors
    log
    health
    rewrite name tasks.containername.default.svc.cluster.local containername.default.svc.cluster.local
    kubernetes cluster.local 10.0.0.0/24
    proxy . /etc/resolv.conf
    cache 30
}
</code></pre>

<p>And then reload coredns as below</p>

<p><code>kubectl exec -n kube-system coredns-xxxxxxx -- kill -SIGUSR1 1</code></p>
