statefulset.yaml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. {{- if and (eq .Values.architecture "replication") (not .Values.sentinel.enabled) }}
  2. apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
  3. kind: StatefulSet
  4. metadata:
  5. name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
  6. namespace: {{ .Release.Namespace | quote }}
  7. labels: {{- include "common.labels.standard" . | nindent 4 }}
  8. app.kubernetes.io/component: replica
  9. {{- if .Values.commonLabels }}
  10. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  11. {{- end }}
  12. {{- if .Values.commonAnnotations }}
  13. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  14. {{- end }}
  15. spec:
  16. {{- if not .Values.replica.autoscaling.enabled }}
  17. replicas: {{ .Values.replica.replicaCount }}
  18. {{- end }}
  19. selector:
  20. matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
  21. app.kubernetes.io/component: replica
  22. serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) }}
  23. {{- if .Values.replica.updateStrategy }}
  24. updateStrategy: {{- toYaml .Values.replica.updateStrategy | nindent 4 }}
  25. {{- end }}
  26. {{- if and .Values.replica.minReadySeconds (semverCompare ">= 1.23-0" (include "common.capabilities.kubeVersion" .)) }}
  27. minReadySeconds: {{ .Values.replica.minReadySeconds }}
  28. {{- end }}
  29. {{- if .Values.replica.podManagementPolicy }}
  30. podManagementPolicy: {{ .Values.replica.podManagementPolicy | quote }}
  31. {{- end }}
  32. template:
  33. metadata:
  34. labels: {{- include "common.labels.standard" . | nindent 8 }}
  35. app.kubernetes.io/component: replica
  36. {{- if .Values.replica.podLabels }}
  37. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.podLabels "context" $ ) | nindent 8 }}
  38. {{- end }}
  39. {{- if .Values.commonLabels }}
  40. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }}
  41. {{- end }}
  42. {{- if and .Values.metrics.enabled .Values.metrics.podLabels }}
  43. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podLabels "context" $ ) | nindent 8 }}
  44. {{- end }}
  45. annotations:
  46. {{- if (include "redis.createConfigmap" .) }}
  47. checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
  48. {{- end }}
  49. checksum/health: {{ include (print $.Template.BasePath "/health-configmap.yaml") . | sha256sum }}
  50. checksum/scripts: {{ include (print $.Template.BasePath "/scripts-configmap.yaml") . | sha256sum }}
  51. checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
  52. {{- if .Values.replica.podAnnotations }}
  53. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.podAnnotations "context" $ ) | nindent 8 }}
  54. {{- end }}
  55. {{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
  56. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
  57. {{- end }}
  58. spec:
  59. {{- include "redis.imagePullSecrets" . | nindent 6 }}
  60. {{- if .Values.replica.hostAliases }}
  61. hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.replica.hostAliases "context" $) | nindent 8 }}
  62. {{- end }}
  63. {{- if .Values.replica.podSecurityContext.enabled }}
  64. securityContext: {{- omit .Values.replica.podSecurityContext "enabled" | toYaml | nindent 8 }}
  65. {{- end }}
  66. serviceAccountName: {{ template "redis.replicaServiceAccountName" . }}
  67. {{- if .Values.replica.priorityClassName }}
  68. priorityClassName: {{ .Values.replica.priorityClassName | quote }}
  69. {{- end }}
  70. {{- if .Values.replica.affinity }}
  71. affinity: {{- include "common.tplvalues.render" (dict "value" .Values.replica.affinity "context" $) | nindent 8 }}
  72. {{- else }}
  73. affinity:
  74. podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAffinityPreset "component" "replica" "context" $) | nindent 10 }}
  75. podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAntiAffinityPreset "component" "replica" "context" $) | nindent 10 }}
  76. nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.replica.nodeAffinityPreset.type "key" .Values.replica.nodeAffinityPreset.key "values" .Values.replica.nodeAffinityPreset.values) | nindent 10 }}
  77. {{- end }}
  78. {{- if .Values.replica.nodeSelector }}
  79. nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.replica.nodeSelector "context" $) | nindent 8 }}
  80. {{- end }}
  81. {{- if .Values.replica.tolerations }}
  82. tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.replica.tolerations "context" $) | nindent 8 }}
  83. {{- end }}
  84. {{- if .Values.replica.topologySpreadConstraints }}
  85. topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.replica.topologySpreadConstraints "context" $) | nindent 8 }}
  86. {{- end }}
  87. {{- if .Values.replica.shareProcessNamespace }}
  88. shareProcessNamespace: {{ .Values.replica.shareProcessNamespace }}
  89. {{- end }}
  90. {{- if .Values.replica.schedulerName }}
  91. schedulerName: {{ .Values.replica.schedulerName | quote }}
  92. {{- end }}
  93. {{- if .Values.replica.dnsPolicy }}
  94. dnsPolicy: {{ .Values.replica.dnsPolicy }}
  95. {{- end }}
  96. {{- if .Values.replica.dnsConfig }}
  97. dnsConfig: {{- include "common.tplvalues.render" (dict "value" .Values.replica.dnsConfig "context" $) | nindent 8 }}
  98. {{- end }}
  99. terminationGracePeriodSeconds: {{ .Values.replica.terminationGracePeriodSeconds }}
  100. containers:
  101. - name: redis
  102. image: {{ template "redis.image" . }}
  103. imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
  104. {{- if not .Values.diagnosticMode.enabled }}
  105. {{- if .Values.replica.lifecycleHooks }}
  106. lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.replica.lifecycleHooks "context" $) | nindent 12 }}
  107. {{- end }}
  108. {{- end }}
  109. {{- if .Values.replica.containerSecurityContext.enabled }}
  110. securityContext: {{- omit .Values.replica.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  111. {{- end }}
  112. {{- if .Values.diagnosticMode.enabled }}
  113. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
  114. {{- else if .Values.replica.command }}
  115. command: {{- include "common.tplvalues.render" (dict "value" .Values.replica.command "context" $) | nindent 12 }}
  116. {{- else }}
  117. command:
  118. - /bin/bash
  119. {{- end }}
  120. {{- if .Values.diagnosticMode.enabled }}
  121. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
  122. {{- else if .Values.replica.args }}
  123. args: {{- include "common.tplvalues.render" (dict "value" .Values.replica.args "context" $) | nindent 12 }}
  124. {{- else }}
  125. args:
  126. - -c
  127. - /opt/bitnami/scripts/start-scripts/start-replica.sh
  128. {{- end }}
  129. env:
  130. - name: BITNAMI_DEBUG
  131. value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
  132. - name: REDIS_REPLICATION_MODE
  133. value: replica
  134. - name: REDIS_MASTER_HOST
  135. {{- if and (eq (int64 .Values.master.count) 1) (ne .Values.master.kind "Deployment") }}
  136. value: {{ template "common.names.fullname" . }}-master-0.{{ template "common.names.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
  137. {{- else }}
  138. value: {{ template "common.names.fullname" . }}-master.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
  139. {{- end }}
  140. - name: REDIS_MASTER_PORT_NUMBER
  141. value: {{ .Values.master.containerPorts.redis | quote }}
  142. - name: ALLOW_EMPTY_PASSWORD
  143. value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
  144. {{- if .Values.auth.enabled }}
  145. {{- if .Values.auth.usePasswordFiles }}
  146. - name: REDIS_PASSWORD_FILE
  147. value: "/opt/bitnami/redis/secrets/redis-password"
  148. - name: REDIS_MASTER_PASSWORD_FILE
  149. value: "/opt/bitnami/redis/secrets/redis-password"
  150. {{- else }}
  151. - name: REDIS_PASSWORD
  152. valueFrom:
  153. secretKeyRef:
  154. name: {{ template "redis.secretName" . }}
  155. key: {{ template "redis.secretPasswordKey" . }}
  156. - name: REDIS_MASTER_PASSWORD
  157. valueFrom:
  158. secretKeyRef:
  159. name: {{ template "redis.secretName" . }}
  160. key: {{ template "redis.secretPasswordKey" . }}
  161. {{- end }}
  162. {{- end }}
  163. - name: REDIS_TLS_ENABLED
  164. value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
  165. {{- if .Values.tls.enabled }}
  166. - name: REDIS_TLS_PORT
  167. value: {{ .Values.replica.containerPorts.redis | quote }}
  168. - name: REDIS_TLS_AUTH_CLIENTS
  169. value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
  170. - name: REDIS_TLS_CERT_FILE
  171. value: {{ template "redis.tlsCert" . }}
  172. - name: REDIS_TLS_KEY_FILE
  173. value: {{ template "redis.tlsCertKey" . }}
  174. - name: REDIS_TLS_CA_FILE
  175. value: {{ template "redis.tlsCACert" . }}
  176. {{- if .Values.tls.dhParamsFilename }}
  177. - name: REDIS_TLS_DH_PARAMS_FILE
  178. value: {{ template "redis.tlsDHParams" . }}
  179. {{- end }}
  180. {{- else }}
  181. - name: REDIS_PORT
  182. value: {{ .Values.replica.containerPorts.redis | quote }}
  183. {{- end }}
  184. {{- if .Values.replica.extraEnvVars }}
  185. {{- include "common.tplvalues.render" (dict "value" .Values.replica.extraEnvVars "context" $) | nindent 12 }}
  186. {{- end }}
  187. {{- if or .Values.replica.extraEnvVarsCM .Values.replica.extraEnvVarsSecret }}
  188. envFrom:
  189. {{- if .Values.replica.extraEnvVarsCM }}
  190. - configMapRef:
  191. name: {{ .Values.replica.extraEnvVarsCM }}
  192. {{- end }}
  193. {{- if .Values.replica.extraEnvVarsSecret }}
  194. - secretRef:
  195. name: {{ .Values.replica.extraEnvVarsSecret }}
  196. {{- end }}
  197. {{- end }}
  198. ports:
  199. - name: redis
  200. containerPort: {{ .Values.replica.containerPorts.redis }}
  201. {{- if not .Values.diagnosticMode.enabled }}
  202. {{- if .Values.replica.customStartupProbe }}
  203. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customStartupProbe "context" $) | nindent 12 }}
  204. {{- else if .Values.replica.startupProbe.enabled }}
  205. startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.replica.startupProbe "enabled") "context" $) | nindent 12 }}
  206. tcpSocket:
  207. port: redis
  208. {{- end }}
  209. {{- if .Values.replica.customLivenessProbe }}
  210. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customLivenessProbe "context" $) | nindent 12 }}
  211. {{- else if .Values.replica.livenessProbe.enabled }}
  212. livenessProbe:
  213. initialDelaySeconds: {{ .Values.replica.livenessProbe.initialDelaySeconds }}
  214. periodSeconds: {{ .Values.replica.livenessProbe.periodSeconds }}
  215. timeoutSeconds: {{ add1 .Values.replica.livenessProbe.timeoutSeconds }}
  216. successThreshold: {{ .Values.replica.livenessProbe.successThreshold }}
  217. failureThreshold: {{ .Values.replica.livenessProbe.failureThreshold }}
  218. exec:
  219. command:
  220. - sh
  221. - -c
  222. - /health/ping_liveness_local_and_master.sh {{ .Values.replica.livenessProbe.timeoutSeconds }}
  223. {{- end }}
  224. {{- if .Values.replica.customReadinessProbe }}
  225. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customReadinessProbe "context" $) | nindent 12 }}
  226. {{- else if .Values.replica.readinessProbe.enabled }}
  227. readinessProbe:
  228. initialDelaySeconds: {{ .Values.replica.readinessProbe.initialDelaySeconds }}
  229. periodSeconds: {{ .Values.replica.readinessProbe.periodSeconds }}
  230. timeoutSeconds: {{ add1 .Values.replica.readinessProbe.timeoutSeconds }}
  231. successThreshold: {{ .Values.replica.readinessProbe.successThreshold }}
  232. failureThreshold: {{ .Values.replica.readinessProbe.failureThreshold }}
  233. exec:
  234. command:
  235. - sh
  236. - -c
  237. - /health/ping_readiness_local_and_master.sh {{ .Values.replica.readinessProbe.timeoutSeconds }}
  238. {{- end }}
  239. {{- end }}
  240. {{- if .Values.replica.resources }}
  241. resources: {{- toYaml .Values.replica.resources | nindent 12 }}
  242. {{- end }}
  243. volumeMounts:
  244. - name: start-scripts
  245. mountPath: /opt/bitnami/scripts/start-scripts
  246. - name: health
  247. mountPath: /health
  248. {{- if .Values.auth.usePasswordFiles }}
  249. - name: redis-password
  250. mountPath: /opt/bitnami/redis/secrets/
  251. {{- end }}
  252. - name: redis-data
  253. mountPath: /data
  254. {{- if .Values.replica.persistence.subPath }}
  255. subPath: {{ .Values.replica.persistence.subPath }}
  256. {{- else if .Values.replica.persistence.subPathExpr }}
  257. subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
  258. {{- end }}
  259. - name: config
  260. mountPath: /opt/bitnami/redis/mounted-etc
  261. - name: redis-tmp-conf
  262. mountPath: /opt/bitnami/redis/etc
  263. {{- if .Values.tls.enabled }}
  264. - name: redis-certificates
  265. mountPath: /opt/bitnami/redis/certs
  266. readOnly: true
  267. {{- end }}
  268. {{- if .Values.replica.extraVolumeMounts }}
  269. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumeMounts "context" $ ) | nindent 12 }}
  270. {{- end }}
  271. {{- if .Values.metrics.enabled }}
  272. - name: metrics
  273. image: {{ include "redis.metrics.image" . }}
  274. imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
  275. {{- if .Values.metrics.containerSecurityContext.enabled }}
  276. securityContext: {{- omit .Values.metrics.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  277. {{- end }}
  278. {{- if .Values.diagnosticMode.enabled }}
  279. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
  280. {{- else if .Values.metrics.command }}
  281. command: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.command "context" $) | nindent 12 }}
  282. {{- else }}
  283. command:
  284. - /bin/bash
  285. - -c
  286. - |
  287. if [[ -f '/secrets/redis-password' ]]; then
  288. export REDIS_PASSWORD=$(cat /secrets/redis-password)
  289. fi
  290. redis_exporter{{- range $key, $value := .Values.metrics.extraArgs }} --{{ $key }}={{ $value }}{{- end }}
  291. {{- end }}
  292. {{- if .Values.diagnosticMode.enabled }}
  293. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
  294. {{- end }}
  295. env:
  296. - name: REDIS_ALIAS
  297. value: {{ template "common.names.fullname" . }}
  298. {{- if .Values.auth.enabled }}
  299. - name: REDIS_USER
  300. value: default
  301. {{- if (not .Values.auth.usePasswordFiles) }}
  302. - name: REDIS_PASSWORD
  303. valueFrom:
  304. secretKeyRef:
  305. name: {{ template "redis.secretName" . }}
  306. key: {{ template "redis.secretPasswordKey" . }}
  307. {{- end }}
  308. {{- end }}
  309. {{- if .Values.tls.enabled }}
  310. - name: REDIS_ADDR
  311. value: rediss://{{ .Values.metrics.redisTargetHost }}:{{ .Values.replica.containerPorts.redis }}
  312. {{- if .Values.tls.authClients }}
  313. - name: REDIS_EXPORTER_TLS_CLIENT_KEY_FILE
  314. value: {{ template "redis.tlsCertKey" . }}
  315. - name: REDIS_EXPORTER_TLS_CLIENT_CERT_FILE
  316. value: {{ template "redis.tlsCert" . }}
  317. {{- end }}
  318. - name: REDIS_EXPORTER_TLS_CA_CERT_FILE
  319. value: {{ template "redis.tlsCACert" . }}
  320. {{- end }}
  321. {{- if .Values.metrics.extraEnvVars }}
  322. {{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraEnvVars "context" $) | nindent 12 }}
  323. {{- end }}
  324. ports:
  325. - name: metrics
  326. containerPort: 9121
  327. {{- if not .Values.diagnosticMode.enabled }}
  328. {{- if .Values.metrics.customStartupProbe }}
  329. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
  330. {{- else if .Values.metrics.startupProbe.enabled }}
  331. startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
  332. tcpSocket:
  333. port: metrics
  334. {{- end }}
  335. {{- if .Values.metrics.customLivenessProbe }}
  336. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
  337. {{- else if .Values.metrics.livenessProbe.enabled }}
  338. livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
  339. tcpSocket:
  340. port: metrics
  341. {{- end }}
  342. {{- if .Values.metrics.customReadinessProbe }}
  343. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
  344. {{- else if .Values.metrics.readinessProbe.enabled }}
  345. readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
  346. httpGet:
  347. path: /
  348. port: metrics
  349. {{- end }}
  350. {{- end }}
  351. {{- if .Values.metrics.resources }}
  352. resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
  353. {{- end }}
  354. volumeMounts:
  355. {{- if .Values.auth.usePasswordFiles }}
  356. - name: redis-password
  357. mountPath: /secrets/
  358. {{- end }}
  359. {{- if .Values.tls.enabled }}
  360. - name: redis-certificates
  361. mountPath: /opt/bitnami/redis/certs
  362. readOnly: true
  363. {{- end }}
  364. {{- if .Values.metrics.extraVolumeMounts }}
  365. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumeMounts "context" $ ) | nindent 12 }}
  366. {{- end }}
  367. {{- end }}
  368. {{- if .Values.replica.sidecars }}
  369. {{- include "common.tplvalues.render" (dict "value" .Values.replica.sidecars "context" $) | nindent 8 }}
  370. {{- end }}
  371. {{- $needsVolumePermissions := and .Values.volumePermissions.enabled .Values.replica.persistence.enabled .Values.replica.podSecurityContext.enabled .Values.replica.containerSecurityContext.enabled }}
  372. {{- if or .Values.replica.initContainers $needsVolumePermissions .Values.sysctl.enabled }}
  373. initContainers:
  374. {{- if .Values.replica.initContainers }}
  375. {{- include "common.tplvalues.render" (dict "value" .Values.replica.initContainers "context" $) | nindent 8 }}
  376. {{- end }}
  377. {{- if $needsVolumePermissions }}
  378. - name: volume-permissions
  379. image: {{ include "redis.volumePermissions.image" . }}
  380. imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
  381. command:
  382. - /bin/bash
  383. - -ec
  384. - |
  385. {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
  386. chown -R `id -u`:`id -G | cut -d " " -f2` {{ .Values.replica.persistence.path }}
  387. {{- else }}
  388. chown -R {{ .Values.replica.containerSecurityContext.runAsUser }}:{{ .Values.replica.podSecurityContext.fsGroup }} {{ .Values.replica.persistence.path }}
  389. {{- end }}
  390. {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
  391. securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
  392. {{- else }}
  393. securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
  394. {{- end }}
  395. {{- if .Values.volumePermissions.resources }}
  396. resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
  397. {{- end }}
  398. volumeMounts:
  399. - name: redis-data
  400. mountPath: {{ .Values.replica.persistence.path }}
  401. {{- if .Values.replica.persistence.subPath }}
  402. subPath: {{ .Values.replica.persistence.subPath }}
  403. {{- else if .Values.replica.persistence.subPathExpr }}
  404. subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
  405. {{- end }}
  406. {{- end }}
  407. {{- if .Values.sysctl.enabled }}
  408. - name: init-sysctl
  409. image: {{ include "redis.sysctl.image" . }}
  410. imagePullPolicy: {{ default "" .Values.sysctl.image.pullPolicy | quote }}
  411. securityContext:
  412. privileged: true
  413. runAsUser: 0
  414. {{- if .Values.sysctl.command }}
  415. command: {{- include "common.tplvalues.render" (dict "value" .Values.sysctl.command "context" $) | nindent 12 }}
  416. {{- end }}
  417. {{- if .Values.sysctl.resources }}
  418. resources: {{- toYaml .Values.sysctl.resources | nindent 12 }}
  419. {{- end }}
  420. {{- if .Values.sysctl.mountHostSys }}
  421. volumeMounts:
  422. - name: host-sys
  423. mountPath: /host-sys
  424. {{- end }}
  425. {{- end }}
  426. {{- end }}
  427. volumes:
  428. - name: start-scripts
  429. configMap:
  430. name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
  431. defaultMode: 0755
  432. - name: health
  433. configMap:
  434. name: {{ printf "%s-health" (include "common.names.fullname" .) }}
  435. defaultMode: 0755
  436. {{- if .Values.auth.usePasswordFiles }}
  437. - name: redis-password
  438. secret:
  439. secretName: {{ template "redis.secretName" . }}
  440. items:
  441. - key: {{ template "redis.secretPasswordKey" . }}
  442. path: redis-password
  443. {{- end }}
  444. - name: config
  445. configMap:
  446. name: {{ include "redis.configmapName" . }}
  447. {{- if .Values.sysctl.mountHostSys }}
  448. - name: host-sys
  449. hostPath:
  450. path: /sys
  451. {{- end }}
  452. - name: redis-tmp-conf
  453. {{- if or .Values.replica.persistence.medium .Values.replica.persistence.sizeLimit }}
  454. emptyDir:
  455. {{- if .Values.replica.persistence.medium }}
  456. medium: {{ .Values.replica.persistence.medium | quote }}
  457. {{- end }}
  458. {{- if .Values.replica.persistence.sizeLimit }}
  459. sizeLimit: {{ .Values.replica.persistence.sizeLimit | quote }}
  460. {{- end }}
  461. {{- else }}
  462. emptyDir: {}
  463. {{- end }}
  464. {{- if .Values.tls.enabled }}
  465. - name: redis-certificates
  466. secret:
  467. secretName: {{ include "redis.tlsSecretName" . }}
  468. defaultMode: 256
  469. {{- end }}
  470. {{- if .Values.replica.extraVolumes }}
  471. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumes "context" $ ) | nindent 8 }}
  472. {{- end }}
  473. {{- if .Values.metrics.extraVolumes }}
  474. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumes "context" $ ) | nindent 8 }}
  475. {{- end }}
  476. {{- if not .Values.replica.persistence.enabled }}
  477. - name: redis-data
  478. {{- if or .Values.replica.persistence.medium .Values.replica.persistence.sizeLimit }}
  479. emptyDir:
  480. {{- if .Values.replica.persistence.medium }}
  481. medium: {{ .Values.replica.persistence.medium | quote }}
  482. {{- end }}
  483. {{- if .Values.replica.persistence.sizeLimit }}
  484. sizeLimit: {{ .Values.replica.persistence.sizeLimit | quote }}
  485. {{- end }}
  486. {{- else }}
  487. emptyDir: {}
  488. {{- end }}
  489. {{- else if .Values.replica.persistence.existingClaim }}
  490. - name: redis-data
  491. persistentVolumeClaim:
  492. claimName: {{ printf "%s" (tpl .Values.replica.persistence.existingClaim .) }}
  493. {{- else }}
  494. volumeClaimTemplates:
  495. - metadata:
  496. name: redis-data
  497. labels: {{- include "common.labels.matchLabels" . | nindent 10 }}
  498. app.kubernetes.io/component: replica
  499. {{- if .Values.replica.persistence.labels }}
  500. {{- toYaml .Values.replica.persistence.labels | nindent 4 }}
  501. {{- end }}
  502. {{- if .Values.replica.persistence.annotations }}
  503. annotations: {{- toYaml .Values.replica.persistence.annotations | nindent 10 }}
  504. {{- end }}
  505. spec:
  506. accessModes:
  507. {{- range .Values.replica.persistence.accessModes }}
  508. - {{ . | quote }}
  509. {{- end }}
  510. resources:
  511. requests:
  512. storage: {{ .Values.replica.persistence.size | quote }}
  513. {{- if .Values.replica.persistence.selector }}
  514. selector: {{- include "common.tplvalues.render" (dict "value" .Values.replica.persistence.selector "context" $) | nindent 10 }}
  515. {{- end }}
  516. {{- if .Values.replica.persistence.dataSource }}
  517. dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.replica.persistence.dataSource "context" $) | nindent 10 }}
  518. {{- end }}
  519. {{- include "common.storage.class" (dict "persistence" .Values.replica.persistence "global" .Values.global) | nindent 8 }}
  520. {{- end }}
  521. {{- end }}