首页 > 解决方案 > task.Container moving from docker to kubernetes

问题描述

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

标签: dockerkubernetesamazon-ekscoredns

解决方案


我同意编辑脚本是最明智的解决方案,但这里是在 kubernetes 中编辑 coredns 的方法。

kubectl edit configmap coredns -n kube-system

然后添加如下重写配置。

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

例如

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

然后重新加载 coredns 如下

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


推荐阅读