statefulset-memcached-chunks.yaml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. {{- if .Values.memcachedChunks.enabled }}
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. name: {{ include "loki.memcachedChunksFullname" . }}
  6. namespace: {{ .Release.Namespace }}
  7. labels:
  8. {{- include "loki.memcachedChunksLabels" . | nindent 4 }}
  9. {{- with .Values.loki.annotations }}
  10. annotations:
  11. {{- toYaml . | nindent 4 }}
  12. {{- end }}
  13. spec:
  14. replicas: {{ .Values.memcachedChunks.replicas }}
  15. updateStrategy:
  16. rollingUpdate:
  17. partition: 0
  18. serviceName: {{ include "loki.memcachedChunksFullname" . }}
  19. revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
  20. selector:
  21. matchLabels:
  22. {{- include "loki.memcachedChunksSelectorLabels" . | nindent 6 }}
  23. template:
  24. metadata:
  25. {{- if or .Values.loki.podAnnotations .Values.memcachedChunks.podAnnotations }}
  26. annotations:
  27. {{- with .Values.loki.podAnnotations }}
  28. {{- toYaml . | nindent 8 }}
  29. {{- end }}
  30. {{- with .Values.memcachedChunks.podAnnotations }}
  31. {{- toYaml . | nindent 8 }}
  32. {{- end }}
  33. {{- end }}
  34. labels:
  35. {{- include "loki.memcachedChunksSelectorLabels" . | nindent 8 }}
  36. {{- with .Values.loki.podLabels }}
  37. {{- toYaml . | nindent 8 }}
  38. {{- end }}
  39. {{- with .Values.memcachedChunks.podLabels }}
  40. {{- toYaml . | nindent 8 }}
  41. {{- end }}
  42. spec:
  43. serviceAccountName: {{ include "loki.serviceAccountName" . }}
  44. {{- with .Values.imagePullSecrets }}
  45. imagePullSecrets:
  46. {{- toYaml . | nindent 8 }}
  47. {{- end }}
  48. {{- with .Values.memcachedChunks.hostAliases }}
  49. hostAliases:
  50. {{- toYaml . | nindent 8 }}
  51. {{- end }}
  52. {{- include "loki.memcachedChunksPriorityClassName" . | nindent 6 }}
  53. securityContext:
  54. {{- toYaml .Values.memcached.podSecurityContext | nindent 8 }}
  55. terminationGracePeriodSeconds: {{ .Values.memcachedChunks.terminationGracePeriodSeconds }}
  56. containers:
  57. - name: memcached
  58. {{- if .Values.memcachedChunks.persistence.enabled }}
  59. lifecycle:
  60. preStop:
  61. exec:
  62. command:
  63. - /bin/sh
  64. - -ec
  65. - |
  66. /usr/bin/pkill -10 memcached
  67. sleep 60s
  68. {{- end }}
  69. image: {{ include "loki.memcachedImage" . }}
  70. imagePullPolicy: {{ .Values.memcached.image.pullPolicy }}
  71. {{- if or .Values.memcachedChunks.extraArgs .Values.memcachedChunks.persistence.enabled }}
  72. args:
  73. {{- if .Values.memcachedChunks.persistence.enabled }}
  74. - --memory-file=/cache-state/memory_file
  75. {{- end }}
  76. {{- with .Values.memcachedChunks.extraArgs }}
  77. {{- toYaml . | nindent 12 }}
  78. {{- end }}
  79. {{- end }}
  80. ports:
  81. - name: http
  82. containerPort: 11211
  83. protocol: TCP
  84. {{- with .Values.memcachedChunks.extraEnv }}
  85. env:
  86. {{- toYaml . | nindent 12 }}
  87. {{- end }}
  88. {{- with .Values.memcachedChunks.extraEnvFrom }}
  89. envFrom:
  90. {{- toYaml . | nindent 12 }}
  91. {{- end }}
  92. securityContext:
  93. {{- toYaml .Values.memcached.containerSecurityContext | nindent 12 }}
  94. readinessProbe:
  95. {{- toYaml .Values.memcached.readinessProbe | nindent 12 }}
  96. livenessProbe:
  97. {{- toYaml .Values.memcached.livenessProbe | nindent 12 }}
  98. {{- if or .Values.memcachedChunks.persistence.enabled .Values.memcachedChunks.extraVolumeMounts }}
  99. volumeMounts:
  100. {{- if .Values.memcachedChunks.persistence.enabled }}
  101. - name: data
  102. mountPath: /cache-state
  103. {{- end }}
  104. {{- if .Values.memcachedChunks.extraVolumeMounts }}
  105. {{- toYaml .Values.memcachedChunks.extraVolumeMounts | nindent 12 }}
  106. {{- end }}
  107. {{- end }}
  108. resources:
  109. {{- toYaml .Values.memcachedChunks.resources | nindent 12 }}
  110. {{- if .Values.memcachedExporter.enabled }}
  111. - name: exporter
  112. args:
  113. - --memcached.address=localhost:11211
  114. - --web.listen-address=0.0.0.0:9150
  115. image: {{ include "loki.memcachedExporterImage" . }}
  116. imagePullPolicy: {{ .Values.memcachedExporter.image.pullPolicy }}
  117. ports:
  118. - name: http-metrics
  119. containerPort: 9150
  120. protocol: TCP
  121. securityContext:
  122. {{- toYaml .Values.memcachedExporter.containerSecurityContext | nindent 12 }}
  123. resources:
  124. {{- toYaml .Values.memcachedExporter.resources | nindent 12 }}
  125. {{- end }}
  126. {{- if .Values.memcachedChunks.extraContainers }}
  127. {{- toYaml .Values.memcachedChunks.extraContainers | nindent 8}}
  128. {{- end }}
  129. {{- with .Values.memcachedChunks.affinity }}
  130. affinity:
  131. {{- tpl . $ | nindent 8 }}
  132. {{- end }}
  133. {{- with .Values.memcachedChunks.nodeSelector }}
  134. nodeSelector:
  135. {{- toYaml . | nindent 8 }}
  136. {{- end }}
  137. {{- with .Values.memcachedChunks.tolerations }}
  138. tolerations:
  139. {{- toYaml . | nindent 8 }}
  140. {{- end }}
  141. {{- if or .Values.memcachedChunks.persistence.enabled .Values.memcachedChunks.volumeClaimTemplates }}
  142. volumeClaimTemplates:
  143. {{- if .Values.memcachedChunks.persistence.enabled }}
  144. - metadata:
  145. name: data
  146. spec:
  147. accessModes:
  148. - ReadWriteOnce
  149. {{- with .Values.memcachedChunks.persistence.storageClass }}
  150. storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
  151. {{- end }}
  152. resources:
  153. requests:
  154. storage: {{ .Values.memcachedChunks.persistence.size | quote }}
  155. {{- end }}
  156. {{- with .Values.memcachedChunks.volumeClaimTemplates }}
  157. {{- toYaml . | nindent 4 }}
  158. {{- end }}
  159. {{- end }}
  160. {{- end }}