zoukankan      html  css  js  c++  java
  • 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
    

      

         

  • 相关阅读:
    Sum Root to Leaf Numbers
    Sum Root to Leaf Numbers
    Sort Colors
    Partition List
    Binary Tree Inorder Traversal
    Binary Tree Postorder Traversal
    Remove Duplicates from Sorted List II
    Remove Duplicates from Sorted List
    Search a 2D Matrix
    leetcode221
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/6072528.html
Copyright © 2011-2022 走看看