天天看點

Kubelet clusterDNS參數

Kubelet config file -- > clusterDNS

clusterDNS:

- "10.32.0.10"

The above is a flag passed to the kubelet file, i dont know what it refers to clsuter DNS ? Is it refers to VPC CIDR or any subnet CIDR ?

1 Answer

​​Active​​​​Oldest​​​​Score​​

It is the address of the DNS server (probably CoreDNS but possibly kube-dns) for the cluster.

它是叢集的 DNS 伺服器位址(可能是 CoreDNS,也可能是 kube-dns) 

Kubernetes uses a DNS server within the cluster so pods can find each other using service names. This is the "cluster DNS" server. Every time a service is created, it gets registered in the DNS server.

Kubernetes 在叢集中使用 DNS 伺服器,是以 pod 可以使用服務名稱找到彼此。這是“叢集 DNS”伺服器。每次建立服務時,它都會在 DNS 伺服器中注冊。

In Linux, the ​

​/etc/resolv.conf​

​​ file is where the DNS server is configured. If you want to use Google's public DNS server (8.8.8.8) your ​

​/etc/resolv.conf​

​​ file has the entry ​

​nameserver 8.8.8.8​

​.

在 Linux 中,該​

​/etc/resolv.conf​

​​檔案是配置 DNS 伺服器的位置。如果您想使用 Google 的公共 DNS 伺服器 (8.8.8.8),您的​

​/etc/resolv.conf​

​​檔案包含​

​nameserver 8.8.8.8​

​.

In Kubernetes, the kubelet process on a worker node configures each pod. Part of the configuration process is to create the file ​

​/etc/resolv.conf​

​​ and specify the correct DNS server. That server is spec'ed by the ​

​clusterDNS​

​ configuration option.

在 Kubernetes 中,工作節點上的 kubelet 程序配置每個 pod。配置過程的一部分是建立檔案​

​/etc/resolv.conf​

​​并指定正确的 DNS 伺服器。該伺服器由​

​clusterDNS​

​配置選項指定。 

How you set it (if you even need to set it yourself) depends on how you're installing kubernetes. It ultimately depends on the CNI provider you're using, but also if you're doing "kubernetes the hard way" versus ​

​kubeadm​

​.

在我們安裝Kubernetes叢集的時候就已經安裝了kube-dns插件,這個插件也是官方推薦安裝的。通過将 Service 注冊到 DNS 中,Kuberentes 可以為我們提供一種簡單的服務注冊發現與負載均衡方式。

​​CoreDNS​​作為CNCF中的托管的一個項目,在Kuberentes1.9版本中,使用kubeadm方式安裝的叢集可以通過以下指令直接安裝CoreDNS。

kubeadm init --feature-gates=CoreDNS=true      

您也可以使用CoreDNS替換Kubernetes插件kube-dns,可以使用 Pod 部署也可以獨立部署,請參考​​Using CoreDNS for Service Discovery​​,下文将介紹如何配置kube-dns。

本文已歸檔到​​kubernetes-handbook​​中。

ClusterDNS和服務發現

  1. 擁有ClusterIP的Service資源,需要具有以下類型的資源記錄。
  • A記錄:​

    ​<service>.<ns>.svc.<zone>. <ttl> IN A <cluster-ip>​

  • SRV記錄:​

    ​_<port>._<proto>.<service>.<ns>.svc.<zone>. <ttl> IN SRV <weight> <priority> <port-number> <service>.<ns>.svc.<zone>​

  • PTR記錄:​

    ​<d>.<c>.<b>.<a>.in-addr.arpa. <ttl> IN PTR <service>.<ns>.svc.<zone>​

  1. Headless 類型的Service資源,需要具有以下類型的資源記錄。
  • A記錄:​

    ​<service>.<ns>.svc.<zone>. <ttl> IN A <endpoint-ip>​

  • SRV記錄:​

    ​_<port>._<proto>.<service>.<ns>.svc.<zone>. <ttl> IN SRV <weight> <priority> <port-number> <hostname>.<service>.<ns>.svc.<zone>​

  • PTR記錄:​

    ​<d>.<c>.<b>.<a>.in-addr.arpa. <ttl> IN PTR <hostname>.<service>.<ns>.svc.<zone>​

  1. ExternalName 類型的Service資源,需要具有CNAME類型的資源記錄。
  • CNAME記錄:​

    ​<service>.<ns>.svc.<zone>. <ttl> IN CNAME <extname>​

繼續閱讀