From d13a8744ce7065ee6a4c9b1892cf548a49a5e9f4 Mon Sep 17 00:00:00 2001 From: Patrick Schratz Date: Thu, 18 May 2023 11:21:20 +0200 Subject: [PATCH] Add `nodeSelector` using platform for kubernetes (#1737) Co-authored-by: Anbraten --- pipeline/backend/kubernetes/pod.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pipeline/backend/kubernetes/pod.go b/pipeline/backend/kubernetes/pod.go index b3f0650b2..b21076c6a 100644 --- a/pipeline/backend/kubernetes/pod.go +++ b/pipeline/backend/kubernetes/pod.go @@ -100,6 +100,16 @@ func Pod(namespace string, step *types.Step, labels, annotations map[string]stri labels["step"] = podName + var platform string + for _, e := range mapToEnvVars(step.Environment) { + if e.Name == "CI_SYSTEM_ARCH" { + platform = e.Value + break + } + } + + NodeSelector := map[string]string{"kubernetes.io/arch": strings.Split(platform, "/")[1]} + pod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: podName, @@ -110,6 +120,7 @@ func Pod(namespace string, step *types.Step, labels, annotations map[string]stri Spec: v1.PodSpec{ RestartPolicy: v1.RestartPolicyNever, HostAliases: hostAliases, + NodeSelector: NodeSelector, Containers: []v1.Container{{ Name: podName, Image: step.Image,