Kubernetes DNS通过主机别名解决

发布于 2025-01-24 22:07:26 字数 121 浏览 1 评论 0原文

对于Kubernetes,它可以在主机文件(62.116.156.20 Servera)中进行设置DNS别名设置一个选项吗? servera是外部服务器。结果,群集中的任何POD都可以通过DNS与服务器联系。

谢谢

it there for Kubernetes an option to set a DNS alias as in can be done within a host file (62.116.156.20 servera)? Where servera is an external server. As a result any pod within the cluster can get in contact to server via DNS.

Thanks

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

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

发布评论

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

评论(1

离去的眼神 2025-01-31 22:07:27

这完全取决于您如何配置和部署豆荚。有一个选项可以在此处记录的每个POD的主机文件中添加自定义DNS条目: https://kubernetes.io/docs/tasks/network/network/customize-hosts-file-for-for-pods/

配置sinip:

apiVersion: v1
kind: Pod
metadata:
  name: hostaliases-pod
spec:
  restartPolicy: Never
  hostAliases:
  - ip: "127.0.0.1"
    hostnames:
    - "foo.local"
    - "bar.local"
  - ip: "10.1.2.3"
    hostnames:
    - "foo.remote"
    - "bar.remote"
  containers:
  - name: cat-hosts
    image: busybox:1.28
    command:
    - cat
    args:
    - "/etc/hosts"

It totally depends how you configure and deploy your pods. There is an option to add a custom DNS entry to the host file of every pod documented here: https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/

configuration snip:

apiVersion: v1
kind: Pod
metadata:
  name: hostaliases-pod
spec:
  restartPolicy: Never
  hostAliases:
  - ip: "127.0.0.1"
    hostnames:
    - "foo.local"
    - "bar.local"
  - ip: "10.1.2.3"
    hostnames:
    - "foo.remote"
    - "bar.remote"
  containers:
  - name: cat-hosts
    image: busybox:1.28
    command:
    - cat
    args:
    - "/etc/hosts"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文