diff --git a/docs/sources/setup/install/helm/reference.md b/docs/sources/setup/install/helm/reference.md
index 8252a6fd103a3..9302913407f77 100644
--- a/docs/sources/setup/install/helm/reference.md
+++ b/docs/sources/setup/install/helm/reference.md
@@ -258,6 +258,24 @@ null
true
+ |
+
+
+ backend.persistence.whenDeleted |
+ string |
+ Enable StatefulSetAutoDeletePVC feature https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention |
+
+"Delete"
+
+ |
+
+
+ backend.persistence.whenScaled |
+ string |
+ |
+
+"Delete"
+
|
@@ -267,6 +285,17 @@ true
{}
+ |
+
+
+ backend.podDisruptionBudget |
+ object |
+ Pod Disruption Budget |
+
+{
+ "maxUnavailable": 1
+}
+
|
@@ -339,6 +368,17 @@ null
{}
+ |
+
+
+ backend.statefulStrategy |
+ object |
+ updateStrategy of the write statefulset. |
+
+{
+ "type": "RollingUpdate"
+}
+
|
@@ -1305,6 +1345,17 @@ See values.yaml
{}
+ |
+
+
+ gateway.podDisruptionBudget |
+ object |
+ Pod Disruption Budget |
+
+{
+ "maxUnavailable": 1
+}
+
|
@@ -2017,7 +2068,9 @@ null
object |
Optional ingester configuration |
-{}
+{
+ "concurrent_flushes": 20
+}
|
@@ -2661,6 +2714,23 @@ null
"type": "RollingUpdate"
}
+
+
+
+ monitoring.podSecurityContext |
+ object |
+ podSecurityContext is the pod security context for the rollout operator. When installing on OpenShift, override podSecurityContext settings with rollout_operator: podSecurityContext: fsGroup: null runAsGroup: null runAsUser: null |
+
+{
+ "fsGroup": 10001,
+ "runAsGroup": 10001,
+ "runAsNonRoot": true,
+ "runAsUser": 10001,
+ "seccompProfile": {
+ "type": "RuntimeDefault"
+ }
+}
+
|
@@ -2724,6 +2794,33 @@ true
null
+ |
+
+
+ monitoring.securityContext.allowPrivilegeEscalation |
+ bool |
+ |
+
+false
+
+ |
+
+
+ monitoring.securityContext.capabilities.drop[0] |
+ string |
+ |
+
+"ALL"
+
+ |
+
+
+ monitoring.securityContext.readOnlyRootFilesystem |
+ bool |
+ |
+
+true
+
|
@@ -3191,6 +3288,15 @@ false
false
+ |
+
+
+ rbac.useExistingRole |
+ bool |
+ Use custom clusterrole for ruler/backend |
+
+false
+
|
@@ -3416,6 +3522,17 @@ null
{}
+ |
+
+
+ read.podDisruptionBudget |
+ object |
+ Pod Disruption Budget |
+
+{
+ "maxUnavailable": 1
+}
+
|
@@ -3488,6 +3605,17 @@ null
{}
+ |
+
+
+ read.statefulStrategy |
+ object |
+ updateStrategy of the write statefulset. |
+
+{
+ "type": "RollingUpdate"
+}
+
|
@@ -3524,6 +3652,26 @@ null
[]
+ |
+
+
+ rollout_operator |
+ object |
+ Setting for the Grafana Rollout Operator https://github.com/grafana/helm-charts/tree/main/charts/rollout-operator |
+
+{
+ "enabled": false
+}
+
+ |
+
+
+ rollout_operator.enabled |
+ bool |
+ This should be true if write.zoneAwareReplication.enabled=true |
+
+false
+
|
@@ -3992,6 +4140,17 @@ null
{}
+ |
+
+
+ singleBinary.podDisruptionBudget |
+ object |
+ Pod Disruption Budget |
+
+{
+ "maxUnavailable": 1
+}
+
|
@@ -4055,6 +4214,17 @@ null
{}
+ |
+
+
+ singleBinary.statefulStrategy |
+ object |
+ updateStrategy of the write statefulset. |
+
+{
+ "type": "RollingUpdate"
+}
+
|
@@ -4429,7 +4599,7 @@ null
write.affinity |
- string |
+ object |
Affinity for write pods. Passed through `tpl` and, thus, to be configured as string |
Hard node and soft zone anti-affinity
@@ -4716,6 +4886,24 @@ null
true
+ |
+ |
+
+ write.persistence.whenDeleted |
+ string |
+ Enable StatefulSetAutoDeletePVC feature https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention |
+
+"Delete"
+
+ |
+
+
+ write.persistence.whenScaled |
+ string |
+ |
+
+"Delete"
+
|
@@ -4725,6 +4913,17 @@ true
{}
+ |
+
+
+ write.podDisruptionBudget |
+ object |
+ Pod Disruption Budget |
+
+{
+ "maxUnavailable": 1
+}
+
|
@@ -4797,6 +4996,17 @@ null
{}
+ |
+
+
+ write.statefulStrategy |
+ object |
+ updateStrategy of the write statefulset. This is ignored when write.zoneAwareReplication.enabled=true. |
+
+{
+ "type": "RollingUpdate"
+}
+
|
@@ -4833,6 +5043,295 @@ null
[]
+ |
+
+
+ write.zoneAwareReplication |
+ object |
+ Options to configure zone-aware replication for write path Example configuration with full geographical redundancy: rollout_operator: enabled: true write: 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 |
+
+{
+ "enabled": false,
+ "maxUnavailable": 10,
+ "migration": {
+ "enabled": false,
+ "excludeDefaultZone": false,
+ "readPath": false,
+ "replicas": 0,
+ "scaleDownDefaultZone": false,
+ "writePath": false
+ },
+ "topologyKey": null,
+ "zones": [
+ {
+ "extraAffinity": {},
+ "name": "zone-a",
+ "nodeSelector": null,
+ "storageClass": null
+ },
+ {
+ "extraAffinity": {},
+ "name": "zone-b",
+ "nodeSelector": null,
+ "storageClass": null
+ },
+ {
+ "extraAffinity": {},
+ "name": "zone-c",
+ "nodeSelector": null,
+ "storageClass": null
+ }
+ ]
+}
+
+ |
+
+
+ write.zoneAwareReplication.enabled |
+ bool |
+ Enable zone-aware replication for write path |
+
+false
+
+ |
+
+
+ write.zoneAwareReplication.maxUnavailable |
+ int |
+ Maximum number of write pods that can be unavailable per zone during rollout |
+
+10
+
+ |
+
+
+ write.zoneAwareReplication.migration |
+ object |
+ Auxiliary values for migration, see https://grafana.com/docs/loki/latest/setup/migrate/migrate-from-single-zone-with-helm/ |
+
+{
+ "enabled": false,
+ "excludeDefaultZone": false,
+ "readPath": false,
+ "replicas": 0,
+ "scaleDownDefaultZone": false,
+ "writePath": false
+}
+
+ |
+
+
+ write.zoneAwareReplication.migration.enabled |
+ bool |
+ Indicate if migration is ongoing for multi zone write |
+
+false
+
+ |
+
+
+ write.zoneAwareReplication.migration.excludeDefaultZone |
+ bool |
+ Exclude default zone on write path |
+
+false
+
+ |
+
+
+ write.zoneAwareReplication.migration.readPath |
+ bool |
+ Enable zone-awareness, read path only |
+
+false
+
+ |
+
+
+ write.zoneAwareReplication.migration.replicas |
+ int |
+ Total number of replicas to start in availability zones when migration is enabled |
+
+0
+
+ |
+
+
+ write.zoneAwareReplication.migration.scaleDownDefaultZone |
+ bool |
+ Scale default zone write pods to 0 |
+
+false
+
+ |
+
+
+ write.zoneAwareReplication.migration.writePath |
+ bool |
+ Enable zone-awareness, write path only |
+
+false
+
+ |
+
+
+ write.zoneAwareReplication.topologyKey |
+ string |
+ topologyKey to use in pod anti-affinity. If unset, no anti-affinity rules are generated. If set, the generated anti-affinity rule makes sure that pods from different zones do not mix. E.g.: topologyKey: 'kubernetes.io/hostname' |
+
+null
+
+ |
+
+
+ write.zoneAwareReplication.zones |
+ list |
+ Zone definitions for write zones. Note: you have to redefine the whole list to change parts as YAML does not allow to modify parts of a list. |
+
+[
+ {
+ "extraAffinity": {},
+ "name": "zone-a",
+ "nodeSelector": null,
+ "storageClass": null
+ },
+ {
+ "extraAffinity": {},
+ "name": "zone-b",
+ "nodeSelector": null,
+ "storageClass": null
+ },
+ {
+ "extraAffinity": {},
+ "name": "zone-c",
+ "nodeSelector": null,
+ "storageClass": null
+ }
+]
+
+ |
+
+
+ write.zoneAwareReplication.zones[0] |
+ object |
+ Name of the zone, used in labels and selectors. Must follow Kubernetes naming restrictions: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ |
+
+{
+ "extraAffinity": {},
+ "name": "zone-a",
+ "nodeSelector": null,
+ "storageClass": null
+}
+
+ |
+
+
+ write.zoneAwareReplication.zones[0].extraAffinity |
+ object |
+ extraAffinity adds user defined custom affinity rules (merged with generated rules) |
+
+{}
+
+ |
+
+
+ write.zoneAwareReplication.zones[0].nodeSelector |
+ string |
+ nodeselector to restrict where pods of this zone can be placed. E.g.: nodeSelector: topology.kubernetes.io/zone: zone-a |
+
+null
+
+ |
+
+
+ write.zoneAwareReplication.zones[0].storageClass |
+ string |
+ write 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 `write.persistentVolume.storageClass`. |
+
+null
+
+ |
+
+
+ write.zoneAwareReplication.zones[1] |
+ object |
+ Name of the zone, used in labels and selectors. Must follow Kubernetes naming restrictions: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ |
+
+{
+ "extraAffinity": {},
+ "name": "zone-b",
+ "nodeSelector": null,
+ "storageClass": null
+}
+
+ |
+
+
+ write.zoneAwareReplication.zones[1].extraAffinity |
+ object |
+ extraAffinity adds user defined custom affinity rules (merged with generated rules) |
+
+{}
+
+ |
+
+
+ write.zoneAwareReplication.zones[1].nodeSelector |
+ string |
+ nodeselector to restrict where pods of this zone can be placed. E.g.: nodeSelector: topology.kubernetes.io/zone: zone-b |
+
+null
+
+ |
+
+
+ write.zoneAwareReplication.zones[1].storageClass |
+ string |
+ write 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 `write.persistentVolume.storageClass`. |
+
+null
+
+ |
+
+
+ write.zoneAwareReplication.zones[2] |
+ object |
+ Name of the zone, used in labels and selectors. Must follow Kubernetes naming restrictions: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ |
+
+{
+ "extraAffinity": {},
+ "name": "zone-c",
+ "nodeSelector": null,
+ "storageClass": null
+}
+
+ |
+
+
+ write.zoneAwareReplication.zones[2].extraAffinity |
+ object |
+ extraAffinity adds user defined custom affinity rules (merged with generated rules) |
+
+{}
+
+ |
+
+
+ write.zoneAwareReplication.zones[2].nodeSelector |
+ string |
+ nodeselector to restrict where pods of this zone can be placed. E.g.: nodeSelector: topology.kubernetes.io/zone: zone-c |
+
+null
+
+ |
+
+
+ write.zoneAwareReplication.zones[2].storageClass |
+ string |
+ write 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 `write.persistentVolume.storageClass`. |
+
+null
+
|
diff --git a/docs/sources/setup/migrate/migrate-from-single-zone-with-helm/index.md b/docs/sources/setup/migrate/migrate-from-single-zone-with-helm/index.md
new file mode 100644
index 0000000000000..734559442a2a2
--- /dev/null
+++ b/docs/sources/setup/migrate/migrate-from-single-zone-with-helm/index.md
@@ -0,0 +1,248 @@
+---
+title: "Migrate from single zone to zone-aware replication in Loki Helm chart version 5.41.0"
+menuTitle: "Migrate to zone-aware ingesters(write) with helm"
+description: "Learn how to migrate ingesters(write) from having a single availability zone to full zone-aware replication using the Grafana Loki Helm chart"
+weight: 800
+keywords:
+ - migrate
+ - ssd
+ - scalable
+ - simple
+ - zone-aware
+ - helm
+---
+
+# Migrate from single zone to zone-aware replication in Loki Helm chart version 5.41.0
+
+> **Note:** This document was tested with Loki versions 2.9.2 and `loki` Helm chart version 5.41.0. It might work with more recent versions of Loki, but it is recommended to verify that no changes to default configs and helm chart values have been made.
+
+The `loki` Helm chart version 5.41.0 allows for enabling zone-aware replication for the write component. This is not enabled by default in version 5.41.0 due to being a breaking change for existing installations and requires a migration.
+
+This document explains how to migrate the write component from single zone to [zone-aware replication]({{< relref "../operations/zone-ingesters" >}}) with Helm.
+
+**Before you begin:**
+
+We recommend having a Grafana instance available to monitor the existing cluster, to make sure there is no data loss during the migration process.
+
+## Migration
+The following are steps to live migrate (no downtime) an existing Loki deployment from a single write StatefulSet to 3 zone aware write StatefulSets.
+
+These instructions assume you are using the SSD `loki` helm chart deployment.
+
+1. Temporarily double max series limits
+
+ Explanation: while the new write StatefulSets are being added, some series will start to be written to new write pods, however the series will also exist on old write pods, thus the series will count twice towards limits. Not updating the limits might lead to writes to be refused due to limits violation.
+
+ The `limits_config.max_global_streams_per_user` Loki configuration parameter has a non-zero default value of 5000. Double the default or your value by setting:
+
+ ```yaml
+ loki:
+ limits_config:
+ max_global_streams_per_user: 10000 # <-- or your value doubled
+ ```
+
+1. Start the migration by using the following helm values:
+ ```yaml
+ rollout_operator:
+ enabled: true
+
+ write:
+ zoneAwareReplication:
+ enabled: true
+ maxUnavailable:
+ topologyKey: 'kubernetes.io/hostname'
+ zones:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ migration:
+ enabled: true
+ ```
+ > **Note**: replace `` with 1/3 of the current replicas.
+ > **Note**: replace `` with your real zones.
+
+ 1. Allow the new changes to be rolled out.
+
+1. Scale up the new write StatefulSets to match the old write StatefulSet.
+ ```yaml
+ rollout_operator:
+ enabled: true
+
+ write:
+ zoneAwareReplication:
+ enabled: true
+ maxUnavailable:
+ topologyKey: 'kubernetes.io/hostname'
+ zones:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ migration:
+ enabled: true
+ replicas:
+ ```
+ > **Note**: replace `` with the number of replicas in the old write StatefulSet - `` will be divided by 3, so if `` is set to 3 then each new StatefulSet replica will be set to 1.
+
+1. Enable zone-awareness on the write path.
+ ```yaml
+ rollout_operator:
+ enabled: true
+
+ write:
+ zoneAwareReplication:
+ enabled: true
+ maxUnavailable:
+ topologyKey: 'kubernetes.io/hostname'
+ zones:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ migration:
+ enabled: true
+ replicas:
+ writePath: true
+ ```
+ 1. Check that all the write pods have restarted properly.
+
+1. Wait `query_ingesters_within` configured hours, by default this is 3h. This ensures that no data will be missing if we query a new write pods.
+
+1. Check that rule evaluations are still correct on the migration, look for increases in the rate for metrics with names with the following suffixes:
+
+ ```
+ rule_evaluations_total
+ rule_evaluation_failures_total
+ rule_group_iterations_missed_total
+ ```
+
+1. Enable zone-awareness on the read path.
+ ```yaml
+ rollout_operator:
+ enabled: true
+
+ write:
+ zoneAwareReplication:
+ enabled: true
+ maxUnavailable:
+ topologyKey: 'kubernetes.io/hostname'
+ zones:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ migration:
+ enabled: true
+ replicas:
+ writePath: true
+ readPath: true
+ ```
+ 1. Check that queries are still executing correctly, for example look at `loki_logql_querystats_latency_seconds_count` to see that you don’t have a big increase in latency or error count for a specific query type.
+
+1. Exclude the non zone-aware write pods from the write path.
+ ```yaml
+ rollout_operator:
+ enabled: true
+
+ write:
+ zoneAwareReplication:
+ enabled: true
+ maxUnavailable:
+ topologyKey: 'kubernetes.io/hostname'
+ zones:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ migration:
+ enabled: true
+ replicas:
+ writePath: true
+ readPath: true
+ excludeDefaultZone: true
+ ```
+ It's a good idea to check rules evaluations again at this point, and also that the zone aware write StatefulSets is now receiving all the write traffic, you can compare `sum(loki_ingester_memory_streams{cluster="",job=~"()/loki-write"})` to `sum(loki_ingester_memory_streams{cluster="",job=~"()/loki-write-zone.*"})`
+
+1. Scale down the non zone-aware write StatefulSet to 0.
+ ```yaml
+ rollout_operator:
+ enabled: true
+
+ write:
+ zoneAwareReplication:
+ enabled: true
+ maxUnavailable:
+ topologyKey: 'kubernetes.io/hostname'
+ zones:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ migration:
+ enabled: true
+ replicas:
+ writePath: true
+ readPath: true
+ excludeDefaultZone: true
+ scaleDownDefaultZone: true
+ ```
+
+1. Wait until all non zone-aware write pods are terminated.
+
+1. Remove all values for used for migration, causing defaults to be used, which removes the old write StatefulSet.
+ ```yaml
+ rollout_operator:
+ enabled: true
+
+ write:
+ zoneAwareReplication:
+ enabled: true
+ maxUnavailable:
+ topologyKey: 'kubernetes.io/hostname'
+ zones:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ - name:
+ nodeSelector:
+ topology.kubernetes.io/zone:
+ # migration: removed from value overrides.
+ ```
+
+1. Wait atleast the `chunk_idle_period` configured hours/minutes, by default this is 30m.
+
+1. Undo the doubling of series limits done in the first step.
\ No newline at end of file
diff --git a/production/helm/loki/CHANGELOG.md b/production/helm/loki/CHANGELOG.md
index 26a36fbbfbc28..5ef68e7da23e8 100644
--- a/production/helm/loki/CHANGELOG.md
+++ b/production/helm/loki/CHANGELOG.md
@@ -13,6 +13,11 @@ Entries should include a reference to the pull request that introduced the chang
[//]: # ( : do not remove this line. This locator is used by the CI pipeline to automatically create a changelog entry for each new Loki release. Add other chart versions and respective changelog entries bellow this line.)
+## 5.41.0
+
+- [CHANGE] Make changes to how labels, annotations, resource names and priorityclassnames are created - matches how it is done in mimir-distributed helm chart.
+- [FEATURE] Add support for zone aware deployment of write component and usage of rollout-operator.
+
## 5.40.1
- [BUGFIX] Remove ruler enabled condition in networkpolicies.
diff --git a/production/helm/loki/Chart.lock b/production/helm/loki/Chart.lock
index 17f1dafad7ae9..a5008b2587db1 100644
--- a/production/helm/loki/Chart.lock
+++ b/production/helm/loki/Chart.lock
@@ -5,5 +5,8 @@ dependencies:
- name: grafana-agent-operator
repository: https://grafana.github.io/helm-charts
version: 0.2.16
-digest: sha256:56eeb13a669bc816c1452cde5d6dddc61f6893f8aff3da1d2b56ce3bdcbcf84d
-generated: "2023-11-09T12:22:25.317696-03:00"
+- name: rollout-operator
+ repository: https://grafana.github.io/helm-charts
+ version: 0.10.0
+digest: sha256:145b8ca76dde55e195c514e81e4607bf227461ba744682c8ce81bce7ed1640b4
+generated: "2023-12-07T08:36:59.813605+01:00"
diff --git a/production/helm/loki/Chart.yaml b/production/helm/loki/Chart.yaml
index c48b788c8445f..d392dfe7ea45c 100644
--- a/production/helm/loki/Chart.yaml
+++ b/production/helm/loki/Chart.yaml
@@ -3,7 +3,7 @@ name: loki
description: Helm chart for Grafana Loki in simple, scalable mode
type: application
appVersion: 2.9.2
-version: 5.40.1
+version: 5.41.0
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki
@@ -21,6 +21,11 @@ dependencies:
version: 0.2.16
repository: https://grafana.github.io/helm-charts
condition: monitoring.selfMonitoring.grafanaAgent.installOperator
+ - name: rollout-operator
+ alias: rollout_operator
+ repository: https://grafana.github.io/helm-charts
+ version: 0.10.0
+ condition: rollout_operator.enabled
maintainers:
- name: trevorwhitney
- name: jeschkies
diff --git a/production/helm/loki/README.md b/production/helm/loki/README.md
index d35dd7d248ff1..d90125a307dbf 100644
--- a/production/helm/loki/README.md
+++ b/production/helm/loki/README.md
@@ -1,6 +1,6 @@
# loki
-![Version: 5.40.1](https://img.shields.io/badge/Version-5.40.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.2](https://img.shields.io/badge/AppVersion-2.9.2-informational?style=flat-square)
+![Version: 5.41.0](https://img.shields.io/badge/Version-5.41.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.2](https://img.shields.io/badge/AppVersion-2.9.2-informational?style=flat-square)
Helm chart for Grafana Loki in simple, scalable mode
@@ -16,5 +16,6 @@ Helm chart for Grafana Loki in simple, scalable mode
|------------|------|---------|
| https://charts.min.io/ | minio(minio) | 4.0.15 |
| https://grafana.github.io/helm-charts | grafana-agent-operator(grafana-agent-operator) | 0.2.16 |
+| https://grafana.github.io/helm-charts | rollout_operator(rollout-operator) | 0.10.0 |
Find more information in the Loki Helm Chart [documentation](https://grafana.com/docs/loki/next/installation/helm).
diff --git a/production/helm/loki/templates/_helpers.tpl b/production/helm/loki/templates/_helpers.tpl
index eb3bf470a6313..5b601e0aa252a 100644
--- a/production/helm/loki/templates/_helpers.tpl
+++ b/production/helm/loki/templates/_helpers.tpl
@@ -119,24 +119,114 @@ Create chart name and version as used by the chart label.
{{- end }}
{{/*
-Common labels
+Resource labels
+Params:
+ ctx = . context
+ component = component name (optional)
+ rolloutZoneName = rollout zone name (optional)
*/}}
{{- define "loki.labels" -}}
-helm.sh/chart: {{ include "loki.chart" . }}
-{{ include "loki.selectorLabels" . }}
-{{- if or (.Chart.AppVersion) (.Values.loki.image.tag) }}
-app.kubernetes.io/version: {{ include "loki.validLabelValue" (.Values.loki.image.tag | default .Chart.AppVersion) | quote }}
+helm.sh/chart: {{ include "loki.chart" .ctx }}
+app.kubernetes.io/name: {{ include "loki.name" .ctx }}
+app.kubernetes.io/instance: {{ .ctx.Release.Name }}
+{{- if .ctx.Chart.AppVersion }}
+app.kubernetes.io/version: {{ .ctx.Chart.AppVersion | quote }}
+{{- end }}
+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 }}
-app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- 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 -}}
{{/*
-Selector labels
+Service selector labels
+Params:
+ ctx = . context
+ component = name of the component
+ rolloutZoneName = rollout zone name (optional)
*/}}
{{- define "loki.selectorLabels" -}}
-app.kubernetes.io/name: {{ include "loki.name" . }}
-app.kubernetes.io/instance: {{ .Release.Name }}
+app.kubernetes.io/name: {{ include "loki.name" .ctx }}
+app.kubernetes.io/instance: {{ .ctx.Release.Name }}
+{{- if .component }}
+app.kubernetes.io/component: {{ .component }}
+{{- 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 -}}
+
+
+{{/*
+POD labels
+Params:
+ ctx = . context
+ component = name of the component
+ memberlist = true if part of memberlist gossip ring
+ rolloutZoneName = rollout zone name (optional)
+*/}}
+{{- define "loki.podLabels" -}}
+{{ with .ctx.Values.loki.podLabels -}}
+{{ toYaml . }}
+{{ end -}}
+helm.sh/chart: {{ include "loki.chart" .ctx }}
+app.kubernetes.io/name: {{ include "loki.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 }}
+{{- $componentSection := include "loki.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 "loki.podAnnotations" -}}
+checksum/config: {{ include (print .ctx.Template.BasePath "/config.yaml") .ctx | sha256sum }}
+{{- with .ctx.Values.loki.podAnnotations }}
+{{ toYaml . }}
+{{- end }}
+{{- if .component }}
+{{- $componentSection := include "loki.componentSectionFromName" . | fromYaml }}
+{{- with ($componentSection).podAnnotations }}
+{{ toYaml . }}
+{{- end }}
+{{- end }}
+{{- end -}}
{{/*
Create the name of the service account to use
@@ -567,7 +657,7 @@ Params:
*/}}
{{- define "loki.ingress.serviceName" -}}
{{- if (eq .svcName "singleBinary") }}
-{{- printf "%s" (include "loki.singleBinaryFullname" .ctx) }}
+{{- printf "%s" (include "loki.resourceName" (dict "ctx" . "component" "single-binary")) }}
{{- else }}
{{- printf "%s-%s" (include "loki.name" .ctx) .svcName }}
{{- end -}}
@@ -595,9 +685,9 @@ Create the service endpoint including port for MinIO.
{{/* Determine the public host for the Loki cluster */}}
{{- define "loki.host" -}}
{{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}}
-{{- $url := printf "%s.%s.svc.%s.:%s" (include "loki.gatewayFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.gateway.service.port | toString) }}
+{{- $url := printf "%s.%s.svc.%s.:%s" (include "loki.resourceName" (dict "ctx" $ "component" "gateway")) .Release.Namespace .Values.global.clusterDomain (.Values.gateway.service.port | toString) }}
{{- if and $isSingleBinary (not .Values.gateway.enabled) }}
- {{- $url = printf "%s.%s.svc.%s.:3100" (include "loki.singleBinaryFullname" .) .Release.Namespace .Values.global.clusterDomain }}
+ {{- $url = printf "%s.%s.svc.%s.:3100" (include "loki.resourceName" (dict "ctx" $ "component" "single-binary")) .Release.Namespace .Values.global.clusterDomain }}
{{- end }}
{{- printf "%s" $url -}}
{{- end -}}
@@ -694,18 +784,18 @@ http {
auth_basic off;
}
- {{- $backendHost := include "loki.backendFullname" .}}
- {{- $readHost := include "loki.readFullname" .}}
- {{- $writeHost := include "loki.writeFullname" .}}
+ {{- $backendHost := include "loki.resourceName" (dict "ctx" . "component" "backend") }}
+ {{- $readHost := include "loki.resourceName" (dict "ctx" . "component" "read") }}
+ {{- $writeHost := include "loki.resourceName" (dict "ctx" . "component" "write") }}
{{- if .Values.read.legacyReadTarget }}
- {{- $backendHost = include "loki.readFullname" . }}
+ {{- $backendHost = include "loki.resourceName" (dict "ctx" . "component" "read") }}
{{- end }}
{{- if gt (int .Values.singleBinary.replicas) 0 }}
- {{- $backendHost = include "loki.singleBinaryFullname" . }}
- {{- $readHost = include "loki.singleBinaryFullname" .}}
- {{- $writeHost = include "loki.singleBinaryFullname" .}}
+ {{- $backendHost = include "loki.resourceName" (dict "ctx" . "component" "single-binary") }}
+ {{- $readHost = include "loki.resourceName" (dict "ctx" . "component" "single-binary") }}
+ {{- $writeHost = include "loki.resourceName" (dict "ctx" . "component" "single-binary") }}
{{- end }}
{{- $writeUrl := printf "http://%s.%s.svc.%s:3100" $writeHost .Release.Namespace .Values.global.clusterDomain }}
@@ -862,13 +952,13 @@ enableServiceLinks: false
{{/* Determine compactor address based on target configuration */}}
{{- define "loki.compactorAddress" -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
-{{- $compactorAddress := include "loki.backendFullname" . -}}
+{{- $compactorAddress := include "loki.resourceName" (dict "ctx" . "component" "backend") -}}
{{- if and $isSimpleScalable .Values.read.legacyReadTarget -}}
{{/* 2 target configuration */}}
-{{- $compactorAddress = include "loki.readFullname" . -}}
+{{- $compactorAddress = include "loki.resourceName" (dict "ctx" . "component" "read") -}}
{{- else if (not $isSimpleScalable) -}}
{{/* single binary */}}
-{{- $compactorAddress = include "loki.singleBinaryFullname" . -}}
+{{- $compactorAddress = include "loki.resourceName" (dict "ctx" . "component" "single-binary") -}}
{{- end -}}
{{- printf "%s" $compactorAddress }}
{{- end }}
@@ -882,3 +972,172 @@ enableServiceLinks: false
{{- end -}}
{{- printf "%s" $schedulerAddress }}
{{- 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" "store-gateway") | fromYaml
+ $componentSection.podLabels ...
+*/}}
+{{- define "loki.componentSectionFromName" -}}
+{{- $componentsMap := dict
+ "single-binary" "singleBinary"
+ "read" "read"
+ "write" "write"
+ "backend" "backend"
+ "gateway" "gateway"
+ "table-manager" "tableManager"
+ "canary" "monitoring.lokiCanary"
+ "grafana-agent" "monitoring.selfMonitoring.grafanaAgent"
+-}}
+{{- $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 -}}
+
+{{/* Get API Versions */}}
+{{- define "loki.podDisruptionBudget.apiVersion" -}}
+ {{- if semverCompare ">= 1.21-0" .Capabilities.KubeVersion.Version -}}
+ {{- print "policy/v1" -}}
+ {{- else -}}
+ {{- print "policy/v1beta1" -}}
+ {{- end -}}
+{{- 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 "write")) $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 -}}
+
+{{/*
+Calculate annotations with zone-awareness
+Params:
+ ctx = . context
+ component = component name
+ rolloutZoneName = rollout zone name (optional)
+*/}}
+{{- define "loki.componentAnnotations" -}}
+{{- $componentSection := include "loki.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 -}}
+
+{{/*
+Calculate PriorityClassName for component
+Params:
+ ctx = . context
+ component = component name
+*/}}
+{{- define "loki.priorityClassName" -}}
+{{- $componentSection := include "loki.componentSectionFromName" . | fromYaml -}}
+{{- $pcn := coalesce .ctx.Values.global.priorityClassName $componentSection.priorityClassName -}}
+{{- if $pcn }}
+priorityClassName: {{ $pcn }}
+{{- end }}
+{{- end }}
+
+{{/* Configure write zone awareness */}}
+{{- define "loki.enableWriteZoneAwareness" -}}
+{{- if .Values.write.zoneAwareReplication.enabled }}
+lifecycler:
+ ring:
+ zone_awareness_enabled: true
+{{- else }}
+lifecycler:
+ ring:
+ zone_awareness_enabled: false
+{{- end }}
+{{- end }}
\ No newline at end of file
diff --git a/production/helm/loki/templates/backend/_helpers-backend.tpl b/production/helm/loki/templates/backend/_helpers-backend.tpl
deleted file mode 100644
index 08f5f8f7b619c..0000000000000
--- a/production/helm/loki/templates/backend/_helpers-backend.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-{{/*
-backend fullname
-*/}}
-{{- define "loki.backendFullname" -}}
-{{ include "loki.name" . }}-backend
-{{- end }}
-
-{{/*
-backend common labels
-*/}}
-{{- define "loki.backendLabels" -}}
-{{ include "loki.labels" . }}
-app.kubernetes.io/component: backend
-{{- end }}
-
-{{/*
-backend selector labels
-*/}}
-{{- define "loki.backendSelectorLabels" -}}
-{{ include "loki.selectorLabels" . }}
-app.kubernetes.io/component: backend
-{{- end }}
-
-{{/*
-backend priority class name
-*/}}
-{{- define "loki.backendPriorityClassName" -}}
-{{- $pcn := coalesce .Values.global.priorityClassName .Values.backend.priorityClassName -}}
-{{- if $pcn }}
-priorityClassName: {{ $pcn }}
-{{- end }}
-{{- end }}
diff --git a/production/helm/loki/templates/backend/hpa.yaml b/production/helm/loki/templates/backend/hpa.yaml
index ea834d6e09741..1d00ec0550b2b 100644
--- a/production/helm/loki/templates/backend/hpa.yaml
+++ b/production/helm/loki/templates/backend/hpa.yaml
@@ -1,3 +1,4 @@
+{{- $args := dict "ctx" . "component" "backend" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) ( .Values.backend.autoscaling.enabled ) }}
@@ -8,14 +9,14 @@ apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
- name: {{ include "loki.backendFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
labels:
- {{- include "loki.backendLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: StatefulSet
- name: {{ include "loki.backendFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
minReplicas: {{ .Values.backend.autoscaling.minReplicas }}
maxReplicas: {{ .Values.backend.autoscaling.maxReplicas }}
{{- with .Values.backend.autoscaling.behavior }}
diff --git a/production/helm/loki/templates/backend/poddisruptionbudget-backend.yaml b/production/helm/loki/templates/backend/poddisruptionbudget-backend.yaml
index d8ce5b06184e9..4ff5b053c83c2 100644
--- a/production/helm/loki/templates/backend/poddisruptionbudget-backend.yaml
+++ b/production/helm/loki/templates/backend/poddisruptionbudget-backend.yaml
@@ -1,15 +1,5 @@
+{{- $args := dict "ctx" . "component" "backend" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (gt (int .Values.backend.replicas) 1) (not .Values.read.legacyReadTarget ) }}
-apiVersion: policy/v1
-kind: PodDisruptionBudget
-metadata:
- name: {{ include "loki.backendFullname" . }}
- namespace: {{ $.Release.Namespace }}
- labels:
- {{- include "loki.backendLabels" . | nindent 4 }}
-spec:
- selector:
- matchLabels:
- {{- include "loki.backendSelectorLabels" . | nindent 6 }}
- maxUnavailable: 1
+{{- include "loki.lib.podDisruptionBudget" $args }}
{{- end }}
diff --git a/production/helm/loki/templates/backend/query-scheduler-discovery.yaml b/production/helm/loki/templates/backend/query-scheduler-discovery.yaml
index 01865863e57ef..20487b3b0b430 100644
--- a/production/helm/loki/templates/backend/query-scheduler-discovery.yaml
+++ b/production/helm/loki/templates/backend/query-scheduler-discovery.yaml
@@ -1,3 +1,4 @@
+{{- $args := dict "ctx" . "component" "backend" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
---
@@ -6,7 +7,7 @@ kind: Service
metadata:
name: query-scheduler-discovery
labels:
- {{- include "loki.backendSelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
prometheus.io/service-monitor: "false"
spec:
type: ClusterIP
@@ -22,5 +23,5 @@ spec:
targetPort: grpc
protocol: TCP
selector:
- {{- include "loki.backendSelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/backend/service-backend-headless.yaml b/production/helm/loki/templates/backend/service-backend-headless.yaml
index 2ed4a9ae18c6a..5ac20f813f449 100644
--- a/production/helm/loki/templates/backend/service-backend-headless.yaml
+++ b/production/helm/loki/templates/backend/service-backend-headless.yaml
@@ -1,13 +1,14 @@
+{{- $args := dict "ctx" . "component" "backend" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
---
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki.backendFullname" . }}-headless
+ name: {{ include "loki.resourceName" $args }}-headless
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.backendSelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- with .Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -36,5 +37,5 @@ spec:
targetPort: grpc
protocol: TCP
selector:
- {{- include "loki.backendSelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/backend/service-backend.yaml b/production/helm/loki/templates/backend/service-backend.yaml
index 47af89e148cc1..0722f962c583e 100644
--- a/production/helm/loki/templates/backend/service-backend.yaml
+++ b/production/helm/loki/templates/backend/service-backend.yaml
@@ -1,13 +1,14 @@
+{{- $args := dict "ctx" . "component" "backend" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
---
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki.backendFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.backendLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -33,5 +34,5 @@ spec:
targetPort: grpc
protocol: TCP
selector:
- {{- include "loki.backendSelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/backend/statefulset-backend.yaml b/production/helm/loki/templates/backend/statefulset-backend.yaml
index 0bdef7e8e7774..4e821b1e84deb 100644
--- a/production/helm/loki/templates/backend/statefulset-backend.yaml
+++ b/production/helm/loki/templates/backend/statefulset-backend.yaml
@@ -1,15 +1,14 @@
+{{- $args := dict "ctx" . "component" "backend" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
- name: {{ include "loki.backendFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.backendLabels" . | nindent 4 }}
- app.kubernetes.io/part-of: memberlist
- {{- if or (not (empty .Values.loki.annotations)) (not (empty .Values.backend.annotations))}}
+ {{- include "loki.labels" $args | nindent 4 }}
annotations:
{{- with .Values.loki.annotations }}
{{- toYaml . | nindent 4 }}
@@ -17,16 +16,14 @@ metadata:
{{- with .Values.backend.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
- {{- end }}
spec:
{{- if not .Values.backend.autoscaling.enabled }}
replicas: {{ .Values.backend.replicas }}
{{- end }}
podManagementPolicy: {{ .Values.backend.podManagementPolicy }}
updateStrategy:
- rollingUpdate:
- partition: 0
- serviceName: {{ include "loki.backendFullname" . }}-headless
+ {{- toYaml .Values.backend.statefulStrategy | nindent 4 }}
+ serviceName: {{ include "loki.name" . }}-backend-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.backend.persistence.enableStatefulSetAutoDeletePVC) (.Values.backend.persistence.volumeClaimsEnabled) }}
{{/*
@@ -34,34 +31,18 @@ spec:
operation easier, and will rely on re-fetching data when needed.
*/}}
persistentVolumeClaimRetentionPolicy:
- whenDeleted: Delete
- whenScaled: Delete
+ whenDeleted: {{ .Values.backend.persistence.whenDeleted }}
+ whenScaled: {{ .Values.backend.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
- {{- include "loki.backendSelectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
template:
metadata:
annotations:
- checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
- {{- with .Values.loki.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.backend.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
+ {{- include "loki.podAnnotations" $args | nindent 8 }}
labels:
- {{- include "loki.backendSelectorLabels" . | nindent 8 }}
- {{- with .Values.loki.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.backend.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.backend.selectorLabels }}
- {{- tpl (toYaml .) $ | nindent 8 }}
- {{- end }}
- app.kubernetes.io/part-of: memberlist
+ {{- include "loki.podLabels" $args | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
@@ -69,7 +50,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
- {{- include "loki.backendPriorityClassName" . | nindent 6 }}
+ {{- include "loki.priorityClassName" $args | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.backend.terminationGracePeriodSeconds }}
@@ -156,6 +137,14 @@ spec:
- -config.file=/etc/loki/config/config.yaml
- -target={{ .Values.backend.targetModule }}
- -legacy-read-mode=false
+ {{- if .Values.write.zoneAwareReplication.migration.enabled }}
+ {{- if not .Values.write.zoneAwareReplication.migration.writePath }}
+ - "-distributor.zone-awareness-enabled=false"
+ {{- end }}
+ {{- if .Values.write.zoneAwareReplication.migration.excludeDefaultZone }}
+ - "-distributor.excluded-zones=zone-default"
+ {{- end }}
+ {{- end }}
{{- with .Values.backend.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
diff --git a/production/helm/loki/templates/backend/clusterrole.yaml b/production/helm/loki/templates/clusterrole.yaml
similarity index 74%
rename from production/helm/loki/templates/backend/clusterrole.yaml
rename to production/helm/loki/templates/clusterrole.yaml
index 176ada056626e..cc63a79b86e21 100644
--- a/production/helm/loki/templates/backend/clusterrole.yaml
+++ b/production/helm/loki/templates/clusterrole.yaml
@@ -3,12 +3,12 @@ kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
labels:
- {{- include "loki.labels" . | nindent 4 }}
-{{- with .Values.annotations }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
+{{- with .Values.loki.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
- name: {{ template "loki.fullname" . }}-clusterrole
+ name: {{ include "loki.name" . }}-clusterrole
{{- if .Values.sidecar.rules.enabled }}
rules:
- apiGroups: [""] # "" indicates the core API group
diff --git a/production/helm/loki/templates/backend/clusterrolebinding.yaml b/production/helm/loki/templates/clusterrolebinding.yaml
similarity index 71%
rename from production/helm/loki/templates/backend/clusterrolebinding.yaml
rename to production/helm/loki/templates/clusterrolebinding.yaml
index 1021fd008980c..4f991e3d7c4f5 100644
--- a/production/helm/loki/templates/backend/clusterrolebinding.yaml
+++ b/production/helm/loki/templates/clusterrolebinding.yaml
@@ -2,10 +2,10 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
- name: {{ template "loki.fullname" . }}-clusterrolebinding
+ name: {{ include "loki.name" . }}-clusterrolebinding
labels:
- {{- include "loki.labels" . | nindent 4 }}
-{{- with .Values.annotations }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
+{{- with .Values.loki.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
@@ -16,7 +16,7 @@ subjects:
roleRef:
kind: ClusterRole
{{- if (not .Values.rbac.useExistingRole) }}
- name: {{ template "loki.fullname" . }}-clusterrole
+ name: {{ include "loki.name" . }}-clusterrole
{{- else }}
name: {{ .Values.rbac.useExistingRole }}
{{- end }}
diff --git a/production/helm/loki/templates/config.yaml b/production/helm/loki/templates/config.yaml
index 101abc353e263..c83692692a23c 100644
--- a/production/helm/loki/templates/config.yaml
+++ b/production/helm/loki/templates/config.yaml
@@ -9,7 +9,7 @@ metadata:
name: {{ tpl .Values.loki.externalConfigSecretName . }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
{{- if eq .Values.loki.configStorageType "Secret" }}
data:
config.yaml: {{ include "loki.calculatedConfig" . | b64enc }}
diff --git a/production/helm/loki/templates/gateway/_helpers-gateway.tpl b/production/helm/loki/templates/gateway/_helpers-gateway.tpl
deleted file mode 100644
index 272814b6c0e1c..0000000000000
--- a/production/helm/loki/templates/gateway/_helpers-gateway.tpl
+++ /dev/null
@@ -1,47 +0,0 @@
-{{/*
-gateway fullname
-*/}}
-{{- define "loki.gatewayFullname" -}}
-{{ include "loki.name" . }}-gateway
-{{- end }}
-
-{{/*
-gateway common labels
-*/}}
-{{- define "loki.gatewayLabels" -}}
-{{ include "loki.labels" . }}
-app.kubernetes.io/component: gateway
-{{- end }}
-
-{{/*
-gateway selector labels
-*/}}
-{{- define "loki.gatewaySelectorLabels" -}}
-{{ include "loki.selectorLabels" . }}
-app.kubernetes.io/component: gateway
-{{- end }}
-
-{{/*
-gateway auth secret name
-*/}}
-{{- define "loki.gatewayAuthSecret" -}}
-{{ .Values.gateway.basicAuth.existingSecret | default (include "loki.gatewayFullname" . ) }}
-{{- end }}
-
-{{/*
-gateway Docker image
-*/}}
-{{- define "loki.gatewayImage" -}}
-{{- $dict := dict "service" .Values.gateway.image "global" .Values.global.image -}}
-{{- include "loki.baseImage" $dict -}}
-{{- end }}
-
-{{/*
-gateway priority class name
-*/}}
-{{- define "loki.gatewayPriorityClassName" -}}
-{{- $pcn := coalesce .Values.global.priorityClassName .Values.gateway.priorityClassName -}}
-{{- if $pcn }}
-priorityClassName: {{ $pcn }}
-{{- end }}
-{{- end }}
diff --git a/production/helm/loki/templates/gateway/configmap-gateway.yaml b/production/helm/loki/templates/gateway/configmap-gateway.yaml
index fe98c73dc3a44..4754cc8f17695 100644
--- a/production/helm/loki/templates/gateway/configmap-gateway.yaml
+++ b/production/helm/loki/templates/gateway/configmap-gateway.yaml
@@ -1,11 +1,12 @@
+{{- $args := dict "ctx" . "component" "gateway" -}}
{{- if and .Values.gateway.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
- name: {{ include "loki.gatewayFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.gatewayLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
data:
nginx.conf: |
{{- tpl .Values.gateway.nginxConfig.file . | indent 2 }}
diff --git a/production/helm/loki/templates/gateway/deployment-gateway.yaml b/production/helm/loki/templates/gateway/deployment-gateway.yaml
index 4ffa0c935b0a4..5ed9be6f9356e 100644
--- a/production/helm/loki/templates/gateway/deployment-gateway.yaml
+++ b/production/helm/loki/templates/gateway/deployment-gateway.yaml
@@ -1,12 +1,12 @@
+{{- $args := dict "ctx" . "component" "gateway" -}}
{{- if .Values.gateway.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
- name: {{ include "loki.gatewayFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.gatewayLabels" . | nindent 4 }}
- {{- if or (not (empty .Values.loki.annotations)) (not (empty .Values.backend.annotations))}}
+ {{- include "loki.labels" $args | nindent 4 }}
annotations:
{{- with .Values.loki.annotations }}
{{- toYaml . | nindent 4 }}
@@ -14,7 +14,6 @@ metadata:
{{- with .Values.gateway.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
- {{- end }}
spec:
{{- if not .Values.gateway.autoscaling.enabled }}
replicas: {{ .Values.gateway.replicas }}
@@ -26,25 +25,13 @@ spec:
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
selector:
matchLabels:
- {{- include "loki.gatewaySelectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
template:
metadata:
annotations:
- checksum/config: {{ include (print .Template.BasePath "/gateway/configmap-gateway.yaml") . | sha256sum }}
- {{- with .Values.loki.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.gateway.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
+ {{- include "loki.podAnnotations" $args | nindent 8 }}
labels:
- {{- with .Values.loki.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.gateway.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- include "loki.gatewaySelectorLabels" . | nindent 8 }}
+ {{- include "loki.podLabels" $args | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{ include "loki.enableServiceLinks" . }}
@@ -52,13 +39,13 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end -}}
- {{- include "loki.gatewayPriorityClassName" . | nindent 6 }}
+ {{- include "loki.priorityClassName" $args | nindent 6 }}
securityContext:
{{- toYaml .Values.gateway.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.gateway.terminationGracePeriodSeconds }}
containers:
- name: nginx
- image: {{ include "loki.gatewayImage" . }}
+ image: {{ include "loki.baseImage" (dict "service" .Values.gateway.image "global" .Values.global.image) }}
imagePullPolicy: {{ .Values.gateway.image.pullPolicy }}
ports:
- name: http
@@ -122,11 +109,11 @@ spec:
volumes:
- name: config
configMap:
- name: {{ include "loki.gatewayFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
{{- if .Values.gateway.basicAuth.enabled }}
- name: auth
secret:
- secretName: {{ include "loki.gatewayAuthSecret" . }}
+ secretName: {{ .Values.gateway.basicAuth.existingSecret | default (include "loki.resourceName" $args ) }}
{{- end }}
- name: tmp
emptyDir: {}
diff --git a/production/helm/loki/templates/gateway/hpa.yaml b/production/helm/loki/templates/gateway/hpa.yaml
index 3541ec6965d68..b3de270072863 100644
--- a/production/helm/loki/templates/gateway/hpa.yaml
+++ b/production/helm/loki/templates/gateway/hpa.yaml
@@ -1,3 +1,4 @@
+{{- $args := dict "ctx" . "component" "gateway" -}}
{{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}}
{{- if .Values.gateway.autoscaling.enabled }}
{{- if $autoscalingv2 }}
@@ -7,15 +8,15 @@ apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
- name: {{ include "loki.gatewayFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.gatewayLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
- name: {{ include "loki.gatewayFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
minReplicas: {{ .Values.gateway.autoscaling.minReplicas }}
maxReplicas: {{ .Values.gateway.autoscaling.maxReplicas }}
{{- with .Values.gateway.autoscaling.behavior }}
diff --git a/production/helm/loki/templates/gateway/ingress-gateway.yaml b/production/helm/loki/templates/gateway/ingress-gateway.yaml
index 6f18e3396f009..85b1fde6fd422 100644
--- a/production/helm/loki/templates/gateway/ingress-gateway.yaml
+++ b/production/helm/loki/templates/gateway/ingress-gateway.yaml
@@ -1,3 +1,4 @@
+{{- $args := dict "ctx" . "component" "gateway" -}}
{{- if and .Values.gateway.enabled -}}
{{- if .Values.gateway.ingress.enabled -}}
{{- $ingressApiIsStable := eq (include "loki.ingress.isStable" .) "true" -}}
@@ -6,10 +7,10 @@
apiVersion: {{ include "loki.ingress.apiVersion" . }}
kind: Ingress
metadata:
- name: {{ include "loki.gatewayFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.gatewayLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- range $labelKey, $labelValue := .Values.gateway.ingress.labels }}
{{ $labelKey }}: {{ $labelValue | toYaml }}
{{- end }}
@@ -46,11 +47,11 @@ spec:
backend:
{{- if $ingressApiIsStable }}
service:
- name: {{ include "loki.gatewayFullname" $ }}
+ name: {{ include "loki.resourceName" $args }}
port:
number: {{ $.Values.gateway.service.port }}
{{- else }}
- serviceName: {{ include "loki.gatewayFullname" $ }}
+ serviceName: {{ include "loki.resourceName" $args }}
servicePort: {{ $.Values.gateway.service.port }}
{{- end }}
{{- end }}
diff --git a/production/helm/loki/templates/gateway/poddisruptionbudget-gateway.yaml b/production/helm/loki/templates/gateway/poddisruptionbudget-gateway.yaml
index 0057c5653d5cc..b48314747a3dc 100644
--- a/production/helm/loki/templates/gateway/poddisruptionbudget-gateway.yaml
+++ b/production/helm/loki/templates/gateway/poddisruptionbudget-gateway.yaml
@@ -1,19 +1,9 @@
+{{- $args := dict "ctx" . "component" "gateway" "memberlist" true -}}
{{- if and .Values.gateway.enabled }}
{{- if or
(and (not .Values.gateway.autoscaling.enabled) (gt (int .Values.gateway.replicas) 1))
(and .Values.gateway.autoscaling.enabled (gt (int .Values.gateway.autoscaling.minReplicas) 1))
}}
-apiVersion: policy/v1
-kind: PodDisruptionBudget
-metadata:
- name: {{ include "loki.gatewayFullname" . }}
- namespace: {{ $.Release.Namespace }}
- labels:
- {{- include "loki.gatewayLabels" . | nindent 4 }}
-spec:
- selector:
- matchLabels:
- {{- include "loki.gatewaySelectorLabels" . | nindent 6 }}
- maxUnavailable: 1
+{{- include "loki.lib.podDisruptionBudget" $args }}
{{- end }}
{{- end }}
diff --git a/production/helm/loki/templates/gateway/secret-gateway.yaml b/production/helm/loki/templates/gateway/secret-gateway.yaml
index c3c5e9a277ade..f8ceed1c902f1 100644
--- a/production/helm/loki/templates/gateway/secret-gateway.yaml
+++ b/production/helm/loki/templates/gateway/secret-gateway.yaml
@@ -1,12 +1,13 @@
{{- with .Values.gateway }}
+{{- $args := dict "ctx" $ "component" "gateway" -}}
{{- if and .enabled .basicAuth.enabled (not .basicAuth.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
- name: {{ include "loki.gatewayFullname" $ }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.gatewayLabels" $ | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
stringData:
.htpasswd: |
{{- tpl .basicAuth.htpasswd $ | nindent 4 }}
diff --git a/production/helm/loki/templates/gateway/service-gateway.yaml b/production/helm/loki/templates/gateway/service-gateway.yaml
index 5cb7a55c3c803..c52e76c4d4dd1 100644
--- a/production/helm/loki/templates/gateway/service-gateway.yaml
+++ b/production/helm/loki/templates/gateway/service-gateway.yaml
@@ -1,11 +1,12 @@
+{{- $args := dict "ctx" . "component" "gateway" -}}
{{- if .Values.gateway.enabled }}
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki.gatewayFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.gatewayLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -36,5 +37,5 @@ spec:
{{- end }}
protocol: TCP
selector:
- {{- include "loki.gatewaySelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/ingress.yaml b/production/helm/loki/templates/ingress.yaml
index ddbcf7fdb618a..bb62f3230b742 100644
--- a/production/helm/loki/templates/ingress.yaml
+++ b/production/helm/loki/templates/ingress.yaml
@@ -6,7 +6,7 @@ metadata:
name: {{ include "loki.fullname" . }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
{{- with .Values.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/lib/pdb.tpl b/production/helm/loki/templates/lib/pdb.tpl
new file mode 100644
index 0000000000000..c605b0b075db0
--- /dev/null
+++ b/production/helm/loki/templates/lib/pdb.tpl
@@ -0,0 +1,23 @@
+{{/*
+Loki common PodDisruptionBudget definition
+Params:
+ ctx = . context
+ component = name of the component
+*/}}
+{{- define "loki.lib.podDisruptionBudget" -}}
+{{- $componentSection := include "loki.componentSectionFromName" . | fromYaml }}
+{{ with ($componentSection).podDisruptionBudget }}
+apiVersion: {{ include "loki.podDisruptionBudget.apiVersion" $.ctx }}
+kind: PodDisruptionBudget
+metadata:
+ name: {{ include "loki.resourceName" (dict "ctx" $.ctx "component" $.component) }}
+ labels:
+ {{- include "loki.labels" (dict "ctx" $.ctx "component" $.component) | nindent 4 }}
+ namespace: {{ $.ctx.Release.Namespace | quote }}
+spec:
+ selector:
+ matchLabels:
+ {{- include "loki.selectorLabels" (dict "ctx" $.ctx "component" $.component) | nindent 6 }}
+{{ toYaml . | indent 2 }}
+{{- end -}}
+{{- end -}}
diff --git a/production/helm/loki/templates/loki-canary/_helpers.tpl b/production/helm/loki/templates/loki-canary/_helpers.tpl
deleted file mode 100644
index 2ea8dd75450f2..0000000000000
--- a/production/helm/loki/templates/loki-canary/_helpers.tpl
+++ /dev/null
@@ -1,40 +0,0 @@
-{{/*
-canary fullname
-*/}}
-{{- define "loki-canary.fullname" -}}
-{{ include "loki.name" . }}-canary
-{{- end }}
-
-{{/*
-canary common labels
-*/}}
-{{- define "loki-canary.labels" -}}
-{{ include "loki.labels" . }}
-app.kubernetes.io/component: canary
-{{- end }}
-
-{{/*
-canary selector labels
-*/}}
-{{- define "loki-canary.selectorLabels" -}}
-{{ include "loki.selectorLabels" . }}
-app.kubernetes.io/component: canary
-{{- end }}
-
-{{/*
-Docker image name for loki-canary
-*/}}
-{{- define "loki-canary.image" -}}
-{{- $dict := dict "service" .Values.monitoring.lokiCanary.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
-{{- include "loki.baseImage" $dict -}}
-{{- end -}}
-
-{{/*
-canary priority class name
-*/}}
-{{- define "loki-canary.priorityClassName" -}}
-{{- $pcn := coalesce .Values.global.priorityClassName .Values.monitoring.lokiCanary.priorityClassName .Values.read.priorityClassName -}}
-{{- if $pcn }}
-priorityClassName: {{ $pcn }}
-{{- end }}
-{{- end }}
diff --git a/production/helm/loki/templates/loki-canary/daemonset.yaml b/production/helm/loki/templates/loki-canary/daemonset.yaml
index 250d1a8ade31e..808347711b325 100644
--- a/production/helm/loki/templates/loki-canary/daemonset.yaml
+++ b/production/helm/loki/templates/loki-canary/daemonset.yaml
@@ -1,17 +1,18 @@
+{{- $args := dict "ctx" . "component" "canary" -}}
{{- with .Values.monitoring.lokiCanary -}}
{{- if .enabled -}}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
- name: {{ include "loki-canary.fullname" $ }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki-canary.labels" $ | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
spec:
selector:
matchLabels:
- {{- include "loki-canary.selectorLabels" $ | nindent 6 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
{{- with .updateStrategy }}
updateStrategy:
{{- toYaml . | nindent 4 }}
@@ -23,22 +24,22 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
- {{- include "loki-canary.selectorLabels" $ | nindent 8 }}
+ {{- include "loki.selectorLabels" $args | nindent 8 }}
{{- with .podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
- serviceAccountName: {{ include "loki-canary.fullname" $ }}
+ serviceAccountName: {{ include "loki.resourceName" $args }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
- {{- include "loki-canary.priorityClassName" $ | nindent 6 }}
+ {{- include "loki.priorityClassName" $args | nindent 6 }}
securityContext:
{{- toYaml $.Values.loki.podSecurityContext | nindent 8 }}
containers:
- name: loki-canary
- image: {{ include "loki-canary.image" $ }}
+ image: {{ include "loki.baseImage" (dict "service" $.Values.monitoring.lokiCanary.image "global" $.Values.global.image "defaultVersion" $.Chart.AppVersion) }}
imagePullPolicy: {{ $.Values.loki.image.pullPolicy }}
args:
- -addr={{- include "loki.host" $ }}
diff --git a/production/helm/loki/templates/loki-canary/service.yaml b/production/helm/loki/templates/loki-canary/service.yaml
index d0fb34e38bf80..22a5ebd789c02 100644
--- a/production/helm/loki/templates/loki-canary/service.yaml
+++ b/production/helm/loki/templates/loki-canary/service.yaml
@@ -1,13 +1,14 @@
{{- with .Values.monitoring.lokiCanary -}}
+{{- $args := dict "ctx" $ "component" "canary" -}}
{{- if .enabled -}}
---
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki-canary.fullname" $ }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki-canary.labels" $ | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with $.Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -29,6 +30,6 @@ spec:
targetPort: http-metrics
protocol: TCP
selector:
- {{- include "loki-canary.selectorLabels" $ | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
{{- end -}}
{{- end -}}
diff --git a/production/helm/loki/templates/loki-canary/serviceaccount.yaml b/production/helm/loki/templates/loki-canary/serviceaccount.yaml
index dbcd2b345faa9..5e0fbc1f25d6c 100644
--- a/production/helm/loki/templates/loki-canary/serviceaccount.yaml
+++ b/production/helm/loki/templates/loki-canary/serviceaccount.yaml
@@ -1,13 +1,14 @@
{{- with .Values.monitoring.lokiCanary -}}
+{{- $args := dict "ctx" $ "component" "canary" -}}
{{- if .enabled -}}
---
apiVersion: v1
kind: ServiceAccount
metadata:
- name: {{ include "loki-canary.fullname" $ }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki-canary.labels" $ | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
diff --git a/production/helm/loki/templates/monitoring/_helpers-monitoring.tpl b/production/helm/loki/templates/monitoring/_helpers-monitoring.tpl
index e54f13004d341..46b2b15a228d3 100644
--- a/production/helm/loki/templates/monitoring/_helpers-monitoring.tpl
+++ b/production/helm/loki/templates/monitoring/_helpers-monitoring.tpl
@@ -3,11 +3,11 @@ Client definition for LogsInstance
*/}}
{{- define "loki.logsInstanceClient" -}}
{{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}}
-{{- $url := printf "http://%s.%s.svc.%s:3100/loki/api/v1/push" (include "loki.writeFullname" .) .Release.Namespace .Values.global.clusterDomain }}
+{{- $url := printf "http://%s.%s.svc.%s:3100/loki/api/v1/push" (include "loki.resourceName" (dict "ctx" $ "component" "write")) .Release.Namespace .Values.global.clusterDomain }}
{{- if $isSingleBinary }}
- {{- $url = printf "http://%s.%s.svc.%s:3100/loki/api/v1/push" (include "loki.singleBinaryFullname" .) .Release.Namespace .Values.global.clusterDomain }}
+ {{- $url = printf "http://%s.%s.svc.%s:3100/loki/api/v1/push" (include "loki.resourceName" (dict "ctx" $ "component" "single-binary")) .Release.Namespace .Values.global.clusterDomain }}
{{- else if .Values.gateway.enabled -}}
- {{- $url = printf "http://%s.%s.svc.%s/loki/api/v1/push" (include "loki.gatewayFullname" .) .Release.Namespace .Values.global.clusterDomain }}
+ {{- $url = printf "http://%s.%s.svc.%s/loki/api/v1/push" (include "loki.resourceName" (dict "ctx" $ "component" "gateway")) .Release.Namespace .Values.global.clusterDomain }}
{{- end -}}
- url: {{ $url }}
externalLabels:
@@ -35,13 +35,3 @@ Convert a recording rule group to yaml
{{- toYaml .rules | nindent 4 }}
{{- end }}
{{- end }}
-
-{{/*
-GrafanaAgent priority class name
-*/}}
-{{- define "grafana-agent.priorityClassName" -}}
-{{- $pcn := coalesce .Values.global.priorityClassName .Values.monitoring.selfMonitoring.grafanaAgent.priorityClassName -}}
-{{- if $pcn }}
-priorityClassName: {{ $pcn }}
-{{- end }}
-{{- end }}
diff --git a/production/helm/loki/templates/monitoring/dashboards/configmap-1.yaml b/production/helm/loki/templates/monitoring/dashboards/configmap-1.yaml
index 6352f25336d4a..f14722e4a9bdd 100644
--- a/production/helm/loki/templates/monitoring/dashboards/configmap-1.yaml
+++ b/production/helm/loki/templates/monitoring/dashboards/configmap-1.yaml
@@ -7,7 +7,7 @@ metadata:
name: {{ include "loki.dashboardsName" $ }}-1
namespace: {{ .namespace | default $.Release.Namespace }}
labels:
- {{- include "loki.labels" $ | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/monitoring/dashboards/configmap-2.yaml b/production/helm/loki/templates/monitoring/dashboards/configmap-2.yaml
index 67d3cf4f9b0d8..ac29614120e13 100644
--- a/production/helm/loki/templates/monitoring/dashboards/configmap-2.yaml
+++ b/production/helm/loki/templates/monitoring/dashboards/configmap-2.yaml
@@ -7,7 +7,7 @@ metadata:
name: {{ include "loki.dashboardsName" $ }}-2
namespace: {{ .namespace | default $.Release.Namespace }}
labels:
- {{- include "loki.labels" $ | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/monitoring/grafana-agent.yaml b/production/helm/loki/templates/monitoring/grafana-agent.yaml
index 010d9604aab70..79e00a7bfce15 100644
--- a/production/helm/loki/templates/monitoring/grafana-agent.yaml
+++ b/production/helm/loki/templates/monitoring/grafana-agent.yaml
@@ -1,3 +1,4 @@
+{{- $args := dict "ctx" . "component" "grafana-agent" -}}
{{- if .Values.monitoring.selfMonitoring.enabled }}
{{- with .Values.monitoring.selfMonitoring.grafanaAgent }}
apiVersion: monitoring.grafana.com/v1alpha1
@@ -6,7 +7,7 @@ metadata:
name: {{ include "loki.fullname" $ }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" $ | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
@@ -17,17 +18,17 @@ metadata:
spec:
serviceAccountName: {{ include "loki.fullname" $ }}-grafana-agent
enableConfigReadAPI: {{ .enableConfigReadAPI }}
- {{- include "grafana-agent.priorityClassName" $ | nindent 2 }}
+ {{- include "loki.priorityClassName" $args | nindent 2 }}
logs:
instanceSelector:
matchLabels:
- {{- include "loki.selectorLabels" $ | nindent 8 }}
+ {{- include "loki.selectorLabels" $args | nindent 8 }}
{{- with $.Values.monitoring.serviceMonitor}}
{{- if .metricsInstance.remoteWrite}}
metrics:
instanceSelector:
matchLabels:
- {{- include "loki.selectorLabels" $ | nindent 8 }}
+ {{- include "loki.selectorLabels" $args | nindent 8 }}
{{- end }}
{{- end }}
{{- with .tolerations }}
diff --git a/production/helm/loki/templates/monitoring/logs-instance.yaml b/production/helm/loki/templates/monitoring/logs-instance.yaml
index 58d5fb045c0cf..f02e308966023 100644
--- a/production/helm/loki/templates/monitoring/logs-instance.yaml
+++ b/production/helm/loki/templates/monitoring/logs-instance.yaml
@@ -10,7 +10,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
- {{- include "loki.labels" $ | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
@@ -25,6 +25,6 @@ spec:
podLogsSelector:
matchLabels:
- {{- include "loki.selectorLabels" $ | nindent 6 }}
+ {{- include "loki.selectorLabels" (dict "ctx" $) | nindent 6 }}
{{- end -}}
{{- end -}}
diff --git a/production/helm/loki/templates/monitoring/metrics-instance.yaml b/production/helm/loki/templates/monitoring/metrics-instance.yaml
index 82102c0ed3fa4..1fcf29899fe5a 100644
--- a/production/helm/loki/templates/monitoring/metrics-instance.yaml
+++ b/production/helm/loki/templates/monitoring/metrics-instance.yaml
@@ -10,7 +10,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
- {{- include "loki.labels" $ | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
@@ -24,7 +24,7 @@ spec:
serviceMonitorSelector:
matchLabels:
- {{- include "loki.selectorLabels" $ | nindent 6 }}
+ {{- include "loki.selectorLabels" (dict "ctx" $) | nindent 6 }}
{{- end -}}
{{- end -}}
{{- end -}}
diff --git a/production/helm/loki/templates/monitoring/pod-logs.yaml b/production/helm/loki/templates/monitoring/pod-logs.yaml
index 4445f3e760779..1a2a1d32edacc 100644
--- a/production/helm/loki/templates/monitoring/pod-logs.yaml
+++ b/production/helm/loki/templates/monitoring/pod-logs.yaml
@@ -11,7 +11,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
- {{- include "loki.labels" $ | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
@@ -52,6 +52,6 @@ spec:
- {{ $.Release.Namespace }}
selector:
matchLabels:
- {{- include "loki.selectorLabels" $ | nindent 6 }}
+ {{- include "loki.selectorLabels" (dict "ctx" $) | nindent 6 }}
{{- end }}
{{- end }}
diff --git a/production/helm/loki/templates/monitoring/servicemonitor.yaml b/production/helm/loki/templates/monitoring/servicemonitor.yaml
index 856cee8f38391..7fdc9b17328ff 100644
--- a/production/helm/loki/templates/monitoring/servicemonitor.yaml
+++ b/production/helm/loki/templates/monitoring/servicemonitor.yaml
@@ -11,7 +11,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
- {{- include "loki.labels" $ | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
@@ -22,7 +22,7 @@ spec:
{{- end }}
selector:
matchLabels:
- {{- include "loki.selectorLabels" $ | nindent 6 }}
+ {{- include "loki.selectorLabels" (dict "ctx" $) | nindent 6 }}
matchExpressions:
- key: prometheus.io/service-monitor
operator: NotIn
diff --git a/production/helm/loki/templates/networkpolicy.yaml b/production/helm/loki/templates/networkpolicy.yaml
index 4424d90db08d4..c726c7ce14532 100644
--- a/production/helm/loki/templates/networkpolicy.yaml
+++ b/production/helm/loki/templates/networkpolicy.yaml
@@ -6,7 +6,7 @@ metadata:
name: {{ include "loki.name" . }}-namespace-only
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
spec:
policyTypes:
- Ingress
@@ -26,13 +26,13 @@ metadata:
name: {{ include "loki.name" . }}-egress-dns
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
spec:
policyTypes:
- Egress
podSelector:
matchLabels:
- {{- include "loki.selectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" (dict "ctx" .) | nindent 6 }}
egress:
- ports:
- port: dns
@@ -63,7 +63,7 @@ spec:
- write
{{- end }}
matchLabels:
- {{- include "loki.selectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" (dict "ctx" .) | nindent 6 }}
ingress:
- ports:
- port: http
@@ -91,7 +91,7 @@ spec:
- Ingress
podSelector:
matchLabels:
- {{- include "loki.selectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" (dict "ctx" .) | nindent 6 }}
ingress:
- ports:
- port: http-metrics
@@ -154,7 +154,7 @@ spec:
- Egress
podSelector:
matchLabels:
- {{- include "loki.selectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" (dict "ctx" .) | nindent 6 }}
egress:
- ports:
{{- range $port := .Values.networkPolicy.externalStorage.ports }}
@@ -186,7 +186,7 @@ spec:
- Egress
podSelector:
matchLabels:
- {{- include "loki.selectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" (dict "ctx" .) | nindent 6 }}
egress:
- ports:
- port: {{ .Values.networkPolicy.discovery.port }}
diff --git a/production/helm/loki/templates/podsecuritypolicy.yaml b/production/helm/loki/templates/podsecuritypolicy.yaml
index 05470d9ff6c7a..65181e34e2dae 100644
--- a/production/helm/loki/templates/podsecuritypolicy.yaml
+++ b/production/helm/loki/templates/podsecuritypolicy.yaml
@@ -4,7 +4,7 @@ kind: PodSecurityPolicy
metadata:
name: {{ include "loki.name" . }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
{{- if .Values.rbac.pspAnnotations }}
annotations:
{{ toYaml .Values.rbac.pspAnnotations | indent 4 }}
diff --git a/production/helm/loki/templates/read/_helpers-read.tpl b/production/helm/loki/templates/read/_helpers-read.tpl
deleted file mode 100644
index d205314a6cc63..0000000000000
--- a/production/helm/loki/templates/read/_helpers-read.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-{{/*
-read fullname
-*/}}
-{{- define "loki.readFullname" -}}
-{{ include "loki.name" . }}-read
-{{- end }}
-
-{{/*
-read common labels
-*/}}
-{{- define "loki.readLabels" -}}
-{{ include "loki.labels" . }}
-app.kubernetes.io/component: read
-{{- end }}
-
-{{/*
-read selector labels
-*/}}
-{{- define "loki.readSelectorLabels" -}}
-{{ include "loki.selectorLabels" . }}
-app.kubernetes.io/component: read
-{{- end }}
-
-{{/*
-read priority class name
-*/}}
-{{- define "loki.readPriorityClassName" -}}
-{{- $pcn := coalesce .Values.global.priorityClassName .Values.read.priorityClassName -}}
-{{- if $pcn }}
-priorityClassName: {{ $pcn }}
-{{- end }}
-{{- end }}
diff --git a/production/helm/loki/templates/read/deployment-read.yaml b/production/helm/loki/templates/read/deployment-read.yaml
index e468752d5723f..53506e18a2e70 100644
--- a/production/helm/loki/templates/read/deployment-read.yaml
+++ b/production/helm/loki/templates/read/deployment-read.yaml
@@ -1,15 +1,14 @@
+{{- $args := dict "ctx" . "component" "read" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
- name: {{ include "loki.readFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- app.kubernetes.io/part-of: memberlist
- {{- include "loki.readLabels" . | nindent 4 }}
- {{- if or (not (empty .Values.loki.annotations)) (not (empty .Values.backend.annotations))}}
+ {{- include "loki.labels" $args | nindent 4 }}
annotations:
{{- with .Values.loki.annotations }}
{{- toYaml . | nindent 4 }}
@@ -17,7 +16,6 @@ metadata:
{{- with .Values.read.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
- {{- end }}
spec:
{{- if not .Values.read.autoscaling.enabled }}
replicas: {{ .Values.read.replicas }}
@@ -29,29 +27,13 @@ spec:
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
selector:
matchLabels:
- {{- include "loki.readSelectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
template:
metadata:
annotations:
- checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
- {{- with .Values.loki.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.read.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
+ {{- include "loki.podAnnotations" $args | nindent 8 }}
labels:
- app.kubernetes.io/part-of: memberlist
- {{- include "loki.readSelectorLabels" . | nindent 8 }}
- {{- with .Values.loki.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.read.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.read.selectorLabels }}
- {{- tpl (toYaml .) $ | nindent 8 }}
- {{- end }}
+ {{- include "loki.podLabels" $args | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
@@ -59,7 +41,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
- {{- include "loki.readPriorityClassName" . | nindent 6 }}
+ {{- include "loki.priorityClassName" $args | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.read.terminationGracePeriodSeconds }}
@@ -71,7 +53,12 @@ spec:
- -config.file=/etc/loki/config/config.yaml
- -target={{ .Values.read.targetModule }}
- -legacy-read-mode=false
- - -common.compactor-grpc-address={{ include "loki.backendFullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}:9095
+ - -common.compactor-grpc-address={{ include "loki.resourceName" (dict "ctx" . "component" "backend") }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}:9095
+ {{- if .Values.write.zoneAwareReplication.migration.enabled }}
+ {{- if not .Values.write.zoneAwareReplication.migration.readPath }}
+ - "-distributor.zone-awareness-enabled=false"
+ {{- end }}
+ {{- end }}
{{- with .Values.read.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
diff --git a/production/helm/loki/templates/read/hpa.yaml b/production/helm/loki/templates/read/hpa.yaml
index 5515ecb0b448b..050ccc2c755f1 100644
--- a/production/helm/loki/templates/read/hpa.yaml
+++ b/production/helm/loki/templates/read/hpa.yaml
@@ -1,3 +1,4 @@
+{{- $args := dict "ctx" . "component" "read" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}}
{{- if and $isSimpleScalable ( .Values.read.autoscaling.enabled ) }}
@@ -8,18 +9,19 @@ apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
- name: {{ include "loki.readFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
+ namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.readLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) }}
kind: Deployment
- name: {{ include "loki.readFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
{{- else }}
kind: StatefulSet
- name: {{ include "loki.readFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
{{- end }}
minReplicas: {{ .Values.read.autoscaling.minReplicas }}
maxReplicas: {{ .Values.read.autoscaling.maxReplicas }}
diff --git a/production/helm/loki/templates/read/poddisruptionbudget-read.yaml b/production/helm/loki/templates/read/poddisruptionbudget-read.yaml
index af4fcbf16d8e5..9c55146e0ba5d 100644
--- a/production/helm/loki/templates/read/poddisruptionbudget-read.yaml
+++ b/production/helm/loki/templates/read/poddisruptionbudget-read.yaml
@@ -1,15 +1,5 @@
+{{- $args := dict "ctx" . "component" "read" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (gt (int .Values.read.replicas) 1) }}
-apiVersion: policy/v1
-kind: PodDisruptionBudget
-metadata:
- name: {{ include "loki.readFullname" . }}
- namespace: {{ $.Release.Namespace }}
- labels:
- {{- include "loki.readLabels" . | nindent 4 }}
-spec:
- selector:
- matchLabels:
- {{- include "loki.readSelectorLabels" . | nindent 6 }}
- maxUnavailable: 1
+{{- include "loki.lib.podDisruptionBudget" $args }}
{{- end }}
diff --git a/production/helm/loki/templates/read/service-read-headless.yaml b/production/helm/loki/templates/read/service-read-headless.yaml
index e3c440082b4f3..83f2483110bba 100644
--- a/production/helm/loki/templates/read/service-read-headless.yaml
+++ b/production/helm/loki/templates/read/service-read-headless.yaml
@@ -1,13 +1,14 @@
+{{- $args := dict "ctx" . "component" "read" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{ if $isSimpleScalable }}
---
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki.readFullname" . }}-headless
+ name: {{ include "loki.resourceName" $args }}-headless
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.readSelectorLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -37,5 +38,5 @@ spec:
protocol: TCP
appProtocol: tcp
selector:
- {{- include "loki.readSelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/read/service-read.yaml b/production/helm/loki/templates/read/service-read.yaml
index b7306edc058d6..48037fce991b4 100644
--- a/production/helm/loki/templates/read/service-read.yaml
+++ b/production/helm/loki/templates/read/service-read.yaml
@@ -1,13 +1,14 @@
+{{- $args := dict "ctx" . "component" "read" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if $isSimpleScalable }}
---
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki.readFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.readLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -33,5 +34,5 @@ spec:
targetPort: grpc
protocol: TCP
selector:
- {{- include "loki.readSelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/read/statefulset-read.yaml b/production/helm/loki/templates/read/statefulset-read.yaml
index 3b0d91d926a3c..baf463c508936 100644
--- a/production/helm/loki/templates/read/statefulset-read.yaml
+++ b/production/helm/loki/templates/read/statefulset-read.yaml
@@ -1,23 +1,29 @@
+{{- $args := dict "ctx" . "component" "read" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (.Values.read.legacyReadTarget ) }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
- name: {{ include "loki.readFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- app.kubernetes.io/part-of: memberlist
- {{- include "loki.readLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
+ annotations:
+ {{- with .Values.loki.annotations }}
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ {{- with .Values.read.annotations }}
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
spec:
{{- if not .Values.read.autoscaling.enabled }}
replicas: {{ .Values.read.replicas }}
{{- end }}
podManagementPolicy: {{ .Values.read.podManagementPolicy }}
updateStrategy:
- rollingUpdate:
- partition: 0
- serviceName: {{ printf "%s-headless" (include "loki.readFullname" .) }}
+ {{- toYaml .Values.read.statefulStrategy | nindent 4 }}
+ serviceName: {{ include "loki.name" . }}-read-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.read.persistence.enableStatefulSetAutoDeletePVC) }}
{{/*
@@ -30,29 +36,13 @@ spec:
{{- end }}
selector:
matchLabels:
- {{- include "loki.readSelectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
template:
metadata:
annotations:
- checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
- {{- with .Values.loki.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.read.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
+ {{- include "loki.podAnnotations" $args | nindent 8 }}
labels:
- app.kubernetes.io/part-of: memberlist
- {{- include "loki.readSelectorLabels" . | nindent 8 }}
- {{- with .Values.loki.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.read.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.read.selectorLabels }}
- {{- tpl (toYaml .) $ | nindent 8 }}
- {{- end }}
+ {{- include "loki.podLabels" $args | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
@@ -61,7 +51,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
- {{- include "loki.readPriorityClassName" . | nindent 6 }}
+ {{- include "loki.priorityClassName" $args | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.read.terminationGracePeriodSeconds }}
@@ -72,6 +62,11 @@ spec:
args:
- -config.file=/etc/loki/config/config.yaml
- -target={{ .Values.read.targetModule }}
+ {{- if .Values.write.zoneAwareReplication.migration.enabled }}
+ {{- if not .Values.write.zoneAwareReplication.migration.readPath }}
+ - "-distributor.zone-awareness-enabled=false"
+ {{- end }}
+ {{- end }}
{{- with .Values.read.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
diff --git a/production/helm/loki/templates/role.yaml b/production/helm/loki/templates/role.yaml
index 1e714b606b93c..55c4974a3cfae 100644
--- a/production/helm/loki/templates/role.yaml
+++ b/production/helm/loki/templates/role.yaml
@@ -5,7 +5,7 @@ metadata:
name: {{ include "loki.name" . }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
{{- if .Values.rbac.pspEnabled }}
rules:
- apiGroups:
diff --git a/production/helm/loki/templates/rolebinding.yaml b/production/helm/loki/templates/rolebinding.yaml
index cc0dfd2adf4b8..ecc8d67db3cda 100644
--- a/production/helm/loki/templates/rolebinding.yaml
+++ b/production/helm/loki/templates/rolebinding.yaml
@@ -5,7 +5,7 @@ metadata:
name: {{ include "loki.name" . }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
diff --git a/production/helm/loki/templates/runtime-configmap.yaml b/production/helm/loki/templates/runtime-configmap.yaml
index 2f38193da615d..7a7d7a3ca344f 100644
--- a/production/helm/loki/templates/runtime-configmap.yaml
+++ b/production/helm/loki/templates/runtime-configmap.yaml
@@ -4,7 +4,7 @@ metadata:
name: {{ include "loki.name" . }}-runtime
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
data:
runtime-config.yaml: |
{{- tpl (toYaml .Values.loki.runtimeConfig) . | nindent 4 }}
diff --git a/production/helm/loki/templates/secret-license.yaml b/production/helm/loki/templates/secret-license.yaml
index eaa519fc39b43..e7ba8eea6df75 100644
--- a/production/helm/loki/templates/secret-license.yaml
+++ b/production/helm/loki/templates/secret-license.yaml
@@ -5,7 +5,7 @@ metadata:
name: enterprise-logs-license
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
data:
license.jwt: {{ .Values.enterprise.license.contents | b64enc }}
{{- end }}
diff --git a/production/helm/loki/templates/securitycontextconstraints.yaml b/production/helm/loki/templates/securitycontextconstraints.yaml
index c3a604d572698..5ba75212ad6dd 100644
--- a/production/helm/loki/templates/securitycontextconstraints.yaml
+++ b/production/helm/loki/templates/securitycontextconstraints.yaml
@@ -4,7 +4,7 @@ kind: SecurityContextConstraints
metadata:
name: {{ include "loki.name" . }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
allowHostDirVolumePlugin: false
allowHostIPC: false
allowHostNetwork: false
diff --git a/production/helm/loki/templates/service-memberlist.yaml b/production/helm/loki/templates/service-memberlist.yaml
index cacb5b1e872bb..4e5635b816cc1 100644
--- a/production/helm/loki/templates/service-memberlist.yaml
+++ b/production/helm/loki/templates/service-memberlist.yaml
@@ -5,7 +5,7 @@ metadata:
name: {{ include "loki.memberlist" . }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
spec:
type: ClusterIP
clusterIP: None
@@ -18,5 +18,5 @@ spec:
publishNotReadyAddresses: {{ . }}
{{- end }}
selector:
- {{- include "loki.selectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" (dict "ctx" .) | nindent 4 }}
app.kubernetes.io/part-of: memberlist
diff --git a/production/helm/loki/templates/serviceaccount.yaml b/production/helm/loki/templates/serviceaccount.yaml
index dd891413648ba..929bf884a6edd 100644
--- a/production/helm/loki/templates/serviceaccount.yaml
+++ b/production/helm/loki/templates/serviceaccount.yaml
@@ -5,7 +5,7 @@ metadata:
name: {{ include "loki.serviceAccountName" . }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" (dict "ctx" .) | nindent 4 }}
{{- with .Values.serviceAccount.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/single-binary/_helpers-single-binary.tpl b/production/helm/loki/templates/single-binary/_helpers-single-binary.tpl
index 4ea3c6d77b91a..f45295e932800 100644
--- a/production/helm/loki/templates/single-binary/_helpers-single-binary.tpl
+++ b/production/helm/loki/templates/single-binary/_helpers-single-binary.tpl
@@ -1,28 +1,3 @@
-{{/*
-singleBinary common labels
-*/}}
-{{- define "loki.singleBinaryLabels" -}}
-{{ include "loki.labels" . }}
-app.kubernetes.io/component: single-binary
-{{- end }}
-
-
-{{/* singleBinary selector labels */}}
-{{- define "loki.singleBinarySelectorLabels" -}}
-{{ include "loki.selectorLabels" . }}
-app.kubernetes.io/component: single-binary
-{{- end }}
-
-{{/*
-singleBinary priority class name
-*/}}
-{{- define "loki.singleBinaryPriorityClassName" -}}
-{{- $pcn := coalesce .Values.global.priorityClassName .Values.singleBinary.priorityClassName -}}
-{{- if $pcn }}
-priorityClassName: {{ $pcn }}
-{{- end }}
-{{- end }}
-
{{/* singleBinary replicas calculation */}}
{{- define "loki.singleBinaryReplicas" -}}
{{- $replicas := 1 }}
diff --git a/production/helm/loki/templates/single-binary/hpa.yaml b/production/helm/loki/templates/single-binary/hpa.yaml
index c529f1899f7d8..20261ca567aaf 100644
--- a/production/helm/loki/templates/single-binary/hpa.yaml
+++ b/production/helm/loki/templates/single-binary/hpa.yaml
@@ -1,3 +1,4 @@
+{{- $args := dict "ctx" . "component" "single-binary" "memberlist" true -}}
{{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}}
{{- $usingObjectStorage := eq (include "loki.isUsingObjectStorage" .) "true" }}
{{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}}
@@ -9,14 +10,14 @@ apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
- name: {{ include "loki.singleBinaryFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
labels:
- {{- include "loki.singleBinaryLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: StatefulSet
- name: {{ include "loki.singleBinaryFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
minReplicas: {{ .Values.singleBinary.autoscaling.minReplicas }}
maxReplicas: {{ .Values.singleBinary.autoscaling.maxReplicas }}
{{- with .Values.singleBinary.autoscaling.behavior }}
diff --git a/production/helm/loki/templates/single-binary/pdb.yaml b/production/helm/loki/templates/single-binary/pdb.yaml
index bb1e1ccc1cb9b..779111f1236a9 100644
--- a/production/helm/loki/templates/single-binary/pdb.yaml
+++ b/production/helm/loki/templates/single-binary/pdb.yaml
@@ -1,16 +1,5 @@
+{{- $args := dict "ctx" . "component" "single-binary" "memberlist" true -}}
{{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}}
{{- if and .Values.podDisruptionBudget $isSingleBinary -}}
----
-apiVersion: policy/v1
-kind: PodDisruptionBudget
-metadata:
- name: {{ template "loki.fullname" . }}
- namespace: {{ $.Release.Namespace }}
- labels:
- {{- include "loki.labels" . | nindent 4 }}
-spec:
- selector:
- matchLabels:
- {{- include "loki.singleBinarySelectorLabels" . | nindent 6 }}
-{{ toYaml .Values.podDisruptionBudget | indent 2 }}
+{{- include "loki.lib.podDisruptionBudget" $args }}
{{- end }}
diff --git a/production/helm/loki/templates/single-binary/service-headless.yaml b/production/helm/loki/templates/single-binary/service-headless.yaml
index 51e111982b95a..6aa5e77b792a1 100644
--- a/production/helm/loki/templates/single-binary/service-headless.yaml
+++ b/production/helm/loki/templates/single-binary/service-headless.yaml
@@ -1,3 +1,4 @@
+{{- $args := dict "ctx" . "component" "single-binary" "memberlist" true -}}
{{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}}
{{- if $isSingleBinary }}
---
@@ -7,7 +8,7 @@ metadata:
name: {{ include "loki.name" . }}-headless
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -31,5 +32,5 @@ spec:
targetPort: http-metrics
protocol: TCP
selector:
- {{- include "loki.selectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/single-binary/service.yaml b/production/helm/loki/templates/single-binary/service.yaml
index 1dee4eba8a6f8..dfa5a8645eaa7 100644
--- a/production/helm/loki/templates/single-binary/service.yaml
+++ b/production/helm/loki/templates/single-binary/service.yaml
@@ -1,13 +1,14 @@
+{{- $args := dict "ctx" . "component" "single-binary" "memberlist" true -}}
{{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}}
{{- if $isSingleBinary }}
---
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki.singleBinaryFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -33,8 +34,5 @@ spec:
targetPort: grpc
protocol: TCP
selector:
- {{- include "loki.singleBinarySelectorLabels" . | nindent 4 }}
- {{- with .Values.singleBinary.selectorLabels }}
- {{- tpl (toYaml .) $ | nindent 4 }}
- {{- end }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/single-binary/statefulset.yaml b/production/helm/loki/templates/single-binary/statefulset.yaml
index b74cc60500d6a..5e8aba56e1d7d 100644
--- a/production/helm/loki/templates/single-binary/statefulset.yaml
+++ b/production/helm/loki/templates/single-binary/statefulset.yaml
@@ -1,14 +1,14 @@
+{{- $args := dict "ctx" . "component" "single-binary" "memberlist" true -}}
{{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}}
{{- if $isSingleBinary }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
- name: {{ include "loki.singleBinaryFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.singleBinaryLabels" . | nindent 4 }}
- app.kubernetes.io/part-of: memberlist
+ {{- include "loki.labels" $args | nindent 4 }}
{{- if or (not (empty .Values.loki.annotations)) (not (empty .Values.singleBinary.annotations))}}
annotations:
{{- with .Values.loki.annotations }}
@@ -22,8 +22,7 @@ spec:
replicas: {{ include "loki.singleBinaryReplicas" . }}
podManagementPolicy: Parallel
updateStrategy:
- rollingUpdate:
- partition: 0
+ {{- toYaml .Values.singleBinary.statefulStrategy | nindent 4 }}
serviceName: {{ include "loki.singleBinaryFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.singleBinary.persistence.enableStatefulSetAutoDeletePVC) (.Values.singleBinary.persistence.enabled) }}
@@ -37,29 +36,13 @@ spec:
{{- end }}
selector:
matchLabels:
- {{- include "loki.singleBinarySelectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
template:
metadata:
annotations:
- checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
- {{- with .Values.loki.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.singleBinary.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
+ {{- include "loki.podAnnotations" $args | nindent 8 }}
labels:
- {{- include "loki.singleBinarySelectorLabels" . | nindent 8 }}
- {{- with .Values.loki.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.singleBinary.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.singleBinary.selectorLabels }}
- {{- tpl (toYaml .) $ | nindent 8 }}
- {{- end }}
- app.kubernetes.io/part-of: memberlist
+ {{- include "loki.podLabels" $args | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
@@ -68,7 +51,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
- {{- include "loki.singleBinaryPriorityClassName" . | nindent 6 }}
+ {{- include "loki.priorityClassName" $args | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.singleBinary.terminationGracePeriodSeconds }}
diff --git a/production/helm/loki/templates/table-manager/_helpers-table-manager.tpl b/production/helm/loki/templates/table-manager/_helpers-table-manager.tpl
deleted file mode 100644
index ff258321c1c30..0000000000000
--- a/production/helm/loki/templates/table-manager/_helpers-table-manager.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-{{/*
-table-manager fullname
-*/}}
-{{- define "loki.tableManagerFullname" -}}
-{{ include "loki.fullname" . }}-table-manager
-{{- end }}
-
-{{/*
-table-manager common labels
-*/}}
-{{- define "loki.tableManagerLabels" -}}
-{{ include "loki.labels" . }}
-app.kubernetes.io/component: table-manager
-{{- end }}
-
-{{/*
-table-manager selector labels
-*/}}
-{{- define "loki.tableManagerSelectorLabels" -}}
-{{ include "loki.selectorLabels" . }}
-app.kubernetes.io/component: table-manager
-{{- end }}
-
-{{/*
-table-manager priority class name
-*/}}
-{{- define "loki.tableManagerPriorityClassName" -}}
-{{- $pcn := coalesce .Values.global.priorityClassName .Values.tableManager.priorityClassName -}}
-{{- if $pcn }}
-priorityClassName: {{ $pcn }}
-{{- end }}
-{{- end }}
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 bc14d1f6df491..9adb1c9199852 100644
--- a/production/helm/loki/templates/table-manager/deployment-table-manager.yaml
+++ b/production/helm/loki/templates/table-manager/deployment-table-manager.yaml
@@ -1,10 +1,11 @@
+{{- $args := dict "ctx" . "component" "table-manager" -}}
{{- if .Values.tableManager.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
- name: {{ include "loki.tableManagerFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
labels:
- {{- include "loki.tableManagerLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
annotations:
{{- with .Values.loki.annotations }}
{{- toYaml . | nindent 4 }}
@@ -17,32 +18,20 @@ spec:
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
selector:
matchLabels:
- {{- include "loki.tableManagerSelectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
template:
metadata:
annotations:
- checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
- {{- with .Values.loki.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.tableManager.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
+ {{- include "loki.podAnnotations" $args | nindent 8 }}
labels:
- {{- include "loki.tableManagerSelectorLabels" . | nindent 8 }}
- {{- with .Values.loki.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.tableManager.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
+ {{- include "loki.podLabels" $args | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
- {{- include "loki.tableManagerPriorityClassName" . | nindent 6 }}
+ {{- include "loki.priorityClassName" $args | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.tableManager.terminationGracePeriodSeconds }}
diff --git a/production/helm/loki/templates/table-manager/service-table-manager.yaml b/production/helm/loki/templates/table-manager/service-table-manager.yaml
index 43443fb57550d..b72033c83b733 100644
--- a/production/helm/loki/templates/table-manager/service-table-manager.yaml
+++ b/production/helm/loki/templates/table-manager/service-table-manager.yaml
@@ -1,17 +1,17 @@
+{{- $args := dict "ctx" . "component" "table-manager" -}}
{{- if .Values.tableManager.enabled }}
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki.fullname" . }}-table-manager
+ name: {{ include "loki.resourceName" $args }}
labels:
- {{- include "loki.labels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
{{- with .Values.tableManager.service.labels }}
{{- toYaml . | nindent 4}}
{{- end }}
- app.kubernetes.io/component: table-manager
annotations:
{{- with .Values.loki.serviceAnnotations }}
{{- toYaml . | nindent 4}}
@@ -31,6 +31,5 @@ spec:
targetPort: grpc
protocol: TCP
selector:
- {{- include "loki.selectorLabels" . | nindent 4 }}
- app.kubernetes.io/component: table-manager
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/table-manager/servicemonitor-table-manager.yaml b/production/helm/loki/templates/table-manager/servicemonitor-table-manager.yaml
index 09aa7279f1653..b067157b219b4 100644
--- a/production/helm/loki/templates/table-manager/servicemonitor-table-manager.yaml
+++ b/production/helm/loki/templates/table-manager/servicemonitor-table-manager.yaml
@@ -1,10 +1,11 @@
+{{- $args := dict "ctx" . "component" "table-manager" -}}
{{- if .Values.tableManager.enabled }}
{{- with .Values.serviceMonitor }}
{{- if .enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
- name: {{ include "loki.tableManagerFullname" $ }}
+ name: {{ include "loki.resourceName" $args }}
{{- with .namespace }}
namespace: {{ . }}
{{- end }}
@@ -13,10 +14,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
- {{- include "loki.tableManagerLabels" $ | nindent 4 }}
- {{- with .labels }}
- {{- toYaml . | nindent 4 }}
- {{- end }}
+ {{- include "loki.labels" $args | nindent 4 }}
spec:
{{- with .namespaceSelector }}
namespaceSelector:
@@ -24,7 +22,7 @@ spec:
{{- end }}
selector:
matchLabels:
- {{- include "loki.tableManagerSelectorLabels" $ | nindent 6 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
endpoints:
- port: http-metrics
{{- with .interval }}
diff --git a/production/helm/loki/templates/tests/_helpers.tpl b/production/helm/loki/templates/tests/_helpers.tpl
index 9ef7c157a6a9b..4ecd032250ca1 100644
--- a/production/helm/loki/templates/tests/_helpers.tpl
+++ b/production/helm/loki/templates/tests/_helpers.tpl
@@ -11,6 +11,6 @@ Docker image name for loki helm test
test common labels
*/}}
{{- define "loki.helmTestLabels" -}}
-{{ include "loki.labels" . }}
+{{ include "loki.labels" (dict "ctx" .) }}
app.kubernetes.io/component: helm-test
{{- end }}
diff --git a/production/helm/loki/templates/validate.yaml b/production/helm/loki/templates/validate.yaml
index 3a2e8ca79fade..0e35344d56d77 100644
--- a/production/helm/loki/templates/validate.yaml
+++ b/production/helm/loki/templates/validate.yaml
@@ -25,3 +25,9 @@
{{- if and $isUsingFilesystem (and (eq $singleBinaryReplicas 0) $atLeastOneScalableReplica) }}
{{- fail "Cannot run Scalable targets (backend, read, write) without an object storage backend."}}
{{- end }}
+
+{{- if .Values.write.zoneAwareReplication.enabled }}
+{{- if not .Values.rollout_operator.enabled }}
+{{- fail "You have enabled zoneAwareReplication for write component, you must also enable the rollout_operator." -}}
+{{- end }}
+{{- end }}
\ No newline at end of file
diff --git a/production/helm/loki/templates/write/_helpers-write.tpl b/production/helm/loki/templates/write/_helpers-write.tpl
deleted file mode 100644
index 8f526bcf2bd24..0000000000000
--- a/production/helm/loki/templates/write/_helpers-write.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-{{/*
-write fullname
-*/}}
-{{- define "loki.writeFullname" -}}
-{{ include "loki.name" . }}-write
-{{- end }}
-
-{{/*
-write common labels
-*/}}
-{{- define "loki.writeLabels" -}}
-{{ include "loki.labels" . }}
-app.kubernetes.io/component: write
-{{- end }}
-
-{{/*
-write selector labels
-*/}}
-{{- define "loki.writeSelectorLabels" -}}
-{{ include "loki.selectorLabels" . }}
-app.kubernetes.io/component: write
-{{- end }}
-
-{{/*
-write priority class name
-*/}}
-{{- define "loki.writePriorityClassName" -}}
-{{- $pcn := coalesce .Values.global.priorityClassName .Values.write.priorityClassName -}}
-{{- if $pcn }}
-priorityClassName: {{ $pcn }}
-{{- end }}
-{{- end }}
diff --git a/production/helm/loki/templates/write/hpa.yaml b/production/helm/loki/templates/write/hpa.yaml
index ba88ee2ddddc9..6ce4431fc8a25 100644
--- a/production/helm/loki/templates/write/hpa.yaml
+++ b/production/helm/loki/templates/write/hpa.yaml
@@ -1,6 +1,7 @@
+{{- $args := dict "ctx" . "component" "write" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}}
-{{- if and $isSimpleScalable ( .Values.write.autoscaling.enabled ) }}
+{{- if and $isSimpleScalable ( .Values.write.autoscaling.enabled ) ( not .Values.write.zoneAwareReplication.enabled) }}
{{- if $autoscalingv2 }}
apiVersion: autoscaling/v2
{{- else }}
@@ -8,15 +9,15 @@ apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
- name: {{ include "loki.writeFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.writeLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: StatefulSet
- name: {{ include "loki.writeFullname" . }}
+ name: {{ include "loki.name" . }}-write
minReplicas: {{ .Values.write.autoscaling.minReplicas }}
maxReplicas: {{ .Values.write.autoscaling.maxReplicas }}
{{- with .Values.write.autoscaling.behavior }}
diff --git a/production/helm/loki/templates/write/poddisruptionbudget-write.yaml b/production/helm/loki/templates/write/poddisruptionbudget-write.yaml
index 24e135604a525..03c78d508cb5f 100644
--- a/production/helm/loki/templates/write/poddisruptionbudget-write.yaml
+++ b/production/helm/loki/templates/write/poddisruptionbudget-write.yaml
@@ -1,15 +1,5 @@
+{{- $args := dict "ctx" . "component" "write" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (gt (int .Values.write.replicas) 1) }}
-apiVersion: policy/v1
-kind: PodDisruptionBudget
-metadata:
- name: {{ include "loki.writeFullname" . }}
- namespace: {{ $.Release.Namespace }}
- labels:
- {{- include "loki.writeLabels" . | nindent 4 }}
-spec:
- selector:
- matchLabels:
- {{- include "loki.writeSelectorLabels" . | nindent 6 }}
- maxUnavailable: 1
+{{- include "loki.lib.podDisruptionBudget" $args }}
{{- end }}
diff --git a/production/helm/loki/templates/write/service-write-headless.yaml b/production/helm/loki/templates/write/service-write-headless.yaml
index 71cdcb7b2db8c..ac1f6b850f545 100644
--- a/production/helm/loki/templates/write/service-write-headless.yaml
+++ b/production/helm/loki/templates/write/service-write-headless.yaml
@@ -1,13 +1,14 @@
+{{- $args := dict "ctx" . "component" "write" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if $isSimpleScalable }}
---
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki.writeFullname" . }}-headless
+ name: {{ include "loki.resourceName" $args }}-headless
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.writeSelectorLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
{{- with .Values.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -37,5 +38,5 @@ spec:
protocol: TCP
appProtocol: tcp
selector:
- {{- include "loki.writeSelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
{{- end }}
diff --git a/production/helm/loki/templates/write/service-write.yaml b/production/helm/loki/templates/write/service-write.yaml
index 35a548c0330c3..0a2f000a692a5 100644
--- a/production/helm/loki/templates/write/service-write.yaml
+++ b/production/helm/loki/templates/write/service-write.yaml
@@ -1,13 +1,21 @@
+{{- $args := dict "ctx" . "component" "write" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if $isSimpleScalable }}
----
+{{- $zonesMap := include "loki.zoneAwareReplicationMap" $args | fromYaml -}}
+{{- range $zoneName, $rolloutZone := $zonesMap }}
+{{- with $ -}}
+{{- $_ := set $args "rolloutZoneName" $zoneName -}}
apiVersion: v1
kind: Service
metadata:
- name: {{ include "loki.writeFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.writeLabels" . | nindent 4 }}
+ {{- include "loki.labels" $args | nindent 4 }}
+ {{- if and $zoneName .Values.write.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.loki.serviceLabels }}
{{- toYaml . | nindent 4}}
{{- end }}
@@ -33,5 +41,8 @@ spec:
targetPort: grpc
protocol: TCP
selector:
- {{- include "loki.writeSelectorLabels" . | nindent 4 }}
+ {{- include "loki.selectorLabels" $args | nindent 4 }}
+---
+{{- end }}
+{{- end }}
{{- end }}
diff --git a/production/helm/loki/templates/write/statefulset-write.yaml b/production/helm/loki/templates/write/statefulset-write.yaml
index 8c5e426d3ffd6..a983589ee0929 100644
--- a/production/helm/loki/templates/write/statefulset-write.yaml
+++ b/production/helm/loki/templates/write/statefulset-write.yaml
@@ -1,32 +1,34 @@
+{{- $args := dict "ctx" . "component" "write" "memberlist" true -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if $isSimpleScalable }}
----
+{{- $zonesMap := include "loki.zoneAwareReplicationMap" $args | fromYaml -}}
+{{- range $zoneName, $rolloutZone := $zonesMap }}
+{{- with $ -}}
+{{- $_ := set $args "rolloutZoneName" $zoneName -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
- name: {{ include "loki.writeFullname" . }}
+ name: {{ include "loki.resourceName" $args }}
namespace: {{ $.Release.Namespace }}
labels:
- {{- include "loki.writeLabels" . | nindent 4 }}
- app.kubernetes.io/part-of: memberlist
- {{- if or (not (empty .Values.loki.annotations)) (not (empty .Values.backend.annotations))}}
+ {{- include "loki.labels" $args | nindent 4 }}
annotations:
+ {{- include "loki.componentAnnotations" $args | nindent 4 }}
{{- with .Values.loki.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
- {{- with .Values.write.annotations }}
- {{- toYaml . | nindent 4 }}
- {{- end }}
- {{- end }}
spec:
-{{- if not .Values.write.autoscaling.enabled }}
- replicas: {{ .Values.write.replicas }}
+{{- if or (not .Values.write.autoscaling.enabled) (.Values.write.zoneAwareReplication.enabled) }}
+ replicas: {{ $rolloutZone.replicas }}
{{- end }}
podManagementPolicy: {{ .Values.write.podManagementPolicy }}
updateStrategy:
- rollingUpdate:
- partition: 0
- serviceName: {{ include "loki.writeFullname" . }}-headless
+ {{- if $zoneName }}
+ type: OnDelete
+ {{- else }}
+ {{- toYaml .Values.write.statefulStrategy | nindent 4 }}
+ {{- end }}
+ serviceName: {{ include "loki.name" . }}-write-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.write.persistence.enableStatefulSetAutoDeletePVC) (.Values.write.persistence.volumeClaimsEnabled) }}
{{/*
@@ -34,34 +36,18 @@ spec:
operation easier, and will rely on re-fetching data when needed.
*/}}
persistentVolumeClaimRetentionPolicy:
- whenDeleted: Delete
- whenScaled: Delete
+ whenDeleted: {{ .Values.write.persistence.whenDeleted }}
+ whenScaled: {{ .Values.write.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
- {{- include "loki.writeSelectorLabels" . | nindent 6 }}
+ {{- include "loki.selectorLabels" $args | nindent 6 }}
template:
metadata:
annotations:
- checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
- {{- with .Values.loki.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.write.podAnnotations }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
+ {{- include "loki.podAnnotations" $args | nindent 8 }}
labels:
- {{- include "loki.writeSelectorLabels" . | nindent 8 }}
- {{- with .Values.loki.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.write.podLabels }}
- {{- toYaml . | nindent 8 }}
- {{- end }}
- {{- with .Values.write.selectorLabels }}
- {{- tpl (toYaml .) $ | nindent 8 }}
- {{- end }}
- app.kubernetes.io/part-of: memberlist
+ {{- include "loki.podLabels" $args | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
@@ -70,7 +56,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
- {{- include "loki.writePriorityClassName" . | nindent 6 }}
+ {{- include "loki.priorityClassName" $args | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.write.terminationGracePeriodSeconds }}
@@ -87,6 +73,23 @@ spec:
args:
- -config.file=/etc/loki/config/config.yaml
- -target={{ .Values.write.targetModule }}
+ {{- if $zoneName }}
+ - "-ingester.availability-zone={{ $zoneName }}"
+ {{- else }}
+ - "-ingester.availability-zone=zone-default"
+ {{- if .Values.write.zoneAwareReplication.migration.enabled }}
+ - "-ingester.flush-on-shutdown=true"
+ - "-ingester.unregister-on-shutdown=true"
+ {{- end }}
+ {{- end }}
+ {{- if .Values.write.zoneAwareReplication.migration.enabled }}
+ {{- if not .Values.write.zoneAwareReplication.migration.writePath }}
+ - "-distributor.zone-awareness-enabled=false"
+ {{- end }}
+ {{- if .Values.write.zoneAwareReplication.migration.excludeDefaultZone }}
+ - "-distributor.excluded-zones=zone-default"
+ {{- end }}
+ {{- end }}
{{- with .Values.write.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
@@ -115,7 +118,7 @@ spec:
{{- if .Values.write.lifecycle }}
lifecycle:
{{- toYaml .Values.write.lifecycle | nindent 12 }}
- {{- else if .Values.write.autoscaling.enabled }}
+ {{- else if and (.Values.write.autoscaling.enabled) (not .Values.write.zoneAwareReplication.enabled) }}
lifecycle:
preStop:
httpGet:
@@ -141,18 +144,22 @@ spec:
{{- with .Values.write.extraContainers }}
{{- toYaml . | nindent 8}}
{{- end }}
- {{- with .Values.write.affinity }}
- affinity:
- {{- tpl . $ | nindent 8 }}
- {{- end }}
{{- with .Values.write.dnsConfig }}
dnsConfig:
{{- tpl . $ | nindent 8 }}
{{- end }}
- {{- with .Values.write.nodeSelector }}
+ {{- with $rolloutZone.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
+ {{- with $rolloutZone.affinity }}
+ affinity:
+ {{- if $zoneName }}
+ {{- toYaml . | nindent 8 }}
+ {{- else }}
+ {{- tpl . $ | nindent 8 }}
+ {{- end }}
+ {{- end }}
{{- with .Values.write.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
@@ -197,8 +204,13 @@ spec:
spec:
accessModes:
- ReadWriteOnce
- {{- with .Values.write.persistence.storageClass }}
- storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
+ {{- $storageClass := default .Values.write.persistence.storageClass $rolloutZone.storageClass }}
+ {{- if $storageClass }}
+ {{- if (eq "-" $storageClass) }}
+ storageClassName: ""
+ {{- else }}
+ storageClassName: {{ $storageClass }}
+ {{- end }}
{{- end }}
resources:
requests:
@@ -211,4 +223,7 @@ spec:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
+---
+{{- end }}
{{- end }}
+{{- end }}
\ No newline at end of file
diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml
index 738cf6ea25ae7..b5367e97926ca 100644
--- a/production/helm/loki/values.yaml
+++ b/production/helm/loki/values.yaml
@@ -115,10 +115,11 @@ loki:
{{- end }}
{{- end }}
- {{- with .Values.loki.ingester }}
ingester:
+ {{- with .Values.loki.ingester }}
{{- tpl (. | toYaml) $ | nindent 4 }}
{{- end }}
+ {{ include "loki.enableWriteZoneAwareness" . | nindent 4 }}
{{- if .Values.loki.commonConfig}}
common:
@@ -539,6 +540,8 @@ rbac:
# apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default'
# -- Whether to install RBAC in the namespace only or cluster-wide. Useful if you want to watch ConfigMap globally.
namespaced: false
+ # -- Use custom clusterrole for ruler/backend
+ useExistingRole: false
# -- Section for configuring optional Helm test
test:
enabled: true
@@ -732,6 +735,35 @@ monitoring:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
+
+ # -- podSecurityContext is the pod security context for the rollout operator.
+ # When installing on OpenShift, override podSecurityContext settings with
+ #
+ # rollout_operator:
+ # podSecurityContext:
+ # fsGroup: null
+ # runAsGroup: null
+ # runAsUser: null
+ podSecurityContext:
+ fsGroup: 10001
+ runAsGroup: 10001
+ runAsNonRoot: true
+ runAsUser: 10001
+ seccompProfile:
+ type: RuntimeDefault
+
+ # Set the container security context
+ securityContext:
+ readOnlyRootFilesystem: true
+ capabilities:
+ drop: [ALL]
+ allowPrivilegeEscalation: false
+
+# -- Setting for the Grafana Rollout Operator https://github.com/grafana/helm-charts/tree/main/charts/rollout-operator
+rollout_operator:
+ # -- This should be true if write.zoneAwareReplication.enabled=true
+ enabled: false
+
# Configuration for the write pod(s)
write:
# -- Number of replicas for the write
@@ -776,6 +808,9 @@ write:
podAnnotations: {}
# -- Additional labels for each `write` pod
podLabels: {}
+ # -- Pod Disruption Budget
+ podDisruptionBudget:
+ maxUnavailable: 1
# -- Additional selector labels for each `write` pod
selectorLabels: {}
service:
@@ -810,18 +845,20 @@ write:
extraVolumeClaimTemplates: []
# -- Resource requests and limits for the write
resources: {}
+ # -- updateStrategy of the write statefulset. This is ignored when write.zoneAwareReplication.enabled=true.
+ statefulStrategy:
+ type: RollingUpdate
# -- Grace period to allow the write to shutdown before it is killed. Especially for the ingester,
# this must be increased. It must be long enough so writes can be gracefully shutdown flushing/transferring
# all data and to successfully leave the member ring on shutdown.
terminationGracePeriodSeconds: 300
- # -- Affinity for write pods. Passed through `tpl` and, thus, to be configured as string
- # @default -- Hard node and soft zone anti-affinity
+ # -- Pod Affinity for write pods. This is ignored when write.zoneAwareReplication.enabled=true.
affinity: |
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
- {{- include "loki.writeSelectorLabels" . | nindent 10 }}
+ {{- include "loki.selectorLabels" (dict "ctx" . "component" "write") | nindent 10 }}
topologyKey: kubernetes.io/hostname
# -- DNS config for write pods
dnsConfig: {}
@@ -851,6 +888,98 @@ write:
storageClass: null
# -- Selector for persistent disk
selector: null
+ # -- Enable StatefulSetAutoDeletePVC feature
+ # https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
+ whenDeleted: Delete
+ whenScaled: Delete
+
+
+ # -- Options to configure zone-aware replication for write path
+ # Example configuration with full geographical redundancy:
+ # rollout_operator:
+ # enabled: true
+ # write:
+ # 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-aware replication for write path
+ enabled: false
+ # -- Maximum number of write pods that can be unavailable per zone during rollout
+ maxUnavailable: 10
+ # -- topologyKey to use in pod anti-affinity. If unset, no anti-affinity rules are generated. If set, the generated anti-affinity rule makes sure that pods from different zones do not mix.
+ # E.g.: topologyKey: 'kubernetes.io/hostname'
+ topologyKey: null
+ # -- Auxiliary values for migration, see https://grafana.com/docs/loki/latest/setup/migrate/migrate-from-single-zone-with-helm/
+ migration:
+ # -- Indicate if migration is ongoing for multi zone write
+ enabled: false
+ # -- Exclude default zone on write path
+ excludeDefaultZone: false
+ # -- Enable zone-awareness, write path only
+ writePath: false
+ # -- Enable zone-awareness, read path only
+ readPath: false
+ # -- Total number of replicas to start in availability zones when migration is enabled
+ replicas: 0
+ # -- Scale default zone write pods to 0
+ scaleDownDefaultZone: false
+ # -- Zone definitions for write 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: {}
+ # -- write 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 `write.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: {}
+ # -- write 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 `write.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: {}
+ # -- write 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 `write.persistentVolume.storageClass`.
+ storageClass: null
+
# Configuration for the table-manager
tableManager:
# -- Specifies whether the table-manager should be enabled
@@ -963,6 +1092,9 @@ read:
podAnnotations: {}
# -- Additional labels for each `read` pod
podLabels: {}
+ # -- Pod Disruption Budget
+ podDisruptionBudget:
+ maxUnavailable: 1
# -- Additional selector labels for each `read` pod
selectorLabels: {}
service:
@@ -990,6 +1122,9 @@ read:
extraVolumes: []
# -- Resource requests and limits for the read
resources: {}
+ # -- updateStrategy of the write statefulset.
+ statefulStrategy:
+ type: RollingUpdate
# -- Grace period to allow the read to shutdown before it is killed
terminationGracePeriodSeconds: 30
# -- Affinity for read pods. Passed through `tpl` and, thus, to be configured as string
@@ -999,7 +1134,7 @@ read:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
- {{- include "loki.readSelectorLabels" . | nindent 10 }}
+ {{- include "loki.selectorLabels" (dict "ctx" . "component" "read") | nindent 10 }}
topologyKey: kubernetes.io/hostname
# -- DNS config for read pods
dnsConfig: {}
@@ -1068,6 +1203,9 @@ backend:
podAnnotations: {}
# -- Additional labels for each `backend` pod
podLabels: {}
+ # -- Pod Disruption Budget
+ podDisruptionBudget:
+ maxUnavailable: 1
# -- Additional selector labels for each `backend` pod
selectorLabels: {}
service:
@@ -1091,6 +1229,9 @@ backend:
extraVolumes: []
# -- Resource requests and limits for the backend
resources: {}
+ # -- updateStrategy of the write statefulset.
+ statefulStrategy:
+ type: RollingUpdate
# -- Grace period to allow the backend to shutdown before it is killed. Especially for the ingester,
# this must be increased. It must be long enough so backends can be gracefully shutdown flushing/transferring
# all data and to successfully leave the member ring on shutdown.
@@ -1102,7 +1243,7 @@ backend:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
- {{- include "loki.backendSelectorLabels" . | nindent 10 }}
+ {{- include "loki.selectorLabels" (dict "ctx" . "component" "backend") | nindent 10 }}
topologyKey: kubernetes.io/hostname
# -- DNS config for backend pods
dnsConfig: {}
@@ -1132,6 +1273,10 @@ backend:
storageClass: null
# -- Selector for persistent disk
selector: null
+ # -- Enable StatefulSetAutoDeletePVC feature
+ # https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
+ whenDeleted: Delete
+ whenScaled: Delete
# Configuration for the single binary node(s)
singleBinary:
# -- Number of replicas for the single binary
@@ -1162,6 +1307,9 @@ singleBinary:
podAnnotations: {}
# -- Additional labels for each `single binary` pod
podLabels: {}
+ # -- Pod Disruption Budget
+ podDisruptionBudget:
+ maxUnavailable: 1
# -- Additional selector labels for each `single binary` pod
selectorLabels: {}
service:
@@ -1187,6 +1335,9 @@ singleBinary:
extraVolumes: []
# -- Resource requests and limits for the single binary
resources: {}
+ # -- updateStrategy of the write statefulset.
+ statefulStrategy:
+ type: RollingUpdate
# -- Grace period to allow the single binary to shutdown before it is killed
terminationGracePeriodSeconds: 30
# -- Affinity for single binary pods. Passed through `tpl` and, thus, to be configured as string
@@ -1196,7 +1347,7 @@ singleBinary:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
- {{- include "loki.singleBinarySelectorLabels" . | nindent 10 }}
+ {{- include "loki.selectorLabels" (dict "ctx" . "component" "single-binary") | nindent 10 }}
topologyKey: kubernetes.io/hostname
# -- DNS config for single binary pods
dnsConfig: {}
@@ -1324,6 +1475,9 @@ gateway:
podAnnotations: {}
# -- Additional labels for gateway pods
podLabels: {}
+ # -- Pod Disruption Budget
+ podDisruptionBudget:
+ maxUnavailable: 1
# -- Additional CLI args for the gateway
extraArgs: []
# -- Environment variables to add to the gateway pods
@@ -1362,7 +1516,7 @@ gateway:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
- {{- include "loki.gatewaySelectorLabels" . | nindent 10 }}
+ {{- include "loki.selectorLabels" (dict "ctx" . "component" "gateway") | nindent 10 }}
topologyKey: kubernetes.io/hostname
# -- DNS config for gateway pods
dnsConfig: {}