Kubernetes's DNS service is implemented based on Skydns and requires close communication with API server, which works by creating an API server monitoring service and notifying Skydns to create a domain name resolution record once a new service is created. Communication between API server and Skydns is done by Kube2sky, both Kube2sky and Skydns need to implement shared configuration and service discovery using ETCD. The following is an architectural diagram of ETCD, which clearly illustrates
Kubernetes how to implement DNS.
650) this.width=650; "src=" http://ww4.sinaimg.cn/mw1024/67a6a651jw1f6mihsxaaxj20fa0h63zj.jpg "width=" 550 "height=" 618 "alt=" 67a6a651jw1f6mihsxaaxj20fa0h63zj.jpg "/>
about Skydns and Kube2sky is installed in the local or pod installation into the k8s cluster, the author on the internet to see two ways, but the author of the local installation of the way to be skeptical, mainly related to virtual network and physical network connectivity issues, Specifically, the IP of the Skydns server should kube an IP address in the clustered virtual network, meaning that the IP needs to be within the specified IP address range of the Kube-apiserver boot parameter –service-cluster-ip-range. and Skydns If it is a localized installation, it is not possible to bind the IP of the DNS server to the IP of a virtual network (that is, the value of the parameter-addr). I would prefer to install it using mirroring mode.
Installation
The contents of the file Kubernetes-dns.yaml as follows:
apiversion: v1kind: replicationcontrollermetadata: name: kube-dns-v6 namespace: default labels: k8s-app: kube-dns version: v6 kubernetes.io/cluster-service: "true" spec: replicas: 1 selector: k8s-app: kube-dns version: v6 template: metadata: labels: k8s-app: kube-dns version: v6 kubernetes.io/ cluster-service: "true" spec: containers: - name: etcd image: index.tenxcloud.com/google_containers/etcd-amd64:2.2.1 command: - /bin/etcd - -listen-client-urls - http://0.0.0.0:2379,http://0.0.0.0:4001 - -advertise-client-urls - http://127.0.0.1:2379,http://127.0.0.1:4001 - - initial-cluster-token - skydns-etcd volumeMounts: - name: etcd-storage mountpath: /var/etcd/data - name: kube2sky image: index.tenxcloud.com/google_containers/kube2sky:1.14 resources: limits: cpu: 100m memory: 50mi livenssProbe: httpget: path: /healthz port: 8080 scheme: HTTP initialDelaySeconds: 60 timeoutseconds: 5 successthreshold: 1 failurethreshold: 5 readinessprobe: httpget: path: /readiness port: 8081 scheme: http initaldelayseconds: 30 timeoutseconds: 5 args : - --domain=cluster.local - Name: skydns image: index.tenxcloud.com/google_ containers/skydns:2015-10-13-8c72f8c resources: args: - -machines=http://127.0.0.1:4001 - -addr=0.0.0.0:53 - - ns-rotate=false - -domain=cluster.local. ports: - containerport: 53 name: dns protocol: UDP - containerport: 53 name: dns-tcp protocol: TCP dnspolicy: default - name: healthz image: index.tenxcloud.com/google_containers/exechealthz:1.0 resources: limits: cpu: 100m memory: 50mi args: - -cmd=nslookup kubernetes.defaults.svc.cluster.local 127.0.0.1 >/dev/null - -port=8080 ports: - containerport: 8080 protocol: tcp
use the following command: Kubectl create - F Kubernetes-dns.yaml
This article is from the "Network Technology exploration" blog, please be sure to keep this source http://heshengkai.blog.51cto.com/5014551/1946236
Kubernetes DNS Service installation configuration