loki:
  auth_enabled: false
  storage:
    bucketNames:
      chunks: {{ .Values.loki.s3.buckets.chunks }}
      ruler: {{ .Values.loki.s3.buckets.ruler }}
      admin: {{ .Values.loki.s3.buckets.admin }}
    s3:
      endpoint: {{ .Values.loki.s3.endpoint }}
      region: {{ .Values.loki.s3.region | default "us-east-1" }}
      secretAccessKey: ${S3SECRET}
      accessKeyId: ${S3KEY}
      s3ForcePathStyle: true
      {{- if .Values.loki.s3.insecure_skip_verify }}
      http_config:
        insecure_skip_verify: true
      {{- end }}
  schemaConfig:
    configs:
    - from: "2022-09-28"
      index:
        period: 24h
        prefix: loki_index_
      object_store: s3
      schema: v13
      store: tsdb
  {{- if .Values.loki.compactor }}
  compactor:
    compaction_interval: 10m
    working_directory: /tmp/loki/compactor
    retention_enabled: true
    retention_delete_delay: 2h
    retention_delete_worker_count: 150
    delete_request_store: s3
  {{- end }}
write:
  extraArgs:
    - -config.expand-env=true
  extraEnv:
  - name: S3KEY
    valueFrom:
      secretKeyRef:
        name: {{ .Values.loki.s3.secret.name | default "s3-credentials"}}
        key: {{ .Values.loki.s3.secret.access_key | default "access_key" }}
  - name: S3SECRET
    valueFrom:
      secretKeyRef:
        name: {{ .Values.loki.s3.secret.name | default "s3-credentials"}}
        key: {{ .Values.loki.s3.secret.access_secret | default "access_secret" }}
  tolerations:
  - effect: "NoSchedule"
    operator: "Equal"
    key: "unschedulable"
    value: "true"
read:
  extraArgs:
    - -config.expand-env=true
  extraEnv:
  - name: S3KEY
    valueFrom:
      secretKeyRef:
        name: {{ .Values.loki.s3.secret.name | default "s3-credentials"}}
        key: {{ .Values.loki.s3.secret.access_key | default "access_key" }}
  - name: S3SECRET
    valueFrom:
      secretKeyRef:
        name: {{ .Values.loki.s3.secret.name | default "s3-credentials"}}
        key: {{ .Values.loki.s3.secret.access_secret | default "access_secret" }}
  tolerations:
  - effect: "NoSchedule"
    operator: "Equal"
    key: "unschedulable"
    value: "true"
{{- if .Values.loki.compactor }}
compactor:
  extraArgs:
    - -config.expand-env=true
  extraEnv:
  - name: S3KEY
    valueFrom:
      secretKeyRef:
        name: {{ .Values.loki.s3.secret.name | default "s3-credentials"}}
        key: {{ .Values.loki.s3.secret.access_key | default "access_key" }}
  - name: S3SECRET
    valueFrom:
      secretKeyRef:
        name: {{ .Values.loki.s3.secret.name | default "s3-credentials"}}
        key: {{ .Values.loki.s3.secret.access_secret | default "access_secret" }}
{{- end }}
backend:
  extraArgs:
    - -config.expand-env=true
  extraEnv:
  - name: S3KEY
    valueFrom:
      secretKeyRef:
        name: {{ .Values.loki.s3.secret.name | default "s3-credentials"}}
        key: {{ .Values.loki.s3.secret.access_key | default "access_key" }}
  - name: S3SECRET
    valueFrom:
      secretKeyRef:
        name: {{ .Values.loki.s3.secret.name | default "s3-credentials"}}
        key: {{ .Values.loki.s3.secret.access_secret | default "access_secret" }}
ingress:
  enabled: true
  ingressClassName: nginx
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-staging
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    oceanbox.io/expose: internal
  hosts:
    - loki.adm.oceanbox.io
  tls:
    - hosts:
       - loki.adm.oceanbox.io
      secretName: loki-distributed-tls
