---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: coredns
  namespace: kube-system
  labels:
    app.kubernetes.io/name: kube-dns
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: kube-dns
  template:
    metadata:
      labels:
        app.kubernetes.io/name: kube-dns
      annotations:
        prometheus.io/scrape: 'true'
        prometheus.io/path: /metrics
        prometheus.io/port: '9153'
    spec:
      serviceAccountName: coredns
      nodeSelector:
        kubernetes.io/role: worker
      tolerations:
        - key: 'CriticalAddonsOnly'
          operator: 'Exists'
      containers:
        - name: coredns
          image: 'coredns/coredns:1.4.0'
          resources:
            limits:
              memory: 170Mi
            requests:
              cpu: 100m
              memory: 70Mi
          args:
            - '-conf'
            - '/etc/coredns/Corefile'
          volumeMounts:
            - name: config
              subPath: Corefile
              mountPath: /etc/coredns/Corefile
              readOnly: true
          ports:
            - name: dns-udp
              containerPort: 53
              protocol: UDP
            - name: dns-tcp
              containerPort: 53
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              add:
                - NET_BIND_SERVICE
              drop:
                - all
            readOnlyRootFilesystem: true
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 60
            timeoutSeconds: 5
            successThreshold: 1
            failureThreshold: 5
      dnsPolicy: Default
      volumes:
        - name: config
          configMap:
            name: coredns-config

