controller-daemonset.yaml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. {{- if or (eq .Values.controller.kind "DaemonSet") (eq .Values.controller.kind "Both") -}}
  2. {{- include "isControllerTagValid" . -}}
  3. apiVersion: apps/v1
  4. kind: DaemonSet
  5. metadata:
  6. labels:
  7. {{- include "ingress-nginx.labels" . | nindent 4 }}
  8. app.kubernetes.io/component: controller
  9. {{- with .Values.controller.labels }}
  10. {{- toYaml . | nindent 4 }}
  11. {{- end }}
  12. name: {{ include "ingress-nginx.controller.fullname" . }}
  13. namespace: {{ .Release.Namespace }}
  14. {{- if .Values.controller.annotations }}
  15. annotations: {{ toYaml .Values.controller.annotations | nindent 4 }}
  16. {{- end }}
  17. spec:
  18. selector:
  19. matchLabels:
  20. {{- include "ingress-nginx.selectorLabels" . | nindent 6 }}
  21. app.kubernetes.io/component: controller
  22. revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
  23. {{- if .Values.controller.updateStrategy }}
  24. updateStrategy: {{ toYaml .Values.controller.updateStrategy | nindent 4 }}
  25. {{- end }}
  26. minReadySeconds: {{ .Values.controller.minReadySeconds }}
  27. template:
  28. metadata:
  29. {{- if .Values.controller.podAnnotations }}
  30. annotations:
  31. {{- range $key, $value := .Values.controller.podAnnotations }}
  32. {{ $key }}: {{ $value | quote }}
  33. {{- end }}
  34. {{- end }}
  35. labels:
  36. {{- include "ingress-nginx.selectorLabels" . | nindent 8 }}
  37. app.kubernetes.io/component: controller
  38. {{- with .Values.controller.labels }}
  39. {{- toYaml . | nindent 8 }}
  40. {{- end }}
  41. {{- if .Values.controller.podLabels }}
  42. {{- toYaml .Values.controller.podLabels | nindent 8 }}
  43. {{- end }}
  44. spec:
  45. {{- if .Values.controller.dnsConfig }}
  46. dnsConfig: {{ toYaml .Values.controller.dnsConfig | nindent 8 }}
  47. {{- end }}
  48. {{- if .Values.controller.hostname }}
  49. hostname: {{ toYaml .Values.controller.hostname | nindent 8 }}
  50. {{- end }}
  51. dnsPolicy: {{ .Values.controller.dnsPolicy }}
  52. {{- if .Values.imagePullSecrets }}
  53. imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 8 }}
  54. {{- end }}
  55. {{- if .Values.controller.priorityClassName }}
  56. priorityClassName: {{ .Values.controller.priorityClassName }}
  57. {{- end }}
  58. {{- if or .Values.controller.podSecurityContext .Values.controller.sysctls }}
  59. securityContext:
  60. {{- end }}
  61. {{- if .Values.controller.podSecurityContext }}
  62. {{- toYaml .Values.controller.podSecurityContext | nindent 8 }}
  63. {{- end }}
  64. {{- if .Values.controller.sysctls }}
  65. sysctls:
  66. {{- range $sysctl, $value := .Values.controller.sysctls }}
  67. - name: {{ $sysctl | quote }}
  68. value: {{ $value | quote }}
  69. {{- end }}
  70. {{- end }}
  71. {{- if .Values.controller.shareProcessNamespace }}
  72. shareProcessNamespace: {{ .Values.controller.shareProcessNamespace }}
  73. {{- end }}
  74. containers:
  75. - name: {{ .Values.controller.containerName }}
  76. {{- with .Values.controller.image }}
  77. image: "{{- if .repository -}}{{ .repository }}{{ else }}{{ .registry }}/{{ include "ingress-nginx.image" . }}{{- end -}}:{{ .tag }}{{ include "ingress-nginx.imageDigest" . }}"
  78. {{- end }}
  79. imagePullPolicy: {{ .Values.controller.image.pullPolicy }}
  80. {{- if .Values.controller.lifecycle }}
  81. lifecycle: {{ toYaml .Values.controller.lifecycle | nindent 12 }}
  82. {{- end }}
  83. args:
  84. {{- include "ingress-nginx.params" . | nindent 12 }}
  85. securityContext: {{ include "controller.containerSecurityContext" . | nindent 12 }}
  86. env:
  87. - name: POD_NAME
  88. valueFrom:
  89. fieldRef:
  90. fieldPath: metadata.name
  91. - name: POD_NAMESPACE
  92. valueFrom:
  93. fieldRef:
  94. fieldPath: metadata.namespace
  95. {{- if .Values.controller.enableMimalloc }}
  96. - name: LD_PRELOAD
  97. value: /usr/local/lib/libmimalloc.so
  98. {{- end }}
  99. {{- if .Values.controller.extraEnvs }}
  100. {{- toYaml .Values.controller.extraEnvs | nindent 12 }}
  101. {{- end }}
  102. {{- if .Values.controller.startupProbe }}
  103. startupProbe: {{ toYaml .Values.controller.startupProbe | nindent 12 }}
  104. {{- end }}
  105. {{- if .Values.controller.livenessProbe }}
  106. livenessProbe: {{ toYaml .Values.controller.livenessProbe | nindent 12 }}
  107. {{- end }}
  108. {{- if .Values.controller.readinessProbe }}
  109. readinessProbe: {{ toYaml .Values.controller.readinessProbe | nindent 12 }}
  110. {{- end }}
  111. ports:
  112. {{- range $key, $value := .Values.controller.containerPort }}
  113. - name: {{ $key }}
  114. containerPort: {{ $value }}
  115. protocol: TCP
  116. {{- if $.Values.controller.hostPort.enabled }}
  117. hostPort: {{ index $.Values.controller.hostPort.ports $key | default $value }}
  118. {{- end }}
  119. {{- end }}
  120. {{- if .Values.controller.metrics.enabled }}
  121. - name: {{ .Values.controller.metrics.portName }}
  122. containerPort: {{ .Values.controller.metrics.port }}
  123. protocol: TCP
  124. {{- end }}
  125. {{- if .Values.controller.admissionWebhooks.enabled }}
  126. - name: webhook
  127. containerPort: {{ .Values.controller.admissionWebhooks.port }}
  128. protocol: TCP
  129. {{- end }}
  130. {{- range $key, $value := .Values.tcp }}
  131. - name: {{ if $.Values.portNamePrefix }}{{ $.Values.portNamePrefix }}-{{ end }}{{ $key }}-tcp
  132. containerPort: {{ $key }}
  133. protocol: TCP
  134. {{- if $.Values.controller.hostPort.enabled }}
  135. hostPort: {{ $key }}
  136. {{- end }}
  137. {{- end }}
  138. {{- range $key, $value := .Values.udp }}
  139. - name: {{ if $.Values.portNamePrefix }}{{ $.Values.portNamePrefix }}-{{ end }}{{ $key }}-udp
  140. containerPort: {{ $key }}
  141. protocol: UDP
  142. {{- if $.Values.controller.hostPort.enabled }}
  143. hostPort: {{ $key }}
  144. {{- end }}
  145. {{- end }}
  146. {{- if (or .Values.controller.customTemplate.configMapName .Values.controller.extraVolumeMounts .Values.controller.admissionWebhooks.enabled .Values.controller.extraModules) }}
  147. volumeMounts:
  148. {{- if .Values.controller.extraModules }}
  149. - name: modules
  150. mountPath: /modules_mount
  151. {{- end }}
  152. {{- if .Values.controller.customTemplate.configMapName }}
  153. - mountPath: /etc/nginx/template
  154. name: nginx-template-volume
  155. readOnly: true
  156. {{- end }}
  157. {{- if .Values.controller.admissionWebhooks.enabled }}
  158. - name: webhook-cert
  159. mountPath: /usr/local/certificates/
  160. readOnly: true
  161. {{- end }}
  162. {{- if .Values.controller.extraVolumeMounts }}
  163. {{- toYaml .Values.controller.extraVolumeMounts | nindent 12 }}
  164. {{- end }}
  165. {{- end }}
  166. {{- if .Values.controller.resources }}
  167. resources: {{ toYaml .Values.controller.resources | nindent 12 }}
  168. {{- end }}
  169. {{- if .Values.controller.extraContainers }}
  170. {{ toYaml .Values.controller.extraContainers | nindent 8 }}
  171. {{- end }}
  172. {{- if (or .Values.controller.extraInitContainers .Values.controller.extraModules) }}
  173. initContainers:
  174. {{- if .Values.controller.extraInitContainers }}
  175. {{ toYaml .Values.controller.extraInitContainers | nindent 8 }}
  176. {{- end }}
  177. {{- if .Values.controller.extraModules }}
  178. {{- range .Values.controller.extraModules }}
  179. - name: {{ .Name }}
  180. image: {{ .Image }}
  181. command: ['sh', '-c', '/usr/local/bin/init_module.sh']
  182. {{- end }}
  183. {{- end }}
  184. {{- end }}
  185. {{- if .Values.controller.hostNetwork }}
  186. hostNetwork: {{ .Values.controller.hostNetwork }}
  187. {{- end }}
  188. {{- if .Values.controller.nodeSelector }}
  189. nodeSelector: {{ toYaml .Values.controller.nodeSelector | nindent 8 }}
  190. {{- end }}
  191. {{- if .Values.controller.tolerations }}
  192. tolerations: {{ toYaml .Values.controller.tolerations | nindent 8 }}
  193. {{- end }}
  194. {{- if .Values.controller.affinity }}
  195. affinity: {{ toYaml .Values.controller.affinity | nindent 8 }}
  196. {{- end }}
  197. {{- if .Values.controller.topologySpreadConstraints }}
  198. topologySpreadConstraints: {{ toYaml .Values.controller.topologySpreadConstraints | nindent 8 }}
  199. {{- end }}
  200. serviceAccountName: {{ template "ingress-nginx.serviceAccountName" . }}
  201. terminationGracePeriodSeconds: {{ .Values.controller.terminationGracePeriodSeconds }}
  202. {{- if (or .Values.controller.customTemplate.configMapName .Values.controller.extraVolumeMounts .Values.controller.admissionWebhooks.enabled .Values.controller.extraVolumes .Values.controller.extraModules) }}
  203. volumes:
  204. {{- if .Values.controller.extraModules }}
  205. - name: modules
  206. emptyDir: {}
  207. {{- end }}
  208. {{- if .Values.controller.customTemplate.configMapName }}
  209. - name: nginx-template-volume
  210. configMap:
  211. name: {{ .Values.controller.customTemplate.configMapName }}
  212. items:
  213. - key: {{ .Values.controller.customTemplate.configMapKey }}
  214. path: nginx.tmpl
  215. {{- end }}
  216. {{- if .Values.controller.admissionWebhooks.enabled }}
  217. - name: webhook-cert
  218. secret:
  219. secretName: {{ include "ingress-nginx.fullname" . }}-admission
  220. {{- end }}
  221. {{- if .Values.controller.extraVolumes }}
  222. {{ toYaml .Values.controller.extraVolumes | nindent 8 }}
  223. {{- end }}
  224. {{- end }}
  225. {{- end }}