Skip to content

Commit

Permalink
Address review issues
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <[email protected]>
  • Loading branch information
kakkoyun committed Nov 18, 2020
1 parent 809eca9 commit be0eed0
Show file tree
Hide file tree
Showing 14 changed files with 388 additions and 363 deletions.
53 changes: 24 additions & 29 deletions all.jsonnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local h = import 'kube-thanos/helpers.libsonnet';
local t = import 'kube-thanos/thanos.libsonnet';

// THIS IS MERELY AN EXAMPLE MEANT TO SHOW HOW TO USE ALL COMPONENTS!
Expand Down Expand Up @@ -113,11 +112,9 @@ local q = t.query(commonConfig {
logLevel: 'debug',
});

local finalRu = ru {
config+:: {
queriers: ['dnssrv+_http._tcp.%s.%s.svc.cluster.local' % [q.service.metadata.name, q.service.metadata.namespace]],
},
};
local finalRu = t.rule(ru.config {
queriers: ['dnssrv+_http._tcp.%s.%s.svc.cluster.local' % [q.service.metadata.name, q.service.metadata.namespace]],
});

local qf = t.queryFrontend(commonConfig {
replicas: 1,
Expand Down Expand Up @@ -150,25 +147,25 @@ local qf = t.queryFrontend(commonConfig {
},
});

local hashrings = [
{
hashring: 'default',
tenants: [],
},
{
hashring: 'region-1',
tenants: [],
},
];

local rcvs = h.receiveHashrings(hashrings, commonConfig {
local rcvs = t.receiveHashrings(commonConfig {
hashrings: [
{
hashring: 'default',
tenants: [],
},
{
hashring: 'region-1',
tenants: [],
},
],
replicas: 1,
replicationFactor: 1,
serviceMonitor: true,
hashringConfigMapName: 'hashring',
});

local strs = h.storeShards(3, commonConfig {
local strs = t.storeShards(commonConfig {
shards: 3,
replicas: 1,
serviceMonitor: true,
bucketCache: {
Expand All @@ -191,16 +188,14 @@ local strs = h.storeShards(3, commonConfig {
},
});

local finalQ = q {
config+:: {
stores: [
'dnssrv+_grpc._tcp.%s.%s.svc.cluster.local' % [service.metadata.name, service.metadata.namespace]
for service in [re.service, ru.service, s.service] +
[rcvs[hashring].service for hashring in std.objectFields(rcvs)] +
[strs[shard].service for shard in std.objectFields(strs)]
],
},
};
local finalQ = t.query(q.config {
stores: [
'dnssrv+_grpc._tcp.%s.%s.svc.cluster.local' % [service.metadata.name, service.metadata.namespace]
for service in [re.service, ru.service, s.service] +
[rcvs[hashring].service for hashring in std.objectFields(rcvs)] +
[strs[shard].service for shard in std.objectFields(strs)]
],
});

{ ['thanos-bucket-' + name]: b[name] for name in std.objectFields(b) } +
{ ['thanos-compact-' + name]: c[name] for name in std.objectFields(c) } +
Expand Down
78 changes: 0 additions & 78 deletions jsonnet/kube-thanos/helpers.libsonnet

This file was deleted.

46 changes: 24 additions & 22 deletions jsonnet/kube-thanos/kube-thanos-bucket.libsonnet
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// These are the defaults for this components configuration.
// When calling the function to generate the component's manifest,
// you can pass an object structured like the default to overwrite default values.
local defaults = {
local defaults = self,
name: 'thanos-bucket',
Expand Down Expand Up @@ -35,30 +38,29 @@ function(params) {
assert std.isNumber(tb.config.replicas) && tb.config.replicas >= 0 : 'thanos bucket replicas has to be number >= 0',
assert std.isObject(tb.config.resources),

service:
{
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: tb.config.name,
namespace: tb.config.namespace,
labels: tb.config.commonLabels,
},
spec: {
ports: [
{
assert std.isString(name),
assert std.isNumber(tb.config.ports[name]),
service: {
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: tb.config.name,
namespace: tb.config.namespace,
labels: tb.config.commonLabels,
},
spec: {
ports: [
{
assert std.isString(name),
assert std.isNumber(tb.config.ports[name]),

name: name,
port: tb.config.ports[name],
targetPort: tb.config.ports[name],
}
for name in std.objectFields(tb.config.ports)
],
selector: tb.config.podLabelSelector,
},
name: name,
port: tb.config.ports[name],
targetPort: tb.config.ports[name],
}
for name in std.objectFields(tb.config.ports)
],
selector: tb.config.podLabelSelector,
},
},

deployment:
local container = {
Expand Down
46 changes: 24 additions & 22 deletions jsonnet/kube-thanos/kube-thanos-compact.libsonnet
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// These are the defaults for this components configuration.
// When calling the function to generate the component's manifest,
// you can pass an object structured like the default to overwrite default values.
local defaults = {
local defaults = self,
name: 'thanos-compact',
Expand Down Expand Up @@ -46,30 +49,29 @@ function(params) {
assert std.isBoolean(tc.config.serviceMonitor),
assert std.isArray(tc.config.deduplicationReplicaLabels),

service:
{
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: tc.config.name,
namespace: tc.config.namespace,
labels: tc.config.commonLabels,
},
spec: {
selector: tc.config.podLabelSelector,
ports: [
{
assert std.isString(name),
assert std.isNumber(tc.config.ports[name]),
service: {
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: tc.config.name,
namespace: tc.config.namespace,
labels: tc.config.commonLabels,
},
spec: {
selector: tc.config.podLabelSelector,
ports: [
{
assert std.isString(name),
assert std.isNumber(tc.config.ports[name]),

name: name,
port: tc.config.ports[name],
targetPort: tc.config.ports[name],
}
for name in std.objectFields(tc.config.ports)
],
},
name: name,
port: tc.config.ports[name],
targetPort: tc.config.ports[name],
}
for name in std.objectFields(tc.config.ports)
],
},
},

statefulSet:
local c = {
Expand Down
1 change: 0 additions & 1 deletion jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,4 @@ function(params) {
],
},
},

}
43 changes: 21 additions & 22 deletions jsonnet/kube-thanos/kube-thanos-query.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,29 @@ function(params) {
assert std.isString(tq.config.queryTimeout),
assert std.isBoolean(tq.config.serviceMonitor),

service:
{
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: tq.config.name,
namespace: tq.config.namespace,
labels: tq.config.commonLabels,
},
spec: {
ports: [
{
assert std.isString(name),
assert std.isNumber(tq.config.ports[name]),
service: {
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: tq.config.name,
namespace: tq.config.namespace,
labels: tq.config.commonLabels,
},
spec: {
ports: [
{
assert std.isString(name),
assert std.isNumber(tq.config.ports[name]),

name: name,
port: tq.config.ports[name],
targetPort: tq.config.ports[name],
}
for name in std.objectFields(tq.config.ports)
],
selector: tq.config.podLabelSelector,
},
name: name,
port: tq.config.ports[name],
targetPort: tq.config.ports[name],
}
for name in std.objectFields(tq.config.ports)
],
selector: tq.config.podLabelSelector,
},
},

deployment:
local c = {
Expand Down
39 changes: 39 additions & 0 deletions jsonnet/kube-thanos/kube-thanos-receive-default-params.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// These are the defaults for this components configuration.
// When calling the function to generate the component's manifest,
// you can pass an object structured like the default to overwrite default values.
{
local defaults = self,
name: 'thanos-receive',
namespace: error 'must provide namespace',
version: error 'must provide version',
image: error 'must provide image',
replicas: error 'must provide replicas',
replicationFactor: error 'must provide replication factor',
objectStorageConfig: error 'must provide objectStorageConfig',
podDisruptionBudgetMaxUnavailable: (std.floor(defaults.replicationFactor / 2)),
hashringConfigMapName: '',
volumeClaimTemplate: {},
retention: '15d',
logLevel: 'info',
resources: {},
serviceMonitor: false,
ports: {
grpc: 10901,
http: 10902,
'remote-write': 19291,
},
tracing: {},

commonLabels:: {
'app.kubernetes.io/name': 'thanos-receive',
'app.kubernetes.io/instance': defaults.name,
'app.kubernetes.io/version': defaults.version,
'app.kubernetes.io/component': 'database-write-hashring',
},

podLabelSelector:: {
[labelName]: defaults.commonLabels[labelName]
for labelName in std.objectFields(defaults.commonLabels)
if !std.setMember(labelName, ['app.kubernetes.io/version'])
},
}
Loading

0 comments on commit be0eed0

Please sign in to comment.