added repo

This commit is contained in:
Your Name
2026-08-26 03:39:42 +05:30
parent 45c25a95af
commit b8575bb8b9
6889 changed files with 1217125 additions and 0 deletions
@@ -0,0 +1,36 @@
{{ if .Values.enterprise.enabled }}
Welcome to Grafana Enterprise Metrics!
{{- else }}
Welcome to Grafana Mimir!
{{- end }}
{{- $gateway := .Values.nginx }}
{{- if eq (include "mimir.gateway.isEnabled" .) "true" }}
{{- $gateway = .Values.gateway }}
{{- end }}
Remote write endpoints for Prometheus or Grafana Agent:
{{ with $gateway.ingress -}}
{{- if .enabled -}}
From outside the cluster via ingress:
{{ range .hosts }} http{{ if .tls }}s{{ end }}://{{ .host }}/api/v1/push
{{ end }}
{{- else -}}
Ingress is not enabled, see the {{ if eq (include "mimir.gateway.isEnabled" $) "true" }}gateway{{ else }}nginx{{ end }}.ingress values.
{{- end -}}
{{- end }}
From inside the cluster:
{{ include "mimir.remoteWriteUrl.inCluster" $ }}
Read address, Grafana data source (Prometheus) URL:
{{ with $gateway.ingress -}}
{{- if .enabled -}}
From outside the cluster via ingress:
{{ range .hosts }} http{{ if .tls }}s{{ end }}://{{ .host }}{{ template "mimir.prometheusHttpPrefix" $ }}
{{ end }}
{{- else -}}
Ingress is not enabled, see the {{ if eq (include "mimir.gateway.isEnabled" $) "true" }}gateway{{ else }}nginx{{ end }}.ingress values.
{{- end -}}
{{- end }}
From inside the cluster:
{{ include "mimir.gatewayUrl" $ }}{{ template "mimir.prometheusHttpPrefix" $ }}
**IMPORTANT**: Always consult CHANGELOG.md file at https://github.com/grafana/mimir/blob/main/operations/helm/charts/mimir-distributed/CHANGELOG.md and the deprecation list there to learn about breaking changes that require action during upgrade.
@@ -0,0 +1 @@
{{- tpl .Values.mimir.config . -}}
@@ -0,0 +1,702 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "mimir.name" -}}
{{- default ( include "mimir.infixName" . ) .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "mimir.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default ( include "mimir.infixName" . ) .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Calculate the infix for naming
*/}}
{{- define "mimir.infixName" -}}
{{- if and .Values.enterprise.enabled .Values.enterprise.legacyLabels -}}enterprise-metrics{{- else -}}mimir{{- end -}}
{{- end -}}
{{/*
Calculate the gateway url
*/}}
{{- define "mimir.gatewayUrl" -}}
{{- if eq (include "mimir.gateway.isEnabled" . ) "true" -}}
http://{{ include "mimir.gateway.service.name" . }}.{{ .Release.Namespace }}.svc:{{ .Values.gateway.service.port | default (include "mimir.serverHttpListenPort" . ) }}
{{- else -}}
http://{{ template "mimir.fullname" . }}-nginx.{{ .Release.Namespace }}.svc:{{ .Values.nginx.service.port }}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "mimir.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Calculate image name based on whether enterprise features are requested
*/}}
{{- define "mimir.imageReference" -}}
{{- if .Values.enterprise.enabled -}}{{ .Values.enterprise.image.repository }}:{{ .Values.enterprise.image.tag }}{{- else -}}{{ .Values.image.repository }}:{{ .Values.image.tag }}{{- end -}}
{{- end -}}
{{/*
For compatibility and to support upgrade from enterprise-metrics chart calculate minio bucket name
*/}}
{{- define "mimir.minioBucketPrefix" -}}
{{- if .Values.enterprise.legacyLabels -}}enterprise-metrics{{- else -}}mimir{{- end -}}
{{- end -}}
{{/*
Create the name of the general service account
*/}}
{{- define "mimir.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "mimir.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Create the name of the ruler service account
*/}}
{{- define "mimir.ruler.serviceAccountName" -}}
{{- if and .Values.ruler.serviceAccount.create (eq .Values.ruler.serviceAccount.name "") -}}
{{- $sa := default (include "mimir.fullname" .) .Values.serviceAccount.name }}
{{- printf "%s-%s" $sa "ruler" }}
{{- else if and .Values.ruler.serviceAccount.create (not (eq .Values.ruler.serviceAccount.name "")) -}}
{{- .Values.ruler.serviceAccount.name -}}
{{- else -}}
{{- include "mimir.serviceAccountName" . -}}
{{- end -}}
{{- end -}}
{{/*
Create the app name for clients. Defaults to the same logic as "mimir.fullname", and default client expects "prometheus".
*/}}
{{- define "client.name" -}}
{{- if .Values.client.name -}}
{{- .Values.client.name -}}
{{- else if .Values.client.fullnameOverride -}}
{{- .Values.client.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default "prometheus" .Values.client.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Calculate the config from structured and unstructured text input
*/}}
{{- define "mimir.calculatedConfig" -}}
{{ tpl (mergeOverwrite (include "mimir.unstructuredConfig" . | fromYaml) .Values.mimir.structuredConfig | toYaml) . }}
{{- end -}}
{{/*
Calculate the config from the unstructured text input
*/}}
{{- define "mimir.unstructuredConfig" -}}
{{ include (print $.Template.BasePath "/_config-render.tpl") . }}
{{- end -}}
{{/*
The volume to mount for mimir configuration
*/}}
{{- define "mimir.configVolume" -}}
{{- if eq .Values.configStorageType "Secret" -}}
secret:
secretName: {{ tpl .Values.externalConfigSecretName . }}
{{- else if eq .Values.configStorageType "ConfigMap" -}}
configMap:
name: {{ tpl .Values.externalConfigSecretName . }}
items:
- key: "mimir.yaml"
path: "mimir.yaml"
{{- end -}}
{{- end -}}
{{/*
Internal servers http listen port - derived from Mimir default
*/}}
{{- define "mimir.serverHttpListenPort" -}}
{{ (((.Values.mimir).structuredConfig).server).http_listen_port | default "8080" }}
{{- end -}}
{{/*
Internal servers grpc listen port - derived from Mimir default
*/}}
{{- define "mimir.serverGrpcListenPort" -}}
{{ (((.Values.mimir).structuredConfig).server).grpc_listen_port | default "9095" }}
{{- end -}}
{{/*
Alertmanager cluster bind address
*/}}
{{- define "mimir.alertmanagerClusterBindAddress" -}}
{{- if (include "mimir.calculatedConfig" . | fromYaml).alertmanager -}}
{{ (include "mimir.calculatedConfig" . | fromYaml).alertmanager.cluster_bind_address | default "" }}
{{- end -}}
{{- end -}}
{{- define "mimir.chunksCacheAddress" -}}
dns+{{ template "mimir.fullname" . }}-chunks-cache.{{ .Release.Namespace }}.svc:{{ (index .Values "chunks-cache").port }}
{{- end -}}
{{- define "mimir.indexCacheAddress" -}}
dns+{{ template "mimir.fullname" . }}-index-cache.{{ .Release.Namespace }}.svc:{{ (index .Values "index-cache").port }}
{{- end -}}
{{- define "mimir.metadataCacheAddress" -}}
dns+{{ template "mimir.fullname" . }}-metadata-cache.{{ .Release.Namespace }}.svc:{{ (index .Values "metadata-cache").port }}
{{- end -}}
{{- define "mimir.resultsCacheAddress" -}}
dns+{{ template "mimir.fullname" . }}-results-cache.{{ .Release.Namespace }}.svc:{{ (index .Values "results-cache").port }}
{{- end -}}
{{- define "mimir.adminCacheAddress" -}}
dns+{{ template "mimir.fullname" . }}-admin-cache.{{ .Release.Namespace }}.svc:{{ (index .Values "admin-cache").port }}
{{- end -}}
{{/*
Memberlist bind port
*/}}
{{- define "mimir.memberlistBindPort" -}}
{{ (((.Values.mimir).structuredConfig).memberlist).bind_port | default "7946" }}
{{- end -}}
{{/*
Resource name template
Params:
ctx = . context
component = component name (optional)
rolloutZoneName = rollout zone name (optional)
*/}}
{{- define "mimir.resourceName" -}}
{{- $resourceName := include "mimir.fullname" .ctx -}}
{{- if .component -}}{{- $resourceName = printf "%s-%s" $resourceName .component -}}{{- end -}}
{{- if and (not .component) .rolloutZoneName -}}{{- printf "Component name cannot be empty if rolloutZoneName (%s) is set" .rolloutZoneName | fail -}}{{- end -}}
{{- if .rolloutZoneName -}}{{- $resourceName = printf "%s-%s" $resourceName .rolloutZoneName -}}{{- end -}}
{{- if gt (len $resourceName) 253 -}}{{- printf "Resource name (%s) exceeds kubernetes limit of 253 character. To fix: shorten release name if this will be a fresh install or shorten zone names (e.g. \"a\" instead of \"zone-a\") if using zone-awareness." $resourceName | fail -}}{{- end -}}
{{- $resourceName -}}
{{- end -}}
{{/*
Resource labels
Params:
ctx = . context
component = component name (optional)
rolloutZoneName = rollout zone name (optional)
*/}}
{{- define "mimir.labels" -}}
{{- if .ctx.Values.enterprise.legacyLabels }}
{{- if .component -}}
app: {{ include "mimir.name" .ctx }}-{{ .component }}
{{- else -}}
app: {{ include "mimir.name" .ctx }}
{{- end }}
chart: {{ template "mimir.chart" .ctx }}
heritage: {{ .ctx.Release.Service }}
release: {{ .ctx.Release.Name }}
{{- else -}}
helm.sh/chart: {{ include "mimir.chart" .ctx }}
app.kubernetes.io/name: {{ include "mimir.name" .ctx }}
app.kubernetes.io/instance: {{ .ctx.Release.Name }}
{{- if .component }}
app.kubernetes.io/component: {{ .component }}
{{- end }}
{{- if .memberlist }}
app.kubernetes.io/part-of: memberlist
{{- end }}
{{- if .ctx.Chart.AppVersion }}
app.kubernetes.io/version: {{ .ctx.Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .ctx.Release.Service }}
{{- end }}
{{- if .rolloutZoneName }}
{{- if not .component }}
{{- printf "Component name cannot be empty if rolloutZoneName (%s) is set" .rolloutZoneName | fail }}
{{- end }}
name: "{{ .component }}-{{ .rolloutZoneName }}" {{- /* Currently required for rollout-operator. https://github.com/grafana/rollout-operator/issues/15 */}}
rollout-group: {{ .component }}
zone: {{ .rolloutZoneName }}
{{- end }}
{{- end -}}
{{/*
POD labels
Params:
ctx = . context
component = name of the component
memberlist = true if part of memberlist gossip ring
rolloutZoneName = rollout zone name (optional)
*/}}
{{- define "mimir.podLabels" -}}
{{ with .ctx.Values.global.podLabels -}}
{{ toYaml . }}
{{ end }}
{{- if .ctx.Values.enterprise.legacyLabels }}
{{- if .component -}}
app: {{ include "mimir.name" .ctx }}-{{ .component }}
{{- if not .rolloutZoneName }}
name: {{ .component }}
{{- end }}
{{- end }}
{{- if .memberlist }}
gossip_ring_member: "true"
{{- end -}}
{{- if .component }}
target: {{ .component }}
release: {{ .ctx.Release.Name }}
{{- end }}
{{- else -}}
helm.sh/chart: {{ include "mimir.chart" .ctx }}
app.kubernetes.io/name: {{ include "mimir.name" .ctx }}
app.kubernetes.io/instance: {{ .ctx.Release.Name }}
app.kubernetes.io/version: {{ .ctx.Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .ctx.Release.Service }}
{{- if .component }}
app.kubernetes.io/component: {{ .component }}
{{- end }}
{{- if .memberlist }}
app.kubernetes.io/part-of: memberlist
{{- end }}
{{- end }}
{{- $componentSection := include "mimir.componentSectionFromName" . | fromYaml }}
{{- with ($componentSection).podLabels }}
{{ toYaml . }}
{{- end }}
{{- if .rolloutZoneName }}
{{- if not .component }}
{{- printf "Component name cannot be empty if rolloutZoneName (%s) is set" .rolloutZoneName | fail }}
{{- end }}
name: "{{ .component }}-{{ .rolloutZoneName }}" {{- /* Currently required for rollout-operator. https://github.com/grafana/rollout-operator/issues/15 */}}
rollout-group: {{ .component }}
zone: {{ .rolloutZoneName }}
{{- end }}
{{- end -}}
{{/*
POD annotations
Params:
ctx = . context
component = name of the component
*/}}
{{- define "mimir.podAnnotations" -}}
{{- if .ctx.Values.useExternalConfig }}
checksum/config: {{ .ctx.Values.externalConfigVersion | quote }}
{{- else -}}
checksum/config: {{ include (print .ctx.Template.BasePath "/mimir-config.yaml") .ctx | sha256sum }}
{{- end }}
{{- with .ctx.Values.global.podAnnotations }}
{{ toYaml . }}
{{- end }}
{{- if .component }}
{{- if .ctx.Values.vaultAgent.enabled }}
{{- include "mimir.vaultAgent.annotations" (dict "ctx" .ctx "component" .component) }}
{{- end }}
{{- $componentSection := include "mimir.componentSectionFromName" . | fromYaml }}
{{- with ($componentSection).podAnnotations }}
{{ toYaml . }}
{{- end }}
{{- end }}
{{- end -}}
{{/*
Service selector labels
Params:
ctx = . context
component = name of the component
rolloutZoneName = rollout zone name (optional)
*/}}
{{- define "mimir.selectorLabels" -}}
{{- if .ctx.Values.enterprise.legacyLabels }}
{{- if .component -}}
app: {{ include "mimir.name" .ctx }}-{{ .component }}
{{- end }}
release: {{ .ctx.Release.Name }}
{{- else -}}
app.kubernetes.io/name: {{ include "mimir.name" .ctx }}
app.kubernetes.io/instance: {{ .ctx.Release.Name }}
{{- if .component }}
app.kubernetes.io/component: {{ .component }}
{{- end }}
{{- end -}}
{{- if .rolloutZoneName }}
{{- if not .component }}
{{- printf "Component name cannot be empty if rolloutZoneName (%s) is set" .rolloutZoneName | fail }}
{{- end }}
rollout-group: {{ .component }}
zone: {{ .rolloutZoneName }}
{{- end }}
{{- end -}}
{{/*
Alertmanager http prefix
*/}}
{{- define "mimir.alertmanagerHttpPrefix" -}}
{{- if (include "mimir.calculatedConfig" . | fromYaml).api }}
{{- (include "mimir.calculatedConfig" . | fromYaml).api.alertmanager_http_prefix | default "/alertmanager" -}}
{{- else -}}
{{- print "/alertmanager" -}}
{{- end -}}
{{- end -}}
{{/*
Prometheus http prefix
*/}}
{{- define "mimir.prometheusHttpPrefix" -}}
{{- if (include "mimir.calculatedConfig" . | fromYaml).api }}
{{- (include "mimir.calculatedConfig" . | fromYaml).api.prometheus_http_prefix | default "/prometheus" -}}
{{- else -}}
{{- print "/prometheus" -}}
{{- end -}}
{{- end -}}
{{/*
KEDA Autoscaling Prometheus address
*/}}
{{- define "mimir.kedaPrometheusAddress" -}}
{{- if not .ctx.Values.kedaAutoscaling.prometheusAddress -}}
{{ include "mimir.metaMonitoring.metrics.remoteReadUrl" . }}
{{- else -}}
{{ .ctx.Values.kedaAutoscaling.prometheusAddress }}
{{- end -}}
{{- end -}}
{{/*
Cluster name that shows up in dashboard metrics
*/}}
{{- define "mimir.clusterName" -}}
{{ (include "mimir.calculatedConfig" . | fromYaml).cluster_name | default .Release.Name }}
{{- end -}}
{{/* Allow KubeVersion to be overridden. */}}
{{- define "mimir.kubeVersion" -}}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride -}}
{{- end -}}
{{/* Get API Versions */}}
{{- define "mimir.podDisruptionBudget.apiVersion" -}}
{{- if semverCompare ">= 1.21-0" (include "mimir.kubeVersion" .) -}}
{{- print "policy/v1" -}}
{{- else -}}
{{- print "policy/v1beta1" -}}
{{- end -}}
{{- end -}}
{{/*
mimir.componentSectionFromName returns the sections from the user .Values in YAML
that corresponds to the requested component. mimir.componentSectionFromName takes two arguments
.ctx = the root context of the chart
.component = the name of the component. mimir.componentSectionFromName uses an internal mapping to know
which component lives where in the values.yaml
Examples:
$componentSection := include "mimir.componentSectionFromName" (dict "ctx" . "component" "store-gateway") | fromYaml
$componentSection.podLabels ...
*/}}
{{- define "mimir.componentSectionFromName" -}}
{{- $componentsMap := dict
"admin-api" "admin_api"
"admin-cache" "admin-cache"
"alertmanager" "alertmanager"
"chunks-cache" "chunks-cache"
"compactor" "compactor"
"continuous-test" "continuous_test"
"distributor" "distributor"
"gateway" "gateway"
"gr-aggr-cache" "gr-aggr-cache"
"gr-metricname-cache" "gr-metricname-cache"
"graphite-querier" "graphite.querier"
"graphite-write-proxy" "graphite.write_proxy"
"index-cache" "index-cache"
"ingester" "ingester"
"memcached" "memcached"
"metadata-cache" "metadata-cache"
"nginx" "nginx"
"overrides-exporter" "overrides_exporter"
"querier" "querier"
"query-frontend" "query_frontend"
"query-scheduler" "query_scheduler"
"results-cache" "results-cache"
"ruler" "ruler"
"ruler-querier" "ruler_querier"
"ruler-query-frontend" "ruler_query_frontend"
"ruler-query-scheduler" "ruler_query_scheduler"
"smoke-test" "smoke_test"
"store-gateway" "store_gateway"
"tokengen" "tokengenJob"
-}}
{{- $componentSection := index $componentsMap .component -}}
{{- if not $componentSection -}}{{- printf "No component section mapping for %s not found in values; submit a bug report if you are a user, edit mimir.componentSectionFromName if you are a contributor" .component | fail -}}{{- end -}}
{{- $section := .ctx.Values -}}
{{- range regexSplit "\\." $componentSection -1 -}}
{{- $section = index $section . -}}
{{- if not $section -}}{{- printf "Component section %s not found in values; values: %s" . ($.ctx.Values | toJson | abbrev 100) | fail -}}{{- end -}}
{{- end -}}
{{- $section | toYaml -}}
{{- end -}}
{{/*
Return the Vault Agent pod annotations if enabled and required by the component
mimir.vaultAgent.annotations takes 2 arguments
.ctx = the root context of the chart
.component = the name of the component
*/}}
{{- define "mimir.vaultAgent.annotations" -}}
{{- $vaultEnabledComponents := dict
"admin-api" true
"alertmanager" true
"compactor" true
"distributor" true
"gateway" true
"ingester" true
"overrides-exporter" true
"querier" true
"query-frontend" true
"query-scheduler" true
"ruler" true
"store-gateway" true
-}}
{{- if hasKey $vaultEnabledComponents .component }}
vault.hashicorp.com/agent-inject: 'true'
vault.hashicorp.com/role: '{{ .ctx.Values.vaultAgent.roleName }}'
vault.hashicorp.com/agent-inject-secret-client.crt: '{{ .ctx.Values.vaultAgent.clientCertPath }}'
vault.hashicorp.com/agent-inject-secret-client.key: '{{ .ctx.Values.vaultAgent.clientKeyPath }}'
vault.hashicorp.com/agent-inject-secret-server.crt: '{{ .ctx.Values.vaultAgent.serverCertPath }}'
vault.hashicorp.com/agent-inject-secret-server.key: '{{ .ctx.Values.vaultAgent.serverKeyPath }}'
vault.hashicorp.com/agent-inject-secret-root.crt: '{{ .ctx.Values.vaultAgent.caCertPath }}'
{{- end}}
{{- end -}}
{{/*
Get the no_auth_tenant from the configuration
*/}}
{{- define "mimir.noAuthTenant" -}}
{{- (include "mimir.calculatedConfig" . | fromYaml).no_auth_tenant | default "anonymous" -}}
{{- end -}}
{{/*
Return if we should create a PodSecurityPolicy. Takes into account user values and supported kubernetes versions.
*/}}
{{- define "mimir.rbac.usePodSecurityPolicy" -}}
{{- and
(
or (semverCompare "< 1.24-0" (include "mimir.kubeVersion" .))
(and (semverCompare "< 1.25-0" (include "mimir.kubeVersion" .)) .Values.rbac.forcePSPOnKubernetes124)
)
(and .Values.rbac.create (eq .Values.rbac.type "psp"))
-}}
{{- end -}}
{{/*
Return if we should create a SecurityContextConstraints. Takes into account user values and supported openshift versions.
*/}}
{{- define "mimir.rbac.useSecurityContextConstraints" -}}
{{- and .Values.rbac.create (eq .Values.rbac.type "scc") -}}
{{- end -}}
{{- define "mimir.remoteWriteUrl.inCluster" -}}
{{ include "mimir.gatewayUrl" . }}/api/v1/push
{{- end -}}
{{- define "mimir.remoteReadUrl.inCluster" -}}
{{ include "mimir.gatewayUrl" . }}{{ include "mimir.prometheusHttpPrefix" . }}
{{- end -}}
{{/*
Creates dict for zone-aware replication configuration
Params:
ctx = . context
component = component name
Return value:
{
zoneName: {
affinity: <affinity>,
nodeSelector: <nodeSelector>,
replicas: <N>,
storageClass: <S>
},
...
}
During migration there is a special case where an extra "zone" is generated with zonaName == "" empty string.
The empty string evaluates to false in boolean expressions so it is treated as the default (non zone-aware) zone,
which allows us to keep generating everything for the default zone.
*/}}
{{- define "mimir.zoneAwareReplicationMap" -}}
{{- $zonesMap := (dict) -}}
{{- $componentSection := include "mimir.componentSectionFromName" . | fromYaml -}}
{{- $defaultZone := (dict "affinity" $componentSection.affinity "nodeSelector" $componentSection.nodeSelector "replicas" $componentSection.replicas "storageClass" $componentSection.storageClass) -}}
{{- if $componentSection.zoneAwareReplication.enabled -}}
{{- $numberOfZones := len $componentSection.zoneAwareReplication.zones -}}
{{- if lt $numberOfZones 3 -}}
{{- fail "When zone-awareness is enabled, you must have at least 3 zones defined." -}}
{{- end -}}
{{- $requestedReplicas := $componentSection.replicas -}}
{{- if and (has .component (list "ingester" "alertmanager")) $componentSection.zoneAwareReplication.migration.enabled (not $componentSection.zoneAwareReplication.migration.writePath) -}}
{{- $requestedReplicas = $componentSection.zoneAwareReplication.migration.replicas }}
{{- end -}}
{{- $replicaPerZone := div (add $requestedReplicas $numberOfZones -1) $numberOfZones -}}
{{- range $idx, $rolloutZone := $componentSection.zoneAwareReplication.zones -}}
{{- $_ := set $zonesMap $rolloutZone.name (dict
"affinity" (($rolloutZone.extraAffinity | default (dict)) | mergeOverwrite (include "mimir.zoneAntiAffinity" (dict "component" $.component "rolloutZoneName" $rolloutZone.name "topologyKey" $componentSection.zoneAwareReplication.topologyKey ) | fromYaml ) )
"nodeSelector" ($rolloutZone.nodeSelector | default (dict) )
"replicas" $replicaPerZone
"storageClass" $rolloutZone.storageClass
) -}}
{{- end -}}
{{- if $componentSection.zoneAwareReplication.migration.enabled -}}
{{- if $componentSection.zoneAwareReplication.migration.scaleDownDefaultZone -}}
{{- $_ := set $defaultZone "replicas" 0 -}}
{{- end -}}
{{- $_ := set $zonesMap "" $defaultZone -}}
{{- end -}}
{{- else -}}
{{- $_ := set $zonesMap "" $defaultZone -}}
{{- end -}}
{{- $zonesMap | toYaml }}
{{- end -}}
{{/*
Calculate anti-affinity for a zone
Params:
component = component name
rolloutZoneName = name of the rollout zone
topologyKey = topology key
*/}}
{{- define "mimir.zoneAntiAffinity" -}}
{{- if .topologyKey -}}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: rollout-group
operator: In
values:
- {{ .component }}
- key: zone
operator: NotIn
values:
- {{ .rolloutZoneName }}
topologyKey: {{ .topologyKey | quote }}
{{- else -}}
{}
{{- end -}}
{{- end -}}
{{/*
Calculate annotations with zone-awareness
Params:
ctx = . context
component = component name
rolloutZoneName = rollout zone name (optional)
*/}}
{{- define "mimir.componentAnnotations" -}}
{{- $componentSection := include "mimir.componentSectionFromName" . | fromYaml -}}
{{- if and (or $componentSection.zoneAwareReplication.enabled $componentSection.zoneAwareReplication.migration.enabled) .rolloutZoneName }}
{{- $map := dict "rollout-max-unavailable" ($componentSection.zoneAwareReplication.maxUnavailable | toString) -}}
{{- toYaml (deepCopy $map | mergeOverwrite $componentSection.annotations) }}
{{- else -}}
{{ toYaml $componentSection.annotations }}
{{- end -}}
{{- end -}}
{{- define "mimir.var_dump" -}}
{{- . | mustToPrettyJson | printf "\nThe JSON output of the dumped var is: \n%s" | fail }}
{{- end -}}
{{/*
siToBytes is used to convert Kubernetes byte units to bytes.
Works for a sub set of SI suffixes: m, k, M, G, T, and their power-of-two equivalents: Ki, Mi, Gi, Ti.
mimir.siToBytes takes 1 argument
.value = the input value with SI unit
*/}}
{{- define "mimir.siToBytes" -}}
{{- if (hasSuffix "Ki" .value) -}}
{{- trimSuffix "Ki" .value | float64 | mul 1024 | ceil | int64 -}}
{{- else if (hasSuffix "Mi" .value) -}}
{{- trimSuffix "Mi" .value | float64 | mul 1048576 | ceil | int64 -}}
{{- else if (hasSuffix "Gi" .value) -}}
{{- trimSuffix "Gi" .value | float64 | mul 1073741824 | ceil | int64 -}}
{{- else if (hasSuffix "Ti" .value) -}}
{{- trimSuffix "Ti" .value | float64 | mul 1099511627776 | ceil | int64 -}}
{{- else if (hasSuffix "k" .value) -}}
{{- trimSuffix "k" .value | float64 | mul 1000 | ceil | int64 -}}
{{- else if (hasSuffix "M" .value) -}}
{{- trimSuffix "M" .value | float64 | mul 1000000 | ceil | int64 -}}
{{- else if (hasSuffix "G" .value) -}}
{{- trimSuffix "G" .value | float64 | mul 1000000000 | ceil | int64 -}}
{{- else if (hasSuffix "T" .value) -}}
{{- trimSuffix "T" .value | float64 | mul 1000000000000 | ceil | int64 -}}
{{- else if (hasSuffix "m" .value) -}}
{{- trimSuffix "m" .value | float64 | mulf 0.001 | ceil | int64 -}}
{{- else -}}
{{- .value }}
{{- end -}}
{{- end -}}
{{/*
parseCPU is used to convert Kubernetes CPU units to the corresponding float value of CPU cores.
The returned value is a string representation. If you need to do any math on it, please parse the string first.
mimir.parseCPU takes 1 argument
.value = the Kubernetes CPU request value
*/}}
{{- define "mimir.parseCPU" -}}
{{- $value_string := .value | toString -}}
{{- if (hasSuffix "m" $value_string) -}}
{{ trimSuffix "m" $value_string | float64 | mulf 0.001 -}}
{{- else -}}
{{- $value_string }}
{{- end -}}
{{- end -}}
{{/*
cpuToMilliCPU is used to convert Kubernetes CPU units to MilliCPU.
The returned value is a string representation. If you need to do any math on it, please parse the string first.
mimir.cpuToMilliCPU takes 1 argument
.value = the Kubernetes CPU request value
*/}}
{{- define "mimir.cpuToMilliCPU" -}}
{{- $value_string := .value | toString -}}
{{- if (hasSuffix "m" $value_string) -}}
{{ trimSuffix "m" $value_string -}}
{{- else -}}
{{- $value_string | float64 | mulf 1000 | toString }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,150 @@
{{- if .Values.enterprise.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{- toYaml .Values.admin_api.annotations | nindent 4 }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "admin-api" "memberlist" true) | nindent 4 }}
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "admin-api") }}
namespace: {{ .Release.Namespace | quote }}
spec:
replicas: {{ .Values.admin_api.replicas }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "admin-api" "memberlist" true) | nindent 6 }}
strategy:
{{- toYaml .Values.admin_api.strategy | nindent 4 }}
template:
metadata:
labels:
{{- include "mimir.podLabels" (dict "ctx" . "component" "admin-api" "memberlist" true) | nindent 8 }}
annotations:
{{- include "mimir.podAnnotations" (dict "ctx" . "component" "admin-api") | nindent 8 }}
namespace: {{ .Release.Namespace | quote }}
spec:
serviceAccountName: {{ template "mimir.serviceAccountName" . }}
{{- if .Values.admin_api.priorityClassName }}
priorityClassName: {{ .Values.admin_api.priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" . "component" "admin-api") | nindent 8 }}
{{- with .Values.admin_api.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: admin-api
image: "{{ include "mimir.imageReference" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-target=admin-api"
- "-config.expand-env=true"
- "-config.file=/etc/mimir/mimir.yaml"
{{- range $key, $value := .Values.admin_api.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.admin_api.extraVolumeMounts }}
{{ toYaml .Values.admin_api.extraVolumeMounts | nindent 12}}
{{- end }}
{{- if .Values.global.extraVolumeMounts }}
{{ toYaml .Values.global.extraVolumeMounts | nindent 12}}
{{- end }}
- name: config
mountPath: /etc/mimir
- name: runtime-config
mountPath: /var/{{ include "mimir.name" . }}
- name: license
mountPath: /license
- name: storage
mountPath: "/data"
{{- if .Values.admin_api.persistence.subPath }}
subPath: {{ .Values.admin_api.persistence.subPath }}
{{- end }}
- name: active-queries
mountPath: /active-query-tracker
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
- name: grpc
containerPort: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
- name: memberlist
containerPort: {{ include "mimir.memberlistBindPort" . }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.admin_api.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.admin_api.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.admin_api.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.admin_api.containerSecurityContext | nindent 12 }}
{{- $jaeger_queue_size := dig "jaegerReporterMaxQueueSize" nil .Values.admin_api }}
{{- if or .Values.global.extraEnv .Values.admin_api.env $jaeger_queue_size }}
env:
{{- with .Values.global.extraEnv }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.admin_api.env }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- if $jaeger_queue_size }}
- name: "JAEGER_REPORTER_MAX_QUEUE_SIZE"
value: {{$jaeger_queue_size | toString | toYaml }}
{{- end }}
{{- end }}
{{- if or .Values.global.extraEnvFrom .Values.admin_api.extraEnvFrom }}
envFrom:
{{- with .Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.admin_api.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.admin_api.extraContainers }}
{{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.admin_api.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.admin_api.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "mimir.lib.topologySpreadConstraints" (dict "ctx" . "component" "admin-api") | nindent 6 }}
{{- with .Values.admin_api.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.admin_api.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "mimir.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "mimir.fullname" . }}-runtime
{{- if .Values.admin_api.extraVolumes }}
{{ toYaml .Values.admin_api.extraVolumes | nindent 8}}
{{- end }}
{{- if .Values.global.extraVolumes }}
{{ toYaml .Values.global.extraVolumes | nindent 8}}
{{- end }}
- name: license
secret:
secretName: {{ tpl .Values.license.secretName . }}
- name: storage
emptyDir: {}
- name: active-queries
emptyDir: {}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if .Values.enterprise.enabled -}}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "admin-api" "memberlist" true) }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if .Values.enterprise.enabled -}}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" . "component" "admin-api" "memberlist" true) }}
{{- end -}}
@@ -0,0 +1,27 @@
{{- if .Values.enterprise.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "admin-api") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "admin-api" "memberlist" true) | nindent 4 }}
{{- with .Values.admin_api.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.admin_api.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
selector:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "admin-api" "memberlist" true) | nindent 4 }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled (index .Values "admin-cache" "enabled") -}}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "admin-cache") }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled (index .Values "admin-cache" "enabled") -}}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "admin-cache") }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled (index .Values "admin-cache" "enabled") -}}
{{- include "mimir.memcached.statefulSet" (dict "ctx" $ "component" "admin-cache" ) }}
{{- end }}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled (index .Values "admin-cache" "enabled") -}}
{{- include "mimir.memcached.service" (dict "ctx" $ "component" "admin-cache" ) }}
{{- end -}}
@@ -0,0 +1,16 @@
{{- if .Values.alertmanager.enabled -}}
{{- if .Values.alertmanager.fallbackConfig -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "alertmanager") }}-fallback-config
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "alertmanager" "memberlist" true) | nindent 4 }}
annotations:
{{- toYaml .Values.alertmanager.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
data:
alertmanager_fallback_config.yaml: |
{{- .Values.alertmanager.fallbackConfig | nindent 4 }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,167 @@
{{- if .Values.alertmanager.enabled -}}
{{- if not .Values.alertmanager.statefulSet.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "alertmanager") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "alertmanager" "memberlist" true) | nindent 4 }}
annotations:
{{- toYaml .Values.alertmanager.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
replicas: {{ .Values.alertmanager.replicas }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "alertmanager" "memberlist" true) | nindent 6 }}
strategy:
{{- toYaml .Values.alertmanager.strategy | nindent 4 }}
template:
metadata:
labels:
{{- include "mimir.podLabels" (dict "ctx" . "component" "alertmanager" "memberlist" true) | nindent 8 }}
annotations:
{{- include "mimir.podAnnotations" (dict "ctx" . "component" "alertmanager") | nindent 8 }}
{{- if .Values.alertmanager.fallbackConfig }}
checksum/alertmanager-fallback-config: {{ include (print .Template.BasePath "/alertmanager/alertmanager-config.yaml") . | sha256sum }}
{{- end }}
namespace: {{ .Release.Namespace | quote }}
spec:
serviceAccountName: {{ template "mimir.serviceAccountName" . }}
{{- if .Values.alertmanager.priorityClassName }}
priorityClassName: {{ .Values.query_frontend.priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" . "component" "alertmanager") | nindent 8 }}
{{- with .Values.alertmanager.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end}}
{{- end }}
containers:
- name: alertmanager
image: "{{ include "mimir.imageReference" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-target=alertmanager"
- "-config.expand-env=true"
- "-config.file=/etc/mimir/mimir.yaml"
{{- range $key, $value := .Values.alertmanager.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.alertmanager.extraVolumeMounts }}
{{ toYaml .Values.alertmanager.extraVolumeMounts | nindent 12}}
{{- end }}
{{- if .Values.global.extraVolumeMounts }}
{{ toYaml .Values.global.extraVolumeMounts | nindent 12}}
{{- end }}
- name: config
mountPath: /etc/mimir
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /license
{{- end }}
- name: runtime-config
mountPath: /var/{{ include "mimir.name" . }}
- name: storage
mountPath: "/data"
{{- if .Values.alertmanager.persistence.subPath }}
subPath: {{ .Values.alertmanager.persistence.subPath }}
{{- end }}
{{- if .Values.alertmanager.fallbackConfig }}
- name: alertmanager-fallback-config
mountPath: /configs/
{{- end }}
- name: tmp
mountPath: /tmp
- name: active-queries
mountPath: /active-query-tracker
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
- name: grpc
containerPort: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
- name: memberlist
containerPort: {{ include "mimir.memberlistBindPort" . }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.alertmanager.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.alertmanager.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.alertmanager.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.alertmanager.containerSecurityContext | nindent 12 }}
{{- if or .Values.global.extraEnv .Values.alertmanager.env }}
env:
{{- with .Values.global.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.alertmanager.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if or .Values.global.extraEnvFrom .Values.alertmanager.extraEnvFrom }}
envFrom:
{{- with .Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.alertmanager.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.alertmanager.extraContainers }}
{{ toYaml .Values.alertmanager.extraContainers | indent 8}}
{{- end }}
{{- with .Values.alertmanager.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.alertmanager.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "mimir.lib.topologySpreadConstraints" (dict "ctx" . "component" "alertmanager") | nindent 6 }}
{{- with .Values.alertmanager.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.alertmanager.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "mimir.configVolume" . | nindent 10 }}
{{- if .Values.enterprise.enabled }}
- name: license
secret:
secretName: {{ tpl .Values.license.secretName . }}
{{- end }}
- name: runtime-config
configMap:
name: {{ template "mimir.fullname" . }}-runtime
{{- if .Values.alertmanager.extraVolumes }}
{{ toYaml .Values.alertmanager.extraVolumes | indent 8}}
{{- end }}
{{- if .Values.global.extraVolumes }}
{{ toYaml .Values.global.extraVolumes | indent 8}}
{{- end }}
- name: storage
emptyDir: {}
- name: tmp
emptyDir: {}
- name: active-queries
emptyDir: {}
{{- if .Values.alertmanager.fallbackConfig }}
- name: alertmanager-fallback-config
configMap:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "alertmanager") }}-fallback-config
{{- end }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if .Values.alertmanager.enabled -}}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "alertmanager" "memberlist" true) }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if .Values.alertmanager.enabled -}}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "alertmanager" "memberlist" true) }}
{{- end -}}
@@ -0,0 +1,226 @@
{{- if .Values.alertmanager.enabled -}}
{{- if .Values.alertmanager.statefulSet.enabled -}}
{{- $args := dict "ctx" . "component" "alertmanager" "memberlist" true -}}
{{- $zonesMap := include "mimir.zoneAwareReplicationMap" $args | fromYaml -}}
{{- range $zoneName, $rolloutZone := $zonesMap }}
{{- with $ -}}
{{- $_ := set $args "rolloutZoneName" $zoneName -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "mimir.resourceName" $args }}
labels:
{{- include "mimir.labels" $args | nindent 4 }}
annotations:
{{- include "mimir.componentAnnotations" $args | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
replicas: {{ $rolloutZone.replicas }}
{{- if and (semverCompare ">= 1.23-0" (include "mimir.kubeVersion" .)) (.Values.alertmanager.persistentVolume.enableRetentionPolicy) }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.alertmanager.persistentVolume.whenDeleted }}
whenScaled: {{ .Values.alertmanager.persistentVolume.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" $args | nindent 6 }}
updateStrategy:
{{- if $zoneName }}
type: OnDelete
{{- else }}
{{- toYaml .Values.alertmanager.statefulStrategy | nindent 4 }}
{{- end }}
serviceName: {{ template "mimir.fullname" . }}-alertmanager
{{- if .Values.alertmanager.persistentVolume.enabled }}
volumeClaimTemplates:
- metadata:
name: storage
{{- if .Values.alertmanager.persistentVolume.annotations }}
annotations:
{{ toYaml .Values.alertmanager.persistentVolume.annotations | nindent 10 }}
{{- end }}
spec:
{{- $storageClass := default .Values.alertmanager.persistentVolume.storageClass $rolloutZone.storageClass }}
{{- if $storageClass }}
{{- if (eq "-" $storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: {{ $storageClass }}
{{- end }}
{{- end }}
accessModes:
{{- toYaml .Values.alertmanager.persistentVolume.accessModes | nindent 10 }}
resources:
requests:
storage: "{{ .Values.alertmanager.persistentVolume.size }}"
{{- end }}
template:
metadata:
labels:
{{- include "mimir.podLabels" $args | nindent 8 }}
annotations:
{{- include "mimir.podAnnotations" $args | nindent 8 }}
{{- if .Values.alertmanager.fallbackConfig }}
checksum/alertmanager-fallback-config: {{ include (print .Template.BasePath "/alertmanager/alertmanager-config.yaml") . | sha256sum }}
{{- end }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- with .Values.alertmanager.schedulerName }}
schedulerName: {{ . | quote }}
{{- end }}
serviceAccountName: {{ template "mimir.serviceAccountName" . }}
{{- if .Values.alertmanager.priorityClassName }}
priorityClassName: {{ .Values.alertmanager.priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" . "component" "alertmanager") | nindent 8 }}
{{- with .Values.alertmanager.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- with $rolloutZone.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $rolloutZone.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "mimir.lib.topologySpreadConstraints" (dict "ctx" . "component" "alertmanager") | nindent 6 }}
{{- with .Values.alertmanager.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.alertmanager.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "mimir.configVolume" . | nindent 10 }}
{{- if .Values.enterprise.enabled }}
- name: license
secret:
secretName: {{ tpl .Values.license.secretName . }}
{{- end }}
- name: runtime-config
configMap:
name: {{ template "mimir.fullname" . }}-runtime
{{- if not .Values.alertmanager.persistentVolume.enabled }}
- name: storage
emptyDir: {}
{{- end }}
- name: tmp
emptyDir: {}
- name: active-queries
emptyDir: {}
{{- if .Values.alertmanager.fallbackConfig }}
- name: alertmanager-fallback-config
configMap:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "alertmanager") }}-fallback-config
{{- end }}
{{- if .Values.alertmanager.extraVolumes }}
{{ toYaml .Values.alertmanager.extraVolumes | nindent 8 }}
{{- end }}
{{- if .Values.global.extraVolumes }}
{{ toYaml .Values.global.extraVolumes | nindent 8 }}
{{- end }}
containers:
{{- if .Values.alertmanager.extraContainers }}
{{ toYaml .Values.alertmanager.extraContainers | nindent 8 }}
{{- end }}
- name: alertmanager
image: "{{ include "mimir.imageReference" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-target=alertmanager"
- "-config.expand-env=true"
- "-config.file=/etc/mimir/mimir.yaml"
{{- if $zoneName }}
- "-alertmanager.sharding-ring.instance-availability-zone={{ $zoneName }}"
{{- else }}
{{- if .Values.alertmanager.zoneAwareReplication.enabled }}
- "-alertmanager.sharding-ring.instance-availability-zone=zone-default"
{{- end }}
{{- end }}
{{- range $key, $value := .Values.alertmanager.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.alertmanager.extraVolumeMounts }}
{{ toYaml .Values.alertmanager.extraVolumeMounts | nindent 12}}
{{- end }}
{{- if .Values.global.extraVolumeMounts }}
{{ toYaml .Values.global.extraVolumeMounts | nindent 12}}
{{- end }}
- name: config
mountPath: /etc/mimir
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /license
{{- end }}
- name: runtime-config
mountPath: /var/{{ include "mimir.name" . }}
- name: storage
mountPath: "/data"
{{- if .Values.alertmanager.persistentVolume.subPath }}
subPath: {{ .Values.alertmanager.persistentVolume.subPath }}
{{- end }}
{{- if .Values.alertmanager.fallbackConfig }}
- name: alertmanager-fallback-config
mountPath: /configs/
{{- end }}
- name: tmp
mountPath: /tmp
- name: active-queries
mountPath: /active-query-tracker
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
- name: grpc
containerPort: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
- name: memberlist
containerPort: {{ include "mimir.memberlistBindPort" . }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.alertmanager.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.alertmanager.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.alertmanager.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.alertmanager.containerSecurityContext | nindent 12 }}
{{- $jaeger_queue_size := dig "jaegerReporterMaxQueueSize" nil .Values.alertmanager }}
{{- if or .Values.global.extraEnv .Values.alertmanager.env $jaeger_queue_size }}
env:
{{- with .Values.global.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.alertmanager.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if $jaeger_queue_size }}
- name: "JAEGER_REPORTER_MAX_QUEUE_SIZE"
value: {{$jaeger_queue_size | toString | toYaml }}
{{- end }}
{{- end }}
{{- if or .Values.global.extraEnvFrom .Values.alertmanager.extraEnvFrom }}
envFrom:
{{- with .Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.alertmanager.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
---
{{ end }}
{{ end }}
{{ end }}
{{ end }}
@@ -0,0 +1,34 @@
{{- if .Values.alertmanager.enabled -}}
{{- $clusterPort := regexReplaceAll ".+[:]" (default "0.0.0.0:9094" (include "mimir.alertmanagerClusterBindAddress" .) ) "" -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "alertmanager") }}-headless
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "alertmanager" "memberlist" true) | nindent 4 }}
prometheus.io/service-monitor: "false"
{{- with .Values.alertmanager.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.alertmanager.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
- port: {{ $clusterPort }}
protocol: TCP
name: cluster
selector:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "alertmanager" "memberlist" true) | nindent 4 }}
{{- end -}}
@@ -0,0 +1,40 @@
{{- if .Values.alertmanager.enabled -}}
{{- $args := dict "ctx" . "component" "alertmanager" "memberlist" true -}}
{{- $zonesMap := include "mimir.zoneAwareReplicationMap" $args | fromYaml -}}
{{- range $zoneName, $rolloutZone := $zonesMap }}
{{- with $ -}}
{{- $_ := set $args "rolloutZoneName" $zoneName -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" $args }}
labels:
{{- include "mimir.labels" $args | nindent 4 }}
{{- if and $zoneName .Values.alertmanager.zoneAwareReplication.migration.enabled }}
# Prevent scraping PODs via this service during migration as the original non zone-aware service already scrapes all PODs and you get duplicate metrics.
prometheus.io/service-monitor: "false"
{{- end }}
{{- with .Values.alertmanager.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.alertmanager.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
selector:
{{- include "mimir.selectorLabels" $args | nindent 4 }}
---
{{ end }}
{{ end }}
{{ end }}
@@ -0,0 +1,3 @@
{{- if index .Values "chunks-cache" "enabled" }}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "chunks-cache") }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if index .Values "chunks-cache" "enabled" }}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "chunks-cache") }}
{{- end -}}
@@ -0,0 +1 @@
{{- include "mimir.memcached.statefulSet" (dict "ctx" $ "component" "chunks-cache" ) }}
@@ -0,0 +1 @@
{{- include "mimir.memcached.service" (dict "ctx" $ "component" "chunks-cache" ) }}
@@ -0,0 +1 @@
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "compactor" "memberlist" true) }}
@@ -0,0 +1 @@
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "compactor" "memberlist" true) }}
@@ -0,0 +1,186 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "compactor") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "compactor" "memberlist" true) | nindent 4 }}
annotations:
{{- toYaml .Values.compactor.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
podManagementPolicy: {{ .Values.compactor.podManagementPolicy }}
{{- if and (semverCompare ">= 1.23-0" (include "mimir.kubeVersion" .)) (.Values.compactor.persistentVolume.enableRetentionPolicy) }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.compactor.persistentVolume.whenDeleted }}
whenScaled: {{ .Values.compactor.persistentVolume.whenScaled }}
{{- end }}
replicas: {{ .Values.compactor.replicas }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "compactor" "memberlist" true) | nindent 6 }}
updateStrategy:
{{- toYaml .Values.compactor.strategy | nindent 4 }}
serviceName: {{ template "mimir.fullname" . }}-compactor
{{- if .Values.compactor.persistentVolume.enabled }}
volumeClaimTemplates:
- metadata:
name: storage
{{- if .Values.compactor.persistentVolume.annotations }}
annotations:
{{ toYaml .Values.compactor.persistentVolume.annotations | nindent 10 }}
{{- end }}
spec:
{{- if .Values.compactor.persistentVolume.storageClass }}
{{- if (eq "-" .Values.compactor.persistentVolume.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.compactor.persistentVolume.storageClass }}"
{{- end }}
{{- end }}
accessModes:
{{- toYaml .Values.compactor.persistentVolume.accessModes | nindent 10 }}
resources:
requests:
storage: "{{ .Values.compactor.persistentVolume.size }}"
{{- end }}
template:
metadata:
labels:
{{- include "mimir.podLabels" (dict "ctx" . "component" "compactor" "memberlist" true) | nindent 8 }}
annotations:
{{- include "mimir.podAnnotations" (dict "ctx" . "component" "compactor") | nindent 8 }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- with .Values.compactor.schedulerName }}
schedulerName: {{ . | quote }}
{{- end }}
serviceAccountName: {{ template "mimir.serviceAccountName" . }}
{{- if .Values.compactor.priorityClassName }}
priorityClassName: {{ .Values.compactor.priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" . "component" "compactor") | nindent 8 }}
{{- with .Values.compactor.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.compactor.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.compactor.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "mimir.lib.topologySpreadConstraints" (dict "ctx" . "component" "compactor") | nindent 6 }}
{{- with .Values.compactor.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.compactor.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "mimir.configVolume" . | nindent 10 }}
{{- if .Values.enterprise.enabled }}
- name: license
secret:
secretName: {{ tpl .Values.license.secretName . }}
{{- end }}
- name: runtime-config
configMap:
name: {{ template "mimir.fullname" . }}-runtime
{{- if not .Values.compactor.persistentVolume.enabled }}
- name: storage
emptyDir: {}
{{- end }}
{{- if .Values.compactor.extraVolumes }}
{{ toYaml .Values.compactor.extraVolumes | nindent 8 }}
{{- end }}
{{- if .Values.global.extraVolumes }}
{{ toYaml .Values.global.extraVolumes | nindent 8 }}
{{- end }}
- name: active-queries
emptyDir: {}
containers:
{{- if .Values.compactor.extraContainers }}
{{ toYaml .Values.compactor.extraContainers | nindent 8 }}
{{- end }}
- name: compactor
image: "{{ include "mimir.imageReference" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-target=compactor"
- "-config.expand-env=true"
- "-config.file=/etc/mimir/mimir.yaml"
{{- range $key, $value := .Values.compactor.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.compactor.extraVolumeMounts }}
{{ toYaml .Values.compactor.extraVolumeMounts | nindent 12}}
{{- end }}
{{- if .Values.global.extraVolumeMounts }}
{{ toYaml .Values.global.extraVolumeMounts | nindent 12}}
{{- end }}
- name: config
mountPath: /etc/mimir
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /license
{{- end }}
- name: runtime-config
mountPath: /var/{{ include "mimir.name" . }}
- name: storage
mountPath: "/data"
{{- if .Values.compactor.persistentVolume.subPath }}
subPath: {{ .Values.compactor.persistentVolume.subPath }}
{{- end }}
- name: active-queries
mountPath: /active-query-tracker
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
- name: grpc
containerPort: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
- name: memberlist
containerPort: {{ include "mimir.memberlistBindPort" . }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.compactor.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.compactor.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.compactor.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.compactor.containerSecurityContext | nindent 12 }}
{{- $jaeger_queue_size := dig "jaegerReporterMaxQueueSize" nil .Values.compactor }}
{{- if or .Values.global.extraEnv .Values.compactor.env $jaeger_queue_size }}
env:
{{- with .Values.global.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.compactor.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if $jaeger_queue_size }}
- name: "JAEGER_REPORTER_MAX_QUEUE_SIZE"
value: {{$jaeger_queue_size | toString | toYaml }}
{{- end }}
{{- end }}
{{- if or .Values.global.extraEnvFrom .Values.compactor.extraEnvFrom }}
envFrom:
{{- with .Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.compactor.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "compactor") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "compactor" "memberlist" true) | nindent 4 }}
{{- with .Values.compactor.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.compactor.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
selector:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "compactor" "memberlist" true) | nindent 4 }}
@@ -0,0 +1,130 @@
{{- if .Values.continuous_test.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{- toYaml .Values.continuous_test.annotations | nindent 4 }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "continuous-test") | nindent 4 }}
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "continuous-test") }}
namespace: {{ .Release.Namespace | quote }}
spec:
replicas: {{ .Values.continuous_test.replicas }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "continuous-test") | nindent 6 }}
strategy:
{{- toYaml .Values.continuous_test.strategy | nindent 4 }}
template:
metadata:
labels:
{{- include "mimir.podLabels" (dict "ctx" . "component" "continuous-test") | nindent 8 }}
annotations:
{{- include "mimir.podAnnotations" (dict "ctx" . "component" "continuous-test") | nindent 8 }}
namespace: {{ .Release.Namespace | quote }}
spec:
serviceAccountName: {{ template "mimir.serviceAccountName" . }}
{{- if .Values.continuous_test.priorityClassName }}
priorityClassName: {{ .Values.continuous_test.priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" . "component" "continuous-test") | nindent 8 }}
{{- with .Values.continuous_test.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: continuous-test
image: "{{ include "mimir.imageReference" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-target=continuous-test"
- "-activity-tracker.filepath="
- "-server.http-listen-port={{ include "mimir.serverHttpListenPort" . }}"
- "-tests.write-read-series-test.num-series={{ .Values.continuous_test.numSeries }}"
- "-tests.write-read-series-test.max-query-age={{ .Values.continuous_test.maxQueryAge }}"
- "-tests.write-endpoint={{ template "mimir.gatewayUrl" . }}"
- "-tests.read-endpoint={{ template "mimir.gatewayUrl" . }}/prometheus"
- "-tests.run-interval={{ .Values.continuous_test.runInterval }}"
{{- if eq .Values.continuous_test.auth.type "tenantId" }}
- "-tests.tenant-id={{ .Values.continuous_test.auth.tenant }}"
{{- end }}
{{- if eq .Values.continuous_test.auth.type "basicAuth" }}
- "-tests.basic-auth-password={{ .Values.continuous_test.auth.password }}"
- "-tests.basic-auth-user={{ .Values.continuous_test.auth.tenant }}"
{{- end }}
{{- if eq .Values.continuous_test.auth.type "bearerToken" }}
- "-tests.bearer-token={{ .Values.continuous_test.auth.bearerToken }}"
{{- end }}
{{- range $key, $value := .Values.continuous_test.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.continuous_test.extraVolumeMounts }}
{{ toYaml .Values.continuous_test.extraVolumeMounts | nindent 12}}
{{- end }}
{{- if .Values.global.extraVolumeMounts }}
{{ toYaml .Values.global.extraVolumeMounts | nindent 12}}
{{- end }}
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
resources:
{{- toYaml .Values.continuous_test.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.continuous_test.containerSecurityContext | nindent 12 }}
{{- $jaeger_queue_size := dig "jaegerReporterMaxQueueSize" nil .Values.continuous_test }}
{{- if or .Values.global.extraEnv .Values.continuous_test.env $jaeger_queue_size }}
env:
{{- with .Values.global.extraEnv }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.continuous_test.env }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- if $jaeger_queue_size }}
- name: "JAEGER_REPORTER_MAX_QUEUE_SIZE"
value: {{$jaeger_queue_size | toString | toYaml }}
{{- end }}
{{- end }}
{{- if or .Values.global.extraEnvFrom .Values.continuous_test.extraEnvFrom }}
envFrom:
{{- with .Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.continuous_test.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.continuous_test.extraContainers }}
{{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.continuous_test.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.continuous_test.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "mimir.lib.topologySpreadConstraints" (dict "ctx" . "component" "continuous-test") | nindent 6 }}
{{- with .Values.continuous_test.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.continuous_test.terminationGracePeriodSeconds }}
volumes:
{{- if .Values.continuous_test.extraVolumes }}
{{ toYaml .Values.continuous_test.extraVolumes | nindent 8}}
{{- end }}
{{- if .Values.global.extraVolumes }}
{{ toYaml .Values.global.extraVolumes | nindent 8}}
{{- end }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if .Values.continuous_test.enabled -}}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "continuous-test") }}
{{- end -}}
@@ -0,0 +1,25 @@
{{- if .Values.continuous_test.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "continuous-test") }}-headless
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "continuous-test") | nindent 4 }}
{{- with .Values.continuous_test.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.continuous_test.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
selector:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "continuous-test") | nindent 4 }}
{{- end -}}
@@ -0,0 +1,179 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "distributor") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "distributor" "memberlist" true) | nindent 4 }}
annotations:
{{- toYaml .Values.distributor.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- if or (not .Values.distributor.kedaAutoscaling.enabled) (.Values.distributor.kedaAutoscaling.preserveReplicas) }}
# If replicas is not number (when using values file it's float64, when using --set arg it's int64) and is false (i.e. null) don't set it
{{- if or (or (kindIs "int64" .Values.distributor.replicas) (kindIs "float64" .Values.distributor.replicas)) (.Values.distributor.replicas) }}
replicas: {{ .Values.distributor.replicas }}
{{- end }}
{{- end }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "distributor" "memberlist" true) | nindent 6 }}
strategy:
{{- toYaml .Values.distributor.strategy | nindent 4 }}
template:
metadata:
labels:
{{- include "mimir.podLabels" (dict "ctx" . "component" "distributor" "memberlist" true) | nindent 8 }}
annotations:
{{- include "mimir.podAnnotations" (dict "ctx" . "component" "distributor") | nindent 8 }}
namespace: {{ .Release.Namespace | quote }}
spec:
serviceAccountName: {{ template "mimir.serviceAccountName" . }}
{{- if .Values.distributor.priorityClassName }}
priorityClassName: {{ .Values.distributor.priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" . "component" "distributor") | nindent 8 }}
{{- with .Values.distributor.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end}}
{{- end }}
containers:
- name: distributor
image: "{{ include "mimir.imageReference" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-target=distributor"
- "-config.expand-env=true"
- "-config.file=/etc/mimir/mimir.yaml"
# When write requests go through distributors via gRPC, we want gRPC clients to re-resolve the distributors DNS
# endpoint before the distributor process is terminated, in order to avoid any failures during graceful shutdown.
# To achieve it, we set a shutdown delay greater than the gRPC max connection age.
- "-server.grpc.keepalive.max-connection-age=60s"
- "-server.grpc.keepalive.max-connection-age-grace=5m"
- "-server.grpc.keepalive.max-connection-idle=1m"
- "-shutdown-delay=90s"
{{- if .Values.ingester.zoneAwareReplication.migration.enabled }}
{{- if not .Values.ingester.zoneAwareReplication.migration.writePath }}
- "-ingester.ring.zone-awareness-enabled=false"
{{- end }}
{{- if .Values.ingester.zoneAwareReplication.migration.excludeDefaultZone }}
- "-ingester.ring.excluded-zones=zone-default"
{{- end }}
{{- end }}
{{- range $key, $value := .Values.distributor.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.distributor.extraVolumeMounts }}
{{ toYaml .Values.distributor.extraVolumeMounts | nindent 12}}
{{- end }}
{{- if .Values.global.extraVolumeMounts }}
{{ toYaml .Values.global.extraVolumeMounts | nindent 12}}
{{- end }}
- name: config
mountPath: /etc/mimir
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /license
{{- end }}
- name: runtime-config
mountPath: /var/{{ include "mimir.name" . }}
- name: storage
mountPath: "/data"
{{- if .Values.distributor.persistence.subPath }}
subPath: {{ .Values.distributor.persistence.subPath }}
{{- end }}
- name: active-queries
mountPath: /active-query-tracker
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
- name: grpc
containerPort: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
- name: memberlist
containerPort: {{ include "mimir.memberlistBindPort" . }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.distributor.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.distributor.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.distributor.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.distributor.containerSecurityContext | nindent 12 }}
{{- $cpu_request := dig "requests" "cpu" nil .Values.distributor.resources }}
{{- $jaeger_queue_size := dig "jaegerReporterMaxQueueSize" nil .Values.distributor }}
{{- if or .Values.global.extraEnv .Values.distributor.env $cpu_request $jaeger_queue_size }}
env:
{{- with .Values.global.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.distributor.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if $cpu_request }}
{{- $cpu_request_doubled := include "mimir.parseCPU" (dict "value" $cpu_request) | float64 | mulf 2 | ceil }}
- name: "GOMAXPROCS"
value: {{ max $cpu_request_doubled 8 | toString | toYaml }}
{{- end }}
{{- if $jaeger_queue_size }}
- name: "JAEGER_REPORTER_MAX_QUEUE_SIZE"
value: {{$jaeger_queue_size | toString | toYaml }}
{{- end }}
{{- end }}
{{- if or .Values.global.extraEnvFrom .Values.distributor.extraEnvFrom }}
envFrom:
{{- with .Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.distributor.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.distributor.extraContainers }}
{{ toYaml .Values.distributor.extraContainers | indent 8}}
{{- end }}
{{- with .Values.distributor.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.distributor.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "mimir.lib.topologySpreadConstraints" (dict "ctx" . "component" "distributor") | nindent 6 }}
{{- with .Values.distributor.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.distributor.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "mimir.configVolume" . | nindent 10 }}
{{- if .Values.enterprise.enabled }}
- name: license
secret:
secretName: {{ tpl .Values.license.secretName . }}
{{- end }}
- name: runtime-config
configMap:
name: {{ template "mimir.fullname" . }}-runtime
{{- if .Values.distributor.extraVolumes }}
{{- toYaml .Values.distributor.extraVolumes | nindent 8}}
{{- end }}
{{- if .Values.global.extraVolumes }}
{{- toYaml .Values.global.extraVolumes | nindent 8}}
{{- end }}
- name: storage
emptyDir: {}
- name: active-queries
emptyDir: {}
@@ -0,0 +1 @@
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "distributor" "memberlist" true) }}
@@ -0,0 +1 @@
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "distributor" "memberlist" true) }}
@@ -0,0 +1,44 @@
{{- if .Values.distributor.kedaAutoscaling.enabled }}
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "distributor") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "distributor") | nindent 4 }}
annotations:
{{- toYaml .Values.distributor.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
advanced:
horizontalPodAutoscalerConfig:
{{- with .Values.distributor.kedaAutoscaling.behavior }}
behavior:
{{- toYaml . | nindent 8 }}
{{- end }}
maxReplicaCount: {{ .Values.distributor.kedaAutoscaling.maxReplicaCount }}
minReplicaCount: {{ .Values.distributor.kedaAutoscaling.minReplicaCount }}
pollingInterval: {{ .Values.kedaAutoscaling.pollingInterval }}
scaleTargetRef:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "distributor") }}
apiVersion: apps/v1
kind: Deployment
triggers:
- metadata:
query: max_over_time(sum(sum by (pod) (rate(container_cpu_usage_seconds_total{container="distributor",namespace="{{ .Release.Namespace }}"}[5m])) and max by (pod) (up{container="distributor",namespace="{{ .Release.Namespace }}"}) > 0)[15m:]) * 1000
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
{{- $cpu_request := dig "requests" "cpu" nil .Values.distributor.resources }}
threshold: {{ mulf (include "mimir.cpuToMilliCPU" (dict "value" $cpu_request)) (divf .Values.distributor.kedaAutoscaling.targetCPUUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
type: prometheus
- metadata:
query: max_over_time(sum((sum by (pod) (container_memory_working_set_bytes{container="distributor",namespace="{{ .Release.Namespace }}"}) and max by (pod) (up{container="distributor",namespace="{{ .Release.Namespace }}"}) > 0) or vector(0))[15m:]) + sum(sum by (pod) (max_over_time(kube_pod_container_resource_requests{container="distributor",namespace="{{ .Release.Namespace }}", resource="memory"}[15m])) and max by (pod) (changes(kube_pod_container_status_restarts_total{container="distributor",namespace="{{ .Release.Namespace }}"}[15m]) > 0) and max by (pod) (kube_pod_container_status_last_terminated_reason{container="distributor",namespace="{{ .Release.Namespace }}", reason="OOMKilled"}) or vector(0))
serverAddress: {{ include "mimir.kedaPrometheusAddress" (dict "ctx" $) }}
{{- $mem_request := dig "requests" "memory" nil .Values.distributor.resources }}
threshold: {{ mulf (include "mimir.siToBytes" (dict "value" $mem_request)) (divf .Values.distributor.kedaAutoscaling.targetMemoryUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
type: prometheus
{{- end }}
@@ -0,0 +1,27 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "distributor") }}-headless
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "distributor" "memberlist" true) | nindent 4 }}
prometheus.io/service-monitor: "false"
{{- with .Values.distributor.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.distributor.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
clusterIP: None
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
selector:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "distributor" "memberlist" true) | nindent 4 }}
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "distributor") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "distributor" "memberlist" true) | nindent 4 }}
{{- with .Values.distributor.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.distributor.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
selector:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "distributor" "memberlist" true) | nindent 4 }}
@@ -0,0 +1,4 @@
{{ range .Values.extraObjects }}
---
{{ tpl (toYaml .) $ }}
{{ end }}
@@ -0,0 +1,21 @@
{{/*
nginx auth Secret name
*/}}
{{- define "mimir.gateway.nginx.authSecret" -}}
{{ .Values.gateway.nginx.basicAuth.existingSecret | default (include "mimir.resourceName" (dict "ctx" . "component" "gateway-nginx") ) }}
{{- end }}
{{/*
Name of the gateway Service resource
*/}}
{{- define "mimir.gateway.service.name" -}}
{{ .Values.gateway.service.nameOverride | default (include "mimir.resourceName" (dict "ctx" . "component" "gateway") ) }}
{{- end }}
{{/*
Returns "true" or "false" strings if the gateway component (nginx or GEM gateway) should be deployed
*/}}
{{- define "mimir.gateway.isEnabled" -}}
{{- or .Values.gateway.enabledNonEnterprise .Values.enterprise.enabled -}}
{{- end }}
@@ -0,0 +1,196 @@
{{- if (eq (include "mimir.gateway.isEnabled" .) "true") }}
{{- with .Values.gateway }}
{{- $isGEMGateway := $.Values.enterprise.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{- toYaml .annotations | nindent 4 }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "gateway") | nindent 4 }}
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "gateway") }}
namespace: {{ $.Release.Namespace | quote }}
spec:
{{- if not .autoscaling.enabled }}
replicas: {{ .replicas }}
{{- end }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $ "component" "gateway") | nindent 6 }}
{{- with .strategy }}
strategy:
{{ toYaml . | trim | indent 4 }}
{{- end }}
template:
metadata:
labels:
{{- include "mimir.podLabels" (dict "ctx" $ "component" "gateway") | nindent 8 }}
annotations:
{{- $annotations := include "mimir.podAnnotations" (dict "ctx" $ "component" "gateway") | fromYaml -}}
{{- if not $isGEMGateway -}}
{{- $annotations = (dict "checksum/config" (include (print $.Template.BasePath "/gateway/nginx-configmap.yaml") $ | sha256sum )) | mergeOverwrite $annotations -}}
{{- end -}}
{{- $annotations | toYaml | nindent 8 }}
namespace: {{ $.Release.Namespace | quote }}
spec:
serviceAccountName: {{ include "mimir.serviceAccountName" $ }}
{{- if .priorityClassName }}
priorityClassName: {{ .priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" $ "component" "gateway") | nindent 8 }}
{{- with .initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if $.Values.image.pullSecrets }}
imagePullSecrets:
{{- range $.Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
{{- if $isGEMGateway }}
- name: gateway
image: {{ include "mimir.imageReference" $ | quote }}
imagePullPolicy: {{ $.Values.image.pullPolicy }}
args:
- "-target=gateway"
- "-config.expand-env=true"
- "-config.file=/etc/mimir/mimir.yaml"
{{- range $key, $value := .extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- with .extraVolumeMounts }}
{{ toYaml . | nindent 12}}
{{- end }}
{{- if $.Values.global.extraVolumeMounts }}
{{ toYaml $.Values.global.extraVolumeMounts | nindent 12 }}
{{- end }}
- name: config
mountPath: /etc/mimir
- name: runtime-config
mountPath: /var/{{ include "mimir.name" $ }}
- name: license
mountPath: /license
- name: tmp
mountPath: /data
- name: active-queries
mountPath: /active-query-tracker
{{- else }}
- name: gateway
image: {{ .nginx.image.registry }}/{{ .nginx.image.repository }}:{{ .nginx.image.tag }}
imagePullPolicy: {{ $.Values.image.pullPolicy }}
{{- with .extraArgs }}
args:
{{- range $key, $value := . }}
- "-{{ $key }} {{ $value }}"
{{- end }}
{{- end }}
volumeMounts:
{{- if .extraVolumeMounts }}
{{ toYaml .extraVolumeMounts | nindent 12 }}
{{- end }}
{{- if $.Values.global.extraVolumeMounts }}
{{ toYaml $.Values.global.extraVolumeMounts | nindent 12 }}
{{- end }}
- name: nginx-config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
{{- if .nginx.basicAuth.enabled }}
- name: auth
mountPath: /etc/nginx/secrets
{{- end }}
- name: tmp
mountPath: /tmp
- name: docker-entrypoint-d-override
mountPath: /docker-entrypoint.d
{{- end }}
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" $ }}
protocol: TCP
readinessProbe:
{{- toYaml .readinessProbe | nindent 12 }}
resources:
{{- toYaml .resources | nindent 12 }}
securityContext:
{{- toYaml .containerSecurityContext | nindent 12 }}
{{- $jaeger_queue_size := dig "jaegerReporterMaxQueueSize" nil . }}
{{- if or $.Values.global.extraEnv .env $jaeger_queue_size }}
env:
{{- with $.Values.global.extraEnv }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with .env }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- if $jaeger_queue_size }}
- name: "JAEGER_REPORTER_MAX_QUEUE_SIZE"
value: {{$jaeger_queue_size | toString | toYaml }}
{{- end }}
{{- end }}
{{- if or $.Values.global.extraEnvFrom .extraEnvFrom }}
envFrom:
{{- with $.Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .extraContainers }}
{{ toYaml . | nindent 8 }}
{{- end }}
{{- with .nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "mimir.lib.topologySpreadConstraints" (dict "ctx" $ "component" "gateway") | nindent 6 }}
{{- with .tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "mimir.configVolume" $ | nindent 10 }}
- name: runtime-config
configMap:
name: {{ include "mimir.fullname" $ }}-runtime
{{- if not $isGEMGateway }}
- name: nginx-config
configMap:
name: {{ include "mimir.fullname" $ }}-gateway-nginx
- name: docker-entrypoint-d-override
emptyDir: {}
{{- end }}
{{- if .nginx.basicAuth.enabled }}
- name: auth
secret:
secretName: {{ include "mimir.gateway.nginx.authSecret" $ }}
{{- end }}
- name: tmp
emptyDir: {}
{{- if $isGEMGateway }}
- name: license
secret:
secretName: {{ tpl $.Values.license.secretName $ }}
- name: storage
emptyDir: {}
- name: active-queries
emptyDir: {}
{{- end -}}
{{- if .extraVolumes }}
{{- toYaml .extraVolumes | nindent 8 }}
{{- end }}
{{- if $.Values.global.extraVolumes }}
{{- toYaml $.Values.global.extraVolumes | nindent 8 }}
{{- end }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,44 @@
{{- if and (eq (include "mimir.gateway.isEnabled" .) "true") .Values.gateway.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Values.gateway.ingress.nameOverride | default (include "mimir.resourceName" (dict "ctx" . "component" "gateway") ) }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "gateway") | nindent 4 }}
{{- with .Values.gateway.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- with .Values.gateway.ingress.ingressClassName }}
ingressClassName: {{ . }}
{{- end -}}
{{- with .Values.gateway.ingress.tls }}
tls:
{{- range . }}
- hosts:
{{- range .hosts }}
- {{ tpl . $ | quote }}
{{- end }}
{{- with .secretName }}
secretName: {{ . }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range .Values.gateway.ingress.hosts }}
- host: {{ tpl .host $ | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ include "mimir.gateway.service.name" $ }}
port:
number: {{ $.Values.gateway.service.port }}
{{- end }}
{{- end }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if eq (include "mimir.gateway.isEnabled" .) "true" -}}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "gateway") }}
{{- end -}}
@@ -0,0 +1,25 @@
{{- if .Values.gateway.route.enabled }}
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "gateway") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "gateway") | nindent 4 }}
{{- with .Values.gateway.route.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ .Release.Namespace | quote }}
spec:
host: {{ tpl .Values.gateway.route.host $ | quote }}
to:
kind: Service
name: {{ include "mimir.gateway.service.name" . }}
weight: 100
port:
targetPort: http-metrics
{{- with .Values.gateway.route.tls }}
tls:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,3 @@
{{- if and (eq (include "mimir.gateway.isEnabled" .) "true") (not .Values.gateway.enabledNonEnterprise) -}}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "gateway") }}
{{- end -}}
@@ -0,0 +1,40 @@
{{- if eq (include "mimir.gateway.isEnabled" .) "true" -}}
{{- with .Values.gateway -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.gateway.service.name" $ }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "gateway") | nindent 4 }}
{{- with .service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .service.annotations | nindent 4 }}
namespace: {{ $.Release.Namespace | quote }}
spec:
type: {{ .service.type }}
{{- with .service.clusterIP }}
clusterIP: {{ . }}
{{- end }}
{{- if and (eq "LoadBalancer" .service.type) .service.loadBalancerIP }}
loadBalancerIP: {{ .service.loadBalancerIP }}
{{- end }}
ports:
- port: {{ .service.port }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
{{- if and (eq "NodePort" .service.type) .service.nodePort }}
nodePort: {{ .service.nodePort }}
{{- end }}
{{- with .service.legacyPort }}
- port: {{ . }}
protocol: TCP
name: legacy-http-metrics
targetPort: http-metrics
{{- end }}
selector:
{{- include "mimir.selectorLabels" (dict "ctx" $ "component" "gateway") | nindent 4 }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,35 @@
{{- if .Values.gateway.autoscaling.enabled }}
{{- if eq (include "mimir.hpa.version" .) "autoscaling/v2" }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "gateway") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "gateway") | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "gateway") }}
minReplicas: {{ .Values.gateway.autoscaling.minReplicas }}
maxReplicas: {{ .Values.gateway.autoscaling.maxReplicas }}
metrics:
{{- with .Values.gateway.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.gateway.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,31 @@
{{- if .Values.gateway.autoscaling.enabled }}
{{- if eq (include "mimir.hpa.version" .) "autoscaling/v2beta1" }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "gateway") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "gateway") | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "gateway") }}
minReplicas: {{ .Values.gateway.autoscaling.minReplicas }}
maxReplicas: {{ .Values.gateway.autoscaling.maxReplicas }}
metrics:
{{- with .Values.gateway.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ . }}
{{- end }}
{{- with .Values.gateway.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ . }}
{{- end }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,12 @@
{{- if and (not .Values.enterprise.enabled) .Values.gateway.enabledNonEnterprise -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "gateway-nginx") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "gateway-nginx") | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
data:
nginx.conf: |
{{- tpl .Values.gateway.nginx.config.file . | nindent 4 }}
{{- end -}}
@@ -0,0 +1,14 @@
{{- if not .Values.enterprise.enabled -}}
{{- if and .Values.gateway.enabledNonEnterprise .Values.gateway.nginx.basicAuth.enabled (not .Values.gateway.nginx.basicAuth.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "gateway-nginx") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "gateway-nginx") | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
stringData:
.htpasswd: |
{{- tpl .Values.gateway.nginx.basicAuth.htpasswd $ | nindent 4 }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,11 @@
{{/*
gossip-ring selector labels
*/}}
{{- define "mimir.gossipRingSelectorLabels" -}}
{{ include "mimir.selectorLabels" . }}
{{- if .ctx.Values.enterprise.legacyLabels }}
gossip_ring_member: "true"
{{- else }}
app.kubernetes.io/part-of: memberlist
{{- end }}
{{- end -}}
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "gossip-ring") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "gossip-ring") | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
clusterIP: None
ports:
- name: gossip-ring
port: {{ include "mimir.memberlistBindPort" . }}
appProtocol: tcp
protocol: TCP
targetPort: {{ include "mimir.memberlistBindPort" . }}
publishNotReadyAddresses: true
selector:
{{- include "mimir.gossipRingSelectorLabels" (dict "ctx" .) | nindent 4 }}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "gr-aggr-cache") }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "gr-aggr-cache") }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.memcached.statefulSet" (dict "ctx" $ "component" "gr-aggr-cache" ) }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.memcached.service" (dict "ctx" $ "component" "gr-aggr-cache" ) }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "gr-metricname-cache") }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "gr-metricname-cache") }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.memcached.statefulSet" (dict "ctx" $ "component" "gr-metricname-cache" ) }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.memcached.service" (dict "ctx" $ "component" "gr-metricname-cache" ) }}
{{- end -}}
@@ -0,0 +1,150 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "graphite-querier") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "graphite-querier") | nindent 4 }}
annotations:
{{- toYaml .Values.graphite.querier.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
replicas: {{ .Values.graphite.querier.replicas }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "graphite-querier") | nindent 6 }}
strategy:
{{- toYaml .Values.graphite.querier.strategy | nindent 4 }}
template:
metadata:
labels:
{{- include "mimir.podLabels" (dict "ctx" . "component" "graphite-querier") | nindent 8 }}
annotations:
{{- include "mimir.podAnnotations" (dict "ctx" . "component" "graphite-querier") | nindent 8 }}
namespace: {{ .Release.Namespace | quote }}
spec:
serviceAccountName: {{ template "mimir.serviceAccountName" . }}
{{- if .Values.graphite.querier.priorityClassName }}
priorityClassName: {{ .Values.graphite.querier.priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" . "component" "graphite-querier") | nindent 8 }}
{{- with .Values.graphite.querier.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
{{- if .Values.graphite.querier.extraContainers }}
{{ toYaml .Values.graphite.querier.extraContainers | nindent 8 }}
{{- end }}
- name: graphite-querier
image: {{ include "mimir.imageReference" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- -target=graphite-querier
- -config.file=/etc/mimir/mimir.yaml
{{- range $key, $value := .Values.graphite.querier.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.graphite.querier.extraVolumeMounts }}
{{ toYaml .Values.graphite.querier.extraVolumeMounts | nindent 12}}
{{- end }}
{{- if .Values.global.extraVolumeMounts }}
{{ toYaml .Values.global.extraVolumeMounts | nindent 12}}
{{- end }}
- name: config
mountPath: /etc/mimir
- name: runtime-config
mountPath: /var/{{ include "mimir.name" . }}
- name: graphite-schemas
mountPath: /etc/graphite-proxy
- name: license
mountPath: /license
- name: storage
mountPath: "/data"
{{- if .Values.graphite.querier.persistence.subPath }}
subPath: {{ .Values.graphite.querier.persistence.subPath }}
{{- end }}
- name: active-queries
mountPath: /active-query-tracker
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
- name: grpc
containerPort: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.graphite.querier.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.graphite.querier.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.graphite.querier.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.graphite.querier.containerSecurityContext | nindent 12 }}
{{- $jaeger_queue_size := dig "jaegerReporterMaxQueueSize" nil .Values.graphite.querier }}
{{- if or .Values.global.extraEnv .Values.graphite.querier.env $jaeger_queue_size }}
env:
{{- with .Values.global.extraEnv }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.graphite.querier.env }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- if $jaeger_queue_size }}
- name: "JAEGER_REPORTER_MAX_QUEUE_SIZE"
value: {{$jaeger_queue_size | toString | toYaml }}
{{- end }}
{{- end }}
{{- if or .Values.global.extraEnvFrom .Values.admin_api.extraEnvFrom }}
envFrom:
{{- with .Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.admin_api.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.graphite.querier.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.graphite.querier.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.graphite.querier.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.graphite.querier.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "mimir.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "mimir.fullname" . }}-runtime
- name: graphite-schemas
configMap:
name: {{ template "mimir.fullname" . }}-graphite-schemas
{{- if .Values.graphite.querier.extraVolumes }}
{{ toYaml .Values.graphite.querier.extraVolumes | indent 8}}
{{- end }}
{{- if .Values.global.extraVolumes }}
{{ toYaml .Values.global.extraVolumes | indent 8}}
{{- end }}
- name: license
secret:
secretName: {{ tpl .Values.license.secretName . }}
- name: storage
emptyDir: {}
- name: active-queries
emptyDir: {}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "graphite-querier") }}
{{- end -}}
@@ -0,0 +1,14 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "graphite-schemas") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "graphite-schemas") | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
data:
storage-schemas.conf: |
{{ .Values.graphite.querier.schemasConfiguration.storageSchemas | indent 4 }}
storage-aggregations.conf: |
{{ .Values.graphite.querier.schemasConfiguration.storageAggregations | indent 4 }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "graphite-querier") }}
{{- end -}}
@@ -0,0 +1,27 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "graphite-querier") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "graphite-querier") | nindent 4 }}
{{- with .Values.graphite.querier.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.graphite.querier.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
selector:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "graphite-querier") | nindent 4 }}
{{- end -}}
@@ -0,0 +1,148 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "graphite-write-proxy") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "graphite-write-proxy") | nindent 4 }}
annotations:
{{- toYaml .Values.graphite.write_proxy.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
replicas: {{ .Values.graphite.write_proxy.replicas }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "graphite-write-proxy") | nindent 6 }}
strategy:
{{- toYaml .Values.graphite.write_proxy.strategy | nindent 4 }}
template:
metadata:
labels:
{{- include "mimir.podLabels" (dict "ctx" . "component" "graphite-write-proxy") | nindent 8 }}
annotations:
{{- include "mimir.podAnnotations" (dict "ctx" . "component" "graphite-write-proxy") | nindent 8 }}
namespace: {{ .Release.Namespace | quote }}
spec:
serviceAccountName: {{ template "mimir.serviceAccountName" . }}
{{- if .Values.graphite.write_proxy.priorityClassName }}
priorityClassName: {{ .Values.graphite.write_proxy.priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" . "component" "graphite-write-proxy") | nindent 8 }}
{{- with .Values.graphite.write_proxy.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end}}
{{- end }}
containers:
{{- if .Values.graphite.write_proxy.extraContainers }}
{{ toYaml .Values.graphite.write_proxy.extraContainers | nindent 8 }}
{{- end }}
- name: graphite-write-proxy
image: "{{ include "mimir.imageReference" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- -target=graphite-write-proxy
- -config.file=/etc/mimir/mimir.yaml
{{- range $key, $value := .Values.graphite.write_proxy.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.graphite.write_proxy.extraVolumeMounts }}
{{ toYaml .Values.graphite.write_proxy.extraVolumeMounts | nindent 12}}
{{- end }}
{{- if .Values.global.extraVolumeMounts }}
{{ toYaml .Values.global.extraVolumeMounts | nindent 12}}
{{- end }}
- name: config
mountPath: /etc/mimir
- name: runtime-config
mountPath: /var/{{ include "mimir.name" . }}
- name: license
mountPath: /license
- name: storage
mountPath: "/data"
{{- if .Values.graphite.write_proxy.persistence.subPath }}
subPath: {{ .Values.graphite.write_proxy.persistence.subPath }}
{{- end }}
- name: active-queries
mountPath: /active-query-tracker
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
- name: grpc
containerPort: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.graphite.write_proxy.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.graphite.write_proxy.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.graphite.write_proxy.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.graphite.write_proxy.containerSecurityContext | nindent 12 }}
{{- $jaeger_queue_size := dig "jaegerReporterMaxQueueSize" nil .Values.graphite.write_proxy }}
{{- if or .Values.global.extraEnv .Values.graphite.write_proxy.env $jaeger_queue_size }}
env:
{{- with .Values.global.extraEnv }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.graphite.write_proxy.env }}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- if $jaeger_queue_size }}
- name: "JAEGER_REPORTER_MAX_QUEUE_SIZE"
value: {{$jaeger_queue_size | toString | toYaml }}
{{- end }}
{{- end }}
{{- if or .Values.global.extraEnvFrom .Values.graphite.write_proxy.extraEnvFrom }}
envFrom:
{{- with .Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.graphite.write_proxy.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.graphite.write_proxy.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.graphite.write_proxy.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.graphite.write_proxy.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.graphite.write_proxy.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "mimir.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "mimir.fullname" . }}-runtime
- name: graphite-schemas
configMap:
name: {{ template "mimir.fullname" . }}-graphite-schemas
{{- if .Values.graphite.write_proxy.extraVolumes }}
{{ toYaml .Values.graphite.write_proxy.extraVolumes | indent 8}}
{{- end }}
{{- if .Values.global.extraVolumes }}
{{ toYaml .Values.global.extraVolumes | indent 8}}
{{- end }}
- name: license
secret:
secretName: {{ tpl .Values.license.secretName . }}
- name: storage
emptyDir: {}
- name: active-queries
emptyDir: {}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "graphite-write-proxy") }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "graphite-write-proxy") }}
{{- end -}}
@@ -0,0 +1,27 @@
{{- if and .Values.enterprise.enabled .Values.graphite.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "graphite-write-proxy") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "graphite-write-proxy") | nindent 4 }}
{{- with .Values.graphite.write_proxy.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.graphite.write_proxy.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
ports:
- port: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
selector:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "graphite-write-proxy") | nindent 4 }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if index .Values "index-cache" "enabled" }}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "index-cache") }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if index .Values "index-cache" "enabled" }}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "index-cache") }}
{{- end -}}
@@ -0,0 +1 @@
{{- include "mimir.memcached.statefulSet" (dict "ctx" $ "component" "index-cache" ) }}
@@ -0,0 +1 @@
{{- include "mimir.memcached.service" (dict "ctx" $ "component" "index-cache" ) }}
@@ -0,0 +1 @@
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "ingester" "memberlist" true) }}
@@ -0,0 +1 @@
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "ingester" "memberlist" true) }}
@@ -0,0 +1,211 @@
{{- $args := dict "ctx" . "component" "ingester" "memberlist" true -}}
{{- $zonesMap := include "mimir.zoneAwareReplicationMap" $args | fromYaml -}}
{{- range $zoneName, $rolloutZone := $zonesMap }}
{{- with $ -}}
{{- $_ := set $args "rolloutZoneName" $zoneName -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "mimir.resourceName" $args }}
labels:
{{- include "mimir.labels" $args | nindent 4 }}
annotations:
{{- include "mimir.componentAnnotations" $args | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
podManagementPolicy: {{ .Values.ingester.podManagementPolicy }}
replicas: {{ $rolloutZone.replicas }}
{{- if and (semverCompare ">= 1.23-0" (include "mimir.kubeVersion" .)) (.Values.ingester.persistentVolume.enableRetentionPolicy) }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.ingester.persistentVolume.whenDeleted }}
whenScaled: {{ .Values.ingester.persistentVolume.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" $args | nindent 6 }}
updateStrategy:
{{- if $zoneName }}
type: OnDelete
{{- else }}
{{- toYaml .Values.ingester.statefulStrategy | nindent 4 }}
{{- end }}
serviceName: {{ template "mimir.fullname" . }}-ingester{{- if not .Values.enterprise.legacyLabels -}}-headless{{- end -}}
{{- if .Values.ingester.persistentVolume.enabled }}
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: storage
{{- if .Values.ingester.persistentVolume.annotations }}
annotations:
{{- toYaml .Values.ingester.persistentVolume.annotations | nindent 10 }}
{{- end }}
spec:
{{- $storageClass := default .Values.ingester.persistentVolume.storageClass $rolloutZone.storageClass }}
{{- if $storageClass }}
{{- if (eq "-" $storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: {{ $storageClass }}
{{- end }}
{{- end }}
accessModes:
{{- toYaml .Values.ingester.persistentVolume.accessModes | nindent 10 }}
resources:
requests:
storage: "{{ .Values.ingester.persistentVolume.size }}"
{{- end }}
template:
metadata:
labels:
{{- include "mimir.podLabels" $args | nindent 8 }}
annotations:
{{- include "mimir.podAnnotations" $args | nindent 8 }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- with .Values.ingester.schedulerName }}
schedulerName: {{ . | quote }}
{{- end }}
serviceAccountName: {{ template "mimir.serviceAccountName" . }}
{{- if .Values.ingester.priorityClassName }}
priorityClassName: {{ .Values.ingester.priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" $args | nindent 8 }}
{{- with .Values.ingester.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- with $rolloutZone.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $rolloutZone.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "mimir.lib.topologySpreadConstraints" (dict "ctx" . "component" "ingester") | nindent 6 }}
{{- with .Values.ingester.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "mimir.configVolume" . | nindent 10 }}
{{- if .Values.enterprise.enabled }}
- name: license
secret:
secretName: {{ tpl .Values.license.secretName . }}
{{- end }}
- name: runtime-config
configMap:
name: {{ template "mimir.fullname" . }}-runtime
{{- if not .Values.ingester.persistentVolume.enabled }}
- name: storage
emptyDir: {}
{{- end }}
{{- if .Values.ingester.extraVolumes }}
{{ toYaml .Values.ingester.extraVolumes | nindent 8 }}
{{- end }}
{{- if .Values.global.extraVolumes }}
{{ toYaml .Values.global.extraVolumes | nindent 8 }}
{{- end }}
- name: active-queries
emptyDir: {}
containers:
{{- if .Values.ingester.extraContainers }}
{{ toYaml .Values.ingester.extraContainers | nindent 8 }}
{{- end }}
- name: ingester
image: "{{ include "mimir.imageReference" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-target=ingester"
- "-config.expand-env=true"
- "-config.file=/etc/mimir/mimir.yaml"
{{- if $zoneName }}
- "-ingester.ring.instance-availability-zone={{ $zoneName }}"
{{- else }}
- "-ingester.ring.instance-availability-zone=zone-default"
{{- if .Values.ingester.zoneAwareReplication.migration.enabled }}
- "-blocks-storage.tsdb.flush-blocks-on-shutdown=true"
- "-ingester.ring.unregister-on-shutdown=true"
{{- end }}
- "-server.grpc-max-concurrent-streams=500"
{{- end }}
{{- range $key, $value := .Values.ingester.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.ingester.extraVolumeMounts }}
{{ toYaml .Values.ingester.extraVolumeMounts | nindent 12}}
{{- end }}
{{- if .Values.global.extraVolumeMounts }}
{{ toYaml .Values.global.extraVolumeMounts | nindent 12}}
{{- end }}
- name: config
mountPath: /etc/mimir
- name: runtime-config
mountPath: /var/{{ include "mimir.name" . }}
- name: storage
mountPath: "/data"
{{- if .Values.ingester.persistentVolume.subPath }}
subPath: {{ .Values.ingester.persistentVolume.subPath }}
{{- end }}
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /license
{{- end }}
- name: active-queries
mountPath: /active-query-tracker
ports:
- name: http-metrics
containerPort: {{ include "mimir.serverHttpListenPort" . }}
protocol: TCP
- name: grpc
containerPort: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
- name: memberlist
containerPort: {{ include "mimir.memberlistBindPort" . }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.ingester.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.ingester.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.ingester.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.ingester.containerSecurityContext | nindent 12 }}
{{- $jaeger_queue_size := dig "jaegerReporterMaxQueueSize" nil .Values.ingester }}
{{- if or .Values.global.extraEnv .Values.ingester.env $jaeger_queue_size }}
env:
{{- with .Values.global.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if $jaeger_queue_size }}
- name: "JAEGER_REPORTER_MAX_QUEUE_SIZE"
value: {{$jaeger_queue_size | toString | toYaml }}
{{- end }}
{{- end }}
{{- if or .Values.global.extraEnvFrom .Values.ingester.extraEnvFrom }}
envFrom:
{{- with .Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
---
{{ end }}
{{ end }}
@@ -0,0 +1,27 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "ingester") }}-headless
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "ingester" "memberlist" true) | nindent 4 }}
prometheus.io/service-monitor: "false"
{{- with .Values.ingester.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.ingester.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
clusterIP: None
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
selector:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "ingester" "memberlist" true) | nindent 4 }}
@@ -0,0 +1,38 @@
{{- $args := dict "ctx" . "component" "ingester" "memberlist" true -}}
{{- $zonesMap := include "mimir.zoneAwareReplicationMap" $args | fromYaml -}}
{{- range $zoneName, $rolloutZone := $zonesMap }}
{{- with $ -}}
{{- $_ := set $args "rolloutZoneName" $zoneName -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" $args }}
labels:
{{- include "mimir.labels" $args | nindent 4 }}
{{- if and $zoneName .Values.ingester.zoneAwareReplication.migration.enabled }}
# Prevent scraping PODs via this service during migration as the original non zone-aware service already scrapes all PODs and you get duplicate metrics.
prometheus.io/service-monitor: "false"
{{- end }}
{{- with .Values.ingester.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.ingester.service.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
type: ClusterIP
ports:
- port: {{ include "mimir.serverHttpListenPort" .}}
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ include "mimir.serverGrpcListenPort" . }}
protocol: TCP
name: grpc
targetPort: grpc
selector:
{{- include "mimir.selectorLabels" $args | nindent 4 }}
---
{{ end }}
{{ end }}
@@ -0,0 +1,46 @@
{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "mimir.fullname" . }}
labels:
{{- include "mimir.labels" (dict "ctx" .) | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- with .Values.ingress.ingressClassName }}
ingressClassName: {{ . }}
{{- end -}}
{{- with .Values.ingress.tls }}
tls:
{{- range . }}
- hosts:
{{- range .hosts }}
- {{ tpl . $ | quote }}
{{- end }}
{{- with .secretName }}
secretName: {{ . }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range $.Values.ingress.hosts }}
- host: {{ tpl . $ | quote }}
http:
paths:
{{- range $svcName, $paths := $.Values.ingress.paths }}
{{- range $paths }}
- path: {{ .path }}
pathType: {{ .pathType | default "Prefix" }}
backend:
service:
name: {{ include "mimir.fullname" $ }}-{{ $svcName }}
port:
number: {{ include "mimir.serverHttpListenPort" $ }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,17 @@
{{/*
Convert labels to string like: key1=value1, key2=value2, ...
Example:
customHeaders:
X-Scope-OrgID: tenant-1
becomes:
customHeaders: "X-Scope-OrgID=tenant-1"
Params:
map = map to convert to csv string
*/}}
{{- define "mimir.lib.mapToCSVString" -}}
{{- $list := list -}}
{{- range $k, $v := $.map -}}
{{- $list = append $list (printf "%s=%s" $k $v) -}}
{{- end -}}
{{ join "," $list }}
{{- end -}}
@@ -0,0 +1,23 @@
{{/*
Mimir common PodDisruptionBudget definition
Params:
ctx = . context
component = name of the component
*/}}
{{- define "mimir.lib.podDisruptionBudget" -}}
{{- $componentSection := include "mimir.componentSectionFromName" . | fromYaml }}
{{ with ($componentSection).podDisruptionBudget }}
apiVersion: {{ include "mimir.podDisruptionBudget.apiVersion" $.ctx }}
kind: PodDisruptionBudget
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $.ctx "component" $.component) }}
labels:
{{- include "mimir.labels" (dict "ctx" $.ctx "component" $.component) | nindent 4 }}
namespace: {{ $.ctx.Release.Namespace | quote }}
spec:
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $.ctx "component" $.component) | nindent 6 }}
{{ toYaml . | indent 2 }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,13 @@
{{/*
Mimir common podSecurityContext
Params:
ctx = . context
component = name of the component
*/}}
{{- define "mimir.lib.podSecurityContext" -}}
{{- $componentSection := include "mimir.componentSectionFromName" . | fromYaml }}
{{- /* Some components have security context in the values.yalm as podSecurityContext and others as securityContext */}}
{{- $podSecurityContextSection := $componentSection.securityContext | default $componentSection.podSecurityContext -}}
{{- $defaultContext := deepCopy .ctx.Values.rbac.podSecurityContext }}
{{- $podSecurityContextSection | mustMergeOverwrite $defaultContext | toYaml -}}
{{- end -}}
@@ -0,0 +1,74 @@
{{/*
Mimir common ServiceMonitor definition
Params:
ctx = . context
component = name of the component
memberlist = true/false, whether component is part of memberlist
*/}}
{{- define "mimir.lib.serviceMonitor" -}}
{{- with .ctx.Values.metaMonitoring.serviceMonitor }}
{{- if .enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "mimir.resourceName" $ }}
namespace: {{ .namespace | default $.ctx.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" $ | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
namespaceSelector:
{{- if .namespaceSelector }}
{{- toYaml .namespaceSelector | nindent 4 }}
{{- else }}
matchNames:
- {{ $.ctx.Release.Namespace }}
{{- end }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" $ | nindent 6 }}
matchExpressions:
- key: prometheus.io/service-monitor
operator: NotIn
values:
- "false"
endpoints:
- port: http-metrics
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
relabelings:
- action: replace
sourceLabels: [job]
replacement: "{{ $.ctx.Release.Namespace }}/{{ $.component }}"
targetLabel: job
{{- if kindIs "string" .clusterLabel }}
- replacement: "{{ .clusterLabel | default (include "mimir.clusterName" $.ctx) }}"
targetLabel: cluster
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .scheme }}
scheme: {{ . }}
{{- end }}
{{- with .tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,21 @@
{{- define "mimir.lib.topologySpreadConstraints" -}}
{{- $componentSection := include "mimir.componentSectionFromName" . | fromYaml -}}
{{- $topologySpreadConstraintsSection := $componentSection.topologySpreadConstraints -}}
{{- $selectorLabels := include "mimir.selectorLabels" . -}}
{{- if $topologySpreadConstraintsSection -}}
{{- $constraints := kindIs "slice" $topologySpreadConstraintsSection | ternary $topologySpreadConstraintsSection (list $topologySpreadConstraintsSection) -}}
topologySpreadConstraints:
{{- range $constraint := $constraints }}
- maxSkew: {{ $constraint.maxSkew }}
topologyKey: {{ $constraint.topologyKey }}
whenUnsatisfiable: {{ $constraint.whenUnsatisfiable }}
labelSelector:
{{- if $constraint.labelSelector -}}
{{- $constraint.labelSelector | toYaml | nindent 4 -}}
{{- else }}
matchLabels:
{{- $selectorLabels | nindent 6 }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,13 @@
{{- if .Values.enterprise.enabled -}}
{{- if not .Values.license.external }}
apiVersion: v1
kind: Secret
metadata:
name: {{ tpl .Values.license.secretName . }}
labels:
{{- include "mimir.labels" (dict "ctx" .) | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
data:
license.jwt: {{ .Values.license.contents | b64enc }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,161 @@
{{/*
memcached StatefulSet
*/}}
{{- define "mimir.memcached.statefulSet" -}}
{{ with (index $.ctx.Values $.component) }}
{{- if .enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $.ctx "component" $.component) }}
labels:
{{- include "mimir.labels" (dict "ctx" $.ctx "component" "memcached") | nindent 4 }}
annotations:
{{- toYaml .annotations | nindent 4 }}
namespace: {{ $.ctx.Release.Namespace | quote }}
spec:
podManagementPolicy: {{ .podManagementPolicy }}
replicas: {{ .replicas }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $.ctx "component" $.component) | nindent 6 }}
updateStrategy:
{{- toYaml .statefulStrategy | nindent 4 }}
serviceName: {{ template "mimir.fullname" $.ctx }}-{{ $.component }}
{{- if .volumeClaimTemplates }}
volumeClaimTemplates:
{{- with .volumeClaimTemplates }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
template:
metadata:
labels:
{{- include "mimir.podLabels" $ | nindent 8 }}
annotations:
{{- with $.ctx.Values.global.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "mimir.serviceAccountName" $.ctx }}
{{- if .priorityClassName }}
priorityClassName: {{ .priorityClassName }}
{{- end }}
securityContext:
{{- include "mimir.lib.podSecurityContext" (dict "ctx" $.ctx "component" "memcached") | nindent 8 }}
{{- with .initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "mimir.lib.topologySpreadConstraints" $ | nindent 6 }}
{{- with .tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .terminationGracePeriodSeconds }}
{{- if $.ctx.Values.image.pullSecrets }}
imagePullSecrets:
{{- range $.ctx.Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
volumes:
{{- with .extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $.ctx.Values.global.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end}}
containers:
{{- if .extraContainers }}
{{ toYaml .extraContainers | nindent 8 }}
{{- end }}
- name: memcached
{{- with $.ctx.Values.memcached.image }}
image: {{ .repository }}:{{ .tag }}
imagePullPolicy: {{ .pullPolicy }}
{{- end }}
resources:
{{- if .resources }}
{{- toYaml .resources | nindent 12 }}
{{- else }}
{{- /* Calculate requested memory as round(allocatedMemory * 1.2). But with integer built-in operators. */}}
{{- $requestMemory := div (add (mul .allocatedMemory 12) 5) 10 }}
limits:
memory: {{ $requestMemory }}Mi
requests:
cpu: 500m
memory: {{ $requestMemory }}Mi
{{- end }}
ports:
- containerPort: {{ .port }}
name: client
args:
- -m {{ .allocatedMemory }}
- --extended=modern,track_sizes{{ with .extraExtendedOptions }},{{ . }}{{ end }}
- -I {{ .maxItemMemory }}m
- -c {{ .connectionLimit }}
- -v
- -u {{ .port }}
{{- range $key, $value := .extraArgs }}
- "-{{ $key }}{{ if $value }} {{ $value }}{{ end }}"
{{- end }}
{{- with $.ctx.Values.global.extraEnv }}
env:
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with $.ctx.Values.global.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml $.ctx.Values.memcached.containerSecurityContext | nindent 12 }}
volumeMounts:
{{- with .extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.ctx.Values.global.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end}}
{{- if $.ctx.Values.memcachedExporter.enabled }}
- name: exporter
{{- with $.ctx.Values.memcachedExporter.image }}
image: {{ .repository}}:{{ .tag }}
imagePullPolicy: {{ .pullPolicy }}
{{- end }}
ports:
- containerPort: 9150
name: http-metrics
args:
- "--memcached.address=localhost:{{ .port }}"
- "--web.listen-address=0.0.0.0:9150"
{{- range $key, $value := $.ctx.Values.memcachedExporter.extraArgs }}
- "--{{ $key }}{{ if $value }}={{ $value }}{{ end }}"
{{- end }}
resources:
{{- toYaml $.ctx.Values.memcachedExporter.resources | nindent 12 }}
securityContext:
{{- toYaml $.ctx.Values.memcachedExporter.containerSecurityContext | nindent 12 }}
{{- if .extraVolumeMounts }}
volumeMounts:
{{- toYaml .extraVolumeMounts | nindent 12 }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,35 @@
{{/*
memcached Service
*/}}
{{- define "mimir.memcached.service" -}}
{{ with (index $.ctx.Values $.component) }}
{{- if .enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $.ctx "component" $.component) }}
labels:
{{- include "mimir.labels" (dict "ctx" $.ctx "component" $.component) | nindent 4 }}
{{- with .service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .service.annotations | nindent 4 }}
namespace: {{ $.ctx.Release.Namespace | quote }}
spec:
type: ClusterIP
clusterIP: None
ports:
- name: memcached-client
port: {{ .port }}
targetPort: {{ .port }}
{{ if $.ctx.Values.memcachedExporter.enabled }}
- name: http-metrics
port: 9150
targetPort: 9150
{{ end }}
selector:
{{- include "mimir.selectorLabels" (dict "ctx" $.ctx "component" $.component) | nindent 4 }}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if index .Values "metadata-cache" "enabled" }}
{{- include "mimir.lib.podDisruptionBudget" (dict "ctx" $ "component" "metadata-cache" ) }}
{{- end -}}
@@ -0,0 +1,3 @@
{{- if index .Values "metadata-cache" "enabled" }}
{{- include "mimir.lib.serviceMonitor" (dict "ctx" $ "component" "metadata-cache") }}
{{- end -}}
@@ -0,0 +1 @@
{{- include "mimir.memcached.statefulSet" (dict "ctx" $ "component" "metadata-cache" ) }}
@@ -0,0 +1 @@
{{- include "mimir.memcached.service" (dict "ctx" $ "component" "metadata-cache" ) }}
@@ -0,0 +1,70 @@
{{- define "mimir.metaMonitoring.metrics.remoteWrite" -}}
{{- $writeBackToMimir := not .url -}}
{{- $url := .url -}}
{{- if $writeBackToMimir -}}
{{- $url = include "mimir.remoteWriteUrl.inCluster" .ctx }}
{{- end -}}
- url: {{ $url }}
{{- if .auth }}
basicAuth:
{{- if .auth.username }}
username:
name: {{ include "mimir.resourceName" (dict "ctx" $.ctx "component" "metrics-instance-usernames") }}
key: {{ .usernameKey | quote }}
{{- end }}
{{- with .auth }}
{{- if and .passwordSecretKey .passwordSecretName }}
password:
name: {{ .passwordSecretName | quote }}
key: {{ .passwordSecretKey | quote }}
{{- else if or .passwordSecretKey .passwordSecretName }}{{ required "Set either both passwordSecretKey and passwordSecretName or neither" nil }}
{{- end }}
{{- end }}
{{- end }}
{{- $headers := .headers -}}
{{- if $writeBackToMimir -}}{{- $_ := set $headers "X-Scope-OrgID" "metamonitoring" -}}{{- end -}}
{{- with $headers }}
headers:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
{{- define "mimir.metaMonitoring.logs.client" -}}
{{- if .url }}
- url: {{ .url }}
{{- if .auth }}
{{- if .auth.tenantId }}
tenantId: {{ .auth.tenantId | quote }}
{{- end }}
basicAuth:
{{- if .auth.username }}
username:
name: {{ include "mimir.resourceName" (dict "ctx" $.ctx "component" "logs-instance-usernames") }}
key: {{ .usernameKey | quote }}
{{- end }}
{{- with .auth }}
{{- if and .passwordSecretKey .passwordSecretName }}
password:
name: {{ .passwordSecretName | quote }}
key: {{ .passwordSecretKey | quote }}
{{- else if or .passwordSecretKey .passwordSecretName }}
{{ required "Set either both passwordSecretKey and passwordSecretName or neither" nil }}
{{- end }}
{{- end }}
{{- end }}
externalLabels:
cluster: {{ include "mimir.clusterName" $.ctx | quote}}
{{- end -}}
{{- end -}}
{{- define "mimir.metaMonitoring.metrics.remoteReadUrl" -}}
{{- with $.ctx.Values.metaMonitoring.grafanaAgent.metrics }}
{{- $writeBackToMimir := not (.remote).url -}}
{{- if $writeBackToMimir -}}
{{- include "mimir.remoteReadUrl.inCluster" $.ctx }}
{{- else -}}
{{- $parsed := urlParse (.remote).url -}}
{{ $parsed.scheme }}://{{ $parsed.host }}/prometheus
{{- end }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,19 @@
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if .enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
subjects:
- kind: ServiceAccount
name: {{ include "mimir.serviceAccountName" $ }}
namespace: {{ .namespace | default $.Release.Namespace }}
{{- end }}
{{- end }}
@@ -0,0 +1,39 @@
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if .enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "grafana-agent") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- nodes
- nodes/proxy
- nodes/metrics
- services
- endpoints
- pods
- events
verbs:
- get
- list
- watch
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- list
- watch
- nonResourceURLs:
- /metrics
- /metrics/cadvisor
verbs:
- get
{{- end }}
{{- end }}
@@ -0,0 +1,59 @@
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if .enabled }}
apiVersion: monitoring.grafana.com/v1alpha1
kind: GrafanaAgent
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "meta-monitoring") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
serviceAccountName: {{ include "mimir.serviceAccountName" $ }}
{{- with .podSecurityContext }}
securityContext:
{{- . | toYaml | nindent 4 }}
{{- end }}
containers:
# The container specs here are merged with the ones in the operator using a strategic merge patch.
- name: config-reloader
{{- if .imageRepo }}{{ if .imageRepo.configReloader }}
{{- with .imageRepo.configReloader }}
image: {{ .repo }}/{{ .image }}:{{ .tag }}
{{- end }}
{{- end }}{{ end }}
{{- with .containerSecurityContext }}
securityContext:
{{- . | toYaml | nindent 8 }}
{{- end }}
- name: grafana-agent
{{- if .imageRepo }}{{ if .imageRepo.grafanaAgent }}
{{- with .imageRepo.grafanaAgent }}
image: {{ .repo }}/{{ .image }}:{{ .tag }}
{{- end }}
{{- end }}{{ end }}
{{- with .containerSecurityContext }}
securityContext:
{{- . | toYaml | nindent 8 }}
{{- end }}
logs:
instanceSelector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $ "component" "meta-monitoring") | nindent 8 }}
# cluster label for logs is added in the LogsInstance
metrics:
scrapeInterval: {{ .metrics.scrapeInterval }}
instanceSelector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $ "component" "meta-monitoring") | nindent 8 }}
externalLabels:
cluster: {{ include "mimir.clusterName" $ }}
{{- end }}
{{- end }}
@@ -0,0 +1,27 @@
{{- $currentScope := .Values.metaMonitoring.dashboards }}
{{- if $currentScope.enabled }}
{{ range $path, $_ := $.Files.Glob "mixins/dashboards/*.json" }}
{{ $file := $path | base }}
{{ $name := print ($file | trimSuffix ".json") "-dashboard" }}
{{- with $currentScope}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $name }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "mimir.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
{{ $file }}: |-
{{ $.Files.Get $path | indent 4 }}
---
{{- end }}
{{ end }}
{{- end }}
@@ -0,0 +1,49 @@
{{- if and .Values.metaMonitoring.grafanaAgent.enabled .Values.metaMonitoring.grafanaAgent.metrics.enabled .Values.metaMonitoring.grafanaAgent.metrics.scrapeK8s.enabled }}
{{- with .Values.metaMonitoring.serviceMonitor }}
{{- if .enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "k8s-ksm") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: {{ $.Values.metaMonitoring.grafanaAgent.metrics.scrapeK8s.kubeStateMetrics.service.port }}
metricRelabelings:
- action: keep
regex: "(^|.*;){{ include "mimir.resourceName" (dict "ctx" $) }}.*"
sourceLabels:
- deployment
- statefulset
- pod
separator: ';'
{{- if kindIs "string" .clusterLabel }}
relabelings:
- targetLabel: cluster
replacement: "{{ .clusterLabel | default (include "mimir.clusterName" $) }}"
{{- end }}
path: /metrics
honorLabels: true # retain namespace label from kube-state-metrics
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- with ((((($.Values).metaMonitoring).grafanaAgent).metrics).scrapeK8s).kubeStateMetrics }}
namespaceSelector:
matchNames:
- {{ .namespace }}
selector:
matchLabels:
{{- toYaml .labelSelectors | nindent 6 }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,91 @@
{{- if and .Values.metaMonitoring.grafanaAgent.enabled .Values.metaMonitoring.grafanaAgent.metrics.enabled .Values.metaMonitoring.grafanaAgent.metrics.scrapeK8s.enabled }}
{{- with .Values.metaMonitoring.serviceMonitor }}
{{- if .enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "k8s-kubelet-cadvisor") }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
port: https-metrics
honorLabels: true # retain namespace label from kubelet
relabelings:
- replacement: kubelet # add so that e.g. up{} metric doesn't get clashes with the other endpoint
targetLabel: source
{{- if kindIs "string" .clusterLabel }}
- targetLabel: cluster
replacement: "{{ .clusterLabel | default (include "mimir.clusterName" $) }}"
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
{{- end }}
metricRelabelings:
- action: keep
regex: storage-{{ include "mimir.resourceName" (dict "ctx" $) }}.*
sourceLabels:
- persistentvolumeclaim # present on kubelet_volume_stats* metrics
- targetLabel: instance # replace so that the metrics work with the default metrics mixin
sourceLabels:
- node
scheme: https
tlsConfig:
caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
path: /metrics/cadvisor
port: https-metrics
honorLabels: true # retain namespace label from cadvisor
relabelings:
- replacement: cadvisor # add so that e.g. up{} metric doesn't get clashes with the other endpoint
targetLabel: source
- targetLabel: instance # replace so that the metrics work with the default metrics mixin
sourceLabels:
- node
{{- if kindIs "string" .clusterLabel }}
- targetLabel: cluster
replacement: "{{ .clusterLabel | default (include "mimir.clusterName" $) }}"
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
{{- end }}
metricRelabelings:
- action: keep
regex: {{ include "mimir.resourceName" (dict "ctx" $) }}.*
sourceLabels:
- pod
scheme: https
tlsConfig:
caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
namespaceSelector:
matchNames:
# "default" is the default namespace in which the operator creates the kubelet service.
- default
selector:
matchLabels:
# This is a service added by the agent operator, so this labels is hardcoded to what the operator creates.
app.kubernetes.io/name: kubelet
{{- end -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,17 @@
{{- if and .Values.metaMonitoring.grafanaAgent.enabled .Values.metaMonitoring.grafanaAgent.logs.enabled }}
{{- with ((.Values.metaMonitoring).grafanaAgent).logs }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "logs-instance-usernames") }}
namespace: {{ (($.Values.metaMonitoring).grafanaAgent).namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }}
data:
{{- range $i, $cfg := prepend (.additionalClientConfigs | default list) .remote }}
{{- if (($cfg).auth).username }}
username-{{ $i }}: {{ (($cfg).auth).username | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,36 @@
{{- with (.Values.metaMonitoring).grafanaAgent }}
{{- if and .enabled .logs.enabled }}
apiVersion: monitoring.grafana.com/v1alpha1
kind: LogsInstance
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "meta-monitoring") }}
namespace: {{ (($.Values.metaMonitoring).grafanaAgent).namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
clients:
{{- if or (.logs).additionalClientConfigs (.logs).remote }}
{{- range $i, $cfg := prepend ((.logs).additionalClientConfigs | default list) (.logs).remote }}
{{- with $cfg }}
{{- include "mimir.metaMonitoring.logs.client" (dict "ctx" $ "url" .url "auth" .auth "usernameKey" (printf "username-%d" $i)) | nindent 6 -}}
{{- end }}
{{- end }}
{{- end }}
# Supply an empty namespace selector to look in all namespaces. Remove
# this to only look in the same namespace as the LogsInstance CR
podLogsNamespaceSelector: {}
podLogsSelector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $) | nindent 6 }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,19 @@
{{- with .Values.metaMonitoring.grafanaAgent }}
{{- if and .enabled .metrics.enabled }}
{{- with .metrics }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "metrics-instance-usernames") }}
namespace: {{ $.Values.metaMonitoring.grafanaAgent.namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }}
data:
{{- range $i, $cfg := prepend (.additionalRemoteWriteConfigs | default list) .remote }}
{{- if (($cfg).auth).username }}
username-{{ $i }}: {{ $cfg.auth.username | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,36 @@
{{- with .Values.metaMonitoring.grafanaAgent }}
{{- if and .enabled .metrics.enabled }}
apiVersion: monitoring.grafana.com/v1alpha1
kind: MetricsInstance
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "meta-monitoring") }}
namespace: {{ $.Values.metaMonitoring.grafanaAgent.namespace | default $.Release.Namespace | quote }}
labels:
{{- include "mimir.labels" (dict "ctx" $ "component" "meta-monitoring" ) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
remoteWrite:
{{- if or (.metrics).additionalRemoteWriteConfigs (.metrics).remote }}
{{- range $i, $cfg := prepend ((.metrics).additionalRemoteWriteConfigs | default list) (.metrics).remote }}
{{- with $cfg }}
{{- include "mimir.metaMonitoring.metrics.remoteWrite" (dict "ctx" $ "url" .url "auth" .auth "usernameKey" (printf "username-%d" $i) "headers" .headers ) | nindent 6 -}}
{{- end }}
{{- end }}
{{- end }}
# Supply an empty namespace selector to look in all namespaces. Remove
# this to only look in the same namespace as the MetricsInstance CR
serviceMonitorNamespaceSelector: {}
serviceMonitorSelector:
# Scrape ServiceMonitors from all components
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" $) | nindent 6 }}
{{- end }}
{{- end }}
@@ -0,0 +1,20 @@
{{- with .Values.metaMonitoring.prometheusRule }}
{{- if .mimirAlerts }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" $ "component" "alerts") }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "mimir.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
spec:
{{- $.Files.Get "mixins/alerts.yaml" | nindent 2 }}
{{- end }}
{{- end }}

Some files were not shown because too many files have changed in this diff Show More