• 公司内网安装dns,然后把域名ning.com直接指向ingress-nginx的ip


    configmap配置

    [root@kubeadm-master dns]# cat dnsmasq-cm.yaml 
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: dnsmasq-configmap
    data:
      dnsmasq.conf: |
        resolv-file=/etc/dnsmasq.d/resolv.dnsmasq
        addn-hosts=/etc/dnsmasq.d/dnsmasqhosts
        ## 下面一句是把ning.com指给192.168.100.110,就是ingress-server的ip
        address=/ning.com/192.168.100.110    
      dnsmasqhosts: |
        192.168.100.110 *.ning.com
      resolv.dnsmasq: |
        nameserver 114.114.114.114
        nameserver 8.8.8.8
    

    DaemonSet配置

    [root@kubeadm-master dns]# cat dnsmasq-daemonset.yaml 
    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
      name: dnsmasq
      labels:
        app: dnsmasq
    spec:
      selector:
        matchLabels:
          app: dnsmasq
      template:
        metadata:
          labels:
            app: dnsmasq
        spec:
          nodeSelector:
            node-role.kubernetes.io/master: ""
          hostNetwork: true
          tolerations:
          - effect: NoSchedule
            operator: Exists
          containers:
          - name: dnsmasq
            image: andyshinn/dnsmasq:latest
            imagePullPolicy: IfNotPresent
            securityContext:
              capabilities:
                add:
                - NET_ADMIN
            readinessProbe:
              tcpSocket:
                port: 53
              initialDelaySeconds: 30
              timeoutSeconds: 1
            livenessProbe:
              tcpSocket:
                port: 53
              initialDelaySeconds: 30
              timeoutSeconds: 1
            ports:
            - containerPort: 53
              protocol: UDP
              name: dns-udp
            - containerPort: 53
              protocol: TCP
              name: dns-tcp       
            volumeMounts:
            - name: config-volume
              mountPath: /etc/dnsmasq.d/ 
          volumes:
            - name: config-volume
              configMap:
                name: dnsmasq-configmap
                items:
                - key: dnsmasqhosts
                  path: dnsmasqhosts
                - key: resolv.dnsmasq
                  path: resolv.dnsmasq
                - key: dnsmasq.conf
                  path: dnsmasq.conf
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: dnsmasq
      labels:
        app: dnsmasq
    spec:
      ports:
      - port: 53
        targetPort: 53
        protocol: TCP
        name: dns-tcp
      - port: 53
        targetPort: 53
        protocol: UDP
        name: dns-udp
      selector:
        app: dnsmasq
    
    kubectl apply -f dnsmasq-cm.yaml -n kube-system
    kubectl apply -f dnsmasq-daemonset.yaml -n kube-system
    

    将客户端的dns指向dnsmasq的ip 及完成

  • 相关阅读:
    redis的数据类型 (一) 字符串
    php 与redis 结合 使用predis
    jquery.datetimepicker.js 当鼠标离开时,不选中当前时间,以达到清空的目的
    nginx 配置 查阅资料
    座机号码的正则表达式
    mysql 局域网同事之间直接用客户端访问
    《CSS揭秘》之毛玻璃效果知识点
    《JavaScript 设计模式与开发实战》第一部分(1、2、3章)笔记
    《JavaScript_DOM编程艺术第二版(中文)》整书笔记
    Node调用C++(dll)
  • 原文地址:https://www.cnblogs.com/blackmood/p/11523559.html
Copyright © 2020-2023  润新知