-
Notifications
You must be signed in to change notification settings - Fork 90
/
affinity_objects.go
52 lines (46 loc) · 1.25 KB
/
affinity_objects.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package kotsadm
import (
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
)
func defaultKOTSNodeAffinity() *corev1.NodeAffinity {
return &corev1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{
NodeSelectorTerms: []corev1.NodeSelectorTerm{
{
MatchExpressions: []corev1.NodeSelectorRequirement{
{
Key: "kubernetes.io/os",
Operator: corev1.NodeSelectorOpIn,
Values: []string{
"linux",
},
},
{
Key: "kubernetes.io/arch",
Operator: corev1.NodeSelectorOpNotIn,
Values: []string{
"arm64",
},
},
},
},
},
},
}
}
func DefaultKOTSNodeLabelSelector() (labels.Selector, error) {
osReq, err := labels.NewRequirement("kubernetes.io/os", selection.In, []string{"linux"})
if err != nil {
return nil, errors.Wrap(err, "failed to create os requirement")
}
archReq, err := labels.NewRequirement("kubernetes.io/arch", selection.NotIn, []string{"arm64"})
if err != nil {
return nil, errors.Wrap(err, "failed to create arch requirement")
}
selector := labels.NewSelector()
selector = selector.Add(*osReq, *archReq)
return selector, nil
}