Installation and deployment testing of DNS in Kubernetes

Source: Internet
Author: User
Tags nslookup k8s

[TOC]

After DNS is installed, the pod can resolve the service through DNS to enable communication

Kubernetes version:

kubectl version   

My current version is 1.9.0.

1, kubectl DNS installation 1.1 Download the configuration file on the official website
https://github.com/kubernetes/kubernetes具体路径是cluster/addons/dns/kube-dns  可能版本不一样,路径略有不同该路径下有三个相似的配置文件:  kube-dns.yaml.base  kube-dns.yaml.in  kube-dns.yaml.sed  

Here, we use the kube-dns.yaml.sed configuration file as a template;

1.2 You need to modify two of these properties
    • $DNS _server_ip Specifies the IP of the k8s DNS, which is apiserver IP by default
    • $DNS _domain, replace with cluster.local (consistent with kube-apiserver definition)
1.3 Specific modification commands, you can use the SED command

Copy the kube-dns.yaml.sed configuration file to one of the servers where the k8s cluster resides

    • Renaming the configuration file
      • Move kube-dns.yaml.sed Kube-dns.yaml
    • Bulk Modify Properties
      • Sed-i ' s/$DNS _server_ip/10.10.10.2/g ' Kube-dns.yaml
      • Sed-i ' s/$DNS _domain/cluster.local/g ' Kube-dns.yaml
1.4 Starting the DNS service
kubectl create -f kube-dns.yaml  
2 Testing DNS Services 2.1 creating a pod and service

Configuration file Curl.yaml

apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: curl  namespace: kube-systemspec:  replicas: 1  template:    metadata:      labels:        app: curl    spec:      containers:      - name: curl        image: appropriate/curl        command: ["sleep"]        args: ["5000"]---apiVersion: v1kind: Servicemetadata:  name: curl  namespace: kube-system  labels:    app: curlspec:  type: ClusterIP  selector:    app: curl  ports:  - port: 80    targetPort: 80    name: http    protocol: TCP
2.2 Creating a DNS test tool pod
apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: tools-dns  namespace: defaultspec:  replicas: 1  template:    metadata:      labels:        app: tools-dns    spec:      containers:      - name: tools-dns        image: tutum/dnsutils:latest        command: ["sleep"]        args: ["5000"]
2.3 View just created test pod, Tools-dns
2.4 After entering the container, use the following command to query
kubectl exec -it tools-dns-5665d49688-8jrnw /bin/bash
    • View a record (that is, address record IPv4)

      • Nslookup-query=a _http._tcp.curl.kube-system
    • View SRV records (a domain Name System (DNS) resource record that identifies the computer that hosts a particular service)
      • Nslookup-query=srv _http._tcp.curl.kube-system
        (Description: Service = 10 (priority) 100 (specific gravity) 80 (port) curl.kube-system.svc.cluster.local (host name).)
2.5 problems found in the test:
1、 如果发现镜像有问题的话,需要更新镜像, 如“k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.10” 改成“ index.tenxcloud.com/jimmy/k8s-dns-dnsmasq-nanny-amd64:1.14.1”将"k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.10" 改成"index.tenxcloud.com/jimmy/k8s-dns-sidecar-amd64:1.14.1"  将" k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.10" 替换为"index.tenxcloud.com/jimmy/k8s-dns-kube-dns-amd64:1.14.12、如果发现"Liveness probe failed: Get http://172.17.97.2:10054/healthcheck/kubedns: dial tcp 172.17.97.2:10054: getsockopt: connection refused"问题,需要将"SRV"改成"A"

Reference documents:
79443852

Installation and deployment testing of DNS in Kubernetes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.