nodelocaldns.yaml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. # Copyright 2018 The Kubernetes Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. #
  15. apiVersion: v1
  16. kind: ServiceAccount
  17. metadata:
  18. name: node-local-dns
  19. namespace: kube-system
  20. labels:
  21. kubernetes.io/cluster-service: "true"
  22. addonmanager.kubernetes.io/mode: Reconcile
  23. ---
  24. apiVersion: v1
  25. kind: Service
  26. metadata:
  27. name: kube-dns-upstream
  28. namespace: kube-system
  29. labels:
  30. k8s-app: kube-dns
  31. kubernetes.io/cluster-service: "true"
  32. addonmanager.kubernetes.io/mode: Reconcile
  33. kubernetes.io/name: "KubeDNSUpstream"
  34. spec:
  35. ports:
  36. - name: dns
  37. port: 53
  38. protocol: UDP
  39. targetPort: 53
  40. - name: dns-tcp
  41. port: 53
  42. protocol: TCP
  43. targetPort: 53
  44. selector:
  45. k8s-app: kube-dns
  46. ---
  47. apiVersion: v1
  48. kind: ConfigMap
  49. metadata:
  50. name: node-local-dns
  51. namespace: kube-system
  52. labels:
  53. addonmanager.kubernetes.io/mode: Reconcile
  54. data:
  55. Corefile: |
  56. __PILLAR__DNS__DOMAIN__:53 {
  57. errors
  58. cache {
  59. success 9984 30
  60. denial 9984 5
  61. }
  62. reload
  63. loop
  64. bind __PILLAR__LOCAL__DNS__ __PILLAR__DNS__SERVER__
  65. forward . __PILLAR__CLUSTER__DNS__ {
  66. force_tcp
  67. }
  68. prometheus :9253
  69. health __PILLAR__LOCAL__DNS__:8080
  70. }
  71. in-addr.arpa:53 {
  72. errors
  73. cache 30
  74. reload
  75. loop
  76. bind __PILLAR__LOCAL__DNS__ __PILLAR__DNS__SERVER__
  77. forward . __PILLAR__CLUSTER__DNS__ {
  78. force_tcp
  79. }
  80. prometheus :9253
  81. }
  82. ip6.arpa:53 {
  83. errors
  84. cache 30
  85. reload
  86. loop
  87. bind __PILLAR__LOCAL__DNS__ __PILLAR__DNS__SERVER__
  88. forward . __PILLAR__CLUSTER__DNS__ {
  89. force_tcp
  90. }
  91. prometheus :9253
  92. }
  93. .:53 {
  94. errors
  95. cache 30
  96. reload
  97. loop
  98. bind __PILLAR__LOCAL__DNS__ __PILLAR__DNS__SERVER__
  99. forward . __PILLAR__UPSTREAM__SERVERS__ {
  100. force_tcp
  101. }
  102. prometheus :9253
  103. }
  104. ---
  105. apiVersion: apps/v1
  106. kind: DaemonSet
  107. metadata:
  108. name: node-local-dns
  109. namespace: kube-system
  110. labels:
  111. k8s-app: node-local-dns
  112. kubernetes.io/cluster-service: "true"
  113. addonmanager.kubernetes.io/mode: Reconcile
  114. spec:
  115. updateStrategy:
  116. rollingUpdate:
  117. maxUnavailable: 10%
  118. selector:
  119. matchLabels:
  120. k8s-app: node-local-dns
  121. template:
  122. metadata:
  123. labels:
  124. k8s-app: node-local-dns
  125. spec:
  126. priorityClassName: system-node-critical
  127. serviceAccountName: node-local-dns
  128. hostNetwork: true
  129. dnsPolicy: Default # Don't use cluster DNS.
  130. tolerations:
  131. - key: "CriticalAddonsOnly"
  132. operator: "Exists"
  133. containers:
  134. - name: node-cache
  135. image: k8s.gcr.io/k8s-dns-node-cache:1.15.7
  136. resources:
  137. requests:
  138. cpu: 25m
  139. memory: 5Mi
  140. args: [ "-localip", "__PILLAR__LOCAL__DNS__,__PILLAR__DNS__SERVER__", "-conf", "/etc/Corefile", "-upstreamsvc", "kube-dns-upstream" ]
  141. securityContext:
  142. privileged: true
  143. ports:
  144. - containerPort: 53
  145. name: dns
  146. protocol: UDP
  147. - containerPort: 53
  148. name: dns-tcp
  149. protocol: TCP
  150. - containerPort: 9253
  151. name: metrics
  152. protocol: TCP
  153. livenessProbe:
  154. httpGet:
  155. host: __PILLAR__LOCAL__DNS__
  156. path: /health
  157. port: 8080
  158. initialDelaySeconds: 60
  159. timeoutSeconds: 5
  160. volumeMounts:
  161. - mountPath: /run/xtables.lock
  162. name: xtables-lock
  163. readOnly: false
  164. - name: config-volume
  165. mountPath: /etc/coredns
  166. - name: kube-dns-config
  167. mountPath: /etc/kube-dns
  168. volumes:
  169. - name: xtables-lock
  170. hostPath:
  171. path: /run/xtables.lock
  172. type: FileOrCreate
  173. - name: kube-dns-config
  174. configMap:
  175. name: kube-dns
  176. optional: true
  177. - name: config-volume
  178. configMap:
  179. name: node-local-dns
  180. items:
  181. - key: Corefile
  182. path: Corefile.base