statefulset.yaml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. {{- if or .Release.IsUpgrade (ne .Values.sentinel.service.type "NodePort") .Values.sentinel.service.nodePorts.redis -}}
  2. {{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled }}
  3. apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
  4. kind: StatefulSet
  5. metadata:
  6. name: {{ printf "%s-node" (include "common.names.fullname" .) }}
  7. namespace: {{ .Release.Namespace | quote }}
  8. labels: {{- include "common.labels.standard" . | nindent 4 }}
  9. app.kubernetes.io/component: node
  10. {{- if .Values.commonLabels }}
  11. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  12. {{- end }}
  13. {{- if or .Values.commonAnnotations .Values.sentinel.annotations }}
  14. annotations:
  15. {{- if .Values.commonAnnotations }}
  16. {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  17. {{- end }}
  18. {{- if .Values.sentinel.annotations }}
  19. {{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.annotations "context" $ ) | nindent 4 }}
  20. {{- end }}
  21. {{- end }}
  22. spec:
  23. replicas: {{ .Values.replica.replicaCount }}
  24. selector:
  25. matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
  26. app.kubernetes.io/component: node
  27. serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) }}
  28. {{- if .Values.replica.updateStrategy }}
  29. updateStrategy: {{- toYaml .Values.replica.updateStrategy | nindent 4 }}
  30. {{- end }}
  31. {{- if and .Values.replica.minReadySeconds (semverCompare ">= 1.23-0" (include "common.capabilities.kubeVersion" .)) }}
  32. minReadySeconds: {{ .Values.replica.minReadySeconds }}
  33. {{- end }}
  34. {{- if .Values.replica.podManagementPolicy }}
  35. podManagementPolicy: {{ .Values.replica.podManagementPolicy | quote }}
  36. {{- end }}
  37. template:
  38. metadata:
  39. labels: {{- include "common.labels.standard" . | nindent 8 }}
  40. app.kubernetes.io/component: node
  41. {{- if .Values.replica.podLabels }}
  42. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.podLabels "context" $ ) | nindent 8 }}
  43. {{- end }}
  44. {{- if .Values.commonLabels }}
  45. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }}
  46. {{- end }}
  47. {{- if and .Values.metrics.enabled .Values.metrics.podLabels }}
  48. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podLabels "context" $ ) | nindent 8 }}
  49. {{- end }}
  50. annotations:
  51. {{- if (include "redis.createConfigmap" .) }}
  52. checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
  53. {{- end }}
  54. checksum/health: {{ include (print $.Template.BasePath "/health-configmap.yaml") . | sha256sum }}
  55. checksum/scripts: {{ include (print $.Template.BasePath "/scripts-configmap.yaml") . | sha256sum }}
  56. checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
  57. {{- if .Values.replica.podAnnotations }}
  58. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.podAnnotations "context" $ ) | nindent 8 }}
  59. {{- end }}
  60. {{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
  61. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
  62. {{- end }}
  63. spec:
  64. {{- include "redis.imagePullSecrets" . | nindent 6 }}
  65. {{- if .Values.replica.hostAliases }}
  66. hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.replica.hostAliases "context" $) | nindent 8 }}
  67. {{- end }}
  68. {{- if .Values.replica.podSecurityContext.enabled }}
  69. securityContext: {{- omit .Values.replica.podSecurityContext "enabled" | toYaml | nindent 8 }}
  70. {{- end }}
  71. serviceAccountName: {{ template "redis.serviceAccountName" . }}
  72. {{- if .Values.replica.priorityClassName }}
  73. priorityClassName: {{ .Values.replica.priorityClassName | quote }}
  74. {{- end }}
  75. {{- if .Values.replica.affinity }}
  76. affinity: {{- include "common.tplvalues.render" (dict "value" .Values.replica.affinity "context" $) | nindent 8 }}
  77. {{- else }}
  78. affinity:
  79. podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAffinityPreset "component" "node" "context" $) | nindent 10 }}
  80. podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAntiAffinityPreset "component" "node" "context" $) | nindent 10 }}
  81. nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.replica.nodeAffinityPreset.type "key" .Values.replica.nodeAffinityPreset.key "values" .Values.replica.nodeAffinityPreset.values) | nindent 10 }}
  82. {{- end }}
  83. {{- if .Values.replica.nodeSelector }}
  84. nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.replica.nodeSelector "context" $) | nindent 8 }}
  85. {{- end }}
  86. {{- if .Values.replica.tolerations }}
  87. tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.replica.tolerations "context" $) | nindent 8 }}
  88. {{- end }}
  89. {{- if .Values.replica.topologySpreadConstraints }}
  90. topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.replica.topologySpreadConstraints "context" $) | nindent 8 }}
  91. {{- end }}
  92. {{- if .Values.replica.shareProcessNamespace }}
  93. shareProcessNamespace: {{ .Values.replica.shareProcessNamespace }}
  94. {{- end }}
  95. {{- if .Values.replica.schedulerName }}
  96. schedulerName: {{ .Values.replica.schedulerName | quote }}
  97. {{- end }}
  98. {{- if .Values.replica.dnsPolicy }}
  99. dnsPolicy: {{ .Values.replica.dnsPolicy }}
  100. {{- end }}
  101. {{- if .Values.replica.dnsConfig }}
  102. dnsConfig: {{- include "common.tplvalues.render" (dict "value" .Values.replica.dnsConfig "context" $) | nindent 8 }}
  103. {{- end }}
  104. terminationGracePeriodSeconds: {{ .Values.sentinel.terminationGracePeriodSeconds }}
  105. containers:
  106. - name: redis
  107. image: {{ template "redis.image" . }}
  108. imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
  109. {{- if not .Values.diagnosticMode.enabled }}
  110. {{- if .Values.replica.lifecycleHooks }}
  111. lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.replica.lifecycleHooks "context" $) | nindent 12 }}
  112. {{- else }}
  113. lifecycle:
  114. preStop:
  115. exec:
  116. command:
  117. - /bin/bash
  118. - -c
  119. - /opt/bitnami/scripts/start-scripts/prestop-redis.sh
  120. {{- end }}
  121. {{- end }}
  122. {{- if .Values.replica.containerSecurityContext.enabled }}
  123. securityContext: {{- omit .Values.replica.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  124. {{- end }}
  125. {{- if .Values.diagnosticMode.enabled }}
  126. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
  127. {{- else if .Values.replica.command }}
  128. command: {{- include "common.tplvalues.render" (dict "value" .Values.replica.command "context" $) | nindent 12 }}
  129. {{- else }}
  130. command:
  131. - /bin/bash
  132. {{- end }}
  133. {{- if .Values.diagnosticMode.enabled }}
  134. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
  135. {{- else if .Values.replica.args }}
  136. args: {{- include "common.tplvalues.render" (dict "value" .Values.replica.args "context" $) | nindent 12 }}
  137. {{- else }}
  138. args:
  139. - -c
  140. - /opt/bitnami/scripts/start-scripts/start-node.sh
  141. {{- end }}
  142. env:
  143. - name: BITNAMI_DEBUG
  144. value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
  145. - name: REDIS_MASTER_PORT_NUMBER
  146. value: {{ .Values.replica.containerPorts.redis | quote }}
  147. - name: ALLOW_EMPTY_PASSWORD
  148. value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
  149. {{- if .Values.auth.enabled }}
  150. {{- if .Values.auth.usePasswordFiles }}
  151. - name: REDIS_PASSWORD_FILE
  152. value: "/opt/bitnami/redis/secrets/redis-password"
  153. - name: REDIS_MASTER_PASSWORD_FILE
  154. value: "/opt/bitnami/redis/secrets/redis-password"
  155. {{- else }}
  156. - name: REDIS_PASSWORD
  157. valueFrom:
  158. secretKeyRef:
  159. name: {{ template "redis.secretName" . }}
  160. key: {{ template "redis.secretPasswordKey" . }}
  161. - name: REDIS_MASTER_PASSWORD
  162. valueFrom:
  163. secretKeyRef:
  164. name: {{ template "redis.secretName" . }}
  165. key: {{ template "redis.secretPasswordKey" . }}
  166. {{- end }}
  167. {{- end }}
  168. - name: REDIS_TLS_ENABLED
  169. value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
  170. {{- if .Values.tls.enabled }}
  171. - name: REDIS_TLS_PORT
  172. value: {{ .Values.replica.containerPorts.redis | quote }}
  173. - name: REDIS_TLS_AUTH_CLIENTS
  174. value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
  175. - name: REDIS_TLS_CERT_FILE
  176. value: {{ template "redis.tlsCert" . }}
  177. - name: REDIS_TLS_KEY_FILE
  178. value: {{ template "redis.tlsCertKey" . }}
  179. - name: REDIS_TLS_CA_FILE
  180. value: {{ template "redis.tlsCACert" . }}
  181. {{- if .Values.tls.dhParamsFilename }}
  182. - name: REDIS_TLS_DH_PARAMS_FILE
  183. value: {{ template "redis.tlsDHParams" . }}
  184. {{- end }}
  185. {{- else }}
  186. - name: REDIS_PORT
  187. value: {{ .Values.replica.containerPorts.redis | quote }}
  188. {{- end }}
  189. - name: REDIS_SENTINEL_TLS_ENABLED
  190. value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
  191. {{- if .Values.tls.enabled }}
  192. - name: REDIS_SENTINEL_TLS_PORT_NUMBER
  193. value: {{ .Values.sentinel.containerPorts.sentinel | quote }}
  194. - name: REDIS_SENTINEL_TLS_AUTH_CLIENTS
  195. value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
  196. - name: REDIS_SENTINEL_TLS_CERT_FILE
  197. value: {{ template "redis.tlsCert" . }}
  198. - name: REDIS_SENTINEL_TLS_KEY_FILE
  199. value: {{ template "redis.tlsCertKey" . }}
  200. - name: REDIS_SENTINEL_TLS_CA_FILE
  201. value: {{ template "redis.tlsCACert" . }}
  202. {{- if .Values.tls.dhParamsFilename }}
  203. - name: REDIS_SENTINEL_TLS_DH_PARAMS_FILE
  204. value: {{ template "redis.tlsDHParams" . }}
  205. {{- end }}
  206. {{- else }}
  207. - name: REDIS_SENTINEL_PORT
  208. value: {{ .Values.sentinel.containerPorts.sentinel | quote }}
  209. {{- end }}
  210. - name: REDIS_DATA_DIR
  211. value: {{ .Values.replica.persistence.path }}
  212. {{- if .Values.replica.externalMaster.enabled }}
  213. - name: REDIS_EXTERNAL_MASTER_HOST
  214. value: {{ .Values.replica.externalMaster.host | quote }}
  215. - name: REDIS_EXTERNAL_MASTER_PORT
  216. value: {{ .Values.replica.externalMaster.port | quote }}
  217. {{- end }}
  218. {{- if .Values.replica.extraEnvVars }}
  219. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraEnvVars "context" $ ) | nindent 12 }}
  220. {{- end }}
  221. {{- if or .Values.replica.extraEnvVarsCM .Values.replica.extraEnvVarsSecret }}
  222. envFrom:
  223. {{- if .Values.replica.extraEnvVarsCM }}
  224. - configMapRef:
  225. name: {{ .Values.replica.extraEnvVarsCM }}
  226. {{- end }}
  227. {{- if .Values.replica.extraEnvVarsSecret }}
  228. - secretRef:
  229. name: {{ .Values.replica.extraEnvVarsSecret }}
  230. {{- end }}
  231. {{- end }}
  232. ports:
  233. - name: redis
  234. containerPort: {{ .Values.replica.containerPorts.redis }}
  235. {{- if not .Values.diagnosticMode.enabled }}
  236. {{- if .Values.replica.customStartupProbe }}
  237. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customStartupProbe "context" $) | nindent 12 }}
  238. {{- else if .Values.replica.startupProbe.enabled }}
  239. startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.replica.startupProbe "enabled") "context" $) | nindent 12 }}
  240. exec:
  241. command:
  242. - sh
  243. - -c
  244. - /health/ping_liveness_local.sh {{ .Values.replica.livenessProbe.timeoutSeconds }}
  245. {{- end }}
  246. {{- if .Values.replica.customLivenessProbe }}
  247. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customLivenessProbe "context" $) | nindent 12 }}
  248. {{- else if .Values.replica.livenessProbe.enabled }}
  249. livenessProbe:
  250. initialDelaySeconds: {{ .Values.replica.livenessProbe.initialDelaySeconds }}
  251. periodSeconds: {{ .Values.replica.livenessProbe.periodSeconds }}
  252. timeoutSeconds: {{ .Values.replica.livenessProbe.timeoutSeconds }}
  253. successThreshold: {{ .Values.replica.livenessProbe.successThreshold }}
  254. failureThreshold: {{ .Values.replica.livenessProbe.failureThreshold }}
  255. exec:
  256. command:
  257. - sh
  258. - -c
  259. - /health/ping_liveness_local.sh {{ .Values.replica.livenessProbe.timeoutSeconds }}
  260. {{- end }}
  261. {{- if .Values.replica.customReadinessProbe }}
  262. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customReadinessProbe "context" $) | nindent 12 }}
  263. {{- else if .Values.replica.readinessProbe.enabled }}
  264. readinessProbe:
  265. initialDelaySeconds: {{ .Values.replica.readinessProbe.initialDelaySeconds }}
  266. periodSeconds: {{ .Values.replica.readinessProbe.periodSeconds }}
  267. timeoutSeconds: {{ .Values.replica.readinessProbe.timeoutSeconds }}
  268. successThreshold: {{ .Values.replica.readinessProbe.successThreshold }}
  269. failureThreshold: {{ .Values.replica.readinessProbe.failureThreshold }}
  270. exec:
  271. command:
  272. - sh
  273. - -c
  274. - /health/ping_readiness_local.sh {{ .Values.replica.readinessProbe.timeoutSeconds }}
  275. {{- end }}
  276. {{- end }}
  277. {{- if .Values.replica.resources }}
  278. resources: {{- toYaml .Values.replica.resources | nindent 12 }}
  279. {{- end }}
  280. volumeMounts:
  281. - name: start-scripts
  282. mountPath: /opt/bitnami/scripts/start-scripts
  283. - name: health
  284. mountPath: /health
  285. {{- if .Values.sentinel.persistence.enabled }}
  286. - name: sentinel-data
  287. mountPath: /opt/bitnami/redis-sentinel/etc
  288. {{- end }}
  289. {{- if .Values.auth.usePasswordFiles }}
  290. - name: redis-password
  291. mountPath: /opt/bitnami/redis/secrets/
  292. {{- end }}
  293. - name: redis-data
  294. mountPath: {{ .Values.replica.persistence.path }}
  295. {{- if .Values.replica.persistence.subPath }}
  296. subPath: {{ .Values.replica.persistence.subPath }}
  297. {{- else if .Values.replica.persistence.subPathExpr }}
  298. subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
  299. {{- end }}
  300. - name: config
  301. mountPath: /opt/bitnami/redis/mounted-etc
  302. - name: redis-tmp-conf
  303. mountPath: /opt/bitnami/redis/etc
  304. - name: tmp
  305. mountPath: /tmp
  306. {{- if .Values.tls.enabled }}
  307. - name: redis-certificates
  308. mountPath: /opt/bitnami/redis/certs
  309. readOnly: true
  310. {{- end }}
  311. {{- if .Values.replica.extraVolumeMounts }}
  312. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumeMounts "context" $ ) | nindent 12 }}
  313. {{- end }}
  314. - name: sentinel
  315. image: {{ template "redis.sentinel.image" . }}
  316. imagePullPolicy: {{ .Values.sentinel.image.pullPolicy | quote }}
  317. {{- if not .Values.diagnosticMode.enabled }}
  318. {{- if .Values.sentinel.lifecycleHooks }}
  319. lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.lifecycleHooks "context" $) | nindent 12 }}
  320. {{- else }}
  321. lifecycle:
  322. preStop:
  323. exec:
  324. command:
  325. - /bin/bash
  326. - -c
  327. - /opt/bitnami/scripts/start-scripts/prestop-sentinel.sh
  328. {{- end }}
  329. {{- end }}
  330. {{- if .Values.sentinel.containerSecurityContext.enabled }}
  331. securityContext: {{- omit .Values.sentinel.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  332. {{- end }}
  333. {{- if .Values.diagnosticMode.enabled }}
  334. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
  335. {{- else if .Values.sentinel.command }}
  336. command: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.command "context" $) | nindent 12 }}
  337. {{- else }}
  338. command:
  339. - /bin/bash
  340. {{- end }}
  341. {{- if .Values.diagnosticMode.enabled }}
  342. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
  343. {{- else if .Values.sentinel.args }}
  344. args: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.args "context" $) | nindent 12 }}
  345. {{- else }}
  346. args:
  347. - -c
  348. - /opt/bitnami/scripts/start-scripts/start-sentinel.sh
  349. {{- end }}
  350. env:
  351. - name: BITNAMI_DEBUG
  352. value: {{ ternary "true" "false" (or .Values.sentinel.image.debug .Values.diagnosticMode.enabled) | quote }}
  353. {{- if .Values.auth.enabled }}
  354. {{- if .Values.auth.usePasswordFiles }}
  355. - name: REDIS_PASSWORD_FILE
  356. value: "/opt/bitnami/redis/secrets/redis-password"
  357. {{- else }}
  358. - name: REDIS_PASSWORD
  359. valueFrom:
  360. secretKeyRef:
  361. name: {{ template "redis.secretName" . }}
  362. key: {{ template "redis.secretPasswordKey" . }}
  363. {{- end }}
  364. {{- else }}
  365. - name: ALLOW_EMPTY_PASSWORD
  366. value: "yes"
  367. {{- end }}
  368. - name: REDIS_SENTINEL_TLS_ENABLED
  369. value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
  370. {{- if .Values.tls.enabled }}
  371. - name: REDIS_SENTINEL_TLS_PORT_NUMBER
  372. value: {{ .Values.sentinel.containerPorts.sentinel | quote }}
  373. - name: REDIS_SENTINEL_TLS_AUTH_CLIENTS
  374. value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
  375. - name: REDIS_SENTINEL_TLS_CERT_FILE
  376. value: {{ template "redis.tlsCert" . }}
  377. - name: REDIS_SENTINEL_TLS_KEY_FILE
  378. value: {{ template "redis.tlsCertKey" . }}
  379. - name: REDIS_SENTINEL_TLS_CA_FILE
  380. value: {{ template "redis.tlsCACert" . }}
  381. {{- if .Values.tls.dhParamsFilename }}
  382. - name: REDIS_SENTINEL_TLS_DH_PARAMS_FILE
  383. value: {{ template "redis.tlsDHParams" . }}
  384. {{- end }}
  385. {{- else }}
  386. - name: REDIS_SENTINEL_PORT
  387. value: {{ .Values.sentinel.containerPorts.sentinel | quote }}
  388. {{- end }}
  389. {{- if .Values.sentinel.externalMaster.enabled }}
  390. - name: REDIS_EXTERNAL_MASTER_HOST
  391. value: {{ .Values.sentinel.externalMaster.host | quote }}
  392. - name: REDIS_EXTERNAL_MASTER_PORT
  393. value: {{ .Values.sentinel.externalMaster.port | quote }}
  394. {{- end }}
  395. {{- if .Values.sentinel.extraEnvVars }}
  396. {{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.extraEnvVars "context" $ ) | nindent 12 }}
  397. {{- end }}
  398. {{- if or .Values.sentinel.extraEnvVarsCM .Values.sentinel.extraEnvVarsSecret }}
  399. envFrom:
  400. {{- if .Values.sentinel.extraEnvVarsCM }}
  401. - configMapRef:
  402. name: {{ .Values.sentinel.extraEnvVarsCM }}
  403. {{- end }}
  404. {{- if .Values.sentinel.extraEnvVarsSecret }}
  405. - secretRef:
  406. name: {{ .Values.sentinel.extraEnvVarsSecret }}
  407. {{- end }}
  408. {{- end }}
  409. ports:
  410. - name: redis-sentinel
  411. containerPort: {{ .Values.sentinel.containerPorts.sentinel }}
  412. {{- if not .Values.diagnosticMode.enabled }}
  413. {{- if .Values.sentinel.customStartupProbe }}
  414. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.customStartupProbe "context" $) | nindent 12 }}
  415. {{- else if .Values.sentinel.startupProbe.enabled }}
  416. startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.sentinel.startupProbe "enabled") "context" $) | nindent 12 }}
  417. exec:
  418. command:
  419. - sh
  420. - -c
  421. - /health/ping_sentinel.sh {{ .Values.sentinel.livenessProbe.timeoutSeconds }}
  422. {{- end }}
  423. {{- if .Values.sentinel.customLivenessProbe }}
  424. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.customLivenessProbe "context" $) | nindent 12 }}
  425. {{- else if .Values.sentinel.livenessProbe.enabled }}
  426. livenessProbe:
  427. initialDelaySeconds: {{ .Values.sentinel.livenessProbe.initialDelaySeconds }}
  428. periodSeconds: {{ .Values.sentinel.livenessProbe.periodSeconds }}
  429. timeoutSeconds: {{ .Values.sentinel.livenessProbe.timeoutSeconds }}
  430. successThreshold: {{ .Values.sentinel.livenessProbe.successThreshold }}
  431. failureThreshold: {{ .Values.sentinel.livenessProbe.failureThreshold }}
  432. exec:
  433. command:
  434. - sh
  435. - -c
  436. - /health/ping_sentinel.sh {{ .Values.sentinel.livenessProbe.timeoutSeconds }}
  437. {{- end }}
  438. {{- end }}
  439. {{- if not .Values.diagnosticMode.enabled }}
  440. {{- if .Values.sentinel.customReadinessProbe }}
  441. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.customReadinessProbe "context" $) | nindent 12 }}
  442. {{- else if .Values.sentinel.readinessProbe.enabled }}
  443. readinessProbe:
  444. initialDelaySeconds: {{ .Values.sentinel.readinessProbe.initialDelaySeconds }}
  445. periodSeconds: {{ .Values.sentinel.readinessProbe.periodSeconds }}
  446. timeoutSeconds: {{ .Values.sentinel.readinessProbe.timeoutSeconds }}
  447. successThreshold: {{ .Values.sentinel.readinessProbe.successThreshold }}
  448. failureThreshold: {{ .Values.sentinel.readinessProbe.failureThreshold }}
  449. exec:
  450. command:
  451. - sh
  452. - -c
  453. - /health/ping_sentinel.sh {{ .Values.sentinel.readinessProbe.timeoutSeconds }}
  454. {{- end }}
  455. {{- end }}
  456. {{- if .Values.sentinel.resources }}
  457. resources: {{- toYaml .Values.sentinel.resources | nindent 12 }}
  458. {{- end }}
  459. volumeMounts:
  460. - name: start-scripts
  461. mountPath: /opt/bitnami/scripts/start-scripts
  462. - name: health
  463. mountPath: /health
  464. - name: sentinel-data
  465. mountPath: /opt/bitnami/redis-sentinel/etc
  466. {{- if .Values.auth.usePasswordFiles }}
  467. - name: redis-password
  468. mountPath: /opt/bitnami/redis/secrets/
  469. {{- end }}
  470. - name: redis-data
  471. mountPath: {{ .Values.replica.persistence.path }}
  472. {{- if .Values.replica.persistence.subPath }}
  473. subPath: {{ .Values.replica.persistence.subPath }}
  474. {{- else if .Values.replica.persistence.subPathExpr }}
  475. subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
  476. {{- end }}
  477. - name: config
  478. mountPath: /opt/bitnami/redis-sentinel/mounted-etc
  479. {{- if .Values.tls.enabled }}
  480. - name: redis-certificates
  481. mountPath: /opt/bitnami/redis/certs
  482. readOnly: true
  483. {{- end }}
  484. {{- if .Values.sentinel.extraVolumeMounts }}
  485. {{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.extraVolumeMounts "context" $ ) | nindent 12 }}
  486. {{- end }}
  487. {{- if .Values.metrics.enabled }}
  488. - name: metrics
  489. image: {{ template "redis.metrics.image" . }}
  490. imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
  491. {{- if .Values.metrics.containerSecurityContext.enabled }}
  492. securityContext: {{- omit .Values.metrics.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  493. {{- end }}
  494. {{- if .Values.diagnosticMode.enabled }}
  495. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
  496. {{- else }}
  497. command:
  498. - /bin/bash
  499. - -c
  500. - |
  501. if [[ -f '/secrets/redis-password' ]]; then
  502. export REDIS_PASSWORD=$(cat /secrets/redis-password)
  503. fi
  504. redis_exporter{{- range $key, $value := .Values.metrics.extraArgs }} --{{ $key }}={{ $value }}{{- end }}
  505. {{- end }}
  506. {{- if .Values.diagnosticMode.enabled }}
  507. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
  508. {{- end }}
  509. env:
  510. - name: REDIS_ALIAS
  511. value: {{ template "common.names.fullname" . }}
  512. {{- if .Values.auth.enabled }}
  513. - name: REDIS_USER
  514. value: default
  515. {{- if (not .Values.auth.usePasswordFiles) }}
  516. - name: REDIS_PASSWORD
  517. valueFrom:
  518. secretKeyRef:
  519. name: {{ template "redis.secretName" . }}
  520. key: {{ template "redis.secretPasswordKey" . }}
  521. {{- end }}
  522. {{- end }}
  523. {{- if .Values.tls.enabled }}
  524. - name: REDIS_ADDR
  525. value: rediss://{{ .Values.metrics.redisTargetHost }}:{{ .Values.replica.containerPorts.redis }}
  526. {{- if .Values.tls.authClients }}
  527. - name: REDIS_EXPORTER_TLS_CLIENT_KEY_FILE
  528. value: {{ template "redis.tlsCertKey" . }}
  529. - name: REDIS_EXPORTER_TLS_CLIENT_CERT_FILE
  530. value: {{ template "redis.tlsCert" . }}
  531. {{- end }}
  532. - name: REDIS_EXPORTER_TLS_CA_CERT_FILE
  533. value: {{ template "redis.tlsCACert" . }}
  534. {{- end }}
  535. {{- if .Values.metrics.extraEnvVars }}
  536. {{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraEnvVars "context" $) | nindent 12 }}
  537. {{- end }}
  538. ports:
  539. - name: metrics
  540. containerPort: 9121
  541. {{- if not .Values.diagnosticMode.enabled }}
  542. {{- if .Values.metrics.customStartupProbe }}
  543. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
  544. {{- else if .Values.metrics.startupProbe.enabled }}
  545. startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
  546. tcpSocket:
  547. port: metrics
  548. {{- end }}
  549. {{- if .Values.metrics.customLivenessProbe }}
  550. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
  551. {{- else if .Values.metrics.livenessProbe.enabled }}
  552. livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
  553. tcpSocket:
  554. port: metrics
  555. {{- end }}
  556. {{- if .Values.metrics.customReadinessProbe }}
  557. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
  558. {{- else if .Values.metrics.readinessProbe.enabled }}
  559. readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
  560. httpGet:
  561. path: /
  562. port: metrics
  563. {{- end }}
  564. {{- end }}
  565. {{- if .Values.metrics.resources }}
  566. resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
  567. {{- end }}
  568. volumeMounts:
  569. {{- if .Values.auth.usePasswordFiles }}
  570. - name: redis-password
  571. mountPath: /secrets/
  572. {{- end }}
  573. {{- if .Values.tls.enabled }}
  574. - name: redis-certificates
  575. mountPath: /opt/bitnami/redis/certs
  576. readOnly: true
  577. {{- end }}
  578. {{- if .Values.metrics.extraVolumeMounts }}
  579. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumeMounts "context" $ ) | nindent 12 }}
  580. {{- end }}
  581. {{- end }}
  582. {{- if .Values.replica.sidecars }}
  583. {{- include "common.tplvalues.render" (dict "value" .Values.replica.sidecars "context" $) | nindent 8 }}
  584. {{- end }}
  585. {{- $needsVolumePermissions := and .Values.volumePermissions.enabled .Values.replica.persistence.enabled .Values.replica.podSecurityContext.enabled .Values.replica.containerSecurityContext.enabled }}
  586. {{- if or .Values.replica.initContainers $needsVolumePermissions .Values.sysctl.enabled }}
  587. initContainers:
  588. {{- if .Values.replica.initContainers }}
  589. {{- include "common.tplvalues.render" (dict "value" .Values.replica.initContainers "context" $) | nindent 8 }}
  590. {{- end }}
  591. {{- if $needsVolumePermissions }}
  592. - name: volume-permissions
  593. image: {{ include "redis.volumePermissions.image" . }}
  594. imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
  595. command:
  596. - /bin/bash
  597. - -ec
  598. - |
  599. {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
  600. chown -R `id -u`:`id -G | cut -d " " -f2` {{ .Values.replica.persistence.path }}
  601. {{- else }}
  602. chown -R {{ .Values.replica.containerSecurityContext.runAsUser }}:{{ .Values.replica.podSecurityContext.fsGroup }} {{ .Values.replica.persistence.path }}
  603. {{- end }}
  604. {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
  605. securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
  606. {{- else }}
  607. securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
  608. {{- end }}
  609. {{- if .Values.volumePermissions.resources }}
  610. resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
  611. {{- end }}
  612. volumeMounts:
  613. - name: redis-data
  614. mountPath: {{ .Values.replica.persistence.path }}
  615. {{- if .Values.replica.persistence.subPath }}
  616. subPath: {{ .Values.replica.persistence.subPath }}
  617. {{- else if .Values.replica.persistence.subPathExpr }}
  618. subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
  619. {{- end }}
  620. {{- end }}
  621. {{- if .Values.sysctl.enabled }}
  622. - name: init-sysctl
  623. image: {{ include "redis.sysctl.image" . }}
  624. imagePullPolicy: {{ default "" .Values.sysctl.image.pullPolicy | quote }}
  625. securityContext:
  626. privileged: true
  627. runAsUser: 0
  628. {{- if .Values.sysctl.command }}
  629. command: {{- include "common.tplvalues.render" (dict "value" .Values.sysctl.command "context" $) | nindent 12 }}
  630. {{- end }}
  631. {{- if .Values.sysctl.resources }}
  632. resources: {{- toYaml .Values.sysctl.resources | nindent 12 }}
  633. {{- end }}
  634. {{- if .Values.sysctl.mountHostSys }}
  635. volumeMounts:
  636. - name: host-sys
  637. mountPath: /host-sys
  638. {{- end }}
  639. {{- end }}
  640. {{- end }}
  641. volumes:
  642. - name: start-scripts
  643. configMap:
  644. name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
  645. defaultMode: 0755
  646. - name: health
  647. configMap:
  648. name: {{ printf "%s-health" (include "common.names.fullname" .) }}
  649. defaultMode: 0755
  650. {{- if .Values.auth.usePasswordFiles }}
  651. - name: redis-password
  652. secret:
  653. secretName: {{ template "redis.secretName" . }}
  654. items:
  655. - key: {{ template "redis.secretPasswordKey" . }}
  656. path: redis-password
  657. {{- end }}
  658. - name: config
  659. configMap:
  660. name: {{ include "redis.configmapName" . }}
  661. {{- if .Values.sysctl.mountHostSys }}
  662. - name: host-sys
  663. hostPath:
  664. path: /sys
  665. {{- end }}
  666. {{- if not .Values.sentinel.persistence.enabled }}
  667. - name: sentinel-data
  668. {{- if or .Values.sentinel.persistence.medium .Values.sentinel.persistence.sizeLimit }}
  669. emptyDir:
  670. {{- if .Values.sentinel.persistence.medium }}
  671. medium: {{ .Values.sentinel.persistence.medium | quote }}
  672. {{- end }}
  673. {{- if .Values.sentinel.persistence.sizeLimit }}
  674. sizeLimit: {{ .Values.sentinel.persistence.sizeLimit | quote }}
  675. {{- end }}
  676. {{- else }}
  677. emptyDir: {}
  678. {{- end }}
  679. {{- end }}
  680. - name: redis-tmp-conf
  681. {{- if or .Values.sentinel.persistence.medium .Values.sentinel.persistence.sizeLimit }}
  682. emptyDir:
  683. {{- if .Values.sentinel.persistence.medium }}
  684. medium: {{ .Values.sentinel.persistence.medium | quote }}
  685. {{- end }}
  686. {{- if .Values.sentinel.persistence.sizeLimit }}
  687. sizeLimit: {{ .Values.sentinel.persistence.sizeLimit | quote }}
  688. {{- end }}
  689. {{- else }}
  690. emptyDir: {}
  691. {{- end }}
  692. - name: tmp
  693. {{- if or .Values.sentinel.persistence.medium .Values.sentinel.persistence.sizeLimit }}
  694. emptyDir:
  695. {{- if .Values.sentinel.persistence.medium }}
  696. medium: {{ .Values.sentinel.persistence.medium | quote }}
  697. {{- end }}
  698. {{- if .Values.sentinel.persistence.sizeLimit }}
  699. sizeLimit: {{ .Values.sentinel.persistence.sizeLimit | quote }}
  700. {{- end }}
  701. {{- else }}
  702. emptyDir: {}
  703. {{- end }}
  704. {{- if .Values.replica.extraVolumes }}
  705. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumes "context" $ ) | nindent 8 }}
  706. {{- end }}
  707. {{- if .Values.metrics.extraVolumes }}
  708. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumes "context" $ ) | nindent 8 }}
  709. {{- end }}
  710. {{- if .Values.sentinel.extraVolumes }}
  711. {{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.extraVolumes "context" $ ) | nindent 8 }}
  712. {{- end }}
  713. {{- if .Values.tls.enabled }}
  714. - name: redis-certificates
  715. secret:
  716. secretName: {{ include "redis.tlsSecretName" . }}
  717. defaultMode: 256
  718. {{- end }}
  719. {{- if not .Values.replica.persistence.enabled }}
  720. - name: redis-data
  721. {{- if or .Values.sentinel.persistence.medium .Values.sentinel.persistence.sizeLimit }}
  722. emptyDir:
  723. {{- if .Values.sentinel.persistence.medium }}
  724. medium: {{ .Values.sentinel.persistence.medium | quote }}
  725. {{- end }}
  726. {{- if .Values.sentinel.persistence.sizeLimit }}
  727. sizeLimit: {{ .Values.sentinel.persistence.sizeLimit | quote }}
  728. {{- end }}
  729. {{- else }}
  730. emptyDir: {}
  731. {{- end }}
  732. {{- else if .Values.replica.persistence.existingClaim }}
  733. - name: redis-data
  734. persistentVolumeClaim:
  735. claimName: {{ printf "%s" (tpl .Values.replica.persistence.existingClaim .) }}
  736. {{- else }}
  737. volumeClaimTemplates:
  738. - metadata:
  739. name: redis-data
  740. labels: {{- include "common.labels.matchLabels" . | nindent 10 }}
  741. app.kubernetes.io/component: node
  742. {{- if .Values.replica.persistence.annotations }}
  743. annotations: {{- toYaml .Values.replica.persistence.annotations | nindent 10 }}
  744. {{- end }}
  745. spec:
  746. accessModes:
  747. {{- range .Values.replica.persistence.accessModes }}
  748. - {{ . | quote }}
  749. {{- end }}
  750. resources:
  751. requests:
  752. storage: {{ .Values.replica.persistence.size | quote }}
  753. {{- if .Values.replica.persistence.selector }}
  754. selector: {{- include "common.tplvalues.render" ( dict "value" .Values.replica.persistence.selector "context" $) | nindent 10 }}
  755. {{- end }}
  756. {{- include "common.storage.class" (dict "persistence" .Values.replica.persistence "global" .Values.global) | nindent 8 }}
  757. {{- if .Values.sentinel.persistence.enabled }}
  758. - metadata:
  759. name: sentinel-data
  760. labels: {{- include "common.labels.matchLabels" . | nindent 10 }}
  761. app.kubernetes.io/component: node
  762. {{- if .Values.sentinel.persistence.labels }}
  763. {{- toYaml .Values.sentinel.persistence.labels | nindent 4 }}
  764. {{- end }}
  765. {{- if .Values.sentinel.persistence.annotations }}
  766. annotations: {{- toYaml .Values.sentinel.persistence.annotations | nindent 10 }}
  767. {{- end }}
  768. spec:
  769. accessModes:
  770. {{- range .Values.sentinel.persistence.accessModes }}
  771. - {{ . | quote }}
  772. {{- end }}
  773. resources:
  774. requests:
  775. storage: {{ .Values.sentinel.persistence.size | quote }}
  776. {{- if .Values.sentinel.persistence.selector }}
  777. selector: {{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.persistence.selector "context" $) | nindent 10 }}
  778. {{- end }}
  779. {{- if .Values.sentinel.persistence.dataSource }}
  780. dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.persistence.dataSource "context" $) | nindent 10 }}
  781. {{- end }}
  782. {{- include "common.storage.class" (dict "persistence" .Values.sentinel.persistence "global" .Values.global) | nindent 8 }}
  783. {{- end }}
  784. {{- end }}
  785. {{- end }}
  786. {{- end }}