default-backend-deployment.yaml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. {{- if .Values.defaultBackend.enabled -}}
  2. apiVersion: apps/v1
  3. kind: Deployment
  4. metadata:
  5. labels:
  6. {{- include "ingress-nginx.labels" . | nindent 4 }}
  7. app.kubernetes.io/component: default-backend
  8. {{- with .Values.defaultBackend.labels }}
  9. {{- toYaml . | nindent 4 }}
  10. {{- end }}
  11. name: {{ include "ingress-nginx.defaultBackend.fullname" . }}
  12. namespace: {{ .Release.Namespace }}
  13. spec:
  14. selector:
  15. matchLabels:
  16. {{- include "ingress-nginx.selectorLabels" . | nindent 6 }}
  17. app.kubernetes.io/component: default-backend
  18. {{- if not .Values.defaultBackend.autoscaling.enabled }}
  19. replicas: {{ .Values.defaultBackend.replicaCount }}
  20. {{- end }}
  21. revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
  22. template:
  23. metadata:
  24. {{- if .Values.defaultBackend.podAnnotations }}
  25. annotations: {{ toYaml .Values.defaultBackend.podAnnotations | nindent 8 }}
  26. {{- end }}
  27. labels:
  28. {{- include "ingress-nginx.selectorLabels" . | nindent 8 }}
  29. app.kubernetes.io/component: default-backend
  30. {{- with .Values.defaultBackend.labels }}
  31. {{- toYaml . | nindent 8 }}
  32. {{- end }}
  33. {{- if .Values.defaultBackend.podLabels }}
  34. {{- toYaml .Values.defaultBackend.podLabels | nindent 8 }}
  35. {{- end }}
  36. spec:
  37. {{- if .Values.imagePullSecrets }}
  38. imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 8 }}
  39. {{- end }}
  40. {{- if .Values.defaultBackend.priorityClassName }}
  41. priorityClassName: {{ .Values.defaultBackend.priorityClassName }}
  42. {{- end }}
  43. {{- if .Values.defaultBackend.podSecurityContext }}
  44. securityContext: {{ toYaml .Values.defaultBackend.podSecurityContext | nindent 8 }}
  45. {{- end }}
  46. containers:
  47. - name: {{ template "ingress-nginx.name" . }}-default-backend
  48. {{- with .Values.defaultBackend.image }}
  49. image: "{{- if .repository -}}{{ .repository }}{{ else }}{{ .registry }}/{{ .image }}{{- end -}}:{{ .tag }}{{- if (.digest) -}} @{{.digest}} {{- end -}}"
  50. {{- end }}
  51. imagePullPolicy: {{ .Values.defaultBackend.image.pullPolicy }}
  52. {{- if .Values.defaultBackend.extraArgs }}
  53. args:
  54. {{- range $key, $value := .Values.defaultBackend.extraArgs }}
  55. {{- /* Accept keys without values or with false as value */}}
  56. {{- if eq ($value | quote | len) 2 }}
  57. - --{{ $key }}
  58. {{- else }}
  59. - --{{ $key }}={{ $value }}
  60. {{- end }}
  61. {{- end }}
  62. {{- end }}
  63. securityContext:
  64. capabilities:
  65. drop:
  66. - ALL
  67. runAsUser: {{ .Values.defaultBackend.image.runAsUser }}
  68. runAsNonRoot: {{ .Values.defaultBackend.image.runAsNonRoot }}
  69. allowPrivilegeEscalation: {{ .Values.defaultBackend.image.allowPrivilegeEscalation }}
  70. readOnlyRootFilesystem: {{ .Values.defaultBackend.image.readOnlyRootFilesystem}}
  71. {{- if .Values.defaultBackend.extraEnvs }}
  72. env: {{ toYaml .Values.defaultBackend.extraEnvs | nindent 12 }}
  73. {{- end }}
  74. livenessProbe:
  75. httpGet:
  76. path: /healthz
  77. port: {{ .Values.defaultBackend.port }}
  78. scheme: HTTP
  79. initialDelaySeconds: {{ .Values.defaultBackend.livenessProbe.initialDelaySeconds }}
  80. periodSeconds: {{ .Values.defaultBackend.livenessProbe.periodSeconds }}
  81. timeoutSeconds: {{ .Values.defaultBackend.livenessProbe.timeoutSeconds }}
  82. successThreshold: {{ .Values.defaultBackend.livenessProbe.successThreshold }}
  83. failureThreshold: {{ .Values.defaultBackend.livenessProbe.failureThreshold }}
  84. readinessProbe:
  85. httpGet:
  86. path: /healthz
  87. port: {{ .Values.defaultBackend.port }}
  88. scheme: HTTP
  89. initialDelaySeconds: {{ .Values.defaultBackend.readinessProbe.initialDelaySeconds }}
  90. periodSeconds: {{ .Values.defaultBackend.readinessProbe.periodSeconds }}
  91. timeoutSeconds: {{ .Values.defaultBackend.readinessProbe.timeoutSeconds }}
  92. successThreshold: {{ .Values.defaultBackend.readinessProbe.successThreshold }}
  93. failureThreshold: {{ .Values.defaultBackend.readinessProbe.failureThreshold }}
  94. ports:
  95. - name: http
  96. containerPort: {{ .Values.defaultBackend.port }}
  97. protocol: TCP
  98. {{- if .Values.defaultBackend.extraVolumeMounts }}
  99. volumeMounts: {{- toYaml .Values.defaultBackend.extraVolumeMounts | nindent 12 }}
  100. {{- end }}
  101. {{- if .Values.defaultBackend.resources }}
  102. resources: {{ toYaml .Values.defaultBackend.resources | nindent 12 }}
  103. {{- end }}
  104. {{- if .Values.defaultBackend.nodeSelector }}
  105. nodeSelector: {{ toYaml .Values.defaultBackend.nodeSelector | nindent 8 }}
  106. {{- end }}
  107. serviceAccountName: {{ template "ingress-nginx.defaultBackend.serviceAccountName" . }}
  108. {{- if .Values.defaultBackend.tolerations }}
  109. tolerations: {{ toYaml .Values.defaultBackend.tolerations | nindent 8 }}
  110. {{- end }}
  111. {{- if .Values.defaultBackend.affinity }}
  112. affinity: {{ toYaml .Values.defaultBackend.affinity | nindent 8 }}
  113. {{- end }}
  114. terminationGracePeriodSeconds: 60
  115. {{- if .Values.defaultBackend.extraVolumes }}
  116. volumes: {{ toYaml .Values.defaultBackend.extraVolumes | nindent 8 }}
  117. {{- end }}
  118. {{- end }}