From de533730d33e19f933f5cb5e6b1647539cbde202 Mon Sep 17 00:00:00 2001 From: gadotroee <55343099+gadotroee@users.noreply.github.com> Date: Tue, 19 Apr 2022 19:35:17 +0300 Subject: [PATCH] Change the affinity to be valid when we are tapping multiple nodes (#1023) --- shared/kubernetes/provider.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/shared/kubernetes/provider.go b/shared/kubernetes/provider.go index d7d034159..67b9e5186 100644 --- a/shared/kubernetes/provider.go +++ b/shared/kubernetes/provider.go @@ -805,14 +805,20 @@ func (provider *Provider) ApplyMizuTapperDaemonSet(ctx context.Context, namespac agentResources := applyconfcore.ResourceRequirements().WithRequests(agentResourceRequests).WithLimits(agentResourceLimits) agentContainer.WithResources(agentResources) - nodeSelectorRequirement := applyconfcore.NodeSelectorRequirement() - nodeSelectorRequirement.WithKey("metadata.name") - nodeSelectorRequirement.WithOperator(core.NodeSelectorOpIn) - nodeSelectorRequirement.WithValues(nodeNames...) - nodeSelectorTerm := applyconfcore.NodeSelectorTerm() - nodeSelectorTerm.WithMatchFields(nodeSelectorRequirement) + matchFields := make([]*applyconfcore.NodeSelectorTermApplyConfiguration, 0) + for _, nodeName := range nodeNames { + nodeSelectorRequirement := applyconfcore.NodeSelectorRequirement() + nodeSelectorRequirement.WithKey("metadata.name") + nodeSelectorRequirement.WithOperator(core.NodeSelectorOpIn) + nodeSelectorRequirement.WithValues(nodeName) + + nodeSelectorTerm := applyconfcore.NodeSelectorTerm() + nodeSelectorTerm.WithMatchFields(nodeSelectorRequirement) + matchFields = append(matchFields, nodeSelectorTerm) + } + nodeSelector := applyconfcore.NodeSelector() - nodeSelector.WithNodeSelectorTerms(nodeSelectorTerm) + nodeSelector.WithNodeSelectorTerms(matchFields...) nodeAffinity := applyconfcore.NodeAffinity() nodeAffinity.WithRequiredDuringSchedulingIgnoredDuringExecution(nodeSelector) affinity := applyconfcore.Affinity()