mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-06 06:46:26 +01:00
222 lines
4.5 KiB
Plaintext
222 lines
4.5 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * nodes/nodes-scheduler-default.adoc
|
|
|
|
[id="nodes-scheduler-default-sample_{context}"]
|
|
= Sample Policy Configurations
|
|
|
|
The configuration below specifies the default scheduler configuration, if it
|
|
were to be specified using the scheduler policy file.
|
|
|
|
[source,yaml]
|
|
----
|
|
{
|
|
"kind": "Policy",
|
|
"apiVersion": "v1",
|
|
"predicates": [
|
|
{
|
|
"name": "RegionZoneAffinity", <1>
|
|
"argument": {
|
|
"serviceAffinity": { <2>
|
|
"labels": ["region, zone"] <3>
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"priorities": [
|
|
{
|
|
"name":"RackSpread", <4>
|
|
"weight" : 1,
|
|
"argument": {
|
|
"serviceAntiAffinity": { <5>
|
|
"label": "rack" <6>
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
----
|
|
|
|
<1> The name for the predicate.
|
|
<2> The type of predicate.
|
|
<3> The labels for the predicate.
|
|
<4> The name for the priority.
|
|
<5> The type of priority.
|
|
<6> The labels for the priority.
|
|
|
|
|
|
In all of the sample configurations below, the list of predicates and priority
|
|
functions is truncated to include only the ones that pertain to the use case
|
|
specified. In practice, a complete/meaningful scheduler policy should include
|
|
most, if not all, of the default predicates and priorities listed above.
|
|
|
|
The following example defines three topological levels, region (affinity) -> zone (affinity) -> rack (anti-affinity):
|
|
|
|
[source,yaml]
|
|
----
|
|
{
|
|
"kind": "Policy",
|
|
"apiVersion": "v1",
|
|
"predicates": [
|
|
{
|
|
"name": "RegionZoneAffinity",
|
|
"argument": {
|
|
"serviceAffinity": {
|
|
"labels": ["region, zone"]
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"priorities": [
|
|
{
|
|
"name":"RackSpread",
|
|
"weight" : 1,
|
|
"argument": {
|
|
"serviceAntiAffinity": {
|
|
"label": "rack"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
----
|
|
|
|
|
|
The following example defines three topological levels, city (affinity) -> building
|
|
(anti-affinity) -> room (anti-affinity):
|
|
|
|
[source,yaml]
|
|
----
|
|
{
|
|
"kind": "Policy",
|
|
"apiVersion": "v1",
|
|
"predicates": [
|
|
{
|
|
"name": "CityAffinity",
|
|
"argument": {
|
|
"serviceAffinity": {
|
|
"label": "city"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"priorities": [
|
|
{
|
|
"name":"BuildingSpread",
|
|
"weight" : 1,
|
|
"argument": {
|
|
"serviceAntiAffinity": {
|
|
"label": "building"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name":"RoomSpread",
|
|
"weight" : 1,
|
|
"argument": {
|
|
"serviceAntiAffinity": {
|
|
"label": "room"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
----
|
|
|
|
The following example defines a policy to only use nodes with the 'region' label defined and prefer nodes with the 'zone'
|
|
label defined:
|
|
|
|
[source,yaml]
|
|
----
|
|
{
|
|
"kind": "Policy",
|
|
"apiVersion": "v1",
|
|
"predicates": [
|
|
{
|
|
"name": "RequireRegion",
|
|
"argument": {
|
|
"labelPreference": {
|
|
"labels": ["region"],
|
|
"presence": true
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"priorities": [
|
|
{
|
|
"name":"ZonePreferred",
|
|
"weight" : 1,
|
|
"argument": {
|
|
"labelPreference": {
|
|
"label": "zone",
|
|
"presence": true
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
----
|
|
|
|
The following example combines both static and configurable predicates and
|
|
also priorities:
|
|
|
|
[source,yaml]
|
|
----
|
|
{
|
|
"kind": "Policy",
|
|
"apiVersion": "v1",
|
|
"predicates": [
|
|
{
|
|
"name": "RegionAffinity",
|
|
"argument": {
|
|
"serviceAffinity": {
|
|
"labels": ["region"]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "RequireRegion",
|
|
"argument": {
|
|
"labelsPresence": {
|
|
"labels": ["region"],
|
|
"presence": true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "BuildingNodesAvoid",
|
|
"argument": {
|
|
"labelsPresence": {
|
|
"label": "building",
|
|
"presence": false
|
|
}
|
|
}
|
|
},
|
|
{"name" : "PodFitsPorts"},
|
|
{"name" : "MatchNodeSelector"}
|
|
],
|
|
"priorities": [
|
|
{
|
|
"name": "ZoneSpread",
|
|
"weight" : 2,
|
|
"argument": {
|
|
"serviceAntiAffinity":{
|
|
"label": "zone"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name":"ZonePreferred",
|
|
"weight" : 1,
|
|
"argument": {
|
|
"labelPreference":{
|
|
"label": "zone",
|
|
"presence": true
|
|
}
|
|
}
|
|
},
|
|
{"name" : "ServiceSpreadingPriority", "weight" : 1}
|
|
]
|
|
}
|
|
----
|