statefulset-memcached-frontend.yaml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. {{- if .Values.memcachedFrontend.enabled }}
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. name: {{ include "loki.memcachedFrontendFullname" . }}
  6. namespace: {{ .Release.Namespace }}
  7. labels:
  8. {{- include "loki.memcachedFrontendLabels" . | nindent 4 }}
  9. {{- with .Values.loki.annotations }}
  10. annotations:
  11. {{- toYaml . | nindent 4 }}
  12. {{- end }}
  13. spec:
  14. replicas: {{ .Values.memcachedFrontend.replicas }}
  15. updateStrategy:
  16. rollingUpdate:
  17. partition: 0
  18. serviceName: {{ include "loki.memcachedFrontendFullname" . }}
  19. revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
  20. selector:
  21. matchLabels:
  22. {{- include "loki.memcachedFrontendSelectorLabels" . | nindent 6 }}
  23. template:
  24. metadata:
  25. {{- if or .Values.loki.podAnnotations .Values.memcachedFrontend.podAnnotations }}
  26. annotations:
  27. {{- with .Values.loki.podAnnotations }}
  28. {{- toYaml . | nindent 8 }}
  29. {{- end }}
  30. {{- with .Values.memcachedFrontend.podAnnotations }}
  31. {{- toYaml . | nindent 8 }}
  32. {{- end }}
  33. {{- end }}
  34. labels:
  35. {{- include "loki.memcachedFrontendSelectorLabels" . | nindent 8 }}
  36. {{- with .Values.loki.podLabels }}
  37. {{- toYaml . | nindent 8 }}
  38. {{- end }}
  39. {{- with .Values.memcachedFrontend.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.memcachedFrontend.hostAliases }}
  49. hostAliases:
  50. {{- toYaml . | nindent 8 }}
  51. {{- end }}
  52. {{- include "loki.memcachedFrontendPriorityClassName" . | nindent 6 }}
  53. securityContext:
  54. {{- toYaml .Values.memcached.podSecurityContext | nindent 8 }}
  55. terminationGracePeriodSeconds: {{ .Values.memcachedFrontend.terminationGracePeriodSeconds }}
  56. containers:
  57. - name: memcached
  58. {{- if .Values.memcachedFrontend.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.memcachedFrontend.extraArgs .Values.memcachedFrontend.persistence.enabled }}
  72. args:
  73. {{- if .Values.memcachedFrontend.persistence.enabled }}
  74. - --memory-file=/cache-state/memory_file
  75. {{- end }}
  76. {{- with .Values.memcachedFrontend.extraArgs }}
  77. {{- toYaml . | nindent 12 }}
  78. {{- end }}
  79. {{- end }}
  80. ports:
  81. - name: http
  82. containerPort: 11211
  83. protocol: TCP
  84. {{- with .Values.memcachedFrontend.extraEnv }}
  85. env:
  86. {{- toYaml . | nindent 12 }}
  87. {{- end }}
  88. {{- with .Values.memcachedFrontend.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 .Values.memcachedFrontend.persistence.enabled }}
  99. volumeMounts:
  100. - name: data
  101. mountPath: /cache-state
  102. {{- end }}
  103. resources:
  104. {{- toYaml .Values.memcachedFrontend.resources | nindent 12 }}
  105. {{- if .Values.memcachedExporter.enabled }}
  106. - name: exporter
  107. args:
  108. - --memcached.address=localhost:11211
  109. - --web.listen-address=0.0.0.0:9150
  110. image: {{ include "loki.memcachedExporterImage" . }}
  111. imagePullPolicy: {{ .Values.memcachedExporter.image.pullPolicy }}
  112. ports:
  113. - name: http-metrics
  114. containerPort: 9150
  115. protocol: TCP
  116. securityContext:
  117. {{- toYaml .Values.memcachedExporter.containerSecurityContext | nindent 12 }}
  118. resources:
  119. {{- toYaml .Values.memcachedExporter.resources | nindent 12 }}
  120. {{- end }}
  121. {{- if .Values.memcachedFrontend.extraContainers }}
  122. {{- toYaml .Values.memcachedFrontend.extraContainers | nindent 8}}
  123. {{- end }}
  124. {{- with .Values.memcachedFrontend.affinity }}
  125. affinity:
  126. {{- tpl . $ | nindent 8 }}
  127. {{- end }}
  128. {{- with .Values.memcachedFrontend.nodeSelector }}
  129. nodeSelector:
  130. {{- toYaml . | nindent 8 }}
  131. {{- end }}
  132. {{- with .Values.memcachedFrontend.tolerations }}
  133. tolerations:
  134. {{- toYaml . | nindent 8 }}
  135. {{- end }}
  136. {{- if .Values.memcachedFrontend.persistence.enabled }}
  137. volumeClaimTemplates:
  138. - metadata:
  139. name: data
  140. spec:
  141. accessModes:
  142. - ReadWriteOnce
  143. {{- with .Values.memcachedFrontend.persistence.storageClass }}
  144. storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
  145. {{- end }}
  146. resources:
  147. requests:
  148. storage: {{ .Values.memcachedFrontend.persistence.size | quote }}
  149. {{- end }}
  150. {{- end }}