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

Add Pod anti-affinity to Thanos Rule #310

Merged
merged 1 commit into from
Jul 11, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel
- [#301](https://github.com/thanos-io/kube-thanos/pull/301) Receive: allow configuration of `minReadySeconds` for StatefulSet
- [#305](https://github.com/thanos-io/kube-thanos/pull/305) Receive: allow configuration of limits-config-file
- [#308](https://github.com/thanos-io/kube-thanos/pull/308) Recive: add store limits flags
- [#310](https://github.com/thanos-io/kube-thanos/pull/310) Ruler: Add host anti-affinity to ruler

### Fixed

Expand Down
18 changes: 18 additions & 0 deletions examples/all/manifests/thanos-rule-statefulSet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ spec:
app.kubernetes.io/name: thanos-rule
app.kubernetes.io/version: v0.30.2
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- thanos-rule
- key: app.kubernetes.io/instance
operator: In
values:
- thanos-rule
namespaces:
- thanos
topologyKey: kubernetes.io/hostname
weight: 100
containers:
- args:
- rule
Expand Down
21 changes: 21 additions & 0 deletions jsonnet/kube-thanos/kube-thanos-rule.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,27 @@ function(params) {
nodeSelector: {
'kubernetes.io/os': 'linux',
},
affinity: { podAntiAffinity: {
local labelSelector = { matchExpressions: [{
key: 'app.kubernetes.io/name',
operator: 'In',
values: [tr.statefulSet.metadata.labels['app.kubernetes.io/name']],
}, {
key: 'app.kubernetes.io/instance',
operator: 'In',
values: [tr.statefulSet.metadata.labels['app.kubernetes.io/instance']],
}] },
preferredDuringSchedulingIgnoredDuringExecution: [
{
podAffinityTerm: {
namespaces: [tr.config.namespace],
topologyKey: 'kubernetes.io/hostname',
labelSelector: labelSelector,
},
weight: 100,
},
],
} },
},
},
volumeClaimTemplates: if std.length(tr.config.volumeClaimTemplate) > 0 then [tr.config.volumeClaimTemplate {
Expand Down