apiVersion: apps/v1
kind: Deployment
metadata:
  name: coredns
  namespace: kube-system
  labels:
    application: coredns
    version: v1.2.0
    kubernetes.io/cluster-service: "true"
    kubernetes.io/name: "CoreDNS"
    component: cluster-dns
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
  selector:
    matchLabels:
      application: coredns
  template:
    metadata:
      labels:
        application: coredns
        version: v1.2.0
        component: cluster-dns
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: application
                  operator: In
                  values:
                  - coredns
              topologyKey: kubernetes.io/hostname
          - weight: 1
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: component
                  operator: In
                  values:
                  - cluster-dns
              topologyKey: kubernetes.io/hostname
      containers:
      - name: coredns
        image: registry.opensource.zalan.do/teapot/coredns:1.2.0
        resources:
          requests:
            cpu: 250m
            memory: 100Mi
        args: [ "-conf", "/etc/coredns/Corefile" ]
        volumeMounts:
        - name: config-volume
          mountPath: /etc/coredns
        ports:
        - containerPort: 53
          name: dns
          protocol: UDP
        - containerPort: 53
          name: dns-tcp
          protocol: TCP
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 60
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 5
        readinessProbe:
          httpGet:
            path: /health
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 10
          timeoutSeconds: 3
          successThreshold: 1
          failureThreshold: 3
        resources:
          requests:
            cpu: 150m
            memory: 100Mi
          limits:
            memory: 100Mi
      dnsPolicy: Default
      volumes:
      - name: config-volume
        configMap:
          name: coredns
          items:
          - key: Corefile
            path: Corefile
