From d9b550322878e77eb1c87da728ccdeb99eb80528 Mon Sep 17 00:00:00 2001
From: Ryan Garcia <garcia.ryan@solute.us>
Date: Mon, 22 Aug 2022 23:15:02 +0000
Subject: [PATCH] SKIP UPGRADE BB template changes for new Loki Chart Refactor

---
 chart/templates/logging/fluentbit/values.yaml |  4 +-
 .../logging/loki/loki-helmrelease.yaml        |  4 +-
 chart/templates/logging/loki/values.yaml      | 42 +++++++--------
 chart/templates/logging/promtail/values.yaml  |  2 +-
 chart/templates/monitoring/values.yaml        |  2 +-
 chart/values.yaml                             | 12 +++--
 tests/test-values.yaml                        | 54 +++++++++----------
 7 files changed, 59 insertions(+), 61 deletions(-)

diff --git a/chart/templates/logging/fluentbit/values.yaml b/chart/templates/logging/fluentbit/values.yaml
index 25436986a7..9d440931b1 100644
--- a/chart/templates/logging/fluentbit/values.yaml
+++ b/chart/templates/logging/fluentbit/values.yaml
@@ -70,7 +70,7 @@ config:
         match                  kube.*
         labels                 job=fluentbit, container=$kubernetes['container_name'], pod=$kubernetes['pod_name'], namespace=$kubernetes['namespace_name'], node_name=$kubernetes['host']
         {{- if eq .Values.loki.strategy "monolith" }}
-        host                   logging-loki
+        host                   loki
         {{- else }}
         host                   logging-loki-write
         {{- end }}
@@ -84,7 +84,7 @@ config:
         match                  host.*
         labels                 job=fluentbit, container=$kubernetes['container_name'], pod=$kubernetes['pod_name'], namespace=$kubernetes['namespace_name'], node_name=$kubernetes['host']
         {{- if eq .Values.loki.strategy "monolith" }}
-        host                   logging-loki
+        host                   loki
         {{- else }}
         host                   logging-loki-write
         {{- end }}
diff --git a/chart/templates/logging/loki/loki-helmrelease.yaml b/chart/templates/logging/loki/loki-helmrelease.yaml
index 038162f20e..5f9de64419 100644
--- a/chart/templates/logging/loki/loki-helmrelease.yaml
+++ b/chart/templates/logging/loki/loki-helmrelease.yaml
@@ -55,13 +55,11 @@ spec:
     - name: kyvernopolicies
       namespace: {{ .Release.Namespace }}
     {{- end }}
-    {{- if (eq .Values.loki.strategy "scalable") }}
     {{- with .Values.loki.objectStorage }}
-    {{- if not (and .endpoint .accessKey .accessSecret .bucketNames) }}
+    {{- if and (eq $.Values.loki.strategy "scalable") (not (and .endpoint .bucketNames)) }}
     - name: minio-operator
       namespace: {{ $.Release.Namespace }}
     {{- end }}
     {{- end }}
-    {{- end }}
   {{- end }}
 {{- end }}
diff --git a/chart/templates/logging/loki/values.yaml b/chart/templates/logging/loki/values.yaml
index 68380a37ac..6679732c1e 100644
--- a/chart/templates/logging/loki/values.yaml
+++ b/chart/templates/logging/loki/values.yaml
@@ -21,45 +21,45 @@ networkPolicies:
 
 monitoring:
   enabled: {{ .Values.monitoring.enabled }}
+{{- if (eq .Values.loki.strategy "scalable") }}
+  serviceMonitor:
+    enabled: {{ .Values.monitoring.enabled }}
+{{- end }}
 
 istio:
   enabled: {{ .Values.istio.enabled }} 
 
-{{- if (eq .Values.loki.strategy "scalable") }}
-global:
-  createGlobalConfig: true
-  existingSecretForConfig: loki-config
-
-  objectStorage:
-    endpoint: {{ .Values.loki.objectStorage.endpoint }}
-    region: {{ .Values.loki.objectStorage.region }}
-    bucketnames: {{ .Values.loki.objectStorage.bucketNames }}
-    access_key_id: {{ .Values.loki.objectStorage.accessKey }}
-    secret_access_key: {{ .Values.loki.objectStorage.accessSecret }}
+loki:
+  storage:
+    bucketNames:
+      {{- toYaml .Values.loki.objectStorage.bucketNames | nindent 6 }}
+    s3:
+      endpoint: {{ .Values.loki.objectStorage.endpoint }}
+      region: {{ .Values.loki.objectStorage.region }}
+      accessKeyId: {{ .Values.loki.objectStorage.accessKey }}
+      secretAccessKey: {{ .Values.loki.objectStorage.accessSecret }}
 
 {{- with .Values.loki.objectStorage }}
-{{- if not (and .endpoint .bucketNames .accessKey .accessSecret) }}
+{{- if and (eq $.Values.loki.strategy "scalable") (not (and .endpoint .region)) }}
 minio:
   enabled: true
 {{- end }}
 {{- end }}
-{{- end }}
 
 {{- if .Values.istio.enabled }}
 podAnnotations:
   {{ include "istioAnnotation" . }}
 {{- end }}
 
-loki:
+monolith:
   enabled: {{ eq .Values.loki.strategy "monolith" }}
   serviceMonitor:
     enabled: {{ .Values.monitoring.enabled }}
-
-loki-simple-scalable:
-  enabled: {{ eq .Values.loki.strategy "scalable" }}
-  imagePullSecrets:
-    - name: private-registry
-  serviceMonitor:
-    enabled: {{ .Values.monitoring.enabled }}
+{{- if (eq .Values.loki.strategy "monolith") }}
+read:
+  disabled: true
+write:
+  disabled: true
+{{- end }}
 
 {{- end -}}
diff --git a/chart/templates/logging/promtail/values.yaml b/chart/templates/logging/promtail/values.yaml
index 19d2ad97a0..71e612fe52 100644
--- a/chart/templates/logging/promtail/values.yaml
+++ b/chart/templates/logging/promtail/values.yaml
@@ -37,7 +37,7 @@ imagePullSecrets:
 config:
   clients:
     {{- if eq .Values.loki.strategy "monolith" }}
-    - url: http://logging-loki.logging.svc.cluster.local:3100/loki/api/v1/push
+    - url: http://loki.logging.svc.cluster.local:3100/loki/api/v1/push
     {{- else }}
     - url: http://logging-loki-write.logging.svc.cluster.local:3100/loki/api/v1/push
     {{- end }}
diff --git a/chart/templates/monitoring/values.yaml b/chart/templates/monitoring/values.yaml
index c135908cf1..390ba4a575 100644
--- a/chart/templates/monitoring/values.yaml
+++ b/chart/templates/monitoring/values.yaml
@@ -236,7 +236,7 @@ grafana:
   - name: Loki
     type: loki
     {{- if eq .Values.loki.strategy "monolith" }}
-    url: http://logging-loki.logging.svc.cluster.local:3100
+    url: http://loki.logging.svc.cluster.local:3100
     {{- else }}
     url: http://logging-loki-read.logging.svc.cluster.local:3100
     {{- end }}
diff --git a/chart/values.yaml b/chart/values.yaml
index 38a521a8ab..5cb8a0a532 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -509,7 +509,7 @@ loki:
   git:
     repo: https://repo1.dso.mil/platform-one/big-bang/apps/sandbox/loki.git
     path: "./chart"
-    tag: "3.0.5-bb.4"
+    tag: "1.7.6-bb.0"
 
   # -- Flux reconciliation overrides specifically for the Loki Package
   flux: {}
@@ -521,7 +521,7 @@ loki:
     # -- S3 compatible endpoint to use for connection information.
     # examples: "https://s3.amazonaws.com" "https://s3.us-gov-west-1.amazonaws.com" "http://minio.minio.svc.cluster.local:9000"
     endpoint: ""
-
+    
     # -- S3 compatible region to use for connection information.
     region: ""
 
@@ -532,9 +532,11 @@ loki:
     # Unencoded string data. This should be placed in the secret values and then encrypted
     accessSecret: ""
 
-    # -- Bucket Names for Loki as a comma delimited list.
-    # examples: "loki-logs"
-    bucketNames: ""
+    # -- Bucket Names for the Loki buckets as YAML
+    # chunks: loki-logs
+    # ruler: loki-ruler
+    # admin: loki-admin
+    bucketNames: {}
 
   # -- Values to passthrough to the Loki chart: https://repo1.dso.mil/platform-one/big-bang/apps/sandbox/loki.git
   values: {}
diff --git a/tests/test-values.yaml b/tests/test-values.yaml
index f5b10cfd57..115814f66b 100644
--- a/tests/test-values.yaml
+++ b/tests/test-values.yaml
@@ -170,7 +170,7 @@ gatekeeper:
           - jaeger/jaeger-operator-cypress-test
           - monitoring/kube-prometheus-stack-cypress-test
           - vault/vault-cypress-test
-          - logging/loki-cypress-test
+          - logging/loki-simple-scalable-cypress-test
           - twistlock/twistlock-cypress-test
           - sonarqube/sonarqube-cypress-test
           - logging/logging-cypress-test
@@ -271,7 +271,7 @@ gatekeeper:
           - jaeger/jaeger-operator-cypress-test
           - monitoring/kube-prometheus-stack-cypress-test
           - vault/vault-cypress-test
-          - logging/loki-cypress-test
+          - logging/loki-simple-scalable-cypress-test
           - twistlock/twistlock-cypress-test
           - sonarqube/sonarqube-cypress-test
           - logging/logging-cypress-test
@@ -569,32 +569,30 @@ loki:
   enabled: false
   strategy: scalable
   values:
-    global:
-      createGlobalConfig: true
-      existingSecretForConfig: "loki-config"
-    loki-simple-scalable:
-      write:
-        replicas: 1
-        persistence:
-          size: 2Gi
-        resources:
-          limits:
-            cpu: 200m
-            memory: 400Mi
-          requests:
-            cpu: 200m
-            memory: 400Mi
-      read:
-        replicas: 1
-        persistence:
-          size: 2Gi
-        resources:
-          limits:
-            cpu: 200m
-            memory: 400Mi
-          requests:
-            cpu: 200m
-            memory: 400Mi
+    minio:
+      enabled: true
+    write:
+      replicas: 1
+      persistence:
+        size: 2Gi
+      resources:
+        limits:
+          cpu: 200m
+          memory: 400Mi
+        requests:
+          cpu: 200m
+          memory: 400Mi
+    read:
+      replicas: 1
+      persistence:
+        size: 2Gi
+      resources:
+        limits:
+          cpu: 200m
+          memory: 400Mi
+        requests:
+          cpu: 200m
+          memory: 400Mi
     bbtests:
       enabled: true
       cypress:
-- 
GitLab