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

receive: Use anti-affinity to spread across zones #119

Merged
merged 1 commit into from
Apr 30, 2020
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
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I would expect podAntiAffinity, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording is extremely confusing I agree, but it's under the podAntiAffinity object, so this does what we expect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, diff was not even showing this word... (: Thanks

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