Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING Change] Single ServiceMonitor for store shards #188

Merged
merged 1 commit into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ We use *breaking* word for marking changes that are not backward compatible (rel

### Changed

-
- [#188](https://github.com/thanos-io/kube-thanos/pull/188) Single ServiceMonitor for store shards

### Added

-

### Fixed

- [#185](https://github.com/thanos-io/kube-thanos/pull/185)A query-frontend, store: make cache types case insensitive
- [#185](https://github.com/thanos-io/kube-thanos/pull/185) query-frontend, store: make cache types case insensitive

## [v0.17.0](https://github.com/thanos-io/kube-thanos/tree/v0.17.0) (2020-12-08)

Expand Down
13 changes: 8 additions & 5 deletions all.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ local finalQ = t.query(q.config {
'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)]
[strs.shards[shard].service for shard in std.objectFields(strs.shards)]
],
});

Expand All @@ -211,8 +211,11 @@ local finalQ = t.query(q.config {
if rcvs[hashring][name] != null
} +
{
['store-' + shard + '-' + name]: strs[shard][name]
for shard in std.objectFields(strs)
for name in std.objectFields(strs[shard])
if strs[shard][name] != null
['store-' + shard + '-' + name]: strs.shards[shard][name]
for shard in std.objectFields(strs.shards)
for name in std.objectFields(strs.shards[shard])
if strs.shards[shard][name] != null
} +
{
'store-shards-serviceMonitor': strs.serviceMonitor,
}
26 changes: 0 additions & 26 deletions examples/all/manifests/store-shard1-serviceMonitor.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions examples/all/manifests/store-shard2-serviceMonitor.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ kind: ServiceMonitor
metadata:
labels:
app.kubernetes.io/component: object-store-gateway
app.kubernetes.io/instance: thanos-store-0
app.kubernetes.io/instance: thanos-store
app.kubernetes.io/name: thanos-store
app.kubernetes.io/version: v0.17.2
store.observatorium.io/shard: shard-0
name: thanos-store-0
name: thanos-store
namespace: thanos
spec:
endpoints:
Expand All @@ -18,9 +17,12 @@ spec:
- namespace
- pod
targetLabel: instance
- regex: shard\-(\d+)
replacement: $1
sourceLabels:
- __meta_kubernetes_service_label_store_observatorium_io_shard
targetLabel: shard
selector:
matchLabels:
app.kubernetes.io/component: object-store-gateway
app.kubernetes.io/instance: thanos-store-0
app.kubernetes.io/name: thanos-store
store.observatorium.io/shard: shard-0
95 changes: 68 additions & 27 deletions jsonnet/kube-thanos/kube-thanos-store-shards.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,76 @@ function(params)
assert std.isNumber(config.shards) && config.shards >= 0 : 'thanos store shards has to be number >= 0';

{ config:: config } + {
['shard' + i]: store(config {
name+: '-%d' % i,
commonLabels+:: { 'store.observatorium.io/shard': 'shard-' + i },
}) {
statefulSet+: {
spec+: {
template+: {
spec+: {
containers: [
if c.name == 'thanos-store' then c {
args+: [
|||
--selector.relabel-config=
- action: hashmod
source_labels: ["__block_id"]
target_label: shard
modulus: %d
- action: keep
source_labels: ["shard"]
regex: %d
||| % [config.shards, i],
],
} else c
for c in super.containers
],
shards: {
kakkoyun marked this conversation as resolved.
Show resolved Hide resolved
['shard' + i]: store(config {
name+: '-%d' % i,
commonLabels+:: { 'store.observatorium.io/shard': 'shard-' + i },
}) {
statefulSet+: {
spec+: {
template+: {
spec+: {
containers: [
if c.name == 'thanos-store' then c {
args+: [
|||
--selector.relabel-config=
- action: hashmod
source_labels: ["__block_id"]
target_label: shard
modulus: %d
- action: keep
source_labels: ["shard"]
regex: %d
||| % [config.shards, i],
],
} else c
for c in super.containers
],
},
},
},
},

serviceMonitor: null,
}
for i in std.range(0, config.shards - 1)
},
} + {
serviceMonitor: if config.serviceMonitor == true then {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'ServiceMonitor',
metadata+: {
name: config.name,
namespace: config.namespace,
labels: config.commonLabels,
},
spec: {
selector: {
matchLabels: {
[key]: config.podLabelSelector[key]
for key in std.objectFields(config.podLabelSelector)
if key != 'app.kubernetes.io/instance'
},
},
endpoints: [
{
port: 'http',
relabelings: [
{
sourceLabels: ['namespace', 'pod'],
separator: '/',
targetLabel: 'instance',
},
{
sourceLabels: ['__meta_kubernetes_service_label_store_observatorium_io_shard'],
regex: 'shard\\-(\\d+)',
replacement: '$1',
targetLabel: 'shard',
},
],
},
],
},
}
for i in std.range(0, config.shards - 1)
},
}