Is there a way to add arbitrary records to kube-dns?

后端 未结 5 1369
遥遥无期
遥遥无期 2020-12-28 21:27

I will use a very specific way to explain my problem, but I think this is better to be specific than explain in an abstract way...

Say, there is a MongoDB replica se

5条回答
  •  遥遥无期
    2020-12-28 22:20

    Use configMap seems better way to set DNS, but it's a little bit heavy when just add a few record (in my opinion). So I add records to /etc/hosts by shell script executed by docker CMD.

    for example:

    Dockerfile

    ...(ignore)
    COPY run.sh /tmp/run.sh
    CMD bash /tmp/run.sh
    

    run.sh

    #!/bin/bash
    echo repl1.mongo.local 192.168.10.100 >> /etc/hosts
    # some else command...
    

    Notice, if your run MORE THAN ONE container in a pod, you have to add script in each container, because kubernetes start container randomly, /etc/hosts may be override by another container (which start later).

提交回复
热议问题