From 39bbd733be4a0d430986d9513476a91334485e9f Mon Sep 17 00:00:00 2001
From: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>
Date: Mon, 27 May 2019 18:55:18 +0530
Subject: [PATCH] ksonnet changes for running loki in single binary (#622)

* ksonnet changes for running loki in single bianry
Added retention config with default values

* Fixed indentation
---
 cmd/loki/loki-local-config.yaml               | 15 ++++++++++
 production/helm/loki-stack/Chart.yaml         |  2 +-
 production/helm/loki/Chart.yaml               |  2 +-
 production/helm/loki/values.yaml              |  3 ++
 production/ksonnet/loki/config.libsonnet      | 18 ++++++++++++
 production/ksonnet/loki/images.libsonnet      |  4 +--
 .../ksonnet/loki/table-manager.libsonnet      | 28 ++++---------------
 7 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/cmd/loki/loki-local-config.yaml b/cmd/loki/loki-local-config.yaml
index 523a854b..4e6978c4 100644
--- a/cmd/loki/loki-local-config.yaml
+++ b/cmd/loki/loki-local-config.yaml
@@ -34,3 +34,18 @@ limits_config:
 
 chunk_store_config:
   max_look_back_period: 0
+
+table_manager:
+  chunk_tables_provisioning:
+    inactive_read_throughput: 0
+    inactive_write_throughput: 0
+    provisioned_read_throughput: 0
+    provisioned_write_throughput: 0
+  index_tables_provisioning:
+    inactive_read_throughput: 0
+    inactive_write_throughput: 0
+    provisioned_read_throughput: 0
+    provisioned_write_throughput: 0
+  retention_deletes_enabled: false
+  retention_period: 0
+
diff --git a/production/helm/loki-stack/Chart.yaml b/production/helm/loki-stack/Chart.yaml
index 750056bc..1f5b6949 100644
--- a/production/helm/loki-stack/Chart.yaml
+++ b/production/helm/loki-stack/Chart.yaml
@@ -1,5 +1,5 @@
 name: loki-stack
-version: 0.9.4
+version: 0.9.5
 appVersion: 0.0.1
 kubeVersion: "^1.10.0-0"
 description: "Loki: like Prometheus, but for logs."
diff --git a/production/helm/loki/Chart.yaml b/production/helm/loki/Chart.yaml
index a19a9805..13795ee0 100644
--- a/production/helm/loki/Chart.yaml
+++ b/production/helm/loki/Chart.yaml
@@ -1,5 +1,5 @@
 name: loki
-version: 0.8.3
+version: 0.8.4
 appVersion: 0.0.1
 kubeVersion: "^1.10.0-0"
 description: "Loki: like Prometheus, but for logs."
diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml
index 1cbfff55..55eed627 100644
--- a/production/helm/loki/values.yaml
+++ b/production/helm/loki/values.yaml
@@ -59,6 +59,9 @@ config:
       directory: /data/loki/chunks
   chunk_store_config:
     max_look_back_period: 0
+  table_manager:
+    retention_deletes_enabled: false
+    retention_period: 0
 
 deploymentStrategy: RollingUpdate
 
diff --git a/production/ksonnet/loki/config.libsonnet b/production/ksonnet/loki/config.libsonnet
index 8960bc4e..b1dd463c 100644
--- a/production/ksonnet/loki/config.libsonnet
+++ b/production/ksonnet/loki/config.libsonnet
@@ -108,6 +108,7 @@
             service: 'memcached-client',
           },
         },
+        max_look_back_period: 0,
       },
 
       schema_config: {
@@ -122,6 +123,23 @@
           },
         }],
       },
+
+      table_manager: {
+        retention_period: 0,
+        retention_deletes_enabled: false,
+        index_tables_provisioning: {
+          inactive_read_throughput: 0,
+          inactive_write_throughput: 0,
+          provisioned_read_throughput: 0,
+          provisioned_write_throughput: 0,
+        },
+        chunk_tables_provisioning: {
+          inactive_read_throughput: 0,
+          inactive_write_throughput: 0,
+          provisioned_read_throughput: 0,
+          provisioned_write_throughput: 0,
+        },
+      },
     },
   },
 
diff --git a/production/ksonnet/loki/images.libsonnet b/production/ksonnet/loki/images.libsonnet
index 4f9f9250..a33db7e6 100644
--- a/production/ksonnet/loki/images.libsonnet
+++ b/production/ksonnet/loki/images.libsonnet
@@ -4,13 +4,11 @@
     memcached: 'memcached:1.5.6-alpine',
     memcachedExporter: 'prom/memcached-exporter:v0.4.1',
 
-    // Our services.
-    tableManager: 'grafana/cortex-table-manager:r56-bd83f04a',
-
     loki: 'grafana/loki:latest',
 
     distributor: self.loki,
     ingester: self.loki,
     querier: self.loki,
+    tableManager: self.loki,
   },
 }
diff --git a/production/ksonnet/loki/table-manager.libsonnet b/production/ksonnet/loki/table-manager.libsonnet
index cef85e9d..51c41c14 100644
--- a/production/ksonnet/loki/table-manager.libsonnet
+++ b/production/ksonnet/loki/table-manager.libsonnet
@@ -1,27 +1,9 @@
 {
   local container = $.core.v1.container,
 
-  table_manager_args:: {
-    'bigtable.project': $._config.bigtable_project,
-    'bigtable.instance': $._config.bigtable_instance,
-    'chunk.storage-client': $._config.storage_backend,
-
-    'dynamodb.original-table-name': '%s_index' % $._config.table_prefix,
-    'dynamodb.use-periodic-tables': true,
-    'dynamodb.periodic-table.prefix': '%s_index_' % $._config.table_prefix,
-    'dynamodb.chunk-table.prefix': '%s_chunks_' % $._config.table_prefix,
-    'dynamodb.periodic-table.from': $._config.schema_start_date,
-    'dynamodb.chunk-table.from': $._config.schema_start_date,
-    'dynamodb.v9-schema-from': $._config.schema_start_date,
-    // Cassandra / BigTable doesn't use these fields, so set them to zero
-    'dynamodb.chunk-table.inactive-read-throughput': 0,
-    'dynamodb.chunk-table.inactive-write-throughput': 0,
-    'dynamodb.chunk-table.read-throughput': 0,
-    'dynamodb.chunk-table.write-throughput': 0,
-    'dynamodb.periodic-table.inactive-read-throughput': 0,
-    'dynamodb.periodic-table.inactive-write-throughput': 0,
-    'dynamodb.periodic-table.read-throughput': 0,
-    'dynamodb.periodic-table.write-throughput': 0,
+  table_manager_args::
+  $._config.commonArgs {
+    target: 'table-manager',
   },
 
   table_manager_container::
@@ -34,7 +16,9 @@
   local deployment = $.apps.v1beta1.deployment,
 
   table_manager_deployment:
-    deployment.new('table-manager', 1, [$.table_manager_container]),
+    deployment.new('table-manager', 1, [$.table_manager_container]) +
+    $.config_hash_mixin +
+    $.util.configVolumeMount('loki', '/etc/loki'),
 
   table_manager_service:
     $.util.serviceFor($.table_manager_deployment),
-- 
GitLab