diff --git a/production/helm/loki/templates/_helpers.tpl b/production/helm/loki/templates/_helpers.tpl index 6a2aa3f218f36..46cf232768070 100644 --- a/production/helm/loki/templates/_helpers.tpl +++ b/production/helm/loki/templates/_helpers.tpl @@ -46,6 +46,134 @@ Params: {{- $resourceName -}} {{- end -}} +{{/* +loki.componentSectionFromName returns the sections from the user .Values in YAML +that corresponds to the requested component. loki.componentSectionFromName takes two arguments + .ctx = the root context of the chart + .component = the name of the component. loki.componentSectionFromName uses an internal mapping to know + which component lives where in the values.yaml +Examples: + $componentSection := include "loki.componentSectionFromName" (dict "ctx" . "component" "ingester") | fromYaml + $componentSection.podLabels ... +*/}} +{{- define "loki.componentSectionFromName" -}} +{{- $componentsMap := dict + "admin-api" "adminApi" + "backend" "backend" + "bloom-compactor" "bloomCompactor" + "bloom-gateway" "bloomGateway" + "chunks-cache" "chunksCache" + "compactor" "compactor" + "distributor" "distributor" + "gateway" "gateway" + "index-gateway" "indexGateway" + "ingester" "ingester" + "memcached" "memcached" + "pattern-ingester" "patternIngester" + "querier" "querier" + "query-frontend" "queryFrontend" + "query-scheduler" "queryScheduler" + "read" "read" + "results-cache" "resultsCache" + "ruler" "ruler" + "single-binary" "singleBinary" + "write" "write" +-}} +{{- $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 loki.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 -}} + +{{/* +Creates dict for zone-aware replication configuration +Params: + ctx = . context + component = component name +Return value: + { + zoneName: { + affinity: , + nodeSelector: , + replicas: , + storageClass: + }, + ... + } +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 "loki.zoneAwareReplicationMap" -}} +{{- $zonesMap := (dict) -}} +{{- $componentSection := include "loki.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" )) $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 "loki.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 "loki.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 -}} + {{/* Return if deployment mode is simple scalable */}} @@ -1121,3 +1249,33 @@ Return the appropriate apiVersion for HorizontalPodAutoscaler. {{- print "autoscaling/v2beta1" -}} {{- end -}} {{- end -}} + +{{/* +Return the templated list for extraEnv and extraEnvFrom +Params: + . = extraEnv/extraEnvFrom list +*/}} +{{- define "loki.templateEnv" -}} +{{- $extraEnv := . }} +{{- with $extraEnv }} +{{- toYaml . | nindent 12 }} +{{- end }} +{{- end -}} + +{{/* +Return the templated dict/list for extraArgs +Params: + . = extraArgs dict/list +*/}} +{{- define "loki.templateArgs" -}} +{{- $extraArgs := . }} +{{- if and $extraArgs (kindIs "slice" $extraArgs) }} + {{- with $extraArgs }} + {{- toYaml . | nindent 12 }} + {{- end }} +{{- else if and $extraArgs (kindIs "map" $extraArgs) -}} + {{- range $key, $value := $extraArgs }} + - "-{{ $key }}={{ $value }}" + {{- end -}} +{{- end -}} +{{- end -}} diff --git a/production/helm/loki/templates/admin-api/deployment-admin-api.yaml b/production/helm/loki/templates/admin-api/deployment-admin-api.yaml index f85bbf90014b4..d631f82dd3c6e 100644 --- a/production/helm/loki/templates/admin-api/deployment-admin-api.yaml +++ b/production/helm/loki/templates/admin-api/deployment-admin-api.yaml @@ -88,9 +88,8 @@ spec: - -admin.client.s3.secret-access-key={{ .Values.minio.secretKey }} - -admin.client.s3.insecure=true {{- end }} - {{- range $key, $value := .Values.adminApi.extraArgs }} - - "-{{ $key }}={{ $value }}" - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.adminApi.extraArgs }} volumeMounts: - name: config mountPath: /etc/loki/config @@ -118,13 +117,11 @@ spec: securityContext: {{- toYaml .Values.adminApi.containerSecurityContext | nindent 12 }} env: - {{- if .Values.adminApi.env }} - {{ toYaml .Values.adminApi.env | nindent 12 }} - {{- end }} - {{- with .Values.adminApi.extraEnvFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.adminApi.extraEnv }} + envFrom: + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.adminApi.extraEnvFrom }} {{- with .Values.adminApi.extraContainers }} {{ toYaml . | nindent 8 }} {{- end }} diff --git a/production/helm/loki/templates/backend/statefulset-backend.yaml b/production/helm/loki/templates/backend/statefulset-backend.yaml index c20ce9f9a0552..aedf36d46465c 100644 --- a/production/helm/loki/templates/backend/statefulset-backend.yaml +++ b/production/helm/loki/templates/backend/statefulset-backend.yaml @@ -160,9 +160,8 @@ spec: - -config.file=/etc/loki/config/config.yaml - -target={{ .Values.backend.targetModule }} - -legacy-read-mode=false - {{- with .Values.backend.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.backend.extraArgs }} ports: - name: http-metrics containerPort: {{ .Values.loki.server.http_listen_port }} @@ -173,14 +172,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.backend.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.backend.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.backend.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.backend.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/bloom-builder/deployment-bloom-builder.yaml b/production/helm/loki/templates/bloom-builder/deployment-bloom-builder.yaml index c04b3ae5ae255..bb46797a7cb16 100644 --- a/production/helm/loki/templates/bloom-builder/deployment-bloom-builder.yaml +++ b/production/helm/loki/templates/bloom-builder/deployment-bloom-builder.yaml @@ -67,9 +67,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=bloom-builder - {{- with .Values.bloomBuilder.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.bloomBuilder.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -80,14 +79,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.bloomBuilder.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.bloomBuilder.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.bloomBuilder.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.bloomBuilder.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/bloom-gateway/statefulset-bloom-gateway.yaml b/production/helm/loki/templates/bloom-gateway/statefulset-bloom-gateway.yaml index 747642b227909..d1074e7154d90 100644 --- a/production/helm/loki/templates/bloom-gateway/statefulset-bloom-gateway.yaml +++ b/production/helm/loki/templates/bloom-gateway/statefulset-bloom-gateway.yaml @@ -75,9 +75,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=bloom-gateway - {{- with .Values.bloomGateway.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.bloomGateway.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -88,14 +87,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.bloomGateway.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.bloomGateway.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.bloomGateway.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.bloomGateway.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} {{- include "loki.bloomGateway.readinessProbe" . | nindent 10 }} diff --git a/production/helm/loki/templates/bloom-planner/statefulset-bloom-planner.yaml b/production/helm/loki/templates/bloom-planner/statefulset-bloom-planner.yaml index d134af39e92c7..8a71c92db54be 100644 --- a/production/helm/loki/templates/bloom-planner/statefulset-bloom-planner.yaml +++ b/production/helm/loki/templates/bloom-planner/statefulset-bloom-planner.yaml @@ -75,9 +75,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=bloom-planner - {{- with .Values.bloomPlanner.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.bloomPlanner.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -88,14 +87,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.bloomPlanner.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.bloomPlanner.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.bloomPlanner.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.bloomPlanner.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} {{- include "loki.bloomPlanner.readinessProbe" . | nindent 10 }} diff --git a/production/helm/loki/templates/compactor/statefulset-compactor.yaml b/production/helm/loki/templates/compactor/statefulset-compactor.yaml index 944ac425bf5ad..ead7b9fa7ba45 100644 --- a/production/helm/loki/templates/compactor/statefulset-compactor.yaml +++ b/production/helm/loki/templates/compactor/statefulset-compactor.yaml @@ -82,9 +82,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=compactor - {{- with .Values.compactor.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.compactor.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -95,14 +94,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.compactor.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.compactor.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.compactor.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.compactor.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} {{- include "loki.compactor.readinessProbe" . | nindent 10 }} diff --git a/production/helm/loki/templates/distributor/deployment-distributor.yaml b/production/helm/loki/templates/distributor/deployment-distributor.yaml index be66bfc6b5240..9350799c70052 100644 --- a/production/helm/loki/templates/distributor/deployment-distributor.yaml +++ b/production/helm/loki/templates/distributor/deployment-distributor.yaml @@ -75,9 +75,8 @@ spec: - -distributor.zone-awareness-enabled=true {{- end }} {{- end }} - {{- with .Values.distributor.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.distributor.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -88,14 +87,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.distributor.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.distributor.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.distributor.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.distributor.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/gateway/deployment-gateway-enterprise.yaml b/production/helm/loki/templates/gateway/deployment-gateway-enterprise.yaml index d75fd5fe65492..2ac4a2752f058 100644 --- a/production/helm/loki/templates/gateway/deployment-gateway-enterprise.yaml +++ b/production/helm/loki/templates/gateway/deployment-gateway-enterprise.yaml @@ -87,9 +87,8 @@ spec: - -gateway.proxy.ruler.url=http://{{ template "loki.backendFullname" . }}-headless.{{ .Release.Namespace }}.svc:3100 - -gateway.proxy.query-scheduler.url=http://{{ template "loki.backendFullname" . }}-headless.{{ .Release.Namespace }}.svc:3100 {{- end }} - {{- range $key, $value := .Values.enterpriseGateway.extraArgs }} - - "-{{ $key }}={{ $value }}" - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.enterpriseGateway.extraArgs }} volumeMounts: - name: config mountPath: /etc/loki/config @@ -111,13 +110,11 @@ spec: securityContext: {{- toYaml .Values.enterpriseGateway.containerSecurityContext | nindent 12 }} env: - {{- if .Values.enterpriseGateway.env }} - {{ toYaml .Values.enterpriseGateway.env | nindent 12 }} - {{- end }} - {{- with .Values.enterpriseGateway.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.enterpriseGateway.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.enterpriseGateway.extraEnvFrom }} {{- with .Values.enterpriseGateway.extraContainers }} {{ toYaml . | nindent 8 }} {{- end }} diff --git a/production/helm/loki/templates/gateway/deployment-gateway-nginx.yaml b/production/helm/loki/templates/gateway/deployment-gateway-nginx.yaml index 2b2d4c7bd7bb7..6087dc570d944 100644 --- a/production/helm/loki/templates/gateway/deployment-gateway-nginx.yaml +++ b/production/helm/loki/templates/gateway/deployment-gateway-nginx.yaml @@ -64,14 +64,10 @@ spec: - name: http-metrics containerPort: {{ .Values.gateway.containerPort }} protocol: TCP - {{- with .Values.gateway.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.gateway.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.gateway.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.gateway.extraEnvFrom }} readinessProbe: {{- toYaml .Values.gateway.readinessProbe | nindent 12 }} securityContext: diff --git a/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml b/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml index d417c978140f7..2da5e56b051a3 100644 --- a/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml +++ b/production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml @@ -76,9 +76,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=index-gateway - {{- with .Values.indexGateway.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.indexGateway.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -91,14 +90,12 @@ spec: containerPort: 7946 protocol: TCP {{- end }} - {{- with .Values.indexGateway.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.indexGateway.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.indexGateway.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.indexGateway.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/ingester/service-ingester-headless.yaml b/production/helm/loki/templates/ingester/service-ingester-headless.yaml index 8a8b92f2ebc5a..4c74a4912bf37 100644 --- a/production/helm/loki/templates/ingester/service-ingester-headless.yaml +++ b/production/helm/loki/templates/ingester/service-ingester-headless.yaml @@ -1,9 +1,7 @@ -{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} -{{- if and $isDistributed (or (not .Values.ingester.zoneAwareReplication.enabled) .Values.ingester.zoneAwareReplication.migration.enabled) }} apiVersion: v1 kind: Service metadata: - name: {{ include "loki.ingesterFullname" . }}-headless + name: {{ include "loki.resourceName" (dict "ctx" . "component" "ingester") }}-headless namespace: {{ .Release.Namespace }} labels: {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} @@ -31,5 +29,4 @@ spec: appProtocol: {{ .Values.ingester.appProtocol.grpc }} {{- end }} selector: - {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} -{{- end -}} + {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} diff --git a/production/helm/loki/templates/ingester/service-ingester-zone-a-headless.yaml b/production/helm/loki/templates/ingester/service-ingester-zone-a-headless.yaml deleted file mode 100644 index 03add3b286fc7..0000000000000 --- a/production/helm/loki/templates/ingester/service-ingester-zone-a-headless.yaml +++ /dev/null @@ -1,38 +0,0 @@ -{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} -{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: {{ include "loki.ingesterFullname" . }}-zone-a-headless - namespace: {{ .Release.Namespace }} - labels: - {{- include "loki.ingesterLabels" . | nindent 4 }} - {{- with .Values.ingester.serviceLabels }} - {{- toYaml . | nindent 4 }} - {{- end }} - annotations: - {{- with .Values.loki.serviceAnnotations }} - {{- toYaml . | nindent 4}} - {{- end }} - {{- with .Values.ingester.serviceAnnotations }} - {{- toYaml . | nindent 4}} - {{- end }} -spec: - clusterIP: None - ports: - - name: http-metrics - port: 3100 - targetPort: http-metrics - protocol: TCP - - name: grpc - port: 9095 - targetPort: grpc - protocol: TCP - {{- if .Values.ingester.appProtocol.grpc }} - appProtocol: {{ .Values.ingester.appProtocol.grpc }} - {{- end }} - selector: - {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} - name: ingester-zone-a - rollout-group: ingester -{{- end -}} diff --git a/production/helm/loki/templates/ingester/service-ingester-zone-b-headless.yaml b/production/helm/loki/templates/ingester/service-ingester-zone-b-headless.yaml deleted file mode 100644 index 607221922a661..0000000000000 --- a/production/helm/loki/templates/ingester/service-ingester-zone-b-headless.yaml +++ /dev/null @@ -1,38 +0,0 @@ -{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} -{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: {{ include "loki.ingesterFullname" . }}-zone-b-headless - namespace: {{ .Release.Namespace }} - labels: - {{- include "loki.ingesterLabels" . | nindent 4 }} - {{- with .Values.ingester.serviceLabels }} - {{- toYaml . | nindent 4 }} - {{- end }} - annotations: - {{- with .Values.loki.serviceAnnotations }} - {{- toYaml . | nindent 4}} - {{- end }} - {{- with .Values.ingester.serviceAnnotations }} - {{- toYaml . | nindent 4}} - {{- end }} -spec: - clusterIP: None - ports: - - name: http-metrics - port: 3100 - targetPort: http-metrics - protocol: TCP - - name: grpc - port: 9095 - targetPort: grpc - protocol: TCP - {{- if .Values.ingester.appProtocol.grpc }} - appProtocol: {{ .Values.ingester.appProtocol.grpc }} - {{- end }} - selector: - {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} - name: ingester-zone-b - rollout-group: ingester -{{- end -}} diff --git a/production/helm/loki/templates/ingester/service-ingester-zone-c-headless.yaml b/production/helm/loki/templates/ingester/service-ingester-zone-c-headless.yaml deleted file mode 100644 index 554144746ae02..0000000000000 --- a/production/helm/loki/templates/ingester/service-ingester-zone-c-headless.yaml +++ /dev/null @@ -1,38 +0,0 @@ -{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} -{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: {{ include "loki.ingesterFullname" . }}-zone-c-headless - namespace: {{ .Release.Namespace }} - labels: - {{- include "loki.ingesterLabels" . | nindent 4 }} - {{- with .Values.ingester.serviceLabels }} - {{- toYaml . | nindent 4 }} - {{- end }} - annotations: - {{- with .Values.loki.serviceAnnotations }} - {{- toYaml . | nindent 4}} - {{- end }} - {{- with .Values.ingester.serviceAnnotations }} - {{- toYaml . | nindent 4}} - {{- end }} -spec: - clusterIP: None - ports: - - name: http-metrics - port: 3100 - targetPort: http-metrics - protocol: TCP - - name: grpc - port: 9095 - targetPort: grpc - protocol: TCP - {{- if .Values.ingester.appProtocol.grpc }} - appProtocol: {{ .Values.ingester.appProtocol.grpc }} - {{- end }} - selector: - {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} - name: ingester-zone-c - rollout-group: ingester -{{- end -}} diff --git a/production/helm/loki/templates/ingester/service-ingester.yaml b/production/helm/loki/templates/ingester/service-ingester.yaml index 94d6f835332b7..a02bc8e8a30ff 100644 --- a/production/helm/loki/templates/ingester/service-ingester.yaml +++ b/production/helm/loki/templates/ingester/service-ingester.yaml @@ -1,9 +1,12 @@ -{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} -{{- if and $isDistributed (or (not .Values.ingester.zoneAwareReplication.enabled) .Values.ingester.zoneAwareReplication.migration.enabled) }} +{{- $args := dict "ctx" . "component" "ingester" "memberlist" true -}} +{{- $zonesMap := include "loki.zoneAwareReplicationMap" $args | fromYaml -}} +{{- range $zoneName, $rolloutZone := $zonesMap }} +{{- with $ -}} +{{- $_ := set $args "rolloutZoneName" $zoneName -}} apiVersion: v1 kind: Service metadata: - name: {{ include "loki.ingesterFullname" . }} + name: {{ include "loki.resourceName" $args }} namespace: {{ .Release.Namespace }} labels: {{- include "loki.ingesterLabels" . | nindent 4 }} @@ -33,4 +36,7 @@ spec: {{- end }} selector: {{- include "loki.ingesterSelectorLabels" . | nindent 4 }} -{{- end -}} + name: {{ include "loki.resourceName" $args }} +--- +{{ end }} +{{ end }} diff --git a/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml b/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml deleted file mode 100644 index e4c35c7dd84c9..0000000000000 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml +++ /dev/null @@ -1,234 +0,0 @@ -{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} -{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }} -{{- $replicas := (include "loki.ingester.replicaCount" .) -}} -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: {{ include "loki.ingesterFullname" . }}-zone-a - namespace: {{ .Release.Namespace }} - labels: - {{- include "loki.ingesterLabels" . | nindent 4 }} - app.kubernetes.io/part-of: memberlist - rollout-group: ingester - name: ingester-zone-a - annotations: - rollout-max-unavailable: "{{ include "loki.ingester.maxUnavailable" (dict "ctx" . "replicas" $replicas)}}" - {{- with .Values.loki.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.ingester.zoneAwareReplication.zoneA.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} -spec: -{{- if not .Values.ingester.autoscaling.enabled }} - replicas: {{ $replicas }} -{{- end }} - podManagementPolicy: Parallel - serviceName: {{ include "loki.ingesterFullname" . }}-zone-a - revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} - {{- if and (semverCompare ">= 1.23-0" (include "loki.kubeVersion" .)) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }} - {{/* - Data on the read nodes is easy to replace, so we want to always delete PVCs to make - operation easier, and will rely on re-fetching data when needed. - */}} - persistentVolumeClaimRetentionPolicy: - whenDeleted: {{ .Values.ingester.persistence.whenDeleted }} - whenScaled: {{ .Values.ingester.persistence.whenScaled }} - {{- end }} - selector: - matchLabels: - {{- include "loki.ingesterSelectorLabels" . | nindent 6 }} - name: ingester-zone-a - rollout-group: ingester -{{- with .Values.ingester.updateStrategy }} - updateStrategy: - {{- tpl (. | toYaml) $ | nindent 4 }} -{{- end }} - template: - metadata: - annotations: - {{- include "loki.config.checksum" . | nindent 8 }} - {{- with .Values.loki.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.zoneAwareReplication.zoneA.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "loki.ingesterSelectorLabels" . | nindent 8 }} - app.kubernetes.io/part-of: memberlist - name: ingester-zone-a - rollout-group: ingester - {{- with .Values.loki.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - spec: - {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} - {{- with .Values.ingester.topologySpreadConstraints }} - topologySpreadConstraints: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - serviceAccountName: {{ include "loki.serviceAccountName" . }} - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.hostAliases }} - hostAliases: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- include "loki.ingesterPriorityClassName" . | nindent 6 }} - securityContext: - {{- toYaml .Values.loki.podSecurityContext | nindent 8 }} - terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }} - {{- with .Values.ingester.initContainers }} - initContainers: - {{- toYaml . | nindent 8 }} - {{- end }} - containers: - - name: ingester - image: {{ include "loki.image" . }} - imagePullPolicy: {{ .Values.loki.image.pullPolicy }} - {{- if or .Values.loki.command .Values.ingester.command }} - command: - - {{ coalesce .Values.ingester.command .Values.loki.command | quote }} - {{- end }} - args: - - -config.file=/etc/loki/config/config.yaml - - -ingester.availability-zone=zone-a - - -ingester.unregister-on-shutdown=false - - -ingester.tokens-file-path=/var/loki/ring-tokens - - -target=ingester - {{- with .Values.ingester.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} - ports: - - name: http-metrics - containerPort: 3100 - protocol: TCP - - name: grpc - containerPort: 9095 - protocol: TCP - - name: http-memberlist - containerPort: 7946 - protocol: TCP - {{- with .Values.ingester.extraEnv }} - env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.extraEnvFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - securityContext: - {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} - {{- include "loki.ingester.readinessProbe" . | nindent 10 }} - {{- include "loki.ingester.livenessProbe" . | nindent 10 }} - volumeMounts: - - name: config - mountPath: /etc/loki/config - - name: runtime-config - mountPath: /etc/loki/runtime-config - - name: data - mountPath: /var/loki - {{- if .Values.enterprise.enabled }} - - name: license - mountPath: /etc/loki/license - {{- end }} - {{- with .Values.ingester.extraVolumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.resources }} - resources: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.lifecycle }} - lifecycle: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if .Values.ingester.extraContainers }} - {{- toYaml .Values.ingester.extraContainers | nindent 8}} - {{- end }} - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: rollout-group - operator: In - values: - - ingester - - key: name - operator: NotIn - values: - - ingester-zone-a - topologyKey: kubernetes.io/hostname - {{- with .Values.ingester.zoneAwareReplication.zoneA.extraAffinity }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.zoneAwareReplication.zoneA.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} - volumes: - - name: config - {{- include "loki.configVolume" . | nindent 10 }} - - name: runtime-config - configMap: - name: {{ template "loki.name" . }}-runtime - {{- if .Values.enterprise.enabled }} - - name: license - secret: - {{- if .Values.enterprise.useExternalLicense }} - secretName: {{ .Values.enterprise.externalLicenseName }} - {{- else }} - secretName: enterprise-logs-license - {{- end }} - {{- end }} - {{- with .Values.ingester.extraVolumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- if not .Values.ingester.persistence.enabled }} - - name: data - emptyDir: {} - {{- else if .Values.ingester.persistence.inMemory }} - - name: data - {{- if .Values.ingester.persistence.inMemory }} - emptyDir: - medium: Memory - {{- end }} - {{- if .Values.ingester.persistence.size }} - sizeLimit: {{ .Values.ingester.persistence.size }} - {{- end }} - {{- else }} - volumeClaimTemplates: - {{- range .Values.ingester.persistence.claims }} - - metadata: - name: {{ .name }} - {{- with .annotations }} - annotations: - {{- . | toYaml | nindent 10 }} - {{- end }} - spec: - accessModes: - - ReadWriteOnce - {{- with .storageClass }} - storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }} - {{- end }} - resources: - requests: - storage: {{ .size | quote }} - {{- end }} - {{- end }} -{{- end }} diff --git a/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml b/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml deleted file mode 100644 index db499cae8d583..0000000000000 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml +++ /dev/null @@ -1,234 +0,0 @@ -{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} -{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }} -{{- $replicas := (include "loki.ingester.replicaCount" .) -}} -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: {{ include "loki.ingesterFullname" . }}-zone-b - namespace: {{ .Release.Namespace }} - labels: - {{- include "loki.ingesterLabels" . | nindent 4 }} - app.kubernetes.io/part-of: memberlist - rollout-group: ingester - name: ingester-zone-b - annotations: - rollout-max-unavailable: "{{ include "loki.ingester.maxUnavailable" (dict "ctx" . "replicas" $replicas)}}" - {{- with .Values.loki.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.ingester.zoneAwareReplication.zoneB.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} -spec: -{{- if not .Values.ingester.autoscaling.enabled }} - replicas: {{ $replicas }} -{{- end }} - podManagementPolicy: Parallel - serviceName: {{ include "loki.ingesterFullname" . }}-zone-b - revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} - {{- if and (semverCompare ">= 1.23-0" (include "loki.kubeVersion" .)) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }} - {{/* - Data on the read nodes is easy to replace, so we want to always delete PVCs to make - operation easier, and will rely on re-fetching data when needed. - */}} - persistentVolumeClaimRetentionPolicy: - whenDeleted: {{ .Values.ingester.persistence.whenDeleted }} - whenScaled: {{ .Values.ingester.persistence.whenScaled }} - {{- end }} - selector: - matchLabels: - {{- include "loki.ingesterSelectorLabels" . | nindent 6 }} - name: ingester-zone-b - rollout-group: ingester -{{- with .Values.ingester.updateStrategy }} - updateStrategy: - {{- tpl (. | toYaml) $ | nindent 4 }} -{{- end }} - template: - metadata: - annotations: - {{- include "loki.config.checksum" . | nindent 8 }} - {{- with .Values.loki.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.zoneAwareReplication.zoneB.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "loki.ingesterSelectorLabels" . | nindent 8 }} - app.kubernetes.io/part-of: memberlist - name: ingester-zone-b - rollout-group: ingester - {{- with .Values.loki.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - spec: - {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} - {{- with .Values.ingester.topologySpreadConstraints }} - topologySpreadConstraints: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - serviceAccountName: {{ include "loki.serviceAccountName" . }} - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.hostAliases }} - hostAliases: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- include "loki.ingesterPriorityClassName" . | nindent 6 }} - securityContext: - {{- toYaml .Values.loki.podSecurityContext | nindent 8 }} - terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }} - {{- with .Values.ingester.initContainers }} - initContainers: - {{- toYaml . | nindent 8 }} - {{- end }} - containers: - - name: ingester - image: {{ include "loki.image" . }} - imagePullPolicy: {{ .Values.loki.image.pullPolicy }} - {{- if or .Values.loki.command .Values.ingester.command }} - command: - - {{ coalesce .Values.ingester.command .Values.loki.command | quote }} - {{- end }} - args: - - -config.file=/etc/loki/config/config.yaml - - -ingester.availability-zone=zone-b - - -ingester.unregister-on-shutdown=false - - -ingester.tokens-file-path=/var/loki/ring-tokens - - -target=ingester - {{- with .Values.ingester.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} - ports: - - name: http-metrics - containerPort: 3100 - protocol: TCP - - name: grpc - containerPort: 9095 - protocol: TCP - - name: http-memberlist - containerPort: 7946 - protocol: TCP - {{- with .Values.ingester.extraEnv }} - env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.extraEnvFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - securityContext: - {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} - {{- include "loki.ingester.readinessProbe" . | nindent 10 }} - {{- include "loki.ingester.livenessProbe" . | nindent 10 }} - volumeMounts: - - name: config - mountPath: /etc/loki/config - - name: runtime-config - mountPath: /etc/loki/runtime-config - - name: data - mountPath: /var/loki - {{- if .Values.enterprise.enabled }} - - name: license - mountPath: /etc/loki/license - {{- end }} - {{- with .Values.ingester.extraVolumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.resources }} - resources: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.lifecycle }} - lifecycle: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if .Values.ingester.extraContainers }} - {{- toYaml .Values.ingester.extraContainers | nindent 8}} - {{- end }} - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: rollout-group - operator: In - values: - - ingester - - key: name - operator: NotIn - values: - - ingester-zone-b - topologyKey: kubernetes.io/hostname - {{- with .Values.ingester.zoneAwareReplication.zoneB.extraAffinity }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.zoneAwareReplication.zoneB.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} - volumes: - - name: config - {{- include "loki.configVolume" . | nindent 10 }} - - name: runtime-config - configMap: - name: {{ template "loki.name" . }}-runtime - {{- if .Values.enterprise.enabled }} - - name: license - secret: - {{- if .Values.enterprise.useExternalLicense }} - secretName: {{ .Values.enterprise.externalLicenseName }} - {{- else }} - secretName: enterprise-logs-license - {{- end }} - {{- end }} - {{- with .Values.ingester.extraVolumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- if not .Values.ingester.persistence.enabled }} - - name: data - emptyDir: {} - {{- else if .Values.ingester.persistence.inMemory }} - - name: data - {{- if .Values.ingester.persistence.inMemory }} - emptyDir: - medium: Memory - {{- end }} - {{- if .Values.ingester.persistence.size }} - sizeLimit: {{ .Values.ingester.persistence.size }} - {{- end }} - {{- else }} - volumeClaimTemplates: - {{- range .Values.ingester.persistence.claims }} - - metadata: - name: {{ .name }} - {{- with .annotations }} - annotations: - {{- . | toYaml | nindent 10 }} - {{- end }} - spec: - accessModes: - - ReadWriteOnce - {{- with .storageClass }} - storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }} - {{- end }} - resources: - requests: - storage: {{ .size | quote }} - {{- end }} - {{- end }} -{{- end }} diff --git a/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml b/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml deleted file mode 100644 index 994b460b9a15f..0000000000000 --- a/production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml +++ /dev/null @@ -1,234 +0,0 @@ -{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} -{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }} -{{- $replicas := (include "loki.ingester.replicaCount" .) -}} -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: {{ include "loki.ingesterFullname" . }}-zone-c - namespace: {{ .Release.Namespace }} - labels: - {{- include "loki.ingesterLabels" . | nindent 4 }} - app.kubernetes.io/part-of: memberlist - rollout-group: ingester - name: ingester-zone-c - annotations: - rollout-max-unavailable: "{{ include "loki.ingester.maxUnavailable" (dict "ctx" . "replicas" $replicas)}}" - {{- with .Values.loki.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.ingester.zoneAwareReplication.zoneC.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} -spec: -{{- if not .Values.ingester.autoscaling.enabled }} - replicas: {{ $replicas }} -{{- end }} - podManagementPolicy: Parallel - serviceName: {{ include "loki.ingesterFullname" . }}-zone-c - revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} - {{- if and (semverCompare ">= 1.23-0" (include "loki.kubeVersion" .)) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }} - {{/* - Data on the read nodes is easy to replace, so we want to always delete PVCs to make - operation easier, and will rely on re-fetching data when needed. - */}} - persistentVolumeClaimRetentionPolicy: - whenDeleted: {{ .Values.ingester.persistence.whenDeleted }} - whenScaled: {{ .Values.ingester.persistence.whenScaled }} - {{- end }} - selector: - matchLabels: - {{- include "loki.ingesterSelectorLabels" . | nindent 6 }} - name: ingester-zone-c - rollout-group: ingester -{{- with .Values.ingester.updateStrategy }} - updateStrategy: - {{- tpl (. | toYaml) $ | nindent 4 }} -{{- end }} - template: - metadata: - annotations: - {{- include "loki.config.checksum" . | nindent 8 }} - {{- with .Values.loki.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.zoneAwareReplication.zoneC.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "loki.ingesterSelectorLabels" . | nindent 8 }} - app.kubernetes.io/part-of: memberlist - name: ingester-zone-c - rollout-group: ingester - {{- with .Values.loki.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - spec: - {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} - {{- with .Values.ingester.topologySpreadConstraints }} - topologySpreadConstraints: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - serviceAccountName: {{ include "loki.serviceAccountName" . }} - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.hostAliases }} - hostAliases: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- include "loki.ingesterPriorityClassName" . | nindent 6 }} - securityContext: - {{- toYaml .Values.loki.podSecurityContext | nindent 8 }} - terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }} - {{- with .Values.ingester.initContainers }} - initContainers: - {{- toYaml . | nindent 8 }} - {{- end }} - containers: - - name: ingester - image: {{ include "loki.image" . }} - imagePullPolicy: {{ .Values.loki.image.pullPolicy }} - {{- if or .Values.loki.command .Values.ingester.command }} - command: - - {{ coalesce .Values.ingester.command .Values.loki.command | quote }} - {{- end }} - args: - - -config.file=/etc/loki/config/config.yaml - - -ingester.availability-zone=zone-c - - -ingester.unregister-on-shutdown=false - - -ingester.tokens-file-path=/var/loki/ring-tokens - - -target=ingester - {{- with .Values.ingester.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} - ports: - - name: http-metrics - containerPort: 3100 - protocol: TCP - - name: grpc - containerPort: 9095 - protocol: TCP - - name: http-memberlist - containerPort: 7946 - protocol: TCP - {{- with .Values.ingester.extraEnv }} - env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.extraEnvFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - securityContext: - {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} - {{- include "loki.ingester.readinessProbe" . | nindent 10 }} - {{- include "loki.ingester.livenessProbe" . | nindent 10 }} - volumeMounts: - - name: config - mountPath: /etc/loki/config - - name: runtime-config - mountPath: /etc/loki/runtime-config - - name: data - mountPath: /var/loki - {{- if .Values.enterprise.enabled }} - - name: license - mountPath: /etc/loki/license - {{- end }} - {{- with .Values.ingester.extraVolumeMounts }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.resources }} - resources: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.lifecycle }} - lifecycle: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- if .Values.ingester.extraContainers }} - {{- toYaml .Values.ingester.extraContainers | nindent 8}} - {{- end }} - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: rollout-group - operator: In - values: - - ingester - - key: name - operator: NotIn - values: - - ingester-zone-c - topologyKey: kubernetes.io/hostname - {{- with .Values.ingester.zoneAwareReplication.zoneC.extraAffinity }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.zoneAwareReplication.zoneC.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.ingester.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} - volumes: - - name: config - {{- include "loki.configVolume" . | nindent 10 }} - - name: runtime-config - configMap: - name: {{ template "loki.name" . }}-runtime - {{- if .Values.enterprise.enabled }} - - name: license - secret: - {{- if .Values.enterprise.useExternalLicense }} - secretName: {{ .Values.enterprise.externalLicenseName }} - {{- else }} - secretName: enterprise-logs-license - {{- end }} - {{- end }} - {{- with .Values.ingester.extraVolumes }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- if not .Values.ingester.persistence.enabled }} - - name: data - emptyDir: {} - {{- else if .Values.ingester.persistence.inMemory }} - - name: data - {{- if .Values.ingester.persistence.inMemory }} - emptyDir: - medium: Memory - {{- end }} - {{- if .Values.ingester.persistence.size }} - sizeLimit: {{ .Values.ingester.persistence.size }} - {{- end }} - {{- else }} - volumeClaimTemplates: - {{- range .Values.ingester.persistence.claims }} - - metadata: - name: {{ .name }} - {{- with .annotations }} - annotations: - {{- . | toYaml | nindent 10 }} - {{- end }} - spec: - accessModes: - - ReadWriteOnce - {{- with .storageClass }} - storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }} - {{- end }} - resources: - requests: - storage: {{ .size | quote }} - {{- end }} - {{- end }} -{{- end }} diff --git a/production/helm/loki/templates/ingester/statefulset-ingester.yaml b/production/helm/loki/templates/ingester/statefulset-ingester.yaml index f66145c1720fd..04defa160ef84 100644 --- a/production/helm/loki/templates/ingester/statefulset-ingester.yaml +++ b/production/helm/loki/templates/ingester/statefulset-ingester.yaml @@ -1,27 +1,31 @@ -{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} -{{- if and $isDistributed (or (not .Values.ingester.zoneAwareReplication.enabled) .Values.ingester.zoneAwareReplication.migration.enabled) }} +{{- $args := dict "ctx" . "component" "ingester" "memberlist" true -}} +{{- $zonesMap := include "loki.zoneAwareReplicationMap" $args | fromYaml -}} +{{- range $zoneName, $rolloutZone := $zonesMap }} +{{- with $ -}} +{{- $_ := set $args "rolloutZoneName" $zoneName -}} apiVersion: apps/v1 kind: StatefulSet metadata: - name: {{ include "loki.ingesterFullname" . }} + name: {{ include "loki.resourceName" $args }} namespace: {{ .Release.Namespace }} labels: {{- include "loki.ingesterLabels" . | nindent 4 }} app.kubernetes.io/part-of: memberlist + name: {{ include "loki.resourceName" $args }} {{- with .Values.loki.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: {{- if not .Values.ingester.autoscaling.enabled }} - replicas: {{ .Values.ingester.replicas }} + replicas: {{ $rolloutZone.replicas }} {{- end }} podManagementPolicy: Parallel {{- with .Values.ingester.updateStrategy }} updateStrategy: {{- tpl (. | toYaml) $ | nindent 4 }} {{- end }} - serviceName: {{ include "loki.ingesterFullname" . }}-headless + serviceName: {{ include "loki.resourceName" $args }}-headless revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} {{- if and (semverCompare ">= 1.23-0" (include "loki.kubeVersion" .)) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }} {{/* @@ -48,6 +52,7 @@ spec: labels: {{- include "loki.ingesterSelectorLabels" . | nindent 8 }} app.kubernetes.io/part-of: memberlist + name: {{ include "loki.resourceName" $args }} {{- with .Values.loki.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} @@ -88,11 +93,10 @@ spec: {{- end }} args: - -config.file=/etc/loki/config/config.yaml - - -ingester.availability-zone=zone-default + - -ingester.availability-zone={{ $zoneName | default "zone-default" }} - -target=ingester - {{- with .Values.ingester.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.ingester.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -103,14 +107,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.ingester.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ingester.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.ingester.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.ingester.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} {{- include "loki.ingester.readinessProbe" . | nindent 10 }} @@ -140,11 +142,11 @@ spec: {{- if .Values.ingester.extraContainers }} {{- toYaml .Values.ingester.extraContainers | nindent 8}} {{- end }} - {{- with .Values.ingester.affinity }} + {{- with $rolloutZone.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.ingester.nodeSelector }} + {{- with $rolloutZone.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} @@ -184,22 +186,29 @@ spec: {{- end }} {{- else }} volumeClaimTemplates: - {{- range .Values.ingester.persistence.claims }} - - metadata: - name: {{ .name }} - {{- with .annotations }} + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: data + {{- if .Values.ingester.persistence.annotations }} annotations: - {{- . | toYaml | nindent 10 }} + {{- toYaml .Values.ingester.persistence.annotations | nindent 10 }} {{- end }} spec: - accessModes: - - ReadWriteOnce - {{- with .storageClass }} - storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }} + {{- $storageClass := default .Values.ingester.persistence.storageClass $rolloutZone.storageClass }} + {{- if $storageClass }} + {{- if (eq "-" $storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: {{ $storageClass }} + {{- end }} {{- end }} + accessModes: + {{- toYaml .Values.ingester.persistence.accessModes | nindent 10 }} resources: requests: - storage: {{ .size | quote }} + storage: "{{ .Values.ingester.persistence.size }}" {{- end }} - {{- end }} -{{- end }} +--- +{{ end }} +{{ end }} diff --git a/production/helm/loki/templates/pattern-ingester/statefulset-pattern-ingester.yaml b/production/helm/loki/templates/pattern-ingester/statefulset-pattern-ingester.yaml index 9538edcb57150..9898b9378922c 100644 --- a/production/helm/loki/templates/pattern-ingester/statefulset-pattern-ingester.yaml +++ b/production/helm/loki/templates/pattern-ingester/statefulset-pattern-ingester.yaml @@ -76,9 +76,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=pattern-ingester - {{- with .Values.patternIngester.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.patternIngester.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -89,14 +88,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.patternIngester.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.patternIngester.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.patternIngester.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.patternIngester.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} {{- include "loki.patternIngester.readinessProbe" . | nindent 10 }} diff --git a/production/helm/loki/templates/querier/deployment-querier.yaml b/production/helm/loki/templates/querier/deployment-querier.yaml index 80699f21fd162..da4e9ddf945e2 100644 --- a/production/helm/loki/templates/querier/deployment-querier.yaml +++ b/production/helm/loki/templates/querier/deployment-querier.yaml @@ -81,9 +81,8 @@ spec: - -distributor.zone-awareness-enabled=true {{- end }} {{- end }} - {{- with .Values.querier.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraArgs }} + {{ include "loki.templateEnv" .Values.querier.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -94,14 +93,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.querier.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.querier.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.querier.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.querier.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/query-frontend/deployment-query-frontend.yaml b/production/helm/loki/templates/query-frontend/deployment-query-frontend.yaml index 6eda5c51dfc0e..f6abe500a89d0 100644 --- a/production/helm/loki/templates/query-frontend/deployment-query-frontend.yaml +++ b/production/helm/loki/templates/query-frontend/deployment-query-frontend.yaml @@ -67,9 +67,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=query-frontend - {{- with .Values.queryFrontend.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraArgs }} + {{ include "loki.templateEnv" .Values.queryFrontend.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -80,14 +79,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.queryFrontend.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.queryFrontend.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.queryFrontend.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.queryFrontend.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/query-scheduler/deployment-query-scheduler.yaml b/production/helm/loki/templates/query-scheduler/deployment-query-scheduler.yaml index 11b2829ebeec0..0fd37d50e53f1 100644 --- a/production/helm/loki/templates/query-scheduler/deployment-query-scheduler.yaml +++ b/production/helm/loki/templates/query-scheduler/deployment-query-scheduler.yaml @@ -61,9 +61,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=query-scheduler - {{- with .Values.queryScheduler.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.queryScheduler.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -74,14 +73,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.queryScheduler.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.queryScheduler.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.queryScheduler.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.queryScheduler.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/read/deployment-read.yaml b/production/helm/loki/templates/read/deployment-read.yaml index 245119cb44dca..cde9f10578d5c 100644 --- a/production/helm/loki/templates/read/deployment-read.yaml +++ b/production/helm/loki/templates/read/deployment-read.yaml @@ -72,9 +72,8 @@ spec: - -target={{ .Values.read.targetModule }} - -legacy-read-mode=false - -common.compactor-grpc-address={{ include "loki.backendFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}:{{ .Values.loki.server.grpc_listen_port }} - {{- with .Values.read.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.read.extraArgs }} ports: - name: http-metrics containerPort: {{ .Values.loki.server.http_listen_port }} @@ -85,14 +84,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.read.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.read.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.read.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.read.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/read/statefulset-read.yaml b/production/helm/loki/templates/read/statefulset-read.yaml index 9d4213b174588..d0ece75f36ef7 100644 --- a/production/helm/loki/templates/read/statefulset-read.yaml +++ b/production/helm/loki/templates/read/statefulset-read.yaml @@ -85,9 +85,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target={{ .Values.read.targetModule }} - {{- with .Values.read.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.read.extraArgs }} ports: - name: http-metrics containerPort: {{ .Values.loki.server.http_listen_port }} @@ -98,14 +97,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.read.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.read.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.read.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.read.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/ruler/statefulset-ruler.yaml b/production/helm/loki/templates/ruler/statefulset-ruler.yaml index 8153a8bb3827f..5f5f100c98533 100644 --- a/production/helm/loki/templates/ruler/statefulset-ruler.yaml +++ b/production/helm/loki/templates/ruler/statefulset-ruler.yaml @@ -62,9 +62,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=ruler - {{- with .Values.ruler.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.ruler.extraArgs }} ports: - name: http-metrics containerPort: 3100 @@ -75,14 +74,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.ruler.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.ruler.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.ruler.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.ruler.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/single-binary/statefulset.yaml b/production/helm/loki/templates/single-binary/statefulset.yaml index 4acd406b9cfa5..d0745cabd4311 100644 --- a/production/helm/loki/templates/single-binary/statefulset.yaml +++ b/production/helm/loki/templates/single-binary/statefulset.yaml @@ -154,9 +154,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target={{ .Values.singleBinary.targetModule }} - {{- with .Values.singleBinary.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.singleBinary.extraArgs }} ports: - name: http-metrics containerPort: {{ .Values.loki.server.http_listen_port }} @@ -167,14 +166,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.singleBinary.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.singleBinary.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.singleBinary.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.singleBinary.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/table-manager/deployment-table-manager.yaml b/production/helm/loki/templates/table-manager/deployment-table-manager.yaml index e3f6d0d94a696..11c9dc53339a4 100644 --- a/production/helm/loki/templates/table-manager/deployment-table-manager.yaml +++ b/production/helm/loki/templates/table-manager/deployment-table-manager.yaml @@ -53,9 +53,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target=table-manager - {{- with .Values.tableManager.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.tableManager.extraArgs }} ports: - name: http-metrics containerPort: {{ .Values.loki.server.http_listen_port }} @@ -63,14 +62,12 @@ spec: - name: grpc containerPort: {{ .Values.loki.server.grpc_listen_port }} protocol: TCP - {{- with .Values.tableManager.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.tableManager.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.tableManager.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.tableManager.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/templates/tokengen/job-tokengen.yaml b/production/helm/loki/templates/tokengen/job-tokengen.yaml index b0950d6f19675..8598cc7e69d58 100644 --- a/production/helm/loki/templates/tokengen/job-tokengen.yaml +++ b/production/helm/loki/templates/tokengen/job-tokengen.yaml @@ -53,9 +53,8 @@ spec: - -config.file=/etc/loki/config/config.yaml - -target={{ .Values.enterprise.tokengen.targetModule }} - -tokengen.token-file=/shared/admin-token - {{- with .Values.enterprise.tokengen.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.enterprise.tokengen.extraArgs }} volumeMounts: {{- if .Values.enterprise.tokengen.extraVolumeMounts }} {{ toYaml .Values.enterprise.tokengen.extraVolumeMounts | nindent 12 }} @@ -69,13 +68,11 @@ spec: - name: license mountPath: /etc/loki/license env: - {{- if .Values.enterprise.tokengen.env }} - {{ toYaml .Values.enterprise.tokengen.env | nindent 12 }} - {{- end }} - {{- with .Values.enterprise.tokengen.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.enterprise.tokengen.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.enterprise.tokengen.extraEnvFrom }} containers: - name: create-secret image: {{ include "loki.kubectlImage" . }} diff --git a/production/helm/loki/templates/write/statefulset-write.yaml b/production/helm/loki/templates/write/statefulset-write.yaml index 4d6183b291c13..e46e174e67da2 100644 --- a/production/helm/loki/templates/write/statefulset-write.yaml +++ b/production/helm/loki/templates/write/statefulset-write.yaml @@ -91,9 +91,8 @@ spec: args: - -config.file=/etc/loki/config/config.yaml - -target={{ .Values.write.targetModule }} - {{- with .Values.write.extraArgs }} - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateArgs" .Values.loki.extraArgs }} + {{ include "loki.templateArgs" .Values.write.extraArgs }} ports: - name: http-metrics containerPort: {{ .Values.loki.server.http_listen_port }} @@ -104,14 +103,12 @@ spec: - name: http-memberlist containerPort: 7946 protocol: TCP - {{- with .Values.write.extraEnv }} env: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.write.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.loki.extraEnv }} + {{ include "loki.templateEnv" .Values.write.extraEnv }} envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} + {{ include "loki.templateEnv" .Values.loki.extraEnvFrom }} + {{ include "loki.templateEnv" .Values.write.extraEnvFrom }} securityContext: {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} readinessProbe: diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index 8c3c5c3bb6e3a..183002c5a9017 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -61,6 +61,16 @@ loki: digest: null # -- Docker image pull policy pullPolicy: IfNotPresent + # -- Common environment variables to add to all pods + extraEnv: [] + # -- Common environment injections to add to all pods + # For example to inject values from a Secret, use: + # extraEnvFrom: + # - secretRef: + # name: mysecret + extraEnvFrom: [] + # -- Common additional CLI arguments for all components + extraArgs: [] # -- Common annotations for all deployments/StatefulSets annotations: {} # -- Common annotations for all pods @@ -1820,73 +1830,114 @@ ingester: enabled: false # -- Use emptyDir with ramdisk for storage. **Please note that all data in ingester will be lost on pod restart** inMemory: false - # -- List of the ingester PVCs - # @notationType -- list - claims: - - name: data - size: 10Gi - # -- Storage class to be used. - # If defined, storageClassName: . - # If set to "-", storageClassName: "", which disables dynamic provisioning. - # If empty or set to null, no storageClassName spec is - # set, choosing the default provisioner (gp2 on AWS, standard on GKE, AWS, and OpenStack). - storageClass: null - # - name: wal - # size: 150Gi + + # Ingester data Persistent Volume Claim annotations + # + annotations: {} + + # Ingester data Persistent Volume access modes + # Must match those of existing PV or dynamic provisioner + # Ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ + accessModes: + - ReadWriteOnce + + # Ingester data Persistent Volume size + size: 2Gi + # -- Enable StatefulSetAutoDeletePVC feature enableStatefulSetAutoDeletePVC: false whenDeleted: Retain whenScaled: Retain + + # Ingester data Persistent Volume Storage Class + # If defined, storageClassName: + # If set to "-", storageClassName: "", which disables dynamic provisioning + # If undefined (the default) or set to null, no storageClassName spec is + # set, choosing the default provisioner. + # + # A per-zone storageClass configuration in `ingester.zoneAwareReplication.zones[*].storageClass` takes precedence over this field. + # + # storageClass: "-" + # -- Adds the appProtocol field to the ingester service. This allows ingester to work with istio protocol selection. appProtocol: # -- Set the optional grpc service protocol. Ex: "grpc", "http2" or "https" grpc: "" - # -- Enabling zone awareness on ingesters will create 3 statefulests where all writes will send a replica to each zone. - # This is primarily intended to accelerate rollout operations by allowing for multiple ingesters within a single - # zone to be shutdown and restart simultaneously (the remaining 2 zones will be guaranteed to have at least one copy - # of the data). - # Note: This can be used to run Loki over multiple cloud provider availability zones however this is not currently - # recommended as Loki is not optimized for this and cross zone network traffic costs can become extremely high - # extremely quickly. Even with zone awareness enabled, it is recommended to run Loki in a single availability zone. + + # -- Options to configure zone-aware replication for ingester + # Example configuration with full geographical redundancy: + # rollout_operator: + # enabled: true + # ingester: + # zoneAwareReplication: + # enabled: true + # topologyKey: 'kubernetes.io/hostname' # This generates default anti-affinity rules + # zones: # Zone list has to be fully redefined for modification. Update with you actual zones or skip to use logical zones only. + # - name: zone-a + # nodeSelector: + # topology.kubernetes.io/zone: us-central1-a + # storageClass: storage-class-us-central1-a + # - name: zone-a + # nodeSelector: + # topology.kubernetes.io/zone: us-central1-b + # storageClass: storage-class-us-central1-b + # - name: zone-c + # nodeSelector: + # topology.kubernetes.io/zone: us-central1-c + # storageClass: storage-class-us-central1-c + # zoneAwareReplication: # -- Enable zone awareness. enabled: true # -- The percent of replicas in each zone that will be restarted at once. In a value of 0-100 maxUnavailablePct: 33 - # -- zoneA configuration - zoneA: - # -- optionally define a node selector for this zone - nodeSelector: null - # -- optionally define extra affinity rules, by default different zones are not allowed to schedule on the same host - extraAffinity: {} - # -- Specific annotations to add to zone A statefulset - annotations: {} - # -- Specific annotations to add to zone A pods - podAnnotations: {} - zoneB: - # -- optionally define a node selector for this zone - nodeSelector: null - # -- optionally define extra affinity rules, by default different zones are not allowed to schedule on the same host - extraAffinity: {} - # -- Specific annotations to add to zone B statefulset - annotations: {} - # -- Specific annotations to add to zone B pods - podAnnotations: {} - zoneC: - # -- optionally define a node selector for this zone - nodeSelector: null - # -- optionally define extra affinity rules, by default different zones are not allowed to schedule on the same host - extraAffinity: {} - # -- Specific annotations to add to zone C statefulset - annotations: {} - # -- Specific annotations to add to zone C pods - podAnnotations: {} - # -- The migration block allows migrating non zone aware ingesters to zone aware ingesters. migration: enabled: false excludeDefaultZone: false readPath: false writePath: false + # -- Zone definitions for ingester zones. Note: you have to redefine the whole list to change parts as YAML does not allow to modify parts of a list. + zones: + # -- Name of the zone, used in labels and selectors. Must follow Kubernetes naming restrictions: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ + - name: zone-a + # -- nodeselector to restrict where pods of this zone can be placed. E.g.: + # nodeSelector: + # topology.kubernetes.io/zone: zone-a + nodeSelector: null + # -- extraAffinity adds user defined custom affinity rules (merged with generated rules) + extraAffinity: {} + # -- Ingester data Persistent Volume Storage Class + # If defined, storageClassName: + # If set to "-", then use `storageClassName: ""`, which disables dynamic provisioning + # If undefined or set to null (the default), then fall back to the value of `ingester.persistentVolume.storageClass`. + storageClass: null + # -- Name of the zone, used in labels and selectors. Must follow Kubernetes naming restrictions: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ + - name: zone-b + # -- nodeselector to restrict where pods of this zone can be placed. E.g.: + # nodeSelector: + # topology.kubernetes.io/zone: zone-b + nodeSelector: null + # -- extraAffinity adds user defined custom affinity rules (merged with generated rules) + extraAffinity: {} + # -- Ingester data Persistent Volume Storage Class + # If defined, storageClassName: + # If set to "-", then use `storageClassName: ""`, which disables dynamic provisioning + # If undefined or set to null (the default), then fall back to the value of `ingester.persistentVolume.storageClass`. + storageClass: null + # -- Name of the zone, used in labels and selectors. Must follow Kubernetes naming restrictions: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ + - name: zone-c + # -- nodeselector to restrict where pods of this zone can be placed. E.g.: + # nodeSelector: + # topology.kubernetes.io/zone: zone-c + nodeSelector: null + # -- extraAffinity adds user defined custom affinity rules (merged with generated rules) + extraAffinity: {} + # -- Ingester data Persistent Volume Storage Class + # If defined, storageClassName: + # If set to "-", then use `storageClassName: ""`, which disables dynamic provisioning + # If undefined or set to null (the default), then fall back to the value of `ingester.persistentVolume.storageClass`. + storageClass: null + # -- Configuration for the distributor distributor: # -- Number of replicas for the distributor