Skip to content

Commit 81ca0e5

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
planner: add a NodeSelector function to the planner
This planner function will select and/or combine the possible sources for our default node selector value(s). If there's no default node selector value in the config or if it is not valid JSON, fall back to the hard-coded default. If available, use the admin specified value. Signed-off-by: John Mulligan <[email protected]>
1 parent aa995ad commit 81ca0e5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

internal/planner/selector.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package planner
4+
5+
import (
6+
"encoding/json"
7+
)
8+
9+
// builtinDefaultNodeSelector defines our defaults if no administrative
10+
// overrides are supplied. Samba containers run only on linux. Currently
11+
// they're only built for x86_64 (amd64).
12+
var builtinDefaultNodeSelector = map[string]string{
13+
"kubernetes.io/os": "linux",
14+
"kubernetes.io/arch": "amd64",
15+
}
16+
17+
// NodeSelector returns a mapping of k8s label names to values that are
18+
// used to select what nodes resources are scheduled to run on.
19+
func (pl *Planner) NodeSelector() (map[string]string, error) {
20+
if pl.GlobalConfig.DefaultNodeSelector == "" {
21+
return builtinDefaultNodeSelector, nil
22+
}
23+
var nsel map[string]string
24+
err := json.Unmarshal([]byte(pl.GlobalConfig.DefaultNodeSelector), &nsel)
25+
if err != nil {
26+
return builtinDefaultNodeSelector, err
27+
}
28+
return nsel, nil
29+
}

0 commit comments

Comments
 (0)