6
6
= Sample Policy Configurations
7
7
8
8
The configuration below specifies the default scheduler configuration, if it
9
- were to be specified via the scheduler policy file.
9
+ were to be specified using the scheduler policy file.
10
10
11
11
[source,yaml]
12
12
----
13
- kind: "Policy"
14
- version: "v1"
15
- predicates:
16
- ...
17
- - name: "RegionZoneAffinity" <1>
18
- argument:
19
- serviceAffinity: <2>
20
- labels: <3>
21
- - "region"
22
- - "zone"
23
- priorities:
24
- ...
25
- - name: "RackSpread" <4>
26
- weight: 1
27
- argument:
28
- serviceAntiAffinity: <5>
29
- label: "rack" <6>
13
+ kind: ConfigMap
14
+ apiVersion: v1
15
+ metadata:
16
+ name: mypolicy
17
+ namespace: openshift-config
18
+ selfLink: /api/v1/namespaces/openshift-config/configmaps/mypolicy
19
+ uid: 83917dfb-4422-11e9-b2c9-0a5e37b2b12e
20
+ resourceVersion: '1100851'
21
+ creationTimestamp: '2019-03-11T17:24:23Z'
22
+ data:
23
+ policy.cfg: "{\n\"kind\" : \"Policy\",\n\"apiVersion\" : \"v1\",\n\"predicates\" : [\n\t{\"name\" : \"PodFitsHostPorts\"},\n\t{\"name\" : \"PodFitsResources\"},\n\t{\"name\" : \"NoDiskConflict\"},\n\t{\"name\" : \"NoVolumeZoneConflict\"},\n\t{\"name\" : \"MatchNodeSelector\"},\n\t{\"name\" : \"HostName\"}\n\t],\n\"priorities\" : [\n\t{\"name\" : \"LeastRequestedPriority\", \"weight\" : 10},\n\t{\"name\" : \"BalancedResourceAllocation\", \"weight\" : 1},\n\t{\"name\" : \"ServiceSpreadingPriority\", \"weight\" : 1},\n\t{\"name\" : \"EqualPriority\", \"weight\" : 1},\n\t{\"name\" : \"labelPreference\", \"label\" : \"rack\", \"presence\" : \"true\", \"weight\" : 2},\n\t]\n}\n "
30
24
----
31
25
32
- <1> The name for the predicate.
33
- <2> The type of predicate.
34
- <3> The labels for the predicate.
35
- <4> The name for the priority.
36
- <5> The type of priority.
37
- <6> The labels for the priority.
38
26
39
27
In all of the sample configurations below, the list of predicates and priority
40
28
functions is truncated to include only the ones that pertain to the use case
@@ -45,120 +33,30 @@ The following example defines three topological levels, region (affinity) -> zon
45
33
46
34
[source,yaml]
47
35
----
48
- kind: "Policy"
49
- version: "v1"
50
- predicates:
51
- ...
52
- - name: "RegionZoneAffinity"
53
- argument:
54
- serviceAffinity:
55
- labels:
56
- - "region"
57
- - "zone"
58
- priorities:
59
- ...
60
- - name: "RackSpread"
61
- weight: 1
62
- argument:
63
- serviceAntiAffinity:
64
- label: "rack"
36
+ "{\n\"kind\" : \"Policy\",\n\"apiVersion\" : \"v1\",\n\"predicates\" : [\n\t{\"name\" : \"RegionZoneAffinity\", \"label\" : \"region\", \"label\" : \"zone\"}\n\t],\n\"priorities\" : [\n\t{\"name\" : \"serviceAntiAffinity\", \"label\" : \"rack\", \"weight\" : 1},\n\t]\n}\n"
65
37
----
66
38
67
39
The following example defines three topological levels, city (affinity) -> building
68
40
(anti-affinity) -> room (anti-affinity):
69
41
70
42
[source,yaml]
71
43
----
72
- kind: "Policy"
73
- version: "v1"
74
- predicates:
75
- ...
76
- - name: "CityAffinity"
77
- argument:
78
- serviceAffinity:
79
- labels:
80
- - "city"
81
- priorities:
82
- ...
83
- - name: "BuildingSpread"
84
- weight: 1
85
- argument:
86
- serviceAntiAffinity:
87
- label: "building"
88
- - name: "RoomSpread"
89
- weight: 1
90
- argument:
91
- serviceAntiAffinity:
92
- label: "room"
44
+ "{\n\"kind\" : \"Policy\",\n\"apiVersion\" : \"v1\",\n\"predicates\" : [\n\t{\"name\" : \"serviceAffinityy\", \"label\" : \"city\"},\n\t],\n\"priorities\" : [\n\t{\"name\" : \"serviceAntiAffinity\", \"label\" : \"building\" \"weight\" : 1}, \n\t{\"name\" : \"serviceAntiAffinity\", \"label\" : \"room\" \"weight\" : 1},\n\t]\n}\n"
93
45
----
94
46
95
47
The following example defines a policy to only use nodes with the 'region' label defined and prefer nodes with the 'zone'
96
48
label defined:
97
49
98
50
[source,yaml]
99
51
----
100
- kind: "Policy"
101
- version: "v1"
102
- predicates:
103
- ...
104
- - name: "RequireRegion"
105
- argument:
106
- labelsPresence:
107
- labels:
108
- - "region"
109
- presence: true
110
- priorities:
111
- ...
112
- - name: "ZonePreferred"
113
- weight: 1
114
- argument:
115
- labelPreference:
116
- label: "zone"
117
- presence: true
52
+ "{\n\"kind\" : \"Policy\",\n\"apiVersion\" : \"v1\",\n\"predicates\" : [\n\t{\"name\" : \"labelsPresence\", \"label\" : \"region\", \"presence\" : \"true\"},\n\t],\n\"priorities\" : [\n\t{\"name\" : \"ZonePreferred\", \"label\" : \"zone\", \"presence\" : \"true\", \"weight\" : 1},\n\t]\n}\n"
118
53
----
119
54
120
55
The following example combines both static and configurable predicates and
121
56
also priorities:
122
57
123
58
[source,yaml]
124
59
----
125
- kind: "Policy"
126
- version: "v1"
127
- predicates:
128
- ...
129
- - name: "RegionAffinity"
130
- argument:
131
- serviceAffinity:
132
- labels:
133
- - "region"
134
- - name: "RequireRegion"
135
- argument:
136
- labelsPresence:
137
- labels:
138
- - "region"
139
- presence: true
140
- - name: "BuildingNodesAvoid"
141
- argument:
142
- labelsPresence:
143
- labels:
144
- - "building"
145
- presence: false
146
- - name: "PodFitsPorts"
147
- - name: "MatchNodeSelector"
148
- priorities:
149
- ...
150
- - name: "ZoneSpread"
151
- weight: 2
152
- argument:
153
- serviceAntiAffinity:
154
- label: "zone"
155
- - name: "ZonePreferred"
156
- weight: 1
157
- argument:
158
- labelPreference:
159
- label: "zone"
160
- presence: true
161
- - name: "ServiceSpreadingPriority"
162
- weight: 1
60
+ "{\n\"kind\" : \"Policy\",\n\"apiVersion\" : \"v1\",\n\"predicates\" : [\n\t{\"name\" : \"labelsPresence\", \"label\" : \"building\", \"presence\" : \"true\"}, \n\t{\"name\" : \"PodFitsHostPorts\"},\n\t{\"name\" : \"MatchNodeSelector\"},\n\t],\n\"priorities\" : [\n\t{\"name\" : \"ZonePreferred\", \"label\" : \"zone\", \"presence\" : \"true\", \"weight\" : 1},\n\t]\n}\n \"
163
61
----
164
62
0 commit comments