Skip to content

Commit 4804992

Browse files
authored
Merge pull request #242 from grafana/paa
podAntiAffinity for StatefulSet
2 parents ee918f2 + 49dfbfa commit 4804992

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ksonnet-util/kausal.libsonnet

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,19 @@ k {
428428
]).spec,
429429
},
430430

431+
antiAffinityStatefulSet:
432+
{
433+
local statefulSet = $.apps.v1.statefulSet,
434+
local podAntiAffinity = statefulSet.mixin.spec.template.spec.affinity.podAntiAffinity,
435+
local name = super.spec.template.metadata.labels.name,
436+
437+
spec+: podAntiAffinity.withRequiredDuringSchedulingIgnoredDuringExecution([
438+
podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecutionType.new() +
439+
podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecutionType.mixin.labelSelector.withMatchLabels({ name: name }) +
440+
podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecutionType.withTopologyKey('kubernetes.io/hostname'),
441+
]).spec,
442+
},
443+
431444
// Add a priority to the pods in a deployment (or deployment-like objects
432445
// such as a statefulset) iff _config.enable_pod_priorities is set to true.
433446
podPriority(p):

0 commit comments

Comments
 (0)