码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-09-15 19:47:14      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:net   bec   域名   tar   contex   hosts   spec   delay   roo   

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 及完成

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

标签:net   bec   域名   tar   contex   hosts   spec   delay   roo   

原文地址:https://www.cnblogs.com/blackmood/p/11523559.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!