Skip to content

Commit

Permalink
Merge pull request #119 from thanos-io/zone-spread
Browse files Browse the repository at this point in the history
receive: Use anti-affinity to spread across zones
  • Loading branch information
brancz authored Apr 30, 2020
2 parents a8b5b71 + 10eb55f commit 1eb4998
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ We use *breaking* word for marking changes that are not backward compatible (rel

- [#105](https://github.com/thanos-io/kube-thanos/pull/105) compactor, store: Add deduplication replica label flags and delete delay labels

- [#119](https://github.com/thanos-io/kube-thanos/pull/119) receive: Distribute receive instances across node zones via pod anti affinity (note: only available on 1.17+).

### Fixed

-
Expand Down
11 changes: 11 additions & 0 deletions examples/all/manifests/thanos-receive-statefulSet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ spec:
- thanos
topologyKey: kubernetes.io/hostname
weight: 100
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- thanos-receive
namespaces:
- thanos
topologyKey: topology.kubernetes.io/zone
weight: 100
containers:
- args:
- receive
Expand Down
10 changes: 10 additions & 0 deletions jsonnet/kube-thanos/kube-thanos-receive.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
matchExpression.withOperator('In') +
matchExpression.withValues([tr.statefulSet.metadata.labels['app.kubernetes.io/instance']]),
]),
affinity.new() +
affinity.withWeight(100) +
affinity.mixin.podAffinityTerm.withNamespaces(tr.config.namespace) +
affinity.mixin.podAffinityTerm.withTopologyKey('topology.kubernetes.io/zone') +
affinity.mixin.podAffinityTerm.labelSelector.withMatchExpressions([
matchExpression.new() +
matchExpression.withKey('app.kubernetes.io/instance') +
matchExpression.withOperator('In') +
matchExpression.withValues([tr.statefulSet.metadata.labels['app.kubernetes.io/instance']]),
]),
]) +
sts.mixin.spec.selector.withMatchLabels(tr.config.podLabelSelector) +
{
Expand Down

0 comments on commit 1eb4998

Please sign in to comment.