--dns 标志相当于 kubernetes yaml 文件吗?

发布于 2025-01-12 05:33:41 字数 187 浏览 2 评论 0原文

我希望在 Kubernetes 集群中创建的 Pod 能够使用我预先存在的自定义 DNS 服务器。

DNS 位于单独的机器上,当运行 docker 容器时,我可以使用 --dns 标志进行设置。

是否可以在 Kubernetes Pod 中复制这一点?
我也愿意接受有关如何做到这一点的其他建议。

I want the pods that are created in my Kubernetes cluster to be able to use my preexisting custom DNS server.

The DNS is on a separate machine and, when running docker containers, I could set this using the --dns flag.

Is it possible to replicate that in Kubernetes pods?
I am also open to other suggestions on how to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不会写诗 2025-01-19 05:33:41

或者您可以在集群级别配置它

更准确地说,如此要点中所示,您可以:

将 kube-dns 配置为使用上游名称服务器,而不是 /etc/resolv.conf 中的名称服务器:

保存在configmap.yml中:

api版本:v1
种类:ConfigMap
元数据:
 名称:kube-dns
 命名空间:kube-system
数据:
 上游名称服务器: |
   [“8.8.8.8”]

然后:

kubectl create -f configmap.yml

官方文档:“CoreDNS 配置相当于 kube-dn"

另外:

检索 kube-dns 正在使用的名称服务器:

kubectl exec -ti -n kube-system \
  $(kubectl get --no-headers=true pods -l k8s-app=kube-dns \
            -o 自定义列=:metadata.name -n kube-system) \
  -c kubedns --cat /etc/resolv.conf

or you can configure it at a cluster level

More precisely, as in this gist, you can:

Configure kube-dns to use an upstream nameserver instead of the one in /etc/resolv.conf:

Save in configmap.yml:

apiVersion: v1
kind: ConfigMap
metadata:
 name: kube-dns
 namespace: kube-system
data:
 upstreamNameservers: |
   ["8.8.8.8"]

Then:

kubectl create -f configmap.yml

Official documentation: "CoreDNS configuration equivalent to kube-dn"

Also:

Retrieve nameserver kube-dns is using:

kubectl exec -ti -n kube-system \
  $(kubectl get --no-headers=true pods -l k8s-app=kube-dns \
            -o custom-columns=:metadata.name -n kube-system) \
  -c kubedns -- cat /etc/resolv.conf
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文