Skip to content

Commit

Permalink
Add Pod anti-affinity to Thanos Rule
Browse files Browse the repository at this point in the history
  • Loading branch information
philipgough committed Jul 11, 2023
1 parent 4c73418 commit 7980f60
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
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

0 comments on commit 7980f60

Please sign in to comment.