-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*: Refactor to not mutate global objects
Signed-off-by: Frederic Branczyk <[email protected]>
- Loading branch information
Showing
54 changed files
with
1,775 additions
and
1,154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,88 @@ | ||
local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; | ||
local sts = k.apps.v1.statefulSet; | ||
local deployment = k.apps.v1.deployment; | ||
local t = (import 'kube-thanos/thanos.libsonnet'); | ||
|
||
local kt = | ||
(import 'kube-thanos/kube-thanos-compactor.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-querier.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-store.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-store-pvc.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-receive.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-receive-pvc.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-sidecar.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-servicemonitors.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-bucket.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-ruler.libsonnet') + | ||
{ | ||
thanos+:: { | ||
// This is just an example image, set what you need | ||
image:: 'quay.io/thanos/thanos:v0.9.0', | ||
objectStorageConfig+:: { | ||
name: 'thanos-objectstorage', | ||
key: 'thanos.yaml', | ||
}, | ||
|
||
querier+: { | ||
replicas:: 3, | ||
}, | ||
store+: { | ||
replicas:: 1, | ||
pvc+:: { | ||
size: '50Gi', | ||
}, | ||
}, | ||
receive+: { | ||
replicas:: 3, | ||
pvc+:: { | ||
size: '50Gi', | ||
local commonConfig = { | ||
config+:: { | ||
local cfg = self, | ||
namespace: 'thanos', | ||
version: 'v0.10.1', | ||
image: 'quay.io/thanos/thanos:' + cfg.version, | ||
objectStorageConfig: { | ||
name: 'thanos-objectstorage', | ||
key: 'thanos.yaml', | ||
}, | ||
volumeClaimTemplate: { | ||
spec: { | ||
accessModes: ['ReadWriteOnce'], | ||
resources: { | ||
requests: { | ||
storage: '10Gi', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
{ ['thanos-compactor-' + name]: kt.thanos.compactor[name] for name in std.objectFields(kt.thanos.compactor) } + | ||
{ ['thanos-querier-' + name]: kt.thanos.querier[name] for name in std.objectFields(kt.thanos.querier) } + | ||
{ ['thanos-receive-' + name]: kt.thanos.receive[name] for name in std.objectFields(kt.thanos.receive) } + | ||
{ ['thanos-bucket-' + name]: kt.thanos.bucket[name] for name in std.objectFields(kt.thanos.bucket) } + | ||
{ ['thanos-store-' + name]: kt.thanos.store[name] for name in std.objectFields(kt.thanos.store) } + | ||
{ ['thanos-ruler-' + name]: kt.thanos.ruler[name] for name in std.objectFields(kt.thanos.ruler) } | ||
}, | ||
}; | ||
|
||
local b = t.bucket + commonConfig + { | ||
config+:: { | ||
name: 'thanos-bucket', | ||
replicas: 1, | ||
}, | ||
}; | ||
|
||
local c = t.compact + t.compact.withVolumeClaimTemplate + t.compact.withServiceMonitor + commonConfig + { | ||
config+:: { | ||
name: 'thanos-compact', | ||
replicas: 1, | ||
}, | ||
}; | ||
|
||
local re = t.receive + t.receive.withVolumeClaimTemplate + t.receive.withServiceMonitor + commonConfig + { | ||
config+:: { | ||
name: 'thanos-receive', | ||
replicas: 1, | ||
replicationFactor: 1, | ||
}, | ||
}; | ||
|
||
local ru = t.rule + t.rule.withVolumeClaimTemplate + t.rule.withServiceMonitor + commonConfig + { | ||
config+:: { | ||
name: 'thanos-rule', | ||
replicas: 1, | ||
}, | ||
}; | ||
|
||
local s = t.store + t.store.withVolumeClaimTemplate + t.store.withServiceMonitor + commonConfig + { | ||
config+:: { | ||
name: 'thanos-store', | ||
replicas: 1, | ||
}, | ||
}; | ||
|
||
local q = t.query + t.query.withServiceMonitor + commonConfig + { | ||
config+:: { | ||
name: 'thanos-query', | ||
replicas: 1, | ||
stores: [ | ||
'dnssrv+_grpc._tcp.%s.%s.svc.cluster.local' % [service.metadata.name, service.metadata.namespace] | ||
for service in [re.service, ru.service, s.service] | ||
], | ||
replicaLabels: ['prometheus_replica', 'rule_replica'], | ||
}, | ||
}; | ||
|
||
local finalRu = ru { | ||
config+:: { | ||
queriers: ['dnssrv+_http._tcp.%s.%s.svc.cluster.local' % [q.service.metadata.name, q.service.metadata.namespace]], | ||
}, | ||
}; | ||
|
||
{ ['thanos-bucket-' + name]: b[name] for name in std.objectFields(b) } + | ||
{ ['thanos-compact-' + name]: c[name] for name in std.objectFields(c) } + | ||
{ ['thanos-receive-' + name]: re[name] for name in std.objectFields(re) } + | ||
{ ['thanos-rule-' + name]: finalRu[name] for name in std.objectFields(finalRu) } + | ||
{ ['thanos-store-' + name]: s[name] for name in std.objectFields(s) } + | ||
{ ['thanos-query-' + name]: q[name] for name in std.objectFields(q) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,88 @@ | ||
local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; | ||
local sts = k.apps.v1.statefulSet; | ||
local deployment = k.apps.v1.deployment; | ||
local t = (import 'kube-thanos/thanos.libsonnet'); | ||
|
||
local kt = | ||
(import 'kube-thanos/kube-thanos-querier.libsonnet') + | ||
(import 'kube-thanos/kube-thanos-store.libsonnet') + | ||
// (import 'kube-thanos/kube-thanos-pvc.libsonnet') + // Uncomment this line to enable PVCs | ||
// (import 'kube-thanos/kube-thanos-receive.libsonnet') + | ||
// (import 'kube-thanos/kube-thanos-sidecar.libsonnet') + | ||
// (import 'kube-thanos/kube-thanos-servicemonitors.libsonnet') + | ||
{ | ||
thanos+:: { | ||
// This is just an example image, set what you need | ||
image:: 'quay.io/thanos/thanos:v0.9.0', | ||
objectStorageConfig+:: { | ||
name: 'thanos-objectstorage', | ||
key: 'thanos.yaml', | ||
}, | ||
|
||
querier+: { | ||
replicas:: 3, | ||
}, | ||
store+: { | ||
replicas:: 1, | ||
local commonConfig = { | ||
config+:: { | ||
local cfg = self, | ||
namespace: 'thanos', | ||
version: 'v0.10.1', | ||
image: 'quay.io/thanos/thanos:' + cfg.version, | ||
objectStorageConfig: { | ||
name: 'thanos-objectstorage', | ||
key: 'thanos.yaml', | ||
}, | ||
volumeClaimTemplate: { | ||
spec: { | ||
accessModes: ['ReadWriteOnce'], | ||
resources: { | ||
requests: { | ||
storage: '10Gi', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}, | ||
}; | ||
|
||
//local b = t.bucket + commonConfig + { | ||
// config+:: { | ||
// name: 'thanos-bucket', | ||
// replicas: 1, | ||
// }, | ||
//}; | ||
// | ||
//local c = t.compact + t.compact.withVolumeClaimTemplate + t.compact.withServiceMonitor + commonConfig + { | ||
// config+:: { | ||
// name: 'thanos-compact', | ||
// replicas: 1, | ||
// }, | ||
//}; | ||
// | ||
//local re = t.receive + t.receive.withVolumeClaimTemplate + t.receive.withServiceMonitor + commonConfig + { | ||
// config+:: { | ||
// name: 'thanos-receive', | ||
// replicas: 1, | ||
// replicationFactor: 1, | ||
// }, | ||
//}; | ||
// | ||
//local ru = t.rule + t.rule.withVolumeClaimTemplate + t.rule.withServiceMonitor + commonConfig + { | ||
// config+:: { | ||
// name: 'thanos-rule', | ||
// replicas: 1, | ||
// }, | ||
//}; | ||
|
||
{ ['thanos-querier-' + name]: kt.thanos.querier[name] for name in std.objectFields(kt.thanos.querier) } + | ||
{ ['thanos-store-' + name]: kt.thanos.store[name] for name in std.objectFields(kt.thanos.store) } | ||
// { ['thanos-receive-' + name]: kt.thanos.receive[name] for name in std.objectFields(kt.thanos.receive) } | ||
local s = t.store + t.store.withVolumeClaimTemplate + t.store.withServiceMonitor + commonConfig + { | ||
config+:: { | ||
name: 'thanos-store', | ||
replicas: 1, | ||
}, | ||
}; | ||
|
||
local q = t.query + t.query.withServiceMonitor + commonConfig + { | ||
config+:: { | ||
name: 'thanos-query', | ||
replicas: 1, | ||
stores: [ | ||
'dnssrv+_grpc._tcp.%s.%s.svc.cluster.local' % [service.metadata.name, service.metadata.namespace] | ||
for service in [s.service] | ||
], | ||
replicaLabels: ['prometheus_replica', 'rule_replica'], | ||
}, | ||
}; | ||
|
||
//local finalRu = ru { | ||
// config+:: { | ||
// queriers: ['dnssrv+_http._tcp.%s.%s.svc.cluster.local' % [q.service.metadata.name, q.service.metadata.namespace]], | ||
// }, | ||
//}; | ||
|
||
//{ ['thanos-bucket-' + name]: b[name] for name in std.objectFields(b) } + | ||
//{ ['thanos-compact-' + name]: c[name] for name in std.objectFields(c) } + | ||
//{ ['thanos-receive-' + name]: re[name] for name in std.objectFields(re) } + | ||
//{ ['thanos-rule-' + name]: finalRu[name] for name in std.objectFields(finalRu) } + | ||
{ ['thanos-store-' + name]: s[name] for name in std.objectFields(s) } + | ||
{ ['thanos-query-' + name]: q[name] for name in std.objectFields(q) } |
Oops, something went wrong.