-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
affinity.go
126 lines (125 loc) · 2.84 KB
/
affinity.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package settings
const (
// ClusterAgentAffinity used to be hardcoded in the agent deployment template but is now defined here as the
// single source of truth.
ClusterAgentAffinity = `{
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{
"matchExpressions": [
{
"key": "beta.kubernetes.io/os",
"operator": "NotIn",
"values": [
"windows"
]
}
]
}
]
},
"preferredDuringSchedulingIgnoredDuringExecution": [
{
"weight": 100,
"preference": {
"matchExpressions": [
{
"key": "node-role.kubernetes.io/controlplane",
"operator": "In",
"values": [
"true"
]
}
]
}
},
{
"weight": 100,
"preference": {
"matchExpressions": [
{
"key": "node-role.kubernetes.io/control-plane",
"operator": "In",
"values": [
"true"
]
}
]
}
},
{
"weight": 100,
"preference": {
"matchExpressions": [
{
"key": "node-role.kubernetes.io/master",
"operator": "In",
"values": [
"true"
]
}
]
}
},
{
"weight": 1,
"preference": {
"matchExpressions": [
{
"key": "cattle.io/cluster-agent",
"operator": "In",
"values": [
"true"
]
}
]
}
}
]
},
"podAntiAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [
{
"weight": 100,
"podAffinityTerm": {
"labelSelector": {
"matchExpressions": [
{
"key": "app",
"operator": "In",
"values": [
"cattle-cluster-agent"
]
}
]
},
"topologyKey": "kubernetes.io/hostname"
}
}
]
}
}`
// FleetAgentAffinity is hardcoded in the rancher/fleet repo in the agent manifest
// https://github.com/rancher/fleet/blob/90e33140906ba5d4931b4e1dee588854cbb300b1/pkg/agent/manifest.go#L178-L195
FleetAgentAffinity = `{
"nodeAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [
{
"weight": 1,
"preference": {
"matchExpressions": [
{
"key": "fleet.cattle.io/agent",
"operator": "In",
"values": [
"true"
]
}
]
}
}
]
}
}`
)