• k8s dns 服务安装配置说明


    1. 提前条件

        安装k8s 集群

    2.  dns  安装配置

         安装方式: 使用controller  service 

        controller  脚本:

           基于官方改动

    apiVersion: v1
    kind: ReplicationController
    metadata:
      name: kube-dns-v8
      namespace: kube-system
      labels:
        k8s-app: kube-dns
        version: v8
        kubernetes.io/cluster-service: "true"
    spec:
      replicas: 1
      selector:
        k8s-app: kube-dns
        version: v8
      template:
        metadata:
          labels:
            k8s-app: kube-dns
            version: v8
            kubernetes.io/cluster-service: "true"
        spec:
          containers:
          - name: etcd
            image: tlitiwwhtmi/etcd
            resources:
              limits:
                cpu: 100m
                memory: 50Mi
            command:
            - /usr/local/bin/etcd
            - -data-dir
            - /var/etcd/data
            - -listen-client-urls
            - http://127.0.0.1:2379,http://127.0.0.1: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: outrider/kube2sky
            resources:
              limits:
                cpu: 100m
                memory: 50Mi
            args:
            # command = "/kube2sky"
            - --domain=cluster.local
            - --kube_master_url=http://10.25.143.50:8080
          - name: skydns
            image: outrider/skydns
            resources:
              limits:
                cpu: 100m
                memory: 50Mi
            args:
            # command = "/skydns"
            - -machines=http://localhost:4001
            - -addr=0.0.0.0:53
            - -domain=cluster.local
            ports:
            - containerPort: 53
              name: dns
              protocol: UDP
            - containerPort: 53
              name: dns-tcp
              protocol: TCP
            livenessProbe:
              httpGet:
                path: /healthz
                port: 8080
                scheme: HTTP
              initialDelaySeconds: 30
              timeoutSeconds: 5
          - name: healthz
            image: outrider/exechealthz
            resources:
              limits:
                cpu: 10m
                memory: 20Mi
            args:
            - -cmd=nslookup kubernetes.default.svc.cluster.local localhost >/dev/null
            - -port=8080
            ports:
            - containerPort: 8080
              protocol: TCP
          volumes:
          - name: etcd-storage
            emptyDir: {}
          dnsPolicy: Default  # Don't use cluster DNS.
    

      

         service

      

    apiVersion: v1
    kind: Service
    metadata:
      name: kube-dns
      namespace: kube-system
      labels:
        k8s-app: kube-dns
        kubernetes.io/cluster-service: "true"
        kubernetes.io/name: "KubeDNS"
    spec:
      selector:
        k8s-app: kube-dns
      clusterIP: 10.254.0.3
      ports:
      - name: dns
        port: 53
        protocol: UDP
      - name: dns-tcp
        port: 53
        protocol: TCP
    

      创建namespace 

        

    apiVersion: v1
    kind: Namespace
    metadata:
      name: kube-system
    

      

    3. node  进行 dns 配置

      在启动脚本添加:

        

     --cluster-dns=10.254.0.3 
     --cluster-domain=cluster.local
    

      

    4. 重启node

      

    5. 测试pod

       

    apiVersion: v1
    kind: Pod
    metadata:
      name: busybox
      namespace: default
    spec:
      containers:
      - image: busybox
        command:
          - sleep
          - "3600"
        imagePullPolicy: IfNotPresent
        name: busybox
      restartPolicy: Always
    

      

    6. 测试

      

    kubectl  exec busybox -- nslookup ngservice
    

     测试结果

    Server:    10.254.0.3
    Address 1: 10.254.0.3
    
    Name:      ngservice
    Address 1: 10.254.52.109
    

      

         

  • 相关阅读:
    天梯赛5-12 愿天下有情人都是失散多年的兄妹 【dfs】
    poj2718 Smallest Difference【贪心】
    HDU problem 5635 LCP Array【思维】
    codeforces 782C Andryusha and Colored Balloons【构造】
    HDU 4278 Faulty Odometer【进制转换】
    codeforces B. The Meeting Place Cannot Be Changed【二分】
    POJ 3264 Balanced Lineup 【线段树】
    HDU 1850
    CodeForces-714C
    HDU Problem 1247 Hat's Words 【字典树】
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/6072528.html
Copyright © 2020-2023  润新知