# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: loki-stack
spec:
  interval: 5m
  chart:
    spec:
      version: "2.x"
      chart: loki-stack
      sourceRef:
        kind: HelmRepository
        name: grafana-charts
      interval: 60m
  # https://github.com/grafana/helm-charts/blob/main/charts/loki-stack/values.yaml
  # https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml
  values:
    grafana:
      enabled: false
      sidecar:
        datasources:
          enabled: true
          maxLines: 1000
    promtail:
      enabled: true
      tolerations:
      - effect: NoSchedule
        key: node-role.kubernetes.io/master
        operator: Exists
      - effect: NoSchedule
        key: node-role.kubernetes.io/control-plane
        operator: Exists
      - effect: NoSchedule
        key: node-group
        operator: Equal
        value: stable
    loki:
      enabled: true
      isDefault: false
      serviceMonitor:
        enabled: true
        additionalLabels:
          prometheus: main
      config:
        chunk_store_config:
          max_look_back_period: 0s
        table_manager:
          retention_deletes_enabled: true
          retention_period: 12h
      nodeSelector:
        node-group: stable
      tolerations:
      - effect: NoSchedule
        key: node-group
        operator: Equal
        value: stable
