From 00a6a01dc5fa8b3a0bbd887c20e79e1d0327fe13 Mon Sep 17 00:00:00 2001 From: Michal Wasilewski Date: Mon, 27 Sep 2021 16:59:02 +0200 Subject: [PATCH 1/4] formatting in thanos-store Signed-off-by: Michal Wasilewski --- jsonnet/kube-thanos/kube-thanos-store.libsonnet | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jsonnet/kube-thanos/kube-thanos-store.libsonnet b/jsonnet/kube-thanos/kube-thanos-store.libsonnet index fbff3768..1846df8e 100644 --- a/jsonnet/kube-thanos/kube-thanos-store.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-store.libsonnet @@ -99,10 +99,15 @@ function(params) { ] else [] ), env: [ - { name: 'OBJSTORE_CONFIG', valueFrom: { secretKeyRef: { - key: ts.config.objectStorageConfig.key, - name: ts.config.objectStorageConfig.name, - } } }, + { + name: 'OBJSTORE_CONFIG', + valueFrom: { + secretKeyRef: { + key: ts.config.objectStorageConfig.key, + name: ts.config.objectStorageConfig.name, + }, + }, + }, { // Inject the host IP to make configuring tracing convenient. name: 'HOST_IP_ADDRESS', From 29f0836c466156d4ae6996cc7051de4bbe66860d Mon Sep 17 00:00:00 2001 From: Michal Wasilewski Date: Mon, 27 Sep 2021 17:16:47 +0200 Subject: [PATCH 2/4] add extraEnv config option to all components in kube-thanos Signed-off-by: Michal Wasilewski --- jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet | 7 ++++++- jsonnet/kube-thanos/kube-thanos-bucket.libsonnet | 7 ++++++- .../kube-thanos-compact-default-params.libsonnet | 1 + jsonnet/kube-thanos/kube-thanos-compact.libsonnet | 6 +++++- jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet | 7 ++++++- jsonnet/kube-thanos/kube-thanos-query.libsonnet | 7 ++++++- .../kube-thanos-receive-default-params.libsonnet | 1 + jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet | 6 +++++- jsonnet/kube-thanos/kube-thanos-receive.libsonnet | 4 ++++ jsonnet/kube-thanos/kube-thanos-rule.libsonnet | 7 ++++++- .../kube-thanos/kube-thanos-store-default-params.libsonnet | 1 + jsonnet/kube-thanos/kube-thanos-store.libsonnet | 6 +++++- 12 files changed, 52 insertions(+), 8 deletions(-) diff --git a/jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet b/jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet index 3c05c9ce..acb84a2f 100644 --- a/jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet @@ -20,6 +20,7 @@ local defaults = { maxTime: '', compactionLevels: [], resolutions: [], + extraEnv: [], commonLabels:: { 'app.kubernetes.io/name': 'thanos-bucket-replicate', @@ -138,7 +139,11 @@ function(params) { }, }, }, - ], + ] + ( + if std.length(tbr.config.extraEnv) > 0 then [ + tbr.config.extraEnv, + ] else [] + ), ports: [ { name: name, containerPort: tbr.config.ports[name] } for name in std.objectFields(tbr.config.ports) diff --git a/jsonnet/kube-thanos/kube-thanos-bucket.libsonnet b/jsonnet/kube-thanos/kube-thanos-bucket.libsonnet index 600b036a..e114f01d 100644 --- a/jsonnet/kube-thanos/kube-thanos-bucket.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-bucket.libsonnet @@ -15,6 +15,7 @@ local defaults = { http: 10902, }, tracing: {}, + extraEnv: [], commonLabels:: { 'app.kubernetes.io/name': 'thanos-bucket', @@ -118,7 +119,11 @@ function(params) { }, }, }, - ], + ] + ( + if std.length(tb.config.extraEnv) > 0 then [ + tb.config.extraEnv, + ] else [] + ), ports: [ { name: name, containerPort: tb.config.ports[name] } for name in std.objectFields(tb.config.ports) diff --git a/jsonnet/kube-thanos/kube-thanos-compact-default-params.libsonnet b/jsonnet/kube-thanos/kube-thanos-compact-default-params.libsonnet index 07705727..6d7fbf9f 100644 --- a/jsonnet/kube-thanos/kube-thanos-compact-default-params.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-compact-default-params.libsonnet @@ -23,6 +23,7 @@ http: 10902, }, tracing: {}, + extraEnv: [], commonLabels:: { 'app.kubernetes.io/name': 'thanos-compact', diff --git a/jsonnet/kube-thanos/kube-thanos-compact.libsonnet b/jsonnet/kube-thanos/kube-thanos-compact.libsonnet index 78c7e0ef..688ce2cf 100644 --- a/jsonnet/kube-thanos/kube-thanos-compact.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-compact.libsonnet @@ -93,7 +93,11 @@ function(params) { }, }, }, - ], + ] + ( + if std.length(tc.config.extraEnv) > 0 then [ + tc.config.extraEnv, + ] else [] + ), ports: [ { name: name, containerPort: tc.config.ports[name] } for name in std.objectFields(tc.config.ports) diff --git a/jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet b/jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet index be655e4f..e1a060f2 100644 --- a/jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet @@ -29,6 +29,7 @@ local defaults = { http: 9090, }, tracing: {}, + extraEnv: [], memcachedDefaults+:: { config+: { @@ -179,7 +180,11 @@ function(params) { }, }, }, - ], + ] + ( + if std.length(tqf.config.extraEnv) > 0 then [ + tqf.config.extraEnv, + ] else [] + ), ports: [ { name: name, containerPort: tqf.config.ports[name] } for name in std.objectFields(tqf.config.ports) diff --git a/jsonnet/kube-thanos/kube-thanos-query.libsonnet b/jsonnet/kube-thanos/kube-thanos-query.libsonnet index db1d3b87..1fe4d07b 100644 --- a/jsonnet/kube-thanos/kube-thanos-query.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-query.libsonnet @@ -24,6 +24,7 @@ local defaults = { logLevel: 'info', logFormat: 'logfmt', tracing: {}, + extraEnv: [], commonLabels:: { 'app.kubernetes.io/name': 'thanos-query', @@ -150,7 +151,11 @@ function(params) { }, }, }, - ], + ] + ( + if std.length(tq.config.extraEnv) > 0 then [ + tq.config.extraEnv, + ] else [] + ), ports: [ { name: port.name, containerPort: port.port } for port in tq.service.spec.ports diff --git a/jsonnet/kube-thanos/kube-thanos-receive-default-params.libsonnet b/jsonnet/kube-thanos/kube-thanos-receive-default-params.libsonnet index baa94506..200abd59 100644 --- a/jsonnet/kube-thanos/kube-thanos-receive-default-params.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-receive-default-params.libsonnet @@ -30,6 +30,7 @@ 'receive="true"', ], tenantLabelName: null, + extraEnv: [], commonLabels:: { 'app.kubernetes.io/name': 'thanos-receive', diff --git a/jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet b/jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet index cc65db6e..fd576bc5 100644 --- a/jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet @@ -111,7 +111,11 @@ function(params) { }, }, }, - ], + ] + ( + if std.length(tr.config.extraEnv) > 0 then [ + tr.config.extraEnv, + ] else [] + ), ports: [{ name: name, containerPort: tr.config.ports[name] } for name in std.objectFields(tr.config.ports)], volumeMounts: [{ name: 'hashring-config', mountPath: '/var/lib/thanos-receive' }], livenessProbe: { failureThreshold: 8, periodSeconds: 30, httpGet: { diff --git a/jsonnet/kube-thanos/kube-thanos-receive.libsonnet b/jsonnet/kube-thanos/kube-thanos-receive.libsonnet index 3ec6ccd7..b2d9289f 100644 --- a/jsonnet/kube-thanos/kube-thanos-receive.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-receive.libsonnet @@ -113,6 +113,10 @@ function(params) { name: tr.config.objectStorageConfig.name, } }, }] else [] + ) + ( + if std.length(tr.config.extraEnv) > 0 then [ + tr.config.extraEnv, + ] else [] ), ports: [ { name: name, containerPort: tr.config.ports[name] } diff --git a/jsonnet/kube-thanos/kube-thanos-rule.libsonnet b/jsonnet/kube-thanos/kube-thanos-rule.libsonnet index 50402844..d81e72b0 100644 --- a/jsonnet/kube-thanos/kube-thanos-rule.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-rule.libsonnet @@ -26,6 +26,7 @@ local defaults = { reloader: 9533, }, tracing: {}, + extraEnv: [], commonLabels:: { 'app.kubernetes.io/name': 'thanos-rule', @@ -146,7 +147,11 @@ function(params) { }, }, }, - ], + ] + ( + if std.length(tr.config.extraEnv) > 0 then [ + tr.config.extraEnv, + ] else [] + ), ports: [ { name: name, containerPort: tr.config.ports[name] } for name in std.objectFields(tr.config.ports) diff --git a/jsonnet/kube-thanos/kube-thanos-store-default-params.libsonnet b/jsonnet/kube-thanos/kube-thanos-store-default-params.libsonnet index caaa9046..b5fc7138 100644 --- a/jsonnet/kube-thanos/kube-thanos-store-default-params.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-store-default-params.libsonnet @@ -24,6 +24,7 @@ tracing: {}, minTime: '', maxTime: '', + extraEnv: [], memcachedDefaults+:: { config+: { diff --git a/jsonnet/kube-thanos/kube-thanos-store.libsonnet b/jsonnet/kube-thanos/kube-thanos-store.libsonnet index 1846df8e..75d133b2 100644 --- a/jsonnet/kube-thanos/kube-thanos-store.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-store.libsonnet @@ -117,7 +117,11 @@ function(params) { }, }, }, - ], + ] + ( + if std.length(ts.config.extraEnv) > 0 then [ + ts.config.extraEnv, + ] else [] + ), ports: [ { name: name, containerPort: ts.config.ports[name] } for name in std.objectFields(ts.config.ports) From db798a88e76335250cb84bdc6af1d167a61b183b Mon Sep 17 00:00:00 2001 From: Michal Wasilewski Date: Mon, 27 Sep 2021 17:23:55 +0200 Subject: [PATCH 3/4] changelog entry Signed-off-by: Michal Wasilewski --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb0eb029..4a60dcc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel - [#237](https://github.com/thanos-io/kube-thanos/pull/237) Add new bucket replicate component. - [#245](https://github.com/thanos-io/kube-thanos/pull/245) Support scraping config reloader sidecar for ruler. +- [#251](https://github.com/thanos-io/kube-thanos/pull/251) Add support for extraEnv (custom environment variables) to all components. ### Fixed From 536eaa8c99fc09acdac0ea1eafd6ed573f22f94c Mon Sep 17 00:00:00 2001 From: Michal Wasilewski Date: Mon, 27 Sep 2021 17:54:58 +0200 Subject: [PATCH 4/4] fix array concatenation broken due to an extra level of composition Signed-off-by: Michal Wasilewski --- jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet | 4 +--- jsonnet/kube-thanos/kube-thanos-bucket.libsonnet | 4 +--- jsonnet/kube-thanos/kube-thanos-compact.libsonnet | 4 +--- jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet | 4 +--- jsonnet/kube-thanos/kube-thanos-query.libsonnet | 4 +--- jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet | 4 +--- jsonnet/kube-thanos/kube-thanos-receive.libsonnet | 4 +--- jsonnet/kube-thanos/kube-thanos-rule.libsonnet | 4 +--- jsonnet/kube-thanos/kube-thanos-store.libsonnet | 4 +--- 9 files changed, 9 insertions(+), 27 deletions(-) diff --git a/jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet b/jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet index acb84a2f..50e84f1f 100644 --- a/jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-bucket-replicate.libsonnet @@ -140,9 +140,7 @@ function(params) { }, }, ] + ( - if std.length(tbr.config.extraEnv) > 0 then [ - tbr.config.extraEnv, - ] else [] + if std.length(tbr.config.extraEnv) > 0 then tbr.config.extraEnv else [] ), ports: [ { name: name, containerPort: tbr.config.ports[name] } diff --git a/jsonnet/kube-thanos/kube-thanos-bucket.libsonnet b/jsonnet/kube-thanos/kube-thanos-bucket.libsonnet index e114f01d..549176b2 100644 --- a/jsonnet/kube-thanos/kube-thanos-bucket.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-bucket.libsonnet @@ -120,9 +120,7 @@ function(params) { }, }, ] + ( - if std.length(tb.config.extraEnv) > 0 then [ - tb.config.extraEnv, - ] else [] + if std.length(tb.config.extraEnv) > 0 then tb.config.extraEnv else [] ), ports: [ { name: name, containerPort: tb.config.ports[name] } diff --git a/jsonnet/kube-thanos/kube-thanos-compact.libsonnet b/jsonnet/kube-thanos/kube-thanos-compact.libsonnet index 688ce2cf..cdc14b13 100644 --- a/jsonnet/kube-thanos/kube-thanos-compact.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-compact.libsonnet @@ -94,9 +94,7 @@ function(params) { }, }, ] + ( - if std.length(tc.config.extraEnv) > 0 then [ - tc.config.extraEnv, - ] else [] + if std.length(tc.config.extraEnv) > 0 then tc.config.extraEnv else [] ), ports: [ { name: name, containerPort: tc.config.ports[name] } diff --git a/jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet b/jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet index e1a060f2..9bcb4ae1 100644 --- a/jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet @@ -181,9 +181,7 @@ function(params) { }, }, ] + ( - if std.length(tqf.config.extraEnv) > 0 then [ - tqf.config.extraEnv, - ] else [] + if std.length(tqf.config.extraEnv) > 0 then tqf.config.extraEnv else [] ), ports: [ { name: name, containerPort: tqf.config.ports[name] } diff --git a/jsonnet/kube-thanos/kube-thanos-query.libsonnet b/jsonnet/kube-thanos/kube-thanos-query.libsonnet index 1fe4d07b..f00b9602 100644 --- a/jsonnet/kube-thanos/kube-thanos-query.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-query.libsonnet @@ -152,9 +152,7 @@ function(params) { }, }, ] + ( - if std.length(tq.config.extraEnv) > 0 then [ - tq.config.extraEnv, - ] else [] + if std.length(tq.config.extraEnv) > 0 then tq.config.extraEnv else [] ), ports: [ { name: port.name, containerPort: port.port } diff --git a/jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet b/jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet index fd576bc5..9a6edbd2 100644 --- a/jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-receive-router.libsonnet @@ -112,9 +112,7 @@ function(params) { }, }, ] + ( - if std.length(tr.config.extraEnv) > 0 then [ - tr.config.extraEnv, - ] else [] + if std.length(tr.config.extraEnv) > 0 then tr.config.extraEnv else [] ), ports: [{ name: name, containerPort: tr.config.ports[name] } for name in std.objectFields(tr.config.ports)], volumeMounts: [{ name: 'hashring-config', mountPath: '/var/lib/thanos-receive' }], diff --git a/jsonnet/kube-thanos/kube-thanos-receive.libsonnet b/jsonnet/kube-thanos/kube-thanos-receive.libsonnet index b2d9289f..eca57b4e 100644 --- a/jsonnet/kube-thanos/kube-thanos-receive.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-receive.libsonnet @@ -114,9 +114,7 @@ function(params) { } }, }] else [] ) + ( - if std.length(tr.config.extraEnv) > 0 then [ - tr.config.extraEnv, - ] else [] + if std.length(tr.config.extraEnv) > 0 then tr.config.extraEnv else [] ), ports: [ { name: name, containerPort: tr.config.ports[name] } diff --git a/jsonnet/kube-thanos/kube-thanos-rule.libsonnet b/jsonnet/kube-thanos/kube-thanos-rule.libsonnet index d81e72b0..b3fc6960 100644 --- a/jsonnet/kube-thanos/kube-thanos-rule.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-rule.libsonnet @@ -148,9 +148,7 @@ function(params) { }, }, ] + ( - if std.length(tr.config.extraEnv) > 0 then [ - tr.config.extraEnv, - ] else [] + if std.length(tr.config.extraEnv) > 0 then tr.config.extraEnv else [] ), ports: [ { name: name, containerPort: tr.config.ports[name] } diff --git a/jsonnet/kube-thanos/kube-thanos-store.libsonnet b/jsonnet/kube-thanos/kube-thanos-store.libsonnet index 75d133b2..d1d51368 100644 --- a/jsonnet/kube-thanos/kube-thanos-store.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-store.libsonnet @@ -118,9 +118,7 @@ function(params) { }, }, ] + ( - if std.length(ts.config.extraEnv) > 0 then [ - ts.config.extraEnv, - ] else [] + if std.length(ts.config.extraEnv) > 0 then ts.config.extraEnv else [] ), ports: [ { name: name, containerPort: ts.config.ports[name] }