apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: coredns
  namespace: kube-system
  labels:
    application: coredns
    version: v1.6.4
    kubernetes.io/cluster-service: "true"
    kubernetes.io/name: "CoreDNS"
    component: cluster-dns
spec:
  updateStrategy:
    type: OnDelete
  selector:
    matchLabels:
      application: coredns
      instance: node-dns
  template:
    metadata:
      labels:
        application: coredns
        instance: node-dns
        version: v1.6.4
        component: cluster-dns
    spec:
      containers:
      - name: dnsmasq
        image: registry.opensource.zalan.do/teapot/k8s-dns-dnsmasq-nanny-amd64:1.15.7-1
        securityContext:
          privileged: true
        livenessProbe:
          httpGet:
            path: /healthcheck/dnsmasq
            port: 9054
            scheme: HTTP
          initialDelaySeconds: 60
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 5
        args:
        - -v=2
        - -logtostderr
        - -configDir=/etc/k8s/dns/dnsmasq-nanny
        - -restartDnsmasq=true
        - --
        - --no-resolv
        - --keep-in-foreground
        - --log-facility=-
        - --cache-size=50000
        - --dns-forward-max=500
        - --neg-ttl=60
        # send requests to the last server first, only fallback to the previous ones if it's unreachable
        - --strict-order
        - --server=10.3.0.11#53
        - --server=127.0.0.1#9254
        ports:
        - containerPort: 53
          name: dns
          protocol: UDP
        - containerPort: 53
          name: dns-tcp
          protocol: TCP
        resources:
          limits:
            cpu: 100m
            memory: 50Mi
      - name: sidecar
        image: registry.opensource.zalan.do/teapot/k8s-dns-sidecar-amd64:1.15.7-1
        securityContext:
          privileged: true
        livenessProbe:
          httpGet:
            path: /metrics
            port: 9054
            scheme: HTTP
          initialDelaySeconds: 60
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 5
        args:
        - --v=2
        - --logtostderr
        - --probe=dnsmasq,127.0.0.1:9254,ec2.amazonaws.com,5,A
        - --prometheus-port=9054
        ports:
        - containerPort: 9054
          name: metrics
          protocol: TCP
        resources:
          limits:
            cpu: 10m
            memory: 45Mi
      - name: coredns
        image: registry.opensource.zalan.do/teapot/coredns:1.6.4
        args: [ "-conf", "/etc/coredns/Corefile" ]
        volumeMounts:
        - name: config-volume
          mountPath: /etc/coredns
        ports:
        - containerPort: 9254
          name: dns
          protocol: UDP
        - containerPort: 9254
          name: dns-tcp
          protocol: TCP
        livenessProbe:
          httpGet:
            path: /health
            port: 9154
            scheme: HTTP
          initialDelaySeconds: 60
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 5
        readinessProbe:
          httpGet:
            path: /health
            port: 9154
            scheme: HTTP
          initialDelaySeconds: 10
          timeoutSeconds: 3
          successThreshold: 1
          failureThreshold: 3
        resources:
          limits:
            cpu: 50m
            memory: 100Mi
      priorityClassName: system-node-critical
      serviceAccountName: coredns
      hostNetwork: true
      dnsPolicy: Default
      tolerations:
      - operator: Exists
        effect: NoSchedule
      - operator: Exists
        effect: NoExecute
      volumes:
      - name: config-volume
        configMap:
          name: coredns-local
          items:
          - key: Corefile
            path: Corefile
