You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.7 KiB

  1. ---
  2. apiVersion: apps/v1
  3. kind: Deployment
  4. metadata:
  5. name: "coredns{{ coredns_ordinal_suffix }}"
  6. namespace: kube-system
  7. labels:
  8. k8s-app: "kube-dns{{ coredns_ordinal_suffix }}"
  9. addonmanager.kubernetes.io/mode: Reconcile
  10. kubernetes.io/name: "coredns{{ coredns_ordinal_suffix }}"
  11. spec:
  12. strategy:
  13. type: RollingUpdate
  14. rollingUpdate:
  15. maxUnavailable: 0
  16. maxSurge: 10%
  17. selector:
  18. matchLabels:
  19. k8s-app: kube-dns{{ coredns_ordinal_suffix }}
  20. template:
  21. metadata:
  22. labels:
  23. k8s-app: kube-dns{{ coredns_ordinal_suffix }}
  24. annotations:
  25. seccomp.security.alpha.kubernetes.io/pod: 'runtime/default'
  26. createdby: 'kubespray'
  27. spec:
  28. priorityClassName: system-cluster-critical
  29. nodeSelector:
  30. kubernetes.io/os: linux
  31. serviceAccountName: coredns
  32. tolerations:
  33. - key: node-role.kubernetes.io/master
  34. effect: NoSchedule
  35. - key: node-role.kubernetes.io/control-plane
  36. effect: NoSchedule
  37. {% if dns_extra_tolerations | default(None) %}
  38. {{ dns_extra_tolerations | list | to_nice_yaml(indent=2) | indent(8) }}
  39. {% endif %}
  40. affinity:
  41. podAntiAffinity:
  42. requiredDuringSchedulingIgnoredDuringExecution:
  43. - topologyKey: "kubernetes.io/hostname"
  44. labelSelector:
  45. matchLabels:
  46. k8s-app: kube-dns{{ coredns_ordinal_suffix }}
  47. nodeAffinity:
  48. preferredDuringSchedulingIgnoredDuringExecution:
  49. - weight: 100
  50. preference:
  51. matchExpressions:
  52. {% if kube_version is version('v1.20.0', '<') %}
  53. - key: node-role.kubernetes.io/master
  54. {% else %}
  55. - key: node-role.kubernetes.io/control-plane
  56. {% endif %}
  57. operator: In
  58. values:
  59. - ""
  60. containers:
  61. - name: coredns
  62. image: "{{ coredns_image_repo }}:{{ coredns_image_tag }}"
  63. imagePullPolicy: {{ k8s_image_pull_policy }}
  64. resources:
  65. # TODO: Set memory limits when we've profiled the container for large
  66. # clusters, then set request = limit to keep this container in
  67. # guaranteed class. Currently, this container falls into the
  68. # "burstable" category so the kubelet doesn't backoff from restarting it.
  69. limits:
  70. memory: {{ dns_memory_limit }}
  71. requests:
  72. cpu: {{ dns_cpu_requests }}
  73. memory: {{ dns_memory_requests }}
  74. args: [ "-conf", "/etc/coredns/Corefile" ]
  75. volumeMounts:
  76. - name: config-volume
  77. mountPath: /etc/coredns
  78. ports:
  79. - containerPort: 53
  80. name: dns
  81. protocol: UDP
  82. - containerPort: 53
  83. name: dns-tcp
  84. protocol: TCP
  85. - containerPort: 9153
  86. name: metrics
  87. protocol: TCP
  88. securityContext:
  89. allowPrivilegeEscalation: false
  90. capabilities:
  91. add:
  92. - NET_BIND_SERVICE
  93. drop:
  94. - all
  95. readOnlyRootFilesystem: true
  96. livenessProbe:
  97. httpGet:
  98. path: /health
  99. port: 8080
  100. scheme: HTTP
  101. timeoutSeconds: 5
  102. successThreshold: 1
  103. failureThreshold: 10
  104. readinessProbe:
  105. httpGet:
  106. path: /ready
  107. port: 8181
  108. scheme: HTTP
  109. timeoutSeconds: 5
  110. successThreshold: 1
  111. failureThreshold: 10
  112. dnsPolicy: Default
  113. volumes:
  114. - name: config-volume
  115. configMap:
  116. name: coredns
  117. items:
  118. - key: Corefile
  119. path: Corefile
  120. {% if dns_etchosts | default(None) %}
  121. - key: hosts
  122. path: hosts
  123. {% endif %}