github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/thanos/templates/ruler/statefulset.yaml (about) 1 {{- $query := (include "thanos.query.values" . | fromYaml) -}} 2 {{- if .Values.ruler.enabled }} 3 apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }} 4 kind: StatefulSet 5 metadata: 6 name: {{ include "common.names.fullname" . }}-ruler 7 namespace: {{ .Release.Namespace | quote }} 8 labels: {{- include "common.labels.standard" . | nindent 4 }} 9 app.kubernetes.io/component: ruler 10 {{- if .Values.commonLabels }} 11 {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} 12 {{- end }} 13 {{- if .Values.commonAnnotations }} 14 annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} 15 {{- end }} 16 spec: 17 {{- if not .Values.ruler.autoscaling.enabled }} 18 replicas: {{ .Values.ruler.replicaCount }} 19 {{- end }} 20 podManagementPolicy: {{ .Values.ruler.podManagementPolicy }} 21 serviceName: {{ include "common.names.fullname" . }}-ruler-headless 22 {{- if .Values.ruler.updateStrategy }} 23 updateStrategy: {{- toYaml .Values.ruler.updateStrategy | nindent 4 }} 24 {{- end }} 25 selector: 26 matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} 27 app.kubernetes.io/component: ruler 28 template: 29 metadata: 30 labels: {{- include "common.labels.standard" . | nindent 8 }} 31 app.kubernetes.io/component: ruler 32 {{- if .Values.commonLabels }} 33 {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }} 34 {{- end }} 35 {{- if .Values.ruler.podLabels }} 36 {{- include "common.tplvalues.render" (dict "value" .Values.ruler.podLabels "context" $) | nindent 8 }} 37 {{- end }} 38 annotations: 39 checksum/objstore-configuration: {{ include (print $.Template.BasePath "/objstore-secret.yaml") . | sha256sum }} 40 checksum/ruler-configuration: {{ include (print $.Template.BasePath "/ruler/configmap.yaml") . | sha256sum }} 41 {{- if .Values.ruler.podAnnotations }} 42 {{- include "common.tplvalues.render" (dict "value" .Values.ruler.podAnnotations "context" $) | nindent 8 }} 43 {{- end }} 44 spec: 45 {{- include "thanos.imagePullSecrets" . | nindent 6 }} 46 serviceAccount: {{ include "thanos.serviceAccountName" (dict "component" "ruler" "context" $) }} 47 automountServiceAccountToken: {{ .Values.ruler.automountServiceAccountToken }} 48 {{- if .Values.ruler.hostAliases }} 49 hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.hostAliases "context" $) | nindent 8 }} 50 {{- end }} 51 {{- if .Values.ruler.affinity }} 52 affinity: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.affinity "context" $) | nindent 8 }} 53 {{- else }} 54 affinity: 55 podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.ruler.podAffinityPreset "component" "ruler" "context" $) | nindent 10 }} 56 podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.ruler.podAntiAffinityPreset "component" "ruler" "context" $) | nindent 10 }} 57 nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.ruler.nodeAffinityPreset.type "key" .Values.ruler.nodeAffinityPreset.key "values" .Values.ruler.nodeAffinityPreset.values) | nindent 10 }} 58 {{- end }} 59 {{- if .Values.ruler.nodeSelector }} 60 nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.nodeSelector "context" $) | nindent 8 }} 61 {{- end }} 62 {{- if .Values.ruler.tolerations }} 63 tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.tolerations "context" $) | nindent 8 }} 64 {{- end }} 65 {{- if .Values.ruler.priorityClassName }} 66 priorityClassName: {{ .Values.ruler.priorityClassName | quote }} 67 {{- end }} 68 {{- if .Values.ruler.schedulerName }} 69 schedulerName: {{ .Values.ruler.schedulerName }} 70 {{- end }} 71 {{- if .Values.ruler.podSecurityContext.enabled }} 72 securityContext: {{- omit .Values.ruler.podSecurityContext "enabled" | toYaml | nindent 8 }} 73 {{- end }} 74 {{- if .Values.ruler.topologySpreadConstraints }} 75 topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.topologySpreadConstraints "context" $) | nindent 8 }} 76 {{- end }} 77 {{- if or .Values.ruler.initContainers (and .Values.volumePermissions.enabled .Values.ruler.persistence.enabled) }} 78 initContainers: 79 {{- if and .Values.volumePermissions.enabled .Values.ruler.persistence.enabled }} 80 - name: init-chmod-data 81 image: {{ include "thanos.volumePermissions.image" . }} 82 imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }} 83 command: 84 - sh 85 - -c 86 - | 87 mkdir -p /data 88 chown -R "{{ .Values.ruler.containerSecurityContext.runAsUser }}:{{ .Values.ruler.podSecurityContext.fsGroup }}" /data 89 securityContext: 90 runAsUser: 0 91 volumeMounts: 92 - name: data 93 mountPath: /data 94 {{- end }} 95 {{- if .Values.ruler.initContainers }} 96 {{- include "common.tplvalues.render" (dict "value" .Values.ruler.initContainers "context" $) | nindent 8 }} 97 {{- end }} 98 {{- end }} 99 containers: 100 {{- if .Values.ruler.sidecars }} 101 {{- include "common.tplvalues.render" (dict "value" .Values.ruler.sidecars "context" $) | nindent 8 }} 102 {{- end }} 103 - name: ruler 104 image: {{ include "thanos.image" . }} 105 imagePullPolicy: {{ .Values.image.pullPolicy | quote }} 106 {{- if .Values.ruler.containerSecurityContext.enabled }} 107 securityContext: {{- omit .Values.ruler.containerSecurityContext "enabled" | toYaml | nindent 12 }} 108 {{- end }} 109 {{- if .Values.ruler.command }} 110 command: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.command "context" $) | nindent 12 }} 111 {{- end }} 112 args: 113 {{- if .Values.ruler.args }} 114 {{- include "common.tplvalues.render" (dict "value" .Values.ruler.args "context" $) | nindent 12 }} 115 {{- else }} 116 - rule 117 - --log.level={{ .Values.ruler.logLevel }} 118 - --log.format={{ .Values.ruler.logFormat }} 119 - --grpc-address=0.0.0.0:10901 120 - --http-address=0.0.0.0:10902 121 - --data-dir=/data 122 - --eval-interval={{ .Values.ruler.evalInterval }} 123 {{- if (include "thanos.httpConfigEnabled" .) }} 124 - --http.config=/conf/http/http-config.yml 125 {{- end }} 126 {{- range .Values.ruler.alertmanagers }} 127 - --alertmanagers.url={{ . }} 128 {{- end }} 129 {{- if .Values.ruler.alertmanagersConfig }} 130 - --alertmanagers.config-file=/conf/alertmanagers/alertmanagers_config.yml 131 {{- end }} 132 {{- if and $query.enabled .Values.ruler.dnsDiscovery.enabled }} 133 - --query=dnssrv+_http._tcp.{{ include "common.names.fullname" . }}-query.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }} 134 {{- end }} 135 - --label={{ .Values.ruler.replicaLabel }}="$(POD_NAME)" 136 - --label=ruler_cluster="{{ .Values.ruler.clusterName }}" 137 - --alert.label-drop={{ .Values.ruler.replicaLabel }} 138 - --objstore.config-file=/conf/objstore/objstore.yml 139 - --rule-file=/conf/rules/*.yaml 140 {{- range .Values.ruler.queries }} 141 - --query={{ . }} 142 {{- end }} 143 {{- if .Values.ruler.extraFlags }} 144 {{- .Values.ruler.extraFlags | toYaml | nindent 12 }} 145 {{- end }} 146 {{- end }} 147 env: 148 - name: POD_NAME 149 valueFrom: 150 fieldRef: 151 fieldPath: metadata.name 152 {{- if .Values.ruler.extraEnvVars }} 153 {{- include "common.tplvalues.render" (dict "value" .Values.ruler.extraEnvVars "context" $) | nindent 12 }} 154 {{- end }} 155 {{- if or .Values.ruler.extraEnvVarsCM .Values.ruler.extraEnvVarsSecret }} 156 envFrom: 157 {{- if .Values.ruler.extraEnvVarsCM }} 158 - configMapRef: 159 name: {{ include "common.tplvalues.render" (dict "value" .Values.ruler.extraEnvVarsCM "context" $) }} 160 {{- end }} 161 {{- if .Values.ruler.extraEnvVarsSecret }} 162 - secretRef: 163 name: {{ include "common.tplvalues.render" (dict "value" .Values.ruler.extraEnvVarsSecret "context" $) }} 164 {{- end }} 165 {{- end }} 166 ports: 167 - name: http 168 containerPort: 10902 169 protocol: TCP 170 - name: grpc 171 containerPort: 10901 172 protocol: TCP 173 {{- if .Values.ruler.customLivenessProbe }} 174 livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.customLivenessProbe "context" $) | nindent 12 }} 175 {{- else if .Values.ruler.livenessProbe.enabled }} 176 livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.ruler.livenessProbe "enabled") "context" $) | nindent 12 }} 177 {{- if not .Values.auth.basicAuthUsers }} 178 httpGet: 179 path: /-/healthy 180 port: http 181 scheme: {{ ternary "HTTPS" "HTTP" .Values.https.enabled }} 182 {{- else }} 183 tcpSocket: 184 port: http 185 {{- end }} 186 {{- end }} 187 {{- if .Values.ruler.customReadinessProbe }} 188 readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.customReadinessProbe "context" $) | nindent 12 }} 189 {{- else if .Values.ruler.readinessProbe.enabled }} 190 readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.ruler.readinessProbe "enabled") "context" $) | nindent 12 }} 191 {{- if not .Values.auth.basicAuthUsers }} 192 httpGet: 193 path: /-/ready 194 port: http 195 scheme: {{ ternary "HTTPS" "HTTP" .Values.https.enabled }} 196 {{- else }} 197 tcpSocket: 198 port: http 199 {{- end }} 200 {{- end }} 201 {{- if .Values.ruler.customStartupProbe }} 202 startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.customStartupProbe "context" $) | nindent 12 }} 203 {{- else if .Values.ruler.startupProbe.enabled }} 204 startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.ruler.startupProbe "enabled") "context" $) | nindent 12 }} 205 {{- if not .Values.auth.basicAuthUsers }} 206 httpGet: 207 path: /-/ready 208 port: http 209 scheme: {{ ternary "HTTPS" "HTTP" .Values.https.enabled }} 210 {{- else }} 211 tcpSocket: 212 port: http 213 {{- end }} 214 {{- end }} 215 {{- if .Values.ruler.lifecycleHooks }} 216 lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.ruler.lifecycleHooks "context" $) | nindent 12 }} 217 {{- end }} 218 {{- if .Values.ruler.resources }} 219 resources: {{- toYaml .Values.ruler.resources | nindent 12 }} 220 {{- end }} 221 volumeMounts: 222 - name: ruler-config 223 mountPath: /conf/rules 224 - name: objstore-config 225 mountPath: /conf/objstore 226 {{- if (include "thanos.httpConfigEnabled" .) }} 227 - name: http-config 228 mountPath: /conf/http 229 {{- if .Values.https.enabled }} 230 - name: http-certs 231 mountPath: /certs 232 {{- end }} 233 {{- end }} 234 - name: data 235 mountPath: /data 236 {{- if .Values.ruler.alertmanagersConfig }} 237 - name: alertmanagers-config 238 mountPath: /conf/alertmanagers 239 {{- end }} 240 {{- if .Values.ruler.extraVolumeMounts }} 241 {{- include "common.tplvalues.render" (dict "value" .Values.ruler.extraVolumeMounts "context" $) | nindent 12 }} 242 {{- end }} 243 volumes: 244 - name: ruler-config 245 configMap: 246 name: {{ include "thanos.ruler.configmapName" . }} 247 - name: objstore-config 248 secret: 249 secretName: {{ include "thanos.objstoreSecretName" . }} 250 {{- if .Values.existingObjstoreSecretItems }} 251 items: {{- toYaml .Values.existingObjstoreSecretItems | nindent 14 }} 252 {{- end }} 253 {{- if (include "thanos.httpConfigEnabled" .) }} 254 - name: http-config 255 secret: 256 secretName: {{ include "thanos.httpConfigSecretName" . }} 257 {{- if .Values.https.enabled }} 258 - name: http-certs 259 secret: 260 secretName: {{ include "thanos.httpCertsSecretName" . }} 261 {{- end }} 262 {{- end }} 263 {{- if .Values.ruler.alertmanagersConfig }} 264 - name: alertmanagers-config 265 secret: 266 secretName: {{ include "common.names.fullname" . }}-ruler-alertmanagers-config 267 {{- end }} 268 {{- if .Values.ruler.extraVolumes }} 269 {{- include "common.tplvalues.render" (dict "value" .Values.ruler.extraVolumes "context" $) | nindent 8 }} 270 {{- end }} 271 {{- if and .Values.ruler.persistence.enabled .Values.ruler.persistence.existingClaim }} 272 - name: data 273 persistentVolumeClaim: 274 claimName: {{ .Values.ruler.persistence.existingClaim }} 275 {{- else if not .Values.ruler.persistence.enabled }} 276 - name: data 277 emptyDir: {} 278 {{- else if and .Values.ruler.persistence.enabled (not .Values.ruler.persistence.existingClaim) }} 279 volumeClaimTemplates: 280 - metadata: 281 name: data 282 {{- if .Values.ruler.persistence.annotations }} 283 annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.ruler.persistence.annotations "context" $) | nindent 10 }} 284 {{- end }} 285 spec: 286 accessModes: 287 {{- range .Values.ruler.persistence.accessModes }} 288 - {{ . | quote }} 289 {{- end }} 290 resources: 291 requests: 292 storage: {{ .Values.ruler.persistence.size | quote }} 293 {{- include "common.storage.class" (dict "persistence" .Values.ruler.persistence "global" .Values.global) | nindent 8 }} 294 {{- end }} 295 {{- end }}