task.Container moving from docker to kubernetes

8/27/2019

I'm trying to bring docker container to kubernetes. In docker you can ask the dns for :

host tasks.containername 

The result are all internal IPs from running containers with this name.

I do the same on kubernetes, by using the headless-services. I can do

host pod-name 

The result are also all internal IPs from the pods.

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 ?

Maybe something in the coredns, with mapping.

best and thank you

-- mickmack
coredns
docker
eks
kubernetes

2 Answers

8/27/2019

I think editing them is the wisest solution.

For sake of clarity, it's not host pod-name but host headless-service

-- Radek 'Goblin' Pieczonka
Source: StackOverflow

8/27/2019

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

kubectl edit configmap coredns -n kube-system

and then add the rewrite config as below.

rewrite name tasks.containername.default.svc.cluster.local containername.default.svc.cluster.local

for example

.: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
}

And then reload coredns as below

kubectl exec -n kube-system coredns-xxxxxxx -- kill -SIGUSR1 1

-- Tummala Dhanvi
Source: StackOverflow