feat!: update helm chart to support distributed mode and 3.0 (#12067)

Signed-off-by: Edward Welch <edward.welch@grafana.com>
Co-authored-by: Trevor Whitney <trevorjwhitney@gmail.com>
Co-authored-by: Dylan Guedes <djmgguedes@gmail.com>
Co-authored-by: J Stickler <julie.stickler@grafana.com>
pull/12522/head^2 helm-loki-6.0.0
Ed Welch 2 years ago committed by GitHub
parent 1c5a736641
commit 79b876b65d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8985
      docs/sources/setup/install/helm/reference.md
  2. 89
      docs/sources/setup/upgrade/upgrade-to-6x/index.md
  3. 6
      production/helm/loki/CHANGELOG.md
  4. 7
      production/helm/loki/Chart.lock
  5. 9
      production/helm/loki/Chart.yaml
  6. 3
      production/helm/loki/README.md
  7. 14
      production/helm/loki/ci/default-single-binary-values.yaml
  8. 9
      production/helm/loki/ci/default-values.yaml
  9. 32
      production/helm/loki/ci/distributed-disabled.yaml
  10. 3
      production/helm/loki/ci/ingress-values.yaml
  11. 22
      production/helm/loki/ci/legacy-monitoring-values.yaml
  12. 70
      production/helm/loki/distributed-values.yaml
  13. 63
      production/helm/loki/simple-scalable-values.yaml
  14. 79
      production/helm/loki/single-binary-values.yaml
  15. 113
      production/helm/loki/src/helm-test/canary_test.go
  16. 11
      production/helm/loki/templates/NOTES.txt
  17. 176
      production/helm/loki/templates/_helpers.tpl
  18. 24
      production/helm/loki/templates/admin-api/_helpers.yaml
  19. 168
      production/helm/loki/templates/admin-api/deployment-admin-api.yaml
  20. 28
      production/helm/loki/templates/admin-api/service-admin-api.yaml
  21. 5
      production/helm/loki/templates/backend/clusterrole.yaml
  22. 5
      production/helm/loki/templates/backend/clusterrolebinding.yaml
  23. 7
      production/helm/loki/templates/backend/statefulset-backend.yaml
  24. 58
      production/helm/loki/templates/bloom-compactor/_helpers-bloom-compactor.tpl
  25. 179
      production/helm/loki/templates/bloom-compactor/statefulset-bloom-compactor.yaml
  26. 58
      production/helm/loki/templates/bloom-gateway/_helpers-bloom-gateway.tpl
  27. 179
      production/helm/loki/templates/bloom-gateway/statefulset-bloom-gateway.yaml
  28. 16
      production/helm/loki/templates/chunks-cache/poddisruptionbudget-chunks-cache.yaml
  29. 1
      production/helm/loki/templates/chunks-cache/service-chunks-cache-headless.yaml
  30. 1
      production/helm/loki/templates/chunks-cache/statefulset-chunks-cache.yaml
  31. 81
      production/helm/loki/templates/compactor/_helpers-compactor.tpl
  32. 35
      production/helm/loki/templates/compactor/service-compactor.yaml
  33. 193
      production/helm/loki/templates/compactor/statefulset-compactor.yaml
  34. 4
      production/helm/loki/templates/config.yaml
  35. 32
      production/helm/loki/templates/distributor/_helpers-distributor.tpl
  36. 152
      production/helm/loki/templates/distributor/deployment-distributor.yaml
  37. 54
      production/helm/loki/templates/distributor/hpa.yaml
  38. 21
      production/helm/loki/templates/distributor/poddisruptionbudget-distributor.yaml
  39. 36
      production/helm/loki/templates/distributor/service-distributor-headless.yaml
  40. 33
      production/helm/loki/templates/distributor/service-distributor.yaml
  41. 2
      production/helm/loki/templates/gateway/_helpers-gateway.tpl
  42. 2
      production/helm/loki/templates/gateway/configmap-gateway.yaml
  43. 132
      production/helm/loki/templates/gateway/deployment-gateway-enterprise.yaml
  44. 6
      production/helm/loki/templates/gateway/deployment-gateway-nginx.yaml
  45. 4
      production/helm/loki/templates/gateway/service-gateway.yaml
  46. 40
      production/helm/loki/templates/index-gateway/_helpers-index-gateway.tpl
  47. 20
      production/helm/loki/templates/index-gateway/poddisruptionbudget-index-gateway.yaml
  48. 27
      production/helm/loki/templates/index-gateway/service-index-gateway-headless.yaml
  49. 32
      production/helm/loki/templates/index-gateway/service-index-gateway.yaml
  50. 186
      production/helm/loki/templates/index-gateway/statefulset-index-gateway.yaml
  51. 74
      production/helm/loki/templates/ingester/_helpers-ingester.tpl
  52. 55
      production/helm/loki/templates/ingester/hpa.yaml
  53. 21
      production/helm/loki/templates/ingester/poddisruptionbudget-ingester-rollout.yaml
  54. 27
      production/helm/loki/templates/ingester/poddisruptionbudget-ingester.yaml
  55. 32
      production/helm/loki/templates/ingester/service-ingester-headless.yaml
  56. 35
      production/helm/loki/templates/ingester/service-ingester-zone-a-headless.yaml
  57. 35
      production/helm/loki/templates/ingester/service-ingester-zone-b-headless.yaml
  58. 35
      production/helm/loki/templates/ingester/service-ingester-zone-c-headless.yaml
  59. 33
      production/helm/loki/templates/ingester/service-ingester.yaml
  60. 232
      production/helm/loki/templates/ingester/statefulset-ingester-zone-a.yaml
  61. 232
      production/helm/loki/templates/ingester/statefulset-ingester-zone-b.yaml
  62. 232
      production/helm/loki/templates/ingester/statefulset-ingester-zone-c.yaml
  63. 204
      production/helm/loki/templates/ingester/statefulset-ingester.yaml
  64. 4
      production/helm/loki/templates/loki-canary/_helpers.tpl
  65. 13
      production/helm/loki/templates/loki-canary/daemonset.yaml
  66. 2
      production/helm/loki/templates/loki-canary/service.yaml
  67. 2
      production/helm/loki/templates/loki-canary/serviceaccount.yaml
  68. 159
      production/helm/loki/templates/memcached/_memcached-statefulset.tpl
  69. 42
      production/helm/loki/templates/memcached/_memcached-svc.tpl
  70. 2
      production/helm/loki/templates/monitoring/logs-instance.yaml
  71. 58
      production/helm/loki/templates/pattern-ingester/_helpers-pattern-ingester.tpl
  72. 179
      production/helm/loki/templates/pattern-ingester/statefulset-pattern-ingester.yaml
  73. 32
      production/helm/loki/templates/querier/_helpers-querier.tpl
  74. 166
      production/helm/loki/templates/querier/deployment-querier.yaml
  75. 55
      production/helm/loki/templates/querier/hpa.yaml
  76. 21
      production/helm/loki/templates/querier/poddisruptionbudget-querier.yaml
  77. 33
      production/helm/loki/templates/querier/service-querier.yaml
  78. 32
      production/helm/loki/templates/query-frontend/_helpers-query-frontend.tpl
  79. 142
      production/helm/loki/templates/query-frontend/deployment-query-frontend.yaml
  80. 55
      production/helm/loki/templates/query-frontend/hpa.yaml
  81. 21
      production/helm/loki/templates/query-frontend/poddisruptionbudget-query-frontent.yaml
  82. 43
      production/helm/loki/templates/query-frontend/service-query-frontend-headless.yaml
  83. 41
      production/helm/loki/templates/query-frontend/service-query-frontend.yaml
  84. 40
      production/helm/loki/templates/query-scheduler/_helpers-query-scheduler.tpl
  85. 140
      production/helm/loki/templates/query-scheduler/deployment-query-scheduler.yaml
  86. 21
      production/helm/loki/templates/query-scheduler/poddisruptionbudget-query-scheduler.yaml
  87. 35
      production/helm/loki/templates/query-scheduler/service-query-scheduler.yaml
  88. 7
      production/helm/loki/templates/read/deployment-read.yaml
  89. 10
      production/helm/loki/templates/read/statefulset-read.yaml
  90. 16
      production/helm/loki/templates/results-cache/poddisruptionbudget-results-cache.yaml
  91. 1
      production/helm/loki/templates/results-cache/service-results-cache-headless.yaml
  92. 1
      production/helm/loki/templates/results-cache/statefulset-results-cache.yaml
  93. 47
      production/helm/loki/templates/ruler/_helpers-ruler.tpl
  94. 14
      production/helm/loki/templates/ruler/configmap-ruler.yaml
  95. 20
      production/helm/loki/templates/ruler/poddisruptionbudget-ruler.yaml
  96. 33
      production/helm/loki/templates/ruler/service-ruler.yaml
  97. 177
      production/helm/loki/templates/ruler/statefulset-ruler.yaml
  98. 7
      production/helm/loki/templates/single-binary/statefulset.yaml
  99. 16
      production/helm/loki/templates/table-manager/deployment-table-manager.yaml
  100. 4
      production/helm/loki/templates/tests/test-canary.yaml
  101. Some files were not shown because too many files have changed in this diff Show More

File diff suppressed because it is too large Load Diff

@ -0,0 +1,89 @@
---
title: Upgrade the Helm chart to 6.0
menuTitle: Upgrade the Helm chart to 6.0
description: Upgrade the Helm chart from 5.x to 6.0.
weight: 800
keywords:
- upgrade
---
## Upgrading to v6.x
v6.x of this chart introduces distributed mode but also introduces breaking changes from v5x.
### Changes
#### BREAKING: `deploymentMode` setting
This only breaks you if you are running the chart in Single Binary mode, you will need to set
```
deploymentMode: SingleBinary
```
#### BREAKING: `lokiCanary` section was moved
This section was moved from within the `monitoring` section to the root level of the values file.
#### BREAKING: `topologySpreadConstraints` and `podAffinity` converted to objects
Previously they were strings which were passed through `tpl` now they are normal objects which will be added to deployments.
Also we removed the soft constraint on zone.
#### BREAKING: `externalConfigSecretName` was removed and replaced.
Instead you can now provide `configObjectName` which is used by Loki components for loading the config.
`generatedConfigObjectName` also can be used to control the name of the config object created by the chart.
This gives greater flexibility in using the chart to still generate a config object but allowing for another process to load and mutate this config into a new object which can be loaded by Loki and `configObjectName`
#### Monitoring
After some consideration of how this chart works with other charts provided by Grafana, we decided to deprecate the monitoring sections of this chart and take a new approach entirely to monitoring Loki, Mimir and Tempo with the [Meta Monitoring Chart](https://github.com/grafana/meta-monitoring-chart).
Reasons:
* There were conflicts with this chart and the Mimir chart both installing the Agent Operator.
* The Agent Operator is deprecated.
* The dependency on the Prometheus operator is not one we are able to support well.
The [Meta Monitoring Chart](https://github.com/grafana/meta-monitoring-chart) is an improvement over the the previous approach because it allows for installing a clustered Grafana Agent which can send metrics, logs, and traces to Grafana Cloud, or letting you install a monitoring-only local installation of Loki, Mimir, Tempo, and Grafana.
The monitoring sections of this chart still exist but are disabled by default.
If you wish to continue using the self monitoring features you should use the following configuration, but please do note a future version of this chart will remove this capability completely:
```
monitoring:
enabled: true
selfMonitoring:
enabled: true
grafanaAgent:
installOperator: true
```
#### Memcached is included and enabled by default
Caching is crucial to the proper operation of Loki and Memcached is now included in this chart and enabled by default for the `chunksCache` and `resultsCache`.
If you are already running Memcached separately you can remove your existing installation and use the Memcached deployments built into this chart.
##### Single Binary
Memcached also deploys for the Single Binary, but this may not be desired in resource constrained environments.
You can disable it with the following configuration:
```
chunksCache:
enabled: false
resultsCache:
enabled: false
```
With these caches disabled, Loki will return to defaults which enables an in-memory results and chunks cache, so you will still get some caching.
#### Distributed mode
This chart introduces the ability to run Loki in distributed, or [microservices mode](https://grafana.com/docs/loki/latest/get-started/deployment-modes/#microservices-mode). Separate instructions on how to enable this as well as how to migrate from the existing community chart will be coming shortly.

@ -13,6 +13,12 @@ Entries should include a reference to the pull request that introduced the chang
[//]: # (<AUTOMATED_UPDATES_LOCATOR> : 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.)
## 6.0.0
- [CHANGE] the lokiCanary section was moved from under monitoring to be under the root of the file.
- [CHANGE] the definitions for topologySpreadConstraints and podAffinity were converted from string templates to objects. Also removed the soft constraint on zone.
- [CHANGE] the externalConfigSecretName was replaced with more generic configs
## 5.47.2
- [ENHANCEMENT] Allow for additional pipeline stages to be configured on the `selfMonitoring` `Podlogs` resource.

@ -5,5 +5,8 @@ dependencies:
- name: grafana-agent-operator
repository: https://grafana.github.io/helm-charts
version: 0.3.15
digest: sha256:b7a42cd0e56544f6168a586fde03e26c801bb20cf69bc004a8f6000d93b98100
generated: "2024-01-27T21:57:28.190462917+05:30"
- name: rollout-operator
repository: https://grafana.github.io/helm-charts
version: 0.13.0
digest: sha256:d0e60c2879039ee5e8b7b10530f0e8790d6d328ee8afca71f01128627e921587
generated: "2024-04-07T14:12:43.317329844-04:00"

@ -2,8 +2,8 @@ apiVersion: v2
name: loki
description: Helm chart for Grafana Loki in simple, scalable mode
type: application
appVersion: 2.9.6
version: 5.47.2
appVersion: 3.0.0
version: 6.0.0
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki
@ -21,6 +21,11 @@ dependencies:
version: 0.3.15
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.13.0
condition: rollout_operator.enabled
maintainers:
- name: trevorwhitney
- name: jeschkies

@ -1,6 +1,6 @@
# loki
![Version: 5.47.2](https://img.shields.io/badge/Version-5.47.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.6](https://img.shields.io/badge/AppVersion-2.9.6-informational?style=flat-square)
![Version: 6.0.0](https://img.shields.io/badge/Version-6.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.0.0](https://img.shields.io/badge/AppVersion-3.0.0-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.3.15 |
| https://grafana.github.io/helm-charts | rollout_operator(rollout-operator) | 0.13.0 |
Find more information in the Loki Helm Chart [documentation](https://grafana.com/docs/loki/next/installation/helm).

@ -0,0 +1,14 @@
---
loki:
commonConfig:
replication_factor: 1
useTestSchema: true
deploymentMode: SingleBinary
singleBinary:
replicas: 1
read:
replicas: 0
write:
replicas: 0
backend:
replicas: 0

@ -2,17 +2,10 @@
loki:
commonConfig:
replication_factor: 1
image:
tag: "main-5e53303"
useTestSchema: true
read:
replicas: 1
write:
replicas: 1
backend:
replicas: 1
monitoring:
serviceMonitor:
labels:
release: "prometheus"
test:
prometheusAddress: "http://prometheus-kube-prometheus-prometheus.prometheus.svc.cluster.local.:9090"

@ -0,0 +1,32 @@
---
loki:
commonConfig:
replication_factor: 1
useTestSchema: true
deploymentMode: Distributed
backend:
replicas: 0
read:
replicas: 0
write:
replicas: 0
ingester:
replicas: 3 # Kind seems to be a single node for testing so the anti-affinity rules fail here with zone awareness
querier:
replicas: 1
queryFrontend:
replicas: 1
queryScheduler:
replicas: 1
distributor:
replicas: 1
compactor:
replicas: 1
indexGateway:
replicas: 1
bloomCompactor:
replicas: 0
bloomGateway:
replicas: 0
minio:
enabled: true

@ -11,8 +11,7 @@ gateway:
loki:
commonConfig:
replication_factor: 1
image:
tag: "main-5e53303"
useTestSchema: true
read:
replicas: 1
write:

@ -0,0 +1,22 @@
---
loki:
commonConfig:
replication_factor: 1
useTestSchema: true
read:
replicas: 1
write:
replicas: 1
backend:
replicas: 1
monitoring:
enabled: true
selfMonitoring:
enabled: true
grafanaAgent:
installOperator: true
serviceMonitor:
labels:
release: "prometheus"
test:
prometheusAddress: "http://prometheus-kube-prometheus-prometheus.prometheus.svc.cluster.local.:9090"

@ -0,0 +1,70 @@
---
loki:
schemaConfig:
configs:
- from: 2024-04-01
store: tsdb
object_store: s3
schema: v13
index:
prefix: loki_index_
period: 24h
ingester:
chunk_encoding: snappy
tracing:
enabled: true
querier:
# Default is 4, if you have enough memory and CPU you can increase, reduce if OOMing
max_concurrent: 4
#gateway:
# ingress:
# enabled: true
# hosts:
# - host: FIXME
# paths:
# - path: /
# pathType: Prefix
deploymentMode: Distributed
ingester:
replicas: 3
querier:
replicas: 3
maxUnavailable: 2
queryFrontend:
replicas: 2
maxUnavailable: 1
queryScheduler:
replicas: 2
distributor:
replicas: 3
maxUnavailable: 2
compactor:
replicas: 1
indexGateway:
replicas: 2
maxUnavailable: 1
bloomCompactor:
replicas: 0
bloomGateway:
replicas: 0
# Enable minio for storage
minio:
enabled: true
# Zero out replica counts of other deployment modes
backend:
replicas: 0
read:
replicas: 0
write:
replicas: 0
singleBinary:
replicas: 0

@ -0,0 +1,63 @@
---
loki:
schemaConfig:
configs:
- from: 2024-04-01
store: tsdb
object_store: s3
schema: v13
index:
prefix: loki_index_
period: 24h
ingester:
chunk_encoding: snappy
tracing:
enabled: true
querier:
# Default is 4, if you have enough memory and CPU you can increase, reduce if OOMing
max_concurrent: 4
#gateway:
# ingress:
# enabled: true
# hosts:
# - host: FIXME
# paths:
# - path: /
# pathType: Prefix
deploymentMode: SimpleScalable
backend:
replicas: 3
read:
replicas: 3
write:
replicas: 3
# Enable minio for storage
minio:
enabled: true
# Zero out replica counts of other deployment modes
singleBinary:
replicas: 0
ingester:
replicas: 0
querier:
replicas: 0
queryFrontend:
replicas: 0
queryScheduler:
replicas: 0
distributor:
replicas: 0
compactor:
replicas: 0
indexGateway:
replicas: 0
bloomCompactor:
replicas: 0
bloomGateway:
replicas: 0

@ -0,0 +1,79 @@
---
loki:
commonConfig:
replication_factor: 1
schemaConfig:
configs:
- from: 2024-04-01
store: tsdb
object_store: s3
schema: v13
index:
prefix: loki_index_
period: 24h
ingester:
chunk_encoding: snappy
tracing:
enabled: true
querier:
# Default is 4, if you have enough memory and CPU you can increase, reduce if OOMing
max_concurrent: 2
#gateway:
# ingress:
# enabled: true
# hosts:
# - host: FIXME
# paths:
# - path: /
# pathType: Prefix
deploymentMode: SingleBinary
singleBinary:
replicas: 1
resources:
limits:
cpu: 3
memory: 4Gi
requests:
cpu: 2
memory: 2Gi
extraEnv:
# Keep a little bit lower than memory limits
- name: GOMEMLIMIT
value: 3750MiB
chunksCache:
# default is 500MB, with limited memory keep this smaller
writebackSizeLimit: 10MB
# Enable minio for storage
minio:
enabled: true
# Zero out replica counts of other deployment modes
backend:
replicas: 0
read:
replicas: 0
write:
replicas: 0
ingester:
replicas: 0
querier:
replicas: 0
queryFrontend:
replicas: 0
queryScheduler:
replicas: 0
distributor:
replicas: 0
compactor:
replicas: 0
indexGateway:
replicas: 0
bloomCompactor:
replicas: 0
bloomGateway:
replicas: 0

@ -7,19 +7,41 @@ import (
"context"
"errors"
"fmt"
"io"
"net/http"
"os"
"testing"
"time"
"github.com/prometheus/client_golang/api"
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
promConfig "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/textparse"
"github.com/stretchr/testify/require"
)
type testResultFunc func(t *testing.T, ctx context.Context, metric string, test func(model.SampleValue) bool, msg string) error
func TestCanary(t *testing.T) {
totalEntriesQuery := "sum(loki_canary_entries_total)"
totalEntriesMissingQuery := "sum(loki_canary_missing_entries_total)"
var testResult testResultFunc
// Default to directly querying a canary and looking for specific metrics.
testResult = testResultCanary
totalEntries := "loki_canary_entries_total"
totalEntriesMissing := "loki_canary_missing_entries_total"
// For backwards compatibility and also for anyone who wants to validate with prometheus instead of querying
// a canary directly, if the CANARY_PROMETHEUS_ADDRESS is specified we will use prometheus to validate.
address := os.Getenv("CANARY_PROMETHEUS_ADDRESS")
if address != "" {
testResult = testResultPrometheus
// Use the sum function to aggregate the results from multiple canaries.
totalEntries = "sum(loki_canary_entries_total)"
totalEntriesMissing = "sum(loki_canary_missing_entries_total)"
}
timeout := getEnv("CANARY_TEST_TIMEOUT", "1m")
timeoutDuration, err := time.ParseDuration(timeout)
@ -32,30 +54,18 @@ func TestCanary(t *testing.T) {
})
t.Run("Canary should have entries", func(t *testing.T) {
client := newClient(t)
eventually(t, func() error {
result, _, err := client.Query(ctx, totalEntriesQuery, time.Now(), v1.WithTimeout(timeoutDuration))
if err != nil {
return err
}
return testResult(t, result, totalEntriesQuery, func(v model.SampleValue) bool {
return testResult(t, ctx, totalEntries, func(v model.SampleValue) bool {
return v > 0
}, fmt.Sprintf("Expected %s to be greater than 0", totalEntriesQuery))
}, fmt.Sprintf("Expected %s to be greater than 0", totalEntries))
}, timeoutDuration, "Expected Loki Canary to have entries")
})
t.Run("Canary should not have missed any entries", func(t *testing.T) {
client := newClient(t)
eventually(t, func() error {
result, _, err := client.Query(ctx, totalEntriesMissingQuery, time.Now(), v1.WithTimeout(timeoutDuration))
if err != nil {
return err
}
return testResult(t, result, totalEntriesMissingQuery, func(v model.SampleValue) bool {
return testResult(t, ctx, totalEntriesMissing, func(v model.SampleValue) bool {
return v == 0
}, fmt.Sprintf("Expected %s to equal 0", totalEntriesMissingQuery))
}, fmt.Sprintf("Expected %s to equal 0", totalEntriesMissing))
}, timeoutDuration, "Expected Loki Canary to not have any missing entries")
})
}
@ -67,7 +77,13 @@ func getEnv(key, fallback string) string {
return fallback
}
func testResult(t *testing.T, result model.Value, query string, test func(model.SampleValue) bool, msg string) error {
func testResultPrometheus(t *testing.T, ctx context.Context, query string, test func(model.SampleValue) bool, msg string) error {
// TODO (ewelch): if we did a lot of these, we'd want to reuse the client but right now we only run a couple tests
client := newClient(t)
result, _, err := client.Query(ctx, query, time.Now())
if err != nil {
return err
}
if v, ok := result.(model.Vector); ok {
for _, s := range v {
t.Logf("%s => %v\n", query, s.Value)
@ -75,7 +91,6 @@ func testResult(t *testing.T, result model.Value, query string, test func(model.
return errors.New(msg)
}
}
return nil
}
@ -94,6 +109,64 @@ func newClient(t *testing.T) v1.API {
return v1.NewAPI(client)
}
func testResultCanary(t *testing.T, ctx context.Context, metric string, test func(model.SampleValue) bool, msg string) error {
address := os.Getenv("CANARY_SERVICE_ADDRESS")
require.NotEmpty(t, address, "CANARY_SERVICE_ADDRESS must be set to a valid kubernetes service for the Loki canaries")
// TODO (ewelch): if we did a lot of these, we'd want to reuse the client but right now we only run a couple tests
client, err := promConfig.NewClientFromConfig(promConfig.HTTPClientConfig{}, "canary-test")
require.NoError(t, err, "Failed to create Prometheus client")
req, err := http.NewRequestWithContext(ctx, http.MethodGet, address, nil)
require.NoError(t, err, "Failed to create request")
rsp, err := client.Do(req)
if rsp != nil {
defer rsp.Body.Close()
}
require.NoError(t, err, "Failed to scrape metrics")
body, err := io.ReadAll(rsp.Body)
require.NoError(t, err, "Failed to read response body")
p, err := textparse.New(body, rsp.Header.Get("Content-Type"), true)
require.NoError(t, err, "Failed to create Prometheus parser")
for {
e, err := p.Next()
if err == io.EOF {
return errors.New("metric not found")
}
if e != textparse.EntrySeries {
continue
}
l := labels.Labels{}
p.Metric(&l)
// Currently we aren't validating any labels, just the metric name, however this could be extended to do so.
name := l.Get(model.MetricNameLabel)
if name != metric {
continue
}
_, _, val := p.Series()
t.Logf("%s => %v\n", metric, val)
// Note: SampleValue has functions for comparing the equality of two floats which is
// why we convert this back to a SampleValue here for easier use intests.
if !test(model.SampleValue(val)) {
return errors.New(msg)
}
// Returning here will only validate that one series was found matching the label name that met the condition
// it could be possible since we don't validate the rest of the labels that there is mulitple series
// but currently this meets the spirit of the test.
return nil
}
}
func eventually(t *testing.T, test func() error, timeoutDuration time.Duration, msg string) {
require.Eventually(t, func() bool {
queryError := test()

@ -17,9 +17,20 @@ Installed components:
{{- if .Values.minio.enabled }}
* minio
{{- end }}
{{- if eq (include "loki.deployment.isScalable" .) "true" }}
* read
* write
{{- if not .Values.read.legacyReadTarget }}
* backend
{{- end }}
{{- else }}
* compactor
* index gateway
* query scheduler
* ruler
* distributor
* ingester
* querier
* query frontend
{{- end }}
{{- end }}

@ -50,17 +50,24 @@ Params:
Return if deployment mode is simple scalable
*/}}
{{- define "loki.deployment.isScalable" -}}
{{- and (eq (include "loki.isUsingObjectStorage" . ) "true") (eq (int .Values.singleBinary.replicas) 0) }}
{{- and (eq (include "loki.isUsingObjectStorage" . ) "true") (or (eq .Values.deploymentMode "SingleBinary<->SimpleScalable") (eq .Values.deploymentMode "SimpleScalable") (eq .Values.deploymentMode "SimpleScalable<->Distributed")) }}
{{- end -}}
{{/*
Return if deployment mode is single binary
*/}}
{{- define "loki.deployment.isSingleBinary" -}}
{{- $nonZeroReplicas := gt (int .Values.singleBinary.replicas) 0 }}
{{- or (eq (include "loki.isUsingObjectStorage" . ) "false") ($nonZeroReplicas) }}
{{- or (eq .Values.deploymentMode "SingleBinary") (eq .Values.deploymentMode "SingleBinary<->SimpleScalable") }}
{{- end -}}
{{/*
Return if deployment mode is distributed
*/}}
{{- define "loki.deployment.isDistributed" -}}
{{- and (eq (include "loki.isUsingObjectStorage" . ) "true") (or (eq .Values.deploymentMode "Distributed") (eq .Values.deploymentMode "SimpleScalable<->Distributed")) }}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
@ -448,7 +455,7 @@ ruler:
{{- end }}
{{/*
Calculate the config from structured and unstructred text input
Calculate the config from structured and unstructured text input
*/}}
{{- define "loki.calculatedConfig" -}}
{{ tpl (mergeOverwrite (tpl .Values.loki.config . | fromYaml) .Values.loki.structuredConfig | toYaml) . }}
@ -460,10 +467,10 @@ The volume to mount for loki configuration
{{- define "loki.configVolume" -}}
{{- if eq .Values.loki.configStorageType "Secret" -}}
secret:
secretName: {{ tpl .Values.loki.externalConfigSecretName . }}
{{- else if eq .Values.loki.configStorageType "ConfigMap" -}}
secretName: {{ tpl .Values.loki.configObjectName . }}
{{- else -}}
configMap:
name: {{ tpl .Values.loki.externalConfigSecretName . }}
name: {{ tpl .Values.loki.configObjectName . }}
items:
- key: "config.yaml"
path: "config.yaml"
@ -697,10 +704,17 @@ http {
{{- end }}
server {
{{- if (.Values.gateway.nginxConfig.ssl) }}
listen 8080 ssl;
{{- if .Values.gateway.nginxConfig.enableIPv6 }}
listen [::]:8080 ssl;
{{- end }}
{{- else }}
listen 8080;
{{- if .Values.gateway.nginxConfig.enableIPv6 }}
listen [::]:8080;
{{- end }}
{{- end }}
{{- if .Values.gateway.basicAuth.enabled }}
auth_basic "Loki";
@ -712,6 +726,9 @@ http {
auth_basic off;
}
########################################################
# Configure backend targets
{{- $backendHost := include "loki.backendFullname" .}}
{{- $readHost := include "loki.readFullname" .}}
{{- $writeHost := include "loki.writeFullname" .}}
@ -720,15 +737,11 @@ http {
{{- $backendHost = include "loki.readFullname" . }}
{{- end }}
{{- if gt (int .Values.singleBinary.replicas) 0 }}
{{- $backendHost = include "loki.singleBinaryFullname" . }}
{{- $readHost = include "loki.singleBinaryFullname" .}}
{{- $writeHost = include "loki.singleBinaryFullname" .}}
{{- end }}
{{- $httpSchema := .Values.gateway.nginxConfig.schema }}
{{- $writeUrl := printf "http://%s.%s.svc.%s:%s" $writeHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $readUrl := printf "http://%s.%s.svc.%s:%s" $readHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $backendUrl := printf "http://%s.%s.svc.%s:%s" $backendHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $writeUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $writeHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $readUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $readHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $backendUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $backendHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- if .Values.gateway.nginxConfig.customWriteUrl }}
{{- $writeUrl = .Values.gateway.nginxConfig.customWriteUrl }}
@ -740,24 +753,61 @@ http {
{{- $backendUrl = .Values.gateway.nginxConfig.customBackendUrl }}
{{- end }}
{{- $singleBinaryHost := include "loki.singleBinaryFullname" . }}
{{- $singleBinaryUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $singleBinaryHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $distributorHost := include "loki.distributorFullname" .}}
{{- $ingesterHost := include "loki.ingesterFullname" .}}
{{- $queryFrontendHost := include "loki.queryFrontendFullname" .}}
{{- $indexGatewayHost := include "loki.indexGatewayFullname" .}}
{{- $rulerHost := include "loki.rulerFullname" .}}
{{- $compactorHost := include "loki.compactorFullname" .}}
{{- $schedulerHost := include "loki.querySchedulerFullname" .}}
{{- $distributorUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $distributorHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) -}}
{{- $ingesterUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $ingesterHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $queryFrontendUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $queryFrontendHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $indexGatewayUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $indexGatewayHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $rulerUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $rulerHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $compactorUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $compactorHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- $schedulerUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $schedulerHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }}
{{- if eq (include "loki.deployment.isSingleBinary" .) "true"}}
{{- $distributorUrl = $singleBinaryUrl }}
{{- $ingesterUrl = $singleBinaryUrl }}
{{- $queryFrontendUrl = $singleBinaryUrl }}
{{- $indexGatewayUrl = $singleBinaryUrl }}
{{- $rulerUrl = $singleBinaryUrl }}
{{- $compactorUrl = $singleBinaryUrl }}
{{- $schedulerUrl = $singleBinaryUrl }}
{{- else if eq (include "loki.deployment.isScalable" .) "true"}}
{{- $distributorUrl = $writeUrl }}
{{- $ingesterUrl = $writeUrl }}
{{- $queryFrontendUrl = $readUrl }}
{{- $indexGatewayUrl = $backendUrl }}
{{- $rulerUrl = $backendUrl }}
{{- $compactorUrl = $backendUrl }}
{{- $schedulerUrl = $backendUrl }}
{{- end -}}
# Distributor
location = /api/prom/push {
proxy_pass {{ $writeUrl }}$request_uri;
proxy_pass {{ $distributorUrl }}$request_uri;
}
location = /loki/api/v1/push {
proxy_pass {{ $writeUrl }}$request_uri;
proxy_pass {{ $distributorUrl }}$request_uri;
}
location = /distributor/ring {
proxy_pass {{ $writeUrl }}$request_uri;
proxy_pass {{ $distributorUrl }}$request_uri;
}
# Ingester
location = /flush {
proxy_pass {{ $writeUrl }}$request_uri;
proxy_pass {{ $ingesterUrl }}$request_uri;
}
location ^~ /ingester/ {
proxy_pass {{ $writeUrl }}$request_uri;
proxy_pass {{ $ingesterUrl }}$request_uri;
}
location = /ingester {
internal; # to suppress 301
@ -765,62 +815,61 @@ http {
# Ring
location = /ring {
proxy_pass {{ $writeUrl }}$request_uri;
proxy_pass {{ $ingesterUrl }}$request_uri;
}
# MemberListKV
location = /memberlist {
proxy_pass {{ $writeUrl }}$request_uri;
proxy_pass {{ $ingesterUrl }}$request_uri;
}
# Ruler
location = /ruler/ring {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /api/prom/rules {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $rulerUrl }}$request_uri;
}
location ^~ /api/prom/rules/ {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /loki/api/v1/rules {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $rulerUrl }}$request_uri;
}
location ^~ /loki/api/v1/rules/ {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /prometheus/api/v1/alerts {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $rulerUrl }}$request_uri;
}
location = /prometheus/api/v1/rules {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $rulerUrl }}$request_uri;
}
# Compactor
location = /compactor/ring {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $compactorUrl }}$request_uri;
}
location = /loki/api/v1/delete {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $compactorUrl }}$request_uri;
}
location = /loki/api/v1/cache/generation_numbers {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $compactorUrl }}$request_uri;
}
# IndexGateway
location = /indexgateway/ring {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $indexGatewayUrl }}$request_uri;
}
# QueryScheduler
location = /scheduler/ring {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $schedulerUrl }}$request_uri;
}
# Config
location = /config {
proxy_pass {{ $backendUrl }}$request_uri;
proxy_pass {{ $ingesterUrl }}$request_uri;
}
{{- if and .Values.enterprise.enabled .Values.enterprise.adminApi.enabled }}
@ -836,29 +885,28 @@ http {
# QueryFrontend, Querier
location = /api/prom/tail {
proxy_pass {{ $readUrl }}$request_uri;
proxy_pass {{ $queryFrontendUrl }}$request_uri;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location = /loki/api/v1/tail {
proxy_pass {{ $readUrl }}$request_uri;
proxy_pass {{ $queryFrontendUrl }}$request_uri;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location ^~ /api/prom/ {
proxy_pass {{ $readUrl }}$request_uri;
proxy_pass {{ $queryFrontendUrl }}$request_uri;
}
location = /api/prom {
internal; # to suppress 301
}
location ^~ /loki/api/v1/ {
proxy_pass {{ $readUrl }}$request_uri;
proxy_pass {{ $queryFrontendUrl }}$request_uri;
}
location = /loki/api/v1 {
internal; # to suppress 301
}
{{- with .Values.gateway.nginxConfig.serverSnippet }}
{{ . | nindent 4 }}
{{- end }}
@ -893,10 +941,50 @@ enableServiceLinks: false
{{/* Determine query-scheduler address */}}
{{- define "loki.querySchedulerAddress" -}}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- $schedulerAddress := ""}}
{{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) -}}
{{- $schedulerAddress = printf "query-scheduler-discovery.%s.svc.%s.:%s" .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.grpc_listen_port | toString) -}}
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed -}}
{{- $schedulerAddress = printf "%s.%s.svc.%s:%s" (include "loki.querySchedulerFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.grpc_listen_port | toString) -}}
{{- end -}}
{{- printf "%s" $schedulerAddress }}
{{- end }}
{{/* Determine querier address */}}
{{- define "loki.querierAddress" -}}
{{- $querierAddress := "" }}
{{- if "loki.deployment.isDistributed "}}
{{- $querierHost := include "loki.querierFullname" .}}
{{- $querierUrl := printf "http://%s.%s.svc.%s:3100" $querierHost .Release.Namespace .Values.global.clusterDomain }}
{{- $querierAddress = $querierUrl }}
{{- end -}}
{{- printf "%s" $querierAddress }}
{{- end }}
{{/* Determine index-gateway address */}}
{{- define "loki.indexGatewayAddress" -}}
{{- $idxGatewayAddress := ""}}
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- $isScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if $isDistributed -}}
{{- $idxGatewayAddress = printf "dns+%s-headless.%s.svc.%s:%s" (include "loki.indexGatewayFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.grpc_listen_port | toString) -}}
{{- end -}}
{{- if $isScalable -}}
{{- $idxGatewayAddress = printf "dns+%s-headless.%s.svc.%s:%s" (include "loki.backendFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.grpc_listen_port | toString) -}}
{{- end -}}
{{- printf "%s" $idxGatewayAddress }}
{{- end }}
{{- define "loki.config.checksum" -}}
checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
{{- end -}}
{{/*
Return the appropriate apiVersion for PodDisruptionBudget.
*/}}
{{- define "loki.pdb.apiVersion" -}}
{{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version) -}}
{{- print "policy/v1" -}}
{{- else -}}
{{- print "policy/v1beta1" -}}
{{- end -}}
{{- end -}}

@ -0,0 +1,24 @@
{{/*
adminApi fullname
*/}}
{{- define "enterprise-logs.adminApiFullname" -}}
{{ include "loki.fullname" . }}-admin-api
{{- end }}
{{/*
adminApi common labels
*/}}
{{- define "enterprise-logs.adminApiLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: admin-api
target: admin-api
{{- end }}
{{/*
adminApi selector labels
*/}}
{{- define "enterprise-logs.adminApiSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: admin-api
target: admin-api
{{- end }}

@ -0,0 +1,168 @@
{{- if .Values.enterprise.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "enterprise-logs.adminApiFullname" . }}
labels:
{{- include "enterprise-logs.adminApiLabels" . | nindent 4 }}
{{- with .Values.adminApi.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
app.kubernetes.io/part-of: memberlist
annotations:
{{- with .Values.adminApi.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.adminApi.replicas }}
selector:
matchLabels:
{{- include "enterprise-logs.adminApiSelectorLabels" . | nindent 6 }}
strategy:
{{- toYaml .Values.adminApi.strategy | nindent 4 }}
template:
metadata:
labels:
{{- include "enterprise-logs.adminApiSelectorLabels" . | nindent 8 }}
{{- with .Values.adminApi.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
app.kubernetes.io/part-of: memberlist
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.adminApi.annotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "loki.serviceAccountName" . }}
{{- if .Values.adminApi.priorityClassName }}
priorityClassName: {{ .Values.adminApi.priorityClassName }}
{{- end }}
securityContext:
{{- toYaml .Values.adminApi.podSecurityContext | nindent 8 }}
initContainers:
# Taken from
# https://github.com/minio/charts/blob/a5c84bcbad884728bff5c9c23541f936d57a13b3/minio/templates/post-install-create-bucket-job.yaml
{{- if .Values.minio.enabled }}
- name: minio-mc
image: "{{ .Values.minio.mcImage.repository }}:{{ .Values.minio.mcImage.tag }}"
imagePullPolicy: {{ .Values.minio.mcImage.pullPolicy }}
command: ["/bin/sh", "/config/initialize"]
env:
- name: MINIO_ENDPOINT
value: {{ .Release.Name }}-minio
- name: MINIO_PORT
value: {{ .Values.minio.service.port | quote }}
volumeMounts:
- name: minio-configuration
mountPath: /config
{{- if .Values.minio.tls.enabled }}
- name: cert-secret-volume-mc
mountPath: {{ .Values.minio.configPathmc }}certs
{{ end }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{- range .Values.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.adminApi.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: admin-api
image: "{{ template "loki.image" . }}"
imagePullPolicy: {{ .Values.enterprise.image.pullPolicy }}
args:
- -target=admin-api
- -config.file=/etc/loki/config/config.yaml
{{- if .Values.minio.enabled }}
- -admin.client.backend-type=s3
- -admin.client.s3.endpoint={{ template "loki.minio" . }}
- -admin.client.s3.bucket-name=enterprise-logs-admin
- -admin.client.s3.access-key-id={{ .Values.minio.accessKey }}
- -admin.client.s3.secret-access-key={{ .Values.minio.secretKey }}
- -admin.client.s3.insecure=true
{{- end }}
{{- range $key, $value := .Values.adminApi.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: license
mountPath: /etc/loki/license
- name: storage
mountPath: /data
{{- if .Values.adminApi.extraVolumeMounts }}
{{ toYaml .Values.adminApi.extraVolumeMounts | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
readinessProbe:
{{- toYaml .Values.adminApi.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.adminApi.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.adminApi.containerSecurityContext | nindent 12 }}
env:
{{- if .Values.adminApi.env }}
{{ toYaml .Values.adminApi.env | nindent 12 }}
{{- end }}
{{- with .Values.adminApi.extraContainers }}
{{ toYaml . | nindent 8 }}
{{- end }}
nodeSelector:
{{- toYaml .Values.adminApi.nodeSelector | nindent 8 }}
affinity:
{{- toYaml .Values.adminApi.affinity | nindent 8 }}
tolerations:
{{- toYaml .Values.adminApi.tolerations | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.adminApi.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
- name: storage
emptyDir: {}
{{- if .Values.adminApi.extraVolumes }}
{{ toYaml .Values.adminApi.extraVolumes | nindent 8 }}
{{- end }}
{{- if .Values.minio.enabled }}
- name: minio-configuration
projected:
sources:
- configMap:
name: {{ .Release.Name }}-minio
- secret:
name: {{ .Release.Name }}-minio
{{- if .Values.minio.tls.enabled }}
- name: cert-secret-volume-mc
secret:
secretName: {{ .Values.minio.tls.certSecret }}
items:
- key: {{ .Values.minio.tls.publicCrt }}
path: CAs/public.crt
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,28 @@
{{- if .Values.enterprise.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "enterprise-logs.adminApiFullname" . }}
labels:
{{- include "enterprise-logs.adminApiLabels" . | nindent 4 }}
{{- with .Values.adminApi.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- with .Values.adminApi.service.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
ports:
- name: http-metrics
port: 3100
protocol: TCP
targetPort: http-metrics
- name: grpc
port: 9095
protocol: TCP
targetPort: grpc
selector:
{{- include "enterprise-logs.adminApiSelectorLabels" . | nindent 4 }}
{{- end }}

@ -1,4 +1,5 @@
{{- if and (not .Values.rbac.namespaced) (not .Values.rbac.useExistingRole) }}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.rbac.namespaced) (not .Values.rbac.useExistingRole) }}
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
@ -17,4 +18,4 @@ rules:
{{- else }}
rules: []
{{- end }}
{{- end }}
{{- end }}

@ -1,4 +1,5 @@
{{- if and (not .Values.rbac.namespaced) }}
{{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}}
{{- if and $isSimpleScalable (not .Values.rbac.namespaced) }}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
@ -21,4 +22,4 @@ roleRef:
name: {{ .Values.rbac.useExistingRole }}
{{- end }}
apiGroup: rbac.authorization.k8s.io
{{- end -}}
{{- end -}}

@ -205,7 +205,7 @@ spec:
{{- toYaml .Values.backend.resources | nindent 12 }}
{{- with .Values.backend.affinity }}
affinity:
{{- tpl . $ | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.backend.dnsConfig }}
dnsConfig:
@ -231,12 +231,7 @@ spec:
{{- toYaml .Values.backend.persistence.dataVolumeParameters | nindent 10 }}
{{- end}}
- name: config
{{- if .Values.loki.existingSecretForConfig }}
secret:
secretName: {{ .Values.loki.existingSecretForConfig }}
{{- else }}
{{- include "loki.configVolume" . | nindent 10 }}
{{- end }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime

@ -0,0 +1,58 @@
{{/*
bloom compactor fullname
*/}}
{{- define "loki.bloomCompactorFullname" -}}
{{ include "loki.fullname" . }}-bloom-compactor
{{- end }}
{{/*
bloom compactor common labels
*/}}
{{- define "loki.bloomCompactorLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: bloom-compactor
{{- end }}
{{/*
bloom compactor selector labels
*/}}
{{- define "loki.bloomCompactorSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: bloom-compactor
{{- end }}
{{/*
bloom compactor readinessProbe
*/}}
{{- define "loki.bloomCompactor.readinessProbe" -}}
{{- with .Values.bloomCompactor.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- else }}
{{- with .Values.loki.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end -}}
{{/*
bloom compactor priority class name
*/}}
{{- define "loki.bloomCompactorPriorityClassName" }}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.bloomCompactor.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}
{{/*
Create the name of the bloom compactor service account
*/}}
{{- define "loki.bloomCompactorServiceAccountName" -}}
{{- if .Values.bloomCompactor.serviceAccount.create -}}
{{ default (print (include "loki.serviceAccountName" .) "-bloom-compactor") .Values.bloomCompactor.serviceAccount.name }}
{{- else -}}
{{ default (include "loki.serviceAccountName" .) .Values.bloomCompactor.serviceAccount.name }}
{{- end -}}
{{- end -}}

@ -0,0 +1,179 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
{{- if (gt (int .Values.bloomCompactor.replicas) 0) -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.bloomCompactorFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.bloomCompactorLabels" . | nindent 4 }}
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.bloomCompactor.replicas }}
podManagementPolicy: Parallel
updateStrategy:
rollingUpdate:
partition: 0
serviceName: {{ include "loki.bloomCompactorFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.bloomCompactor.persistence.enableStatefulSetAutoDeletePVC) }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.bloomCompactor.persistence.whenDeleted }}
whenScaled: {{ .Values.bloomCompactor.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.bloomCompactorSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.bloomCompactor.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.bloomCompactorSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.bloomCompactor.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.bloomCompactor.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.bloomCompactorPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.bloomCompactor.terminationGracePeriodSeconds }}
{{- with .Values.bloomCompactor.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: bloom-compactor
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.bloomCompactor.command }}
command:
- {{ coalesce .Values.bloomCompactor.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=bloom-compactor
{{- with .Values.bloomCompactor.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.bloomCompactor.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.bloomCompactor.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
{{- include "loki.bloomCompactor.readinessProbe" . | nindent 10 }}
volumeMounts:
- name: temp
mountPath: /tmp
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.bloomCompactor.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.bloomCompactor.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.bloomCompactor.extraContainers }}
{{- toYaml .Values.bloomCompactor.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.bloomCompactor.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.bloomCompactor.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: temp
emptyDir: {}
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- if not .Values.bloomCompactor.persistence.enabled }}
- name: data
emptyDir: {}
{{- end }}
{{- with .Values.bloomCompactor.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.bloomCompactor.persistence.enabled }}
volumeClaimTemplates:
{{- range .Values.bloomCompactor.persistence.claims }}
- metadata:
name: {{ .name }}
{{- with .annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .size | quote }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}

@ -0,0 +1,58 @@
{{/*
bloom gateway fullname
*/}}
{{- define "loki.bloomGatewayFullname" -}}
{{ include "loki.fullname" . }}-bloom-gateway
{{- end }}
{{/*
bloom gateway common labels
*/}}
{{- define "loki.bloomGatewayLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: bloom-gateway
{{- end }}
{{/*
bloom gateway selector labels
*/}}
{{- define "loki.bloomGatewaySelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: bloom-gateway
{{- end }}
{{/*
bloom gateway readinessProbe
*/}}
{{- define "loki.bloomGateway.readinessProbe" -}}
{{- with .Values.bloomGateway.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- else }}
{{- with .Values.loki.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end -}}
{{/*
bloom gateway priority class name
*/}}
{{- define "loki.bloomGatewayPriorityClassName" }}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.bloomGateway.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}
{{/*
Create the name of the bloom gateway service account
*/}}
{{- define "loki.bloomGatewayServiceAccountName" -}}
{{- if .Values.bloomGateway.serviceAccount.create -}}
{{ default (print (include "loki.serviceAccountName" .) "-bloom-gateway") .Values.bloomGateway.serviceAccount.name }}
{{- else -}}
{{ default (include "loki.serviceAccountName" .) .Values.bloomGateway.serviceAccount.name }}
{{- end -}}
{{- end -}}

@ -0,0 +1,179 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
{{- if (gt (int .Values.bloomGateway.replicas) 0) -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.bloomGatewayFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.bloomGatewayLabels" . | nindent 4 }}
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.bloomGateway.replicas }}
podManagementPolicy: Parallel
updateStrategy:
rollingUpdate:
partition: 0
serviceName: {{ include "loki.bloomGatewayFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.bloomGateway.persistence.enableStatefulSetAutoDeletePVC) }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.bloomGateway.persistence.whenDeleted }}
whenScaled: {{ .Values.bloomGateway.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.bloomGatewaySelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.bloomGateway.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.bloomGatewaySelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.bloomGateway.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.bloomGateway.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.bloomGatewayPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.bloomGateway.terminationGracePeriodSeconds }}
{{- with .Values.bloomGateway.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: bloom-gateway
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.bloomGateway.command }}
command:
- {{ coalesce .Values.bloomGateway.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=bloom-gateway
{{- with .Values.bloomGateway.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.bloomGateway.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.bloomGateway.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
{{- include "loki.bloomGateway.readinessProbe" . | nindent 10 }}
volumeMounts:
- name: temp
mountPath: /tmp
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.bloomGateway.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.bloomGateway.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.bloomGateway.extraContainers }}
{{- toYaml .Values.bloomGateway.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.bloomGateway.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.bloomGateway.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: temp
emptyDir: {}
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- if not .Values.bloomGateway.persistence.enabled }}
- name: data
emptyDir: {}
{{- end }}
{{- with .Values.bloomGateway.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.bloomGateway.persistence.enabled }}
volumeClaimTemplates:
{{- range .Values.bloomGateway.persistence.claims }}
- metadata:
name: {{ .name }}
{{- with .annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .size | quote }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}

@ -0,0 +1,16 @@
{{- if .Values.chunksCache.enabled }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.fullname" . }}-memcached-chunks-cache
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: memcached-chunks-cache
spec:
selector:
matchLabels:
{{- include "loki.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: memcached-chunks-cache
maxUnavailable: 1
{{- end -}}

@ -0,0 +1 @@
{{- include "loki.memcached.service" (dict "ctx" $ "valuesSection" "chunksCache" "component" "chunks-cache" ) }}

@ -0,0 +1 @@
{{- include "loki.memcached.statefulSet" (dict "ctx" $ "valuesSection" "chunksCache" "component" "chunks-cache" ) }}

@ -0,0 +1,81 @@
{{/*
compactor fullname
*/}}
{{- define "loki.compactorFullname" -}}
{{ include "loki.fullname" . }}-compactor
{{- end }}
{{/*
compactor common labels
*/}}
{{- define "loki.compactorLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: compactor
{{- end }}
{{/*
compactor selector labels
*/}}
{{- define "loki.compactorSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: compactor
{{- end }}
{{/*
compactor image
*/}}
{{- define "loki.compactorImage" -}}
{{- $dict := dict "loki" .Values.loki.image "service" .Values.compactor.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "loki.lokiImage" $dict -}}
{{- end }}
{{/*
compactor readinessProbe
*/}}
{{- define "loki.compactor.readinessProbe" -}}
{{- with .Values.compactor.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- else }}
{{- with .Values.loki.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end -}}
{{/*
compactor livenessProbe
*/}}
{{- define "loki.compactor.livenessProbe" -}}
{{- with .Values.compactor.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 2 }}
{{- else }}
{{- with .Values.loki.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end -}}
{{/*
compactor priority class name
*/}}
{{- define "loki.compactorPriorityClassName" }}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.compactor.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}
{{/*
Create the name of the compactor service account
*/}}
{{- define "loki.compactorServiceAccountName" -}}
{{- if .Values.compactor.serviceAccount.create -}}
{{ default (print (include "loki.serviceAccountName" .) "-compactor") .Values.compactor.serviceAccount.name }}
{{- else -}}
{{ default (include "loki.serviceAccountName" .) .Values.compactor.serviceAccount.name }}
{{- end -}}
{{- end -}}

@ -0,0 +1,35 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.compactorFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.labels" . | nindent 4 }}
{{- with .Values.compactor.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
app.kubernetes.io/component: compactor
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.compactor.appProtocol.grpc }}
appProtocol: {{ .Values.compactor.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: compactor
{{- end }}

@ -0,0 +1,193 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.compactorFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.compactorLabels" . | nindent 4 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.compactor.replicas }}
podManagementPolicy: Parallel
updateStrategy:
rollingUpdate:
partition: 0
serviceName: {{ include "loki.compactorFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.compactor.persistence.enableStatefulSetAutoDeletePVC) }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.compactor.persistence.whenDeleted }}
whenScaled: {{ .Values.compactor.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.compactorSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.compactor.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.compactorSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.compactor.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
{{- with .Values.compactor.topologySpreadConstraints }}
topologySpreadConstraints:
{{- tpl . $ | nindent 8 }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.compactor.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.compactorPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.compactor.terminationGracePeriodSeconds }}
{{- with .Values.compactor.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: compactor
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.compactor.command }}
command:
- {{ coalesce .Values.compactor.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=compactor
{{- with .Values.compactor.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.compactor.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.compactor.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
{{- include "loki.compactor.readinessProbe" . | nindent 10 }}
{{- include "loki.compactor.livenessProbe" . | nindent 10 }}
volumeMounts:
- name: temp
mountPath: /tmp
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.compactor.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.compactor.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.compactor.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.compactor.extraContainers }}
{{- toYaml .Values.compactor.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.compactor.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.compactor.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.compactor.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: temp
emptyDir: {}
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- if not .Values.compactor.persistence.enabled }}
- name: data
emptyDir: {}
{{- end }}
{{- with .Values.compactor.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.compactor.persistence.enabled }}
volumeClaimTemplates:
{{- range .Values.compactor.persistence.claims }}
- metadata:
name: {{ .name }}
{{- with .annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .size | quote }}
{{- end }}
{{- end }}
{{- end }}

@ -1,4 +1,4 @@
{{- if not .Values.loki.existingSecretForConfig -}}
{{- if .Values.loki.generatedConfigObjectName -}}
apiVersion: v1
{{- if eq .Values.loki.configStorageType "Secret" }}
kind: Secret
@ -6,7 +6,7 @@ kind: Secret
kind: ConfigMap
{{- end }}
metadata:
name: {{ tpl .Values.loki.externalConfigSecretName . }}
name: {{ tpl .Values.loki.generatedConfigObjectName . }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "loki.labels" . | nindent 4 }}

@ -0,0 +1,32 @@
{{/*
distributor fullname
*/}}
{{- define "loki.distributorFullname" -}}
{{ include "loki.fullname" . }}-distributor
{{- end }}
{{/*
distributor common labels
*/}}
{{- define "loki.distributorLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: distributor
{{- end }}
{{/*
distributor selector labels
*/}}
{{- define "loki.distributorSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: distributor
{{- end }}
{{/*
distributor priority class name
*/}}
{{- define "loki.distributorPriorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.distributor.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}

@ -0,0 +1,152 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "loki.distributorFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.distributorLabels" . | nindent 4 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.distributor.autoscaling.enabled }}
replicas: {{ .Values.distributor.replicas }}
{{- end }}
strategy:
rollingUpdate:
maxSurge: {{ .Values.distributor.maxSurge }}
maxUnavailable: 1
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "loki.distributorSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.distributor.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.distributorSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.distributor.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.distributor.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.distributorPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.distributor.terminationGracePeriodSeconds }}
containers:
- name: distributor
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.distributor.command }}
command:
- {{ coalesce .Values.distributor.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=distributor
{{- if .Values.ingester.zoneAwareReplication.enabled }}
{{- if and (.Values.ingester.zoneAwareReplication.migration.enabled) (not .Values.ingester.zoneAwareReplication.migration.writePath) }}
- -distributor.zone-awareness-enabled=false
{{- else }}
- -distributor.zone-awareness-enabled=true
{{- end }}
{{- end }}
{{- with .Values.distributor.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.distributor.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.distributor.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
livenessProbe:
{{- toYaml .Values.loki.livenessProbe | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.distributor.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.distributor.resources | nindent 12 }}
{{- if .Values.distributor.extraContainers }}
{{- toYaml .Values.distributor.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.distributor.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.distributor.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.distributor.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.distributor.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}

@ -0,0 +1,54 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.distributor.autoscaling.enabled }}
{{- $apiVersion := include "loki.hpa.apiVersion" . -}}
apiVersion: {{ $apiVersion }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "loki.distributorFullname" . }}
labels:
{{- include "loki.distributorLabels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "loki.distributorFullname" . }}
minReplicas: {{ .Values.distributor.autoscaling.minReplicas }}
maxReplicas: {{ .Values.distributor.autoscaling.maxReplicas }}
metrics:
{{- with .Values.distributor.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.distributor.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.distributor.autoscaling.customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.distributor.autoscaling.behavior.enabled }}
behavior:
{{- with .Values.distributor.autoscaling.behavior.scaleDown }}
scaleDown: {{ toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.distributor.autoscaling.behavior.scaleUp }}
scaleUp: {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,21 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (gt (int .Values.distributor.replicas) 1) }}
{{- if kindIs "invalid" .Values.distributor.maxUnavailable }}
{{- fail "`.Values.distributor.maxUnavailable` must be set when `.Values.distributor.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.distributorFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.distributorLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "loki.distributorSelectorLabels" . | nindent 6 }}
{{- with .Values.distributor.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,36 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.distributorFullname" . }}-headless
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.distributorSelectorLabels" . | nindent 4 }}
{{- with .Values.distributor.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
variant: headless
prometheus.io/service-monitor: "false"
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
clusterIP: None
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.distributor.appProtocol.grpc }}
appProtocol: {{ .Values.distributor.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.distributorSelectorLabels" . | nindent 4 }}
{{- end -}}

@ -0,0 +1,33 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.distributorFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.distributorLabels" . | nindent 4 }}
{{- with .Values.distributor.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.distributor.appProtocol.grpc }}
appProtocol: {{ .Values.distributor.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.distributorSelectorLabels" . | nindent 4 }}
{{- end -}}

@ -2,7 +2,7 @@
gateway fullname
*/}}
{{- define "loki.gatewayFullname" -}}
{{ include "loki.name" . }}-gateway
{{ include "loki.fullname" . }}-gateway
{{- end }}
{{/*

@ -1,4 +1,4 @@
{{- if and .Values.gateway.enabled }}
{{- if and .Values.gateway.enabled (not (and .Values.enterprise.enabled .Values.enterprise.gelGateway)) }}
apiVersion: v1
kind: ConfigMap
metadata:

@ -0,0 +1,132 @@
{{- if and .Values.gateway.enabled .Values.enterprise.enabled .Values.enterprise.gelGateway }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "loki.gatewayFullname" . }}
labels:
{{- include "loki.gatewayLabels" . | nindent 4 }}
{{- with .Values.enterpriseGateway.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- with .Values.enterpriseGateway.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.enterpriseGateway.replicas }}
selector:
matchLabels:
{{- include "loki.gatewaySelectorLabels" . | nindent 6 }}
strategy:
{{- toYaml .Values.enterpriseGateway.strategy | nindent 4 }}
template:
metadata:
labels:
{{- include "loki.gatewaySelectorLabels" . | nindent 8 }}
{{- with .Values.enterpriseGateway.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.enterpriseGateway.annotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "loki.serviceAccountName" . }}
{{- if .Values.enterpriseGateway.priorityClassName }}
priorityClassName: {{ .Values.enterpriseGateway.priorityClassName }}
{{- end }}
securityContext:
{{- toYaml .Values.enterpriseGateway.podSecurityContext | nindent 8 }}
initContainers:
{{- toYaml .Values.enterpriseGateway.initContainers | nindent 8 }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{- range .Values.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.enterpriseGateway.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: gateway
image: "{{ template "loki.image" . }}"
imagePullPolicy: {{ .Values.enterprise.image.pullPolicy }}
args:
- -target=gateway
- -config.file=/etc/loki/config/config.yaml
{{- if .Values.minio.enabled }}
- -admin.client.backend-type=s3
- -admin.client.s3.endpoint={{ template "loki.minio" . }}
- -admin.client.s3.bucket-name=enterprise-logs-admin
- -admin.client.s3.access-key-id={{ .Values.minio.accessKey }}
- -admin.client.s3.secret-access-key={{ .Values.minio.secretKey }}
- -admin.client.s3.insecure=true
{{- end }}
{{- if .Values.enterpriseGateway.useDefaultProxyURLs }}
- -gateway.proxy.default.url=http://{{ template "loki.fullname" . }}-admin-api.{{ .Release.Namespace }}.svc:3100
- -gateway.proxy.admin-api.url=http://{{ template "loki.fullname" . }}-admin-api.{{ .Release.Namespace }}.svc:3100
- -gateway.proxy.distributor.url=dns:///{{ template "loki.fullname" . }}-distributor-headless.{{ .Release.Namespace }}.svc:9095
- -gateway.proxy.ingester.url=http://{{ template "loki.fullname" . }}-ingester.{{ .Release.Namespace }}.svc:3100
- -gateway.proxy.query-frontend.url=http://{{ template "loki.fullname" . }}-query-frontend.{{ .Release.Namespace }}.svc:3100
- -gateway.proxy.ruler.url=http://{{ template "loki.fullname" . }}-ruler.{{ .Release.Namespace }}.svc:3100
{{- end }}
{{- range $key, $value := .Values.enterpriseGateway.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: license
mountPath: /etc/loki/license
- name: storage
mountPath: /data
{{- if .Values.enterpriseGateway.extraVolumeMounts }}
{{ toYaml .Values.enterpriseGateway.extraVolumeMounts | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
readinessProbe:
{{- toYaml .Values.enterpriseGateway.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.enterpriseGateway.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.enterpriseGateway.containerSecurityContext | nindent 12 }}
env:
{{- if .Values.enterpriseGateway.env }}
{{ toYaml .Values.enterpriseGateway.env | nindent 12 }}
{{- end }}
{{- with .Values.enterpriseGateway.extraContainers }}
{{ toYaml . | nindent 8 }}
{{- end }}
nodeSelector:
{{- toYaml .Values.enterpriseGateway.nodeSelector | nindent 8 }}
affinity:
{{- toYaml .Values.enterpriseGateway.affinity | nindent 8 }}
tolerations:
{{- toYaml .Values.enterpriseGateway.tolerations | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.enterpriseGateway.terminationGracePeriodSeconds }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
- name: storage
emptyDir: {}
{{- if .Values.enterpriseGateway.extraVolumes }}
{{ toYaml .Values.enterpriseGateway.extraVolumes | nindent 8 }}
{{- end }}
{{- end }}

@ -1,4 +1,4 @@
{{- if .Values.gateway.enabled }}
{{- if and .Values.gateway.enabled (not (and .Values.enterprise.enabled .Values.enterprise.gelGateway)) }}
apiVersion: apps/v1
kind: Deployment
metadata:
@ -61,7 +61,7 @@ spec:
image: {{ include "loki.gatewayImage" . }}
imagePullPolicy: {{ .Values.gateway.image.pullPolicy }}
ports:
- name: http
- name: http-metrics
containerPort: 8080
protocol: TCP
{{- with .Values.gateway.extraEnv }}
@ -101,7 +101,7 @@ spec:
{{- end }}
{{- with .Values.gateway.affinity }}
affinity:
{{- tpl . $ | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.gateway.dnsConfig }}
dnsConfig:

@ -28,9 +28,9 @@ spec:
loadBalancerIP: {{ .Values.gateway.service.loadBalancerIP }}
{{- end }}
ports:
- name: http
- name: http-metrics
port: {{ .Values.gateway.service.port }}
targetPort: http
targetPort: http-metrics
{{- if and (eq "NodePort" .Values.gateway.service.type) .Values.gateway.service.nodePort }}
nodePort: {{ .Values.gateway.service.nodePort }}
{{- end }}

@ -0,0 +1,40 @@
{{/*
index-gateway fullname
*/}}
{{- define "loki.indexGatewayFullname" -}}
{{ include "loki.fullname" . }}-index-gateway
{{- end }}
{{/*
index-gateway common labels
*/}}
{{- define "loki.indexGatewayLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: index-gateway
{{- end }}
{{/*
index-gateway selector labels
*/}}
{{- define "loki.indexGatewaySelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: index-gateway
{{- end }}
{{/*
index-gateway image
*/}}
{{- define "loki.indexGatewayImage" -}}
{{- $dict := dict "loki" .Values.loki.image "service" .Values.indexGateway.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "loki.lokiImage" $dict -}}
{{- end }}
{{/*
index-gateway priority class name
*/}}
{{- define "loki.indexGatewayPriorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.indexGateway.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}

@ -0,0 +1,20 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (gt (int .Values.indexGateway.replicas) 1) }}
{{- if kindIs "invalid" .Values.indexGateway.maxUnavailable }}
{{- fail "`.Values.indexGateway.maxUnavailable` must be set when `.Values.indexGateway.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.indexGatewayFullname" . }}
labels:
{{- include "loki.indexGatewayLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 6 }}
{{- with .Values.indexGateway.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,27 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.indexGatewayFullname" . }}-headless
labels:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 4 }}
prometheus.io/service-monitor: "false"
spec:
type: ClusterIP
clusterIP: None
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- with .Values.indexGateway.appProtocol.grpc }}
appProtocol: {{ . }}
{{- end }}
selector:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 4 }}
{{- end }}

@ -0,0 +1,32 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.indexGatewayFullname" . }}
labels:
{{- include "loki.indexGatewayLabels" . | nindent 4 }}
{{- with .Values.indexGateway.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- with .Values.indexGateway.appProtocol.grpc }}
appProtocol: {{ . }}
{{- end }}
selector:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 4 }}
{{- end }}

@ -0,0 +1,186 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.indexGatewayFullname" . }}
labels:
{{- include "loki.indexGatewayLabels" . | nindent 4 }}
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.indexGateway.replicas }}
updateStrategy:
rollingUpdate:
partition: 0
serviceName: {{ include "loki.indexGatewayFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.indexGateway.persistence.enableStatefulSetAutoDeletePVC) }}
{{/*
Data on the read nodes is easy to replace, so we want to always delete PVCs to make
operation easier, and will rely on re-fetching data when needed.
*/}}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.indexGateway.persistence.whenDeleted }}
whenScaled: {{ .Values.indexGateway.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 8 }}
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.indexGateway.joinMemberlist }}
app.kubernetes.io/part-of: memberlist
{{- end }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.indexGatewayPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.indexGateway.terminationGracePeriodSeconds }}
{{- with .Values.indexGateway.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: index-gateway
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=index-gateway
{{- with .Values.indexGateway.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
{{- if .Values.indexGateway.joinMemberlist }}
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- end }}
{{- with .Values.indexGateway.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.indexGateway.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
livenessProbe:
{{- toYaml .Values.loki.livenessProbe | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.indexGateway.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.indexGateway.resources | nindent 12 }}
{{- if .Values.indexGateway.extraContainers }}
{{- toYaml .Values.indexGateway.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.indexGateway.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.indexGateway.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if not .Values.indexGateway.persistence.enabled }}
- name: data
emptyDir: {}
{{- else if .Values.indexGateway.persistence.inMemory }}
- name: data
{{- if .Values.indexGateway.persistence.inMemory }}
emptyDir:
medium: Memory
{{- end }}
{{- if .Values.indexGateway.persistence.size }}
sizeLimit: {{ .Values.indexGateway.persistence.size }}
{{- end }}
{{- else }}
volumeClaimTemplates:
- metadata:
name: data
{{- with .Values.indexGateway.persistence.annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .Values.indexGateway.persistence.storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .Values.indexGateway.persistence.size | quote }}
{{- end }}
{{- end }}

@ -0,0 +1,74 @@
{{/*
ingester fullname
*/}}
{{- define "loki.ingesterFullname" -}}
{{ include "loki.fullname" . }}-ingester
{{- end }}
{{/*
ingester common labels
*/}}
{{- define "loki.ingesterLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: ingester
{{- end }}
{{/*
ingester selector labels
*/}}
{{- define "loki.ingesterSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: ingester
{{- end }}
{{/*
ingester priority class name
*/}}
{{- define "loki.ingesterPriorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.ingester.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}
{{- define "loki.ingester.readinessProbe" -}}
{{- with .Values.ingester.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- else }}
{{- with .Values.loki.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end -}}
{{- define "loki.ingester.livenessProbe" -}}
{{- with .Values.ingester.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 2 }}
{{- else }}
{{- with .Values.loki.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end -}}
{{/*
expects global context
*/}}
{{- define "loki.ingester.replicaCount" -}}
{{- ceil (divf .Values.ingester.replicas 3) -}}
{{- end -}}
{{/*
expects a dict
{
"replicas": replicas in a zone,
"ctx": global context
}
*/}}
{{- define "loki.ingester.maxUnavailable" -}}
{{- ceil (mulf .replicas (divf (int .ctx.Values.ingester.zoneAwareReplication.maxUnavailablePct) 100)) -}}
{{- end -}}

@ -0,0 +1,55 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.ingester.autoscaling.enabled }}
{{- $apiVersion := include "loki.hpa.apiVersion" . -}}
apiVersion: {{ $apiVersion }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "loki.ingesterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Statefulset
name: {{ include "loki.ingesterFullname" . }}
minReplicas: {{ .Values.ingester.autoscaling.minReplicas }}
maxReplicas: {{ .Values.ingester.autoscaling.maxReplicas }}
metrics:
{{- with .Values.ingester.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.ingester.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.ingester.autoscaling.customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.ingester.autoscaling.behavior.enabled }}
behavior:
{{- with .Values.ingester.autoscaling.behavior.scaleDown }}
scaleDown: {{ toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.ingester.autoscaling.behavior.scaleUp }}
scaleUp: {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,21 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (gt (int .Values.ingester.replicas) 1) (.Values.ingester.zoneAwareReplication.enabled) }}
{{- if kindIs "invalid" .Values.ingester.maxUnavailable }}
{{- fail "`.Values.ingester.maxUnavailable` must be set when `.Values.ingester.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.ingesterFullname" . }}-rollout
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
rollout-group: ingester
{{- with .Values.ingester.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,27 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (gt (int .Values.ingester.replicas) 1) (or (not .Values.ingester.zoneAwareReplication.enabled) .Values.ingester.zoneAwareReplication.migration.enabled) }}
{{- if kindIs "invalid" .Values.ingester.maxUnavailable }}
{{- fail "`.Values.ingester.maxUnavailable` must be set when `.Values.ingester.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.ingesterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "loki.ingesterSelectorLabels" . | nindent 6 }}
{{/* zone aware ingesters get their own pod disruption budget, ignore them here */}}
matchExpressions:
- key: rollout-group
operator: NotIn
values:
- "ingester"
{{- with .Values.ingester.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,32 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (or (not .Values.ingester.zoneAwareReplication.enabled) .Values.ingester.zoneAwareReplication.migration.enabled) }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.ingesterFullname" . }}-headless
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}
prometheus.io/service-monitor: "false"
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
clusterIP: None
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.ingester.appProtocol.grpc }}
appProtocol: {{ .Values.ingester.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}
{{- end -}}

@ -0,0 +1,35 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.ingesterFullname" . }}-zone-a-headless
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
{{- with .Values.ingester.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
clusterIP: None
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.ingester.appProtocol.grpc }}
appProtocol: {{ .Values.ingester.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}
name: ingester-zone-a
rollout-group: ingester
{{- end -}}

@ -0,0 +1,35 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.ingesterFullname" . }}-zone-b-headless
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
{{- with .Values.ingester.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
clusterIP: None
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.ingester.appProtocol.grpc }}
appProtocol: {{ .Values.ingester.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}
name: ingester-zone-b
rollout-group: ingester
{{- end -}}

@ -0,0 +1,35 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.ingesterFullname" . }}-zone-c-headless
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
{{- with .Values.ingester.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
clusterIP: None
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.ingester.appProtocol.grpc }}
appProtocol: {{ .Values.ingester.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}
name: ingester-zone-c
rollout-group: ingester
{{- end -}}

@ -0,0 +1,33 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (or (not .Values.ingester.zoneAwareReplication.enabled) .Values.ingester.zoneAwareReplication.migration.enabled) }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.ingesterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
{{- with .Values.ingester.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.ingester.appProtocol.grpc }}
appProtocol: {{ .Values.ingester.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}
{{- end -}}

@ -0,0 +1,232 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }}
{{- $replicas := (include "loki.ingester.replicaCount" .) -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.ingesterFullname" . }}-zone-a
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
app.kubernetes.io/part-of: memberlist
rollout-group: ingester
name: ingester-zone-a
annotations:
rollout-max-unavailable: "{{ include "loki.ingester.maxUnavailable" (dict "ctx" . "replicas" $replicas)}}"
{{- with .Values.loki.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.ingester.zoneAwareReplication.zoneA.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.ingester.autoscaling.enabled }}
replicas: {{ $replicas }}
{{- end }}
podManagementPolicy: Parallel
serviceName: {{ include "loki.ingesterFullname" . }}-zone-a
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }}
{{/*
Data on the read nodes is easy to replace, so we want to always delete PVCs to make
operation easier, and will rely on re-fetching data when needed.
*/}}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.ingester.persistence.whenDeleted }}
whenScaled: {{ .Values.ingester.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.ingesterSelectorLabels" . | nindent 6 }}
name: ingester-zone-a
rollout-group: ingester
updateStrategy:
type: OnDelete
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.zoneAwareReplication.zoneA.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.ingesterSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
name: ingester-zone-a
rollout-group: ingester
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
{{- with .Values.ingester.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.ingesterPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }}
{{- with .Values.ingester.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: ingester
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.ingester.command }}
command:
- {{ coalesce .Values.ingester.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -ingester.availability-zone=zone-a
- -ingester.unregister-on-shutdown=false
- -ingester.tokens-file-path=/var/loki/ring-tokens
- -target=ingester
{{- with .Values.ingester.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.ingester.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
{{- include "loki.ingester.readinessProbe" . | nindent 10 }}
{{- include "loki.ingester.livenessProbe" . | nindent 10 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.ingester.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.ingester.extraContainers }}
{{- toYaml .Values.ingester.extraContainers | nindent 8}}
{{- end }}
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: rollout-group
operator: In
values:
- ingester
- key: name
operator: NotIn
values:
- ingester-zone-a
topologyKey: kubernetes.io/hostname
{{- with .Values.ingester.zoneAwareReplication.zoneA.extraAffinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.zoneAwareReplication.zoneA.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.ingester.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if not .Values.ingester.persistence.enabled }}
- name: data
emptyDir: {}
{{- else if .Values.ingester.persistence.inMemory }}
- name: data
{{- if .Values.ingester.persistence.inMemory }}
emptyDir:
medium: Memory
{{- end }}
{{- if .Values.ingester.persistence.size }}
sizeLimit: {{ .Values.ingester.persistence.size }}
{{- end }}
{{- else }}
volumeClaimTemplates:
{{- range .Values.ingester.persistence.claims }}
- metadata:
name: {{ .name }}
{{- with .annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .size | quote }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,232 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }}
{{- $replicas := (include "loki.ingester.replicaCount" .) -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.ingesterFullname" . }}-zone-b
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
app.kubernetes.io/part-of: memberlist
rollout-group: ingester
name: ingester-zone-b
annotations:
rollout-max-unavailable: "{{ include "loki.ingester.maxUnavailable" (dict "ctx" . "replicas" $replicas)}}"
{{- with .Values.loki.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.ingester.zoneAwareReplication.zoneB.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.ingester.autoscaling.enabled }}
replicas: {{ $replicas }}
{{- end }}
podManagementPolicy: Parallel
serviceName: {{ include "loki.ingesterFullname" . }}-zone-b
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }}
{{/*
Data on the read nodes is easy to replace, so we want to always delete PVCs to make
operation easier, and will rely on re-fetching data when needed.
*/}}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.ingester.persistence.whenDeleted }}
whenScaled: {{ .Values.ingester.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.ingesterSelectorLabels" . | nindent 6 }}
name: ingester-zone-b
rollout-group: ingester
updateStrategy:
type: OnDelete
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.zoneAwareReplication.zoneB.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.ingesterSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
name: ingester-zone-b
rollout-group: ingester
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
{{- with .Values.ingester.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.ingesterPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }}
{{- with .Values.ingester.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: ingester
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.ingester.command }}
command:
- {{ coalesce .Values.ingester.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -ingester.availability-zone=zone-b
- -ingester.unregister-on-shutdown=false
- -ingester.tokens-file-path=/var/loki/ring-tokens
- -target=ingester
{{- with .Values.ingester.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.ingester.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
{{- include "loki.ingester.readinessProbe" . | nindent 10 }}
{{- include "loki.ingester.livenessProbe" . | nindent 10 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.ingester.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.ingester.extraContainers }}
{{- toYaml .Values.ingester.extraContainers | nindent 8}}
{{- end }}
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: rollout-group
operator: In
values:
- ingester
- key: name
operator: NotIn
values:
- ingester-zone-b
topologyKey: kubernetes.io/hostname
{{- with .Values.ingester.zoneAwareReplication.zoneA.extraAffinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.zoneAwareReplication.zoneA.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.ingester.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if not .Values.ingester.persistence.enabled }}
- name: data
emptyDir: {}
{{- else if .Values.ingester.persistence.inMemory }}
- name: data
{{- if .Values.ingester.persistence.inMemory }}
emptyDir:
medium: Memory
{{- end }}
{{- if .Values.ingester.persistence.size }}
sizeLimit: {{ .Values.ingester.persistence.size }}
{{- end }}
{{- else }}
volumeClaimTemplates:
{{- range .Values.ingester.persistence.claims }}
- metadata:
name: {{ .name }}
{{- with .annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .size | quote }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,232 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.ingester.zoneAwareReplication.enabled }}
{{- $replicas := (include "loki.ingester.replicaCount" .) -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.ingesterFullname" . }}-zone-c
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
app.kubernetes.io/part-of: memberlist
rollout-group: ingester
name: ingester-zone-c
annotations:
rollout-max-unavailable: "{{ include "loki.ingester.maxUnavailable" (dict "ctx" . "replicas" $replicas)}}"
{{- with .Values.loki.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.ingester.zoneAwareReplication.zoneC.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.ingester.autoscaling.enabled }}
replicas: {{ $replicas }}
{{- end }}
podManagementPolicy: Parallel
serviceName: {{ include "loki.ingesterFullname" . }}-zone-c
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }}
{{/*
Data on the read nodes is easy to replace, so we want to always delete PVCs to make
operation easier, and will rely on re-fetching data when needed.
*/}}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.ingester.persistence.whenDeleted }}
whenScaled: {{ .Values.ingester.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.ingesterSelectorLabels" . | nindent 6 }}
name: ingester-zone-c
rollout-group: ingester
updateStrategy:
type: OnDelete
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.zoneAwareReplication.zoneC.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.ingesterSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
name: ingester-zone-c
rollout-group: ingester
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
{{- with .Values.ingester.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.ingesterPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }}
{{- with .Values.ingester.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: ingester
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.ingester.command }}
command:
- {{ coalesce .Values.ingester.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -ingester.availability-zone=zone-c
- -ingester.unregister-on-shutdown=false
- -ingester.tokens-file-path=/var/loki/ring-tokens
- -target=ingester
{{- with .Values.ingester.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.ingester.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
{{- include "loki.ingester.readinessProbe" . | nindent 10 }}
{{- include "loki.ingester.livenessProbe" . | nindent 10 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.ingester.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.ingester.extraContainers }}
{{- toYaml .Values.ingester.extraContainers | nindent 8}}
{{- end }}
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: rollout-group
operator: In
values:
- ingester
- key: name
operator: NotIn
values:
- ingester-zone-c
topologyKey: kubernetes.io/hostname
{{- with .Values.ingester.zoneAwareReplication.zoneA.extraAffinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.zoneAwareReplication.zoneA.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.ingester.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if not .Values.ingester.persistence.enabled }}
- name: data
emptyDir: {}
{{- else if .Values.ingester.persistence.inMemory }}
- name: data
{{- if .Values.ingester.persistence.inMemory }}
emptyDir:
medium: Memory
{{- end }}
{{- if .Values.ingester.persistence.size }}
sizeLimit: {{ .Values.ingester.persistence.size }}
{{- end }}
{{- else }}
volumeClaimTemplates:
{{- range .Values.ingester.persistence.claims }}
- metadata:
name: {{ .name }}
{{- with .annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .size | quote }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,204 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (or (not .Values.ingester.zoneAwareReplication.enabled) .Values.ingester.zoneAwareReplication.migration.enabled) }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.ingesterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.ingester.autoscaling.enabled }}
replicas: {{ .Values.ingester.replicas }}
{{- end }}
podManagementPolicy: Parallel
updateStrategy:
rollingUpdate:
partition: 0
serviceName: {{ include "loki.ingesterFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.ingester.persistence.enableStatefulSetAutoDeletePVC) }}
{{/*
Data on the read nodes is easy to replace, so we want to always delete PVCs to make
operation easier, and will rely on re-fetching data when needed.
*/}}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.ingester.persistence.whenDeleted }}
whenScaled: {{ .Values.ingester.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.ingesterSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.ingesterSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
{{- with .Values.ingester.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.ingesterPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }}
{{- with .Values.ingester.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: ingester
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.ingester.command }}
command:
- {{ coalesce .Values.ingester.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -ingester.ring.instance-availability-zone=zone-default
- -target=ingester
{{- with .Values.ingester.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.ingester.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
{{- include "loki.ingester.readinessProbe" . | nindent 10 }}
{{- include "loki.ingester.livenessProbe" . | nindent 10 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.ingester.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ingester.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.ingester.extraContainers }}
{{- toYaml .Values.ingester.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.ingester.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ingester.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.ingester.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if not .Values.ingester.persistence.enabled }}
- name: data
emptyDir: { }
{{- else if .Values.ingester.persistence.inMemory }}
- name: data
{{- if .Values.ingester.persistence.inMemory }}
emptyDir:
medium: Memory
{{- end }}
{{- if .Values.ingester.persistence.size }}
sizeLimit: {{ .Values.ingester.persistence.size }}
{{- end }}
{{- else }}
volumeClaimTemplates:
{{- range .Values.ingester.persistence.claims }}
- metadata:
name: {{ .name }}
{{- with .annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .size | quote }}
{{- end }}
{{- end }}
{{- end }}

@ -25,7 +25,7 @@ app.kubernetes.io/component: canary
Docker image name for loki-canary
*/}}
{{- define "loki-canary.image" -}}
{{- $dict := dict "service" .Values.monitoring.lokiCanary.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- $dict := dict "service" .Values.lokiCanary.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "loki.baseImage" $dict -}}
{{- end -}}
@ -33,7 +33,7 @@ Docker image name for loki-canary
canary priority class name
*/}}
{{- define "loki-canary.priorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.monitoring.lokiCanary.priorityClassName .Values.read.priorityClassName -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.lokiCanary.priorityClassName .Values.read.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}

@ -1,4 +1,4 @@
{{- with .Values.monitoring.lokiCanary -}}
{{- with .Values.lokiCanary -}}
{{- if .enabled -}}
---
apiVersion: apps/v1
@ -52,11 +52,18 @@ spec:
- -user={{ $.Values.monitoring.selfMonitoring.tenant.name }}
- -tenant-id={{ $.Values.monitoring.selfMonitoring.tenant.name }}
{{- end }}
{{- if .push }}
- -push=true
{{- end }}
{{- with .extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml $.Values.loki.containerSecurityContext | nindent 12 }}
volumeMounts:
{{- with $.Values.lokiCanary.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3500
@ -107,5 +114,9 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
{{- with $.Values.lokiCanary.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}

@ -1,4 +1,4 @@
{{- with .Values.monitoring.lokiCanary -}}
{{- with .Values.lokiCanary -}}
{{- if .enabled -}}
---
apiVersion: v1

@ -1,4 +1,4 @@
{{- with .Values.monitoring.lokiCanary -}}
{{- with .Values.lokiCanary -}}
{{- if .enabled -}}
---
apiVersion: v1

@ -0,0 +1,159 @@
{{/*
memcached StatefulSet
Params:
ctx = . context
valuesSection = name of the section in values.yaml
component = name of the component
valuesSection and component are specified separately because helm prefers camelcase for naming convetion and k8s components are named with snake case.
*/}}
{{- define "loki.memcached.statefulSet" -}}
{{ with (index $.ctx.Values $.valuesSection) }}
{{- if .enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.resourceName" (dict "ctx" $.ctx "component" $.component) }}
labels:
{{- include "loki.labels" $.ctx | nindent 4 }}
app.kubernetes.io/component: "memcached-{{ $.component }}"
name: "memcached-{{ $.component }}"
annotations:
{{- toYaml .annotations | nindent 4 }}
namespace: {{ $.ctx.Release.Namespace | quote }}
spec:
podManagementPolicy: {{ .podManagementPolicy }}
replicas: {{ .replicas }}
selector:
matchLabels:
{{- include "loki.selectorLabels" $.ctx | nindent 6 }}
app.kubernetes.io/component: "memcached-{{ $.component }}"
name: "memcached-{{ $.component }}"
updateStrategy:
{{- toYaml .statefulStrategy | nindent 4 }}
serviceName: {{ template "loki.fullname" $.ctx }}-{{ $.component }}
template:
metadata:
labels:
{{- include "loki.selectorLabels" $.ctx | nindent 8 }}
app.kubernetes.io/component: "memcached-{{ $.component }}"
name: "memcached-{{ $.component }}"
{{- with $.ctx.Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- with $.ctx.Values.global.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "loki.serviceAccountName" $.ctx }}
{{- if .priorityClassName }}
priorityClassName: {{ .priorityClassName }}
{{- end }}
securityContext:
{{- toYaml $.ctx.Values.memcached.podSecurityContext | nindent 8 }}
initContainers:
{{- toYaml .initContainers | nindent 8 }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
affinity:
{{- toYaml .affinity | nindent 8 }}
topologySpreadConstraints:
{{- toYaml .topologySpreadConstraints | nindent 8 }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
terminationGracePeriodSeconds: {{ .terminationGracePeriodSeconds }}
{{- if $.ctx.Values.imagePullSecrets }}
imagePullSecrets:
{{- range $.ctx.Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .extraVolumes }}
volumes:
{{- toYaml .extraVolumes | nindent 8 }}
{{- end }}
containers:
{{- if .extraContainers }}
{{ toYaml .extraContainers | nindent 8 }}
{{- end }}
- name: memcached
{{- with $.ctx.Values.memcached.image }}
image: {{ .repository }}:{{ .tag }}
imagePullPolicy: {{ .pullPolicy }}
{{- end }}
resources:
{{- if .resources }}
{{- toYaml .resources | nindent 12 }}
{{- else }}
{{- /* Calculate requested memory as round(allocatedMemory * 1.2). But with integer built-in operators. */}}
{{- $requestMemory := div (add (mul .allocatedMemory 12) 5) 10 }}
limits:
memory: {{ $requestMemory }}Mi
requests:
cpu: 500m
memory: {{ $requestMemory }}Mi
{{- end }}
ports:
- containerPort: {{ .port }}
name: client
args:
- -m {{ .allocatedMemory }}
- --extended=modern,track_sizes{{ with .extraExtendedOptions }},{{ . }}{{ end }}
- -I {{ .maxItemMemory }}m
- -c {{ .connectionLimit }}
- -v
- -u {{ .port }}
{{- range $key, $value := .extraArgs }}
- "-{{ $key }}{{ if $value }} {{ $value }}{{ end }}"
{{- end }}
env:
{{- with $.ctx.Values.global.extraEnv }}
{{ toYaml . | nindent 12 }}
{{- end }}
envFrom:
{{- with $.ctx.Values.global.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml $.ctx.Values.memcached.containerSecurityContext | nindent 12 }}
{{- if .extraVolumeMounts }}
volumeMounts:
{{- toYaml .extraVolumeMounts | nindent 12 }}
{{- end }}
{{- if $.ctx.Values.memcachedExporter.enabled }}
- name: exporter
{{- with $.ctx.Values.memcachedExporter.image }}
image: {{ .repository}}:{{ .tag }}
imagePullPolicy: {{ .pullPolicy }}
{{- end }}
ports:
- containerPort: 9150
name: http-metrics
args:
- "--memcached.address=localhost:{{ .port }}"
- "--web.listen-address=0.0.0.0:9150"
{{- range $key, $value := $.ctx.Values.memcachedExporter.extraArgs }}
- "--{{ $key }}{{ if $value }}={{ $value }}{{ end }}"
{{- end }}
resources:
{{- toYaml $.ctx.Values.memcachedExporter.resources | nindent 12 }}
securityContext:
{{- toYaml $.ctx.Values.memcachedExporter.containerSecurityContext | nindent 12 }}
{{- if .extraVolumeMounts }}
volumeMounts:
{{- toYaml .extraVolumeMounts | nindent 12 }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end -}}

@ -0,0 +1,42 @@
{{/*
memcached Service
Params:
ctx = . context
valuesSection = name of the section in values.yaml
component = name of the component
valuesSection and component are specified separately because helm prefers camelcase for naming convetion and k8s components are named with snake case.
*/}}
{{- define "loki.memcached.service" -}}
{{ with (index $.ctx.Values $.valuesSection) }}
{{- if .enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.resourceName" (dict "ctx" $.ctx "component" $.component) }}
labels:
{{- include "loki.labels" $.ctx | nindent 4 }}
app.kubernetes.io/component: "memcached-{{ $.component }}"
{{- with .service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .service.annotations | nindent 4 }}
namespace: {{ $.ctx.Release.Namespace | quote }}
spec:
type: ClusterIP
clusterIP: None
ports:
- name: memcached-client
port: {{ .port }}
targetPort: {{ .port }}
{{ if $.ctx.Values.memcachedExporter.enabled -}}
- name: http-metrics
port: 9150
targetPort: 9150
{{ end }}
selector:
{{- include "loki.selectorLabels" $.ctx | nindent 4 }}
app.kubernetes.io/component: "memcached-{{ $.component }}"
{{- end -}}
{{- end -}}
{{- end -}}

@ -27,4 +27,4 @@ spec:
matchLabels:
{{- include "loki.selectorLabels" $ | nindent 6 }}
{{- end -}}
{{- end -}}
{{- end -}}

@ -0,0 +1,58 @@
{{/*
pattern ingester fullname
*/}}
{{- define "loki.patternIngesterFullname" -}}
{{ include "loki.fullname" . }}-pattern-ingester
{{- end }}
{{/*
pattern ingester common labels
*/}}
{{- define "loki.patternIngesterLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: pattern-ingester
{{- end }}
{{/*
pattern ingester selector labels
*/}}
{{- define "loki.patternIngesterSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: pattern-ingester
{{- end }}
{{/*
pattern ingester readinessProbe
*/}}
{{- define "loki.patternIngester.readinessProbe" -}}
{{- with .Values.patternIngester.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- else }}
{{- with .Values.loki.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end -}}
{{/*
pattern ingester priority class name
*/}}
{{- define "loki.patternIngesterPriorityClassName" }}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.patternIngester.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}
{{/*
Create the name of the pattern ingester service account
*/}}
{{- define "loki.patternIngesterServiceAccountName" -}}
{{- if .Values.patternIngester.serviceAccount.create -}}
{{ default (print (include "loki.serviceAccountName" .) "-pattern-ingester") .Values.patternIngester.serviceAccount.name }}
{{- else -}}
{{ default (include "loki.serviceAccountName" .) .Values.patternIngester.serviceAccount.name }}
{{- end -}}
{{- end -}}

@ -0,0 +1,179 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
{{- if (gt (int .Values.patternIngester.replicas) 0) -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.patternIngesterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.patternIngesterLabels" . | nindent 4 }}
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.patternIngester.replicas }}
podManagementPolicy: Parallel
updateStrategy:
rollingUpdate:
partition: 0
serviceName: {{ include "loki.patternIngesterFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.patternIngester.persistence.enableStatefulSetAutoDeletePVC) }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.patternIngester.persistence.whenDeleted }}
whenScaled: {{ .Values.patternIngester.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.patternIngesterSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.patternIngester.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.patternIngesterSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.patternIngester.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.patternIngester.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.patternIngesterPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.patternIngester.terminationGracePeriodSeconds }}
{{- with .Values.patternIngester.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: pattern-ingester
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.patternIngester.command }}
command:
- {{ coalesce .Values.patternIngester.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=pattern-ingester
{{- with .Values.patternIngester.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.patternIngester.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.patternIngester.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
{{- include "loki.patternIngester.readinessProbe" . | nindent 10 }}
volumeMounts:
- name: temp
mountPath: /tmp
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.patternIngester.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.patternIngester.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.patternIngester.extraContainers }}
{{- toYaml .Values.patternIngester.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.patternIngester.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.patternIngester.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: temp
emptyDir: {}
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- if not .Values.patternIngester.persistence.enabled }}
- name: data
emptyDir: {}
{{- end }}
{{- with .Values.patternIngester.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.patternIngester.persistence.enabled }}
volumeClaimTemplates:
{{- range .Values.patternIngester.persistence.claims }}
- metadata:
name: {{ .name }}
{{- with .annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .size | quote }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}

@ -0,0 +1,32 @@
{{/*
querier fullname
*/}}
{{- define "loki.querierFullname" -}}
{{ include "loki.fullname" . }}-querier
{{- end }}
{{/*
querier common labels
*/}}
{{- define "loki.querierLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: querier
{{- end }}
{{/*
querier selector labels
*/}}
{{- define "loki.querierSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: querier
{{- end }}
{{/*
querier priority class name
*/}}
{{- define "loki.querierPriorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.querier.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}

@ -0,0 +1,166 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "loki.querierFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.querierLabels" . | nindent 4 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.querier.autoscaling.enabled }}
replicas: {{ .Values.querier.replicas }}
{{- end }}
strategy:
rollingUpdate:
maxSurge: {{ .Values.querier.maxSurge }}
maxUnavailable: 1
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "loki.querierSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.querier.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.querierSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.querier.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
{{- with .Values.querier.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.querier.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.querierPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.querier.terminationGracePeriodSeconds }}
{{- with .Values.querier.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: querier
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=querier
{{- if .Values.ingester.zoneAwareReplication.enabled }}
{{- if and (.Values.ingester.zoneAwareReplication.migration.enabled) (not .Values.ingester.zoneAwareReplication.migration.readPath) }}
- -distributor.zone-awareness-enabled=false
{{- else }}
- -distributor.zone-awareness-enabled=true
{{- end }}
{{- end }}
{{- with .Values.querier.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.querier.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.querier.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
livenessProbe:
{{- toYaml .Values.loki.livenessProbe | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.querier.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.querier.resources | nindent 12 }}
{{- if .Values.querier.extraContainers }}
{{- toYaml .Values.querier.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.querier.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.querier.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.querier.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.querier.dnsConfig }}
dnsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
- name: data
emptyDir: {}
{{- with .Values.querier.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}

@ -0,0 +1,55 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.querier.autoscaling.enabled }}
{{- $apiVersion := include "loki.hpa.apiVersion" . -}}
apiVersion: {{ $apiVersion }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "loki.querierFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.querierLabels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "loki.querierFullname" . }}
minReplicas: {{ .Values.querier.autoscaling.minReplicas }}
maxReplicas: {{ .Values.querier.autoscaling.maxReplicas }}
metrics:
{{- with .Values.querier.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.querier.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.querier.autoscaling.customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.querier.autoscaling.behavior.enabled }}
behavior:
{{- with .Values.querier.autoscaling.behavior.scaleDown }}
scaleDown: {{ toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.querier.autoscaling.behavior.scaleUp }}
scaleUp: {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,21 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (gt (int .Values.querier.replicas) 1) }}
{{- if kindIs "invalid" .Values.querier.maxUnavailable }}
{{- fail "`.Values.querier.maxUnavailable` must be set when `.Values.querier.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.querierFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.querierLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "loki.querierSelectorLabels" . | nindent 6 }}
{{- with .Values.querier.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,33 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.querierFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.querierLabels" . | nindent 4 }}
{{- with .Values.querier.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.querier.appProtocol.grpc }}
appProtocol: {{ .Values.querier.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.querierSelectorLabels" . | nindent 4 }}
{{- end -}}

@ -0,0 +1,32 @@
{{/*
query-frontend fullname
*/}}
{{- define "loki.queryFrontendFullname" -}}
{{ include "loki.fullname" . }}-query-frontend
{{- end }}
{{/*
query-frontend common labels
*/}}
{{- define "loki.queryFrontendLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: query-frontend
{{- end }}
{{/*
query-frontend selector labels
*/}}
{{- define "loki.queryFrontendSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: query-frontend
{{- end }}
{{/*
query-frontend priority class name
*/}}
{{- define "loki.queryFrontendPriorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.queryFrontend.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}

@ -0,0 +1,142 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "loki.queryFrontendFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.queryFrontendLabels" . | nindent 4 }}
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.queryFrontend.autoscaling.enabled }}
replicas: {{ .Values.queryFrontend.replicas }}
{{- end }}
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "loki.queryFrontendSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryFrontend.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.queryFrontendSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryFrontend.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryFrontend.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.queryFrontendPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.queryFrontend.terminationGracePeriodSeconds }}
containers:
- name: query-frontend
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
{{- if or .Values.loki.command .Values.queryFrontend.command }}
command:
- {{ coalesce .Values.queryFrontend.command .Values.loki.command | quote }}
{{- end }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=query-frontend
{{- with .Values.queryFrontend.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.queryFrontend.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.queryFrontend.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.queryFrontend.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.queryFrontend.resources | nindent 12 }}
{{- if .Values.queryFrontend.extraContainers }}
{{- toYaml .Values.queryFrontend.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.queryFrontend.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryFrontend.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryFrontend.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.queryFrontend.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}

@ -0,0 +1,55 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.queryFrontend.autoscaling.enabled }}
{{- $apiVersion := include "loki.hpa.apiVersion" . -}}
apiVersion: {{ $apiVersion }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "loki.queryFrontendFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.queryFrontendLabels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "loki.queryFrontendFullname" . }}
minReplicas: {{ .Values.queryFrontend.autoscaling.minReplicas }}
maxReplicas: {{ .Values.queryFrontend.autoscaling.maxReplicas }}
metrics:
{{- with .Values.queryFrontend.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.queryFrontend.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
{{- if (eq $apiVersion "autoscaling/v2") }}
target:
type: Utilization
averageUtilization: {{ . }}
{{- else }}
targetAverageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.queryFrontend.autoscaling.customMetrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.queryFrontend.autoscaling.behavior.enabled }}
behavior:
{{- with .Values.queryFrontend.autoscaling.behavior.scaleDown }}
scaleDown: {{ toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.queryFrontend.autoscaling.behavior.scaleUp }}
scaleUp: {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,21 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (gt (int .Values.queryFrontend.replicas) 1) }}
{{- if kindIs "invalid" .Values.queryFrontend.maxUnavailable }}
{{- fail "`.Values.queryFrontend.maxUnavailable` must be set when `.Values.queryFrontend.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.queryFrontendFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.queryFrontendLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "loki.queryFrontendSelectorLabels" . | nindent 6 }}
{{- with .Values.queryFrontend.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,43 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.queryFrontendFullname" . }}-headless
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.queryFrontendLabels" . | nindent 4 }}
{{- with .Values.queryFrontend.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
prometheus.io/service-monitor: "false"
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
clusterIP: None
type: ClusterIP
publishNotReadyAddresses: true
ports:
- name: http-metrics
port: 3100
targetPort: http
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.queryFrontend.appProtocol.grpc }}
appProtocol: {{ .Values.queryFrontend.appProtocol.grpc }}
{{- end }}
- name: grpclb
port: 9096
targetPort: grpc
protocol: TCP
{{- if .Values.queryFrontend.appProtocol.grpc }}
appProtocol: {{ .Values.queryFrontend.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.queryFrontendSelectorLabels" . | nindent 4 }}
{{- end -}}

@ -0,0 +1,41 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.queryFrontendFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.queryFrontendLabels" . | nindent 4 }}
{{- with .Values.queryFrontend.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
publishNotReadyAddresses: true
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- if .Values.queryFrontend.appProtocol.grpc }}
appProtocol: {{ .Values.queryFrontend.appProtocol.grpc }}
{{- end }}
- name: grpclb
port: 9096
targetPort: grpc
protocol: TCP
{{- if .Values.queryFrontend.appProtocol.grpc }}
appProtocol: {{ .Values.queryFrontend.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.queryFrontendSelectorLabels" . | nindent 4 }}
{{- end -}}

@ -0,0 +1,40 @@
{{/*
query-scheduler fullname
*/}}
{{- define "loki.querySchedulerFullname" -}}
{{ include "loki.fullname" . }}-query-scheduler
{{- end }}
{{/*
query-scheduler common labels
*/}}
{{- define "loki.querySchedulerLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: query-scheduler
{{- end }}
{{/*
query-scheduler selector labels
*/}}
{{- define "loki.querySchedulerSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: query-scheduler
{{- end }}
{{/*
query-scheduler image
*/}}
{{- define "loki.querySchedulerImage" -}}
{{- $dict := dict "loki" .Values.loki.image "service" .Values.queryScheduler.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "loki.lokiImage" $dict -}}
{{- end }}
{{/*
query-scheduler priority class name
*/}}
{{- define "loki.querySchedulerPriorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.queryScheduler.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}

@ -0,0 +1,140 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "loki.querySchedulerFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.querySchedulerLabels" . | nindent 4 }}
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.queryScheduler.replicas }}
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "loki.querySchedulerSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryScheduler.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.querySchedulerSelectorLabels" . | nindent 8 }}
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryScheduler.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
app.kubernetes.io/part-of: memberlist
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryScheduler.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.querySchedulerPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.queryScheduler.terminationGracePeriodSeconds }}
containers:
- name: query-scheduler
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=query-scheduler
{{- with .Values.queryScheduler.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.queryScheduler.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.queryScheduler.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
livenessProbe:
{{- toYaml .Values.loki.livenessProbe | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.queryScheduler.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.queryScheduler.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.queryScheduler.extraContainers }}
{{- toYaml .Values.queryScheduler.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.queryScheduler.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryScheduler.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.queryScheduler.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.queryScheduler.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}

@ -0,0 +1,21 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (gt (int .Values.queryScheduler.replicas) 1) }}
{{- if kindIs "invalid" .Values.queryScheduler.maxUnavailable }}
{{- fail "`.Values.queryScheduler.maxUnavailable` must be set when `.Values.queryScheduler.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.querySchedulerFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.querySchedulerLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "loki.querySchedulerSelectorLabels" . | nindent 6 }}
{{- with .Values.queryScheduler.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,35 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.querySchedulerFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.querySchedulerLabels" . | nindent 4 }}
{{- with .Values.queryScheduler.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
ports:
- name: http-metrics
port: 3100
targetPort: http
protocol: TCP
- name: grpclb
port: 9095
targetPort: grpc
protocol: TCP
{{- with .Values.queryScheduler.appProtocol.grpc }}
appProtocol: {{ . }}
{{- end }}
selector:
{{- include "loki.querySchedulerSelectorLabels" . | nindent 4 }}
{{- end }}

@ -120,7 +120,7 @@ spec:
{{- end }}
{{- with .Values.read.affinity }}
affinity:
{{- tpl . $ | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.read.dnsConfig }}
dnsConfig:
@ -144,12 +144,7 @@ spec:
- name: data
emptyDir: {}
- name: config
{{- if .Values.loki.existingSecretForConfig }}
secret:
secretName: {{ .Values.loki.existingSecretForConfig }}
{{- else }}
{{- include "loki.configVolume" . | nindent 10 }}
{{- end }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime

@ -133,7 +133,7 @@ spec:
{{- end }}
{{- with .Values.read.affinity }}
affinity:
{{- tpl . $ | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.read.dnsConfig }}
dnsConfig:
@ -155,13 +155,7 @@ spec:
- name: tmp
emptyDir: {}
- name: config
{{- if .Values.loki.existingSecretForConfig }}
secret:
secretName: {{ .Values.loki.existingSecretForConfig }}
{{- else }}
configMap:
name: {{ include "loki.name" . }}
{{- end }}
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime

@ -0,0 +1,16 @@
{{- if .Values.resultsCache.enabled }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.fullname" . }}-memcached-results-cache
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: memcached-results-cache
spec:
selector:
matchLabels:
{{- include "loki.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: memcached-results-cache
maxUnavailable: 1
{{- end -}}

@ -0,0 +1 @@
{{- include "loki.memcached.service" (dict "ctx" $ "valuesSection" "resultsCache" "component" "results-cache" ) }}

@ -0,0 +1 @@
{{- include "loki.memcached.statefulSet" (dict "ctx" $ "valuesSection" "resultsCache" "component" "results-cache" ) }}

@ -0,0 +1,47 @@
{{/*
ruler fullname
*/}}
{{- define "loki.rulerFullname" -}}
{{ include "loki.fullname" . }}-ruler
{{- end }}
{{/*
ruler common labels
*/}}
{{- define "loki.rulerLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: ruler
{{- end }}
{{/*
ruler selector labels
*/}}
{{- define "loki.rulerSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: ruler
{{- end }}
{{/*
ruler image
*/}}
{{- define "loki.rulerImage" -}}
{{- $dict := dict "loki" .Values.loki.image "service" .Values.ruler.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "loki.lokiImage" $dict -}}
{{- end }}
{{/*
format rules dir
*/}}
{{- define "loki.rulerRulesDirName" -}}
rules-{{ . | replace "_" "-" | trimSuffix "-" | lower }}
{{- end }}
{{/*
ruler priority class name
*/}}
{{- define "loki.rulerPriorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.ruler.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}

@ -0,0 +1,14 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
{{- range $dir, $files := .Values.ruler.directories }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "loki.rulerFullname" $ }}-{{ include "loki.rulerRulesDirName" $dir }}
labels:
{{- include "loki.rulerLabels" $ | nindent 4 }}
data:
{{- toYaml $files | nindent 2}}
{{- end }}
{{- end }}

@ -0,0 +1,20 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (gt (int .Values.ruler.replicas) 1) }}
{{- if kindIs "invalid" .Values.ruler.maxUnavailable }}
{{- fail "`.Values.ruler.maxUnavailable` must be set when `.Values.ruler.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.rulerFullname" . }}
labels:
{{- include "loki.rulerLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "loki.rulerSelectorLabels" . | nindent 6 }}
{{- with .Values.ruler.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,33 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.ruler.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.rulerFullname" . }}
labels:
{{- include "loki.rulerSelectorLabels" . | nindent 4 }}
{{- with .Values.ruler.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
clusterIP: None
ports:
- name: http-metrics
port: 3100
targetPort: http
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- with .Values.ruler.appProtocol.grpc }}
appProtocol: {{ . }}
{{- end }}
selector:
{{- include "loki.rulerSelectorLabels" . | nindent 4 }}
{{- end }}

@ -0,0 +1,177 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed .Values.ruler.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.rulerFullname" . }}
labels:
{{- include "loki.rulerLabels" . | nindent 4 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.ruler.replicas }}
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
serviceName: {{ include "loki.rulerFullname" . }}
selector:
matchLabels:
{{- include "loki.rulerSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ruler.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.rulerSelectorLabels" . | nindent 8 }}
app.kubernetes.io/part-of: memberlist
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ruler.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ruler.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.rulerPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.ruler.terminationGracePeriodSeconds }}
{{- with .Values.ruler.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: ruler
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=ruler
{{- with .Values.ruler.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- with .Values.ruler.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ruler.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
- name: tmp
mountPath: /tmp/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- range $dir, $_ := .Values.ruler.directories }}
- name: {{ include "loki.rulerRulesDirName" $dir }}
mountPath: /etc/loki/rules/{{ $dir }}
{{- end }}
{{- with .Values.ruler.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.ruler.resources | nindent 12 }}
{{- with .Values.ruler.extraContainers }}
{{- toYaml . | nindent 8}}
{{- end }}
{{- with .Values.ruler.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ruler.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ruler.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ruler.dnsConfig }}
dnsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- range $dir, $_ := .Values.ruler.directories }}
- name: {{ include "loki.rulerRulesDirName" $dir }}
configMap:
name: {{ include "loki.rulerFullname" $ }}-{{ include "loki.rulerRulesDirName" $dir }}
{{- end }}
- name: tmp
emptyDir: {}
{{- with .Values.ruler.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if not .Values.ruler.persistence.enabled }}
- name: data
emptyDir: {}
{{- else }}
volumeClaimTemplates:
- metadata:
name: data
{{- with .Values.ruler.persistence.annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .Values.ruler.persistence.storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .Values.ruler.persistence.size | quote }}
{{- end }}
{{- end }}

@ -135,7 +135,7 @@ spec:
{{- end }}
{{- with .Values.singleBinary.affinity }}
affinity:
{{- tpl . $ | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.singleBinary.dnsConfig }}
dnsConfig:
@ -153,12 +153,7 @@ spec:
- name: tmp
emptyDir: {}
- name: config
{{- if .Values.loki.existingSecretForConfig }}
secret:
secretName: {{ .Values.loki.existingSecretForConfig }}
{{- else }}
{{- include "loki.configVolume" . | nindent 10 }}
{{- end }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime

@ -80,6 +80,10 @@ spec:
volumeMounts:
- name: config
mountPath: /etc/loki/config
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.tableManager.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
@ -90,7 +94,7 @@ spec:
{{- end }}
{{- with .Values.tableManager.affinity }}
affinity:
{{- tpl . $ | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tableManager.dnsConfig }}
dnsConfig:
@ -106,12 +110,16 @@ spec:
{{- end }}
volumes:
- name: config
{{- if .Values.loki.existingSecretForConfig }}
{{- include "loki.configVolume" . | nindent 10 }}
{{- if .Values.enterprise.enabled }}
- name: license
secret:
secretName: {{ .Values.loki.existingSecretForConfig }}
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
{{- include "loki.configVolume" . | nindent 10 }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.tableManager.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}

@ -1,5 +1,5 @@
{{- with .Values.test }}
{{- if and .enabled $.Values.monitoring.selfMonitoring.enabled $.Values.monitoring.lokiCanary.enabled }}
{{- if $.Values.lokiCanary.enabled }}
---
apiVersion: v1
kind: Pod
@ -21,6 +21,8 @@ spec:
- name: loki-helm-test
image: {{ include "loki.helmTestImage" $ }}
env:
- name: CANARY_SERVICE_ADDRESS
value: "{{ .canaryServiceAddress }}"
- name: CANARY_PROMETHEUS_ADDRESS
value: "{{ .prometheusAddress }}"
{{- with .timeout }}

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

Loading…
Cancel
Save