apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/component: dns-server
    app.kubernetes.io/name: coredns
    app.kubernetes.io/version: 1.8.4
  name: coredns
  namespace: dns
spec:
  replicas: 2
  selector:
    matchLabels:
      app.kubernetes.io/component: dns-server
      app.kubernetes.io/name: coredns
  strategy:
    rollingUpdate:
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/component: dns-server
        app.kubernetes.io/name: coredns
        app.kubernetes.io/version: 1.8.4
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app.kubernetes.io/name
                  operator: In
                  values:
                  - coredns
              topologyKey: kubernetes.io/hostname
            weight: 100
      containers:
      - args:
        - -conf
        - /etc/coredns/Corefile
        envFrom:
        - secretRef:
            name: coredns-envs
        image: coredns/coredns:1.8.4
        imagePullPolicy: Always
        livenessProbe:
          failureThreshold: 5
          httpGet:
            path: /health
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 60
          successThreshold: 1
          timeoutSeconds: 5
        name: coredns
        ports:
        - containerPort: 53
          name: dns-udp
          protocol: UDP
        - containerPort: 53
          name: dns-tcp
          protocol: TCP
        - containerPort: 9153
          name: metrics
          protocol: TCP
        readinessProbe:
          httpGet:
            path: /ready
            port: 8181
            scheme: HTTP
        resources:
          limits:
            cpu: 200m
            memory: 170Mi
          requests:
            cpu: 100m
            memory: 30Mi
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            add:
            - NET_BIND_SERVICE
            drop:
            - all
        volumeMounts:
        - mountPath: /etc/coredns
          name: corefile
          readOnly: true
      dnsConfig:
        nameservers:
        - 45.90.28.182
        - 45.90.30.182
        - 192.168.2.1
      dnsPolicy: Default
      serviceAccountName: coredns
      volumes:
      - configMap:
          items:
          - key: Corefile
            path: Corefile
          name: coredns-corefile
        name: corefile
