mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-02-14 18:09:58 +00:00
* chore: add nwa Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: update helm-schema version Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: update helm-schema version Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> --------- Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
36 lines
898 B
Go
36 lines
898 B
Go
// Copyright 2020-2025 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2"
|
|
)
|
|
|
|
const (
|
|
NodeSelectorAnnotation = "scheduler.alpha.kubernetes.io/node-selector"
|
|
)
|
|
|
|
func BuildNodeSelector(tnt *capsulev1beta2.Tenant, nsAnnotations map[string]string) map[string]string {
|
|
if nsAnnotations == nil {
|
|
nsAnnotations = make(map[string]string)
|
|
}
|
|
|
|
selector := make([]string, 0, len(tnt.Spec.NodeSelector))
|
|
|
|
for k, v := range tnt.Spec.NodeSelector {
|
|
selector = append(selector, fmt.Sprintf("%s=%s", k, v))
|
|
}
|
|
// Sorting the resulting slice: iterating over maps is randomized, and we could end-up
|
|
// in multiple reconciliations upon multiple node selectors.
|
|
sort.Strings(selector)
|
|
|
|
nsAnnotations[NodeSelectorAnnotation] = strings.Join(selector, ",")
|
|
|
|
return nsAnnotations
|
|
}
|