mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Merge pull request #62002 from k82cn/k8s_61410_1
Automatic merge from submit-queue (batch tested with PRs 62495, 63003, 62829, 62151, 62002). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Added MatchFields to NodeSelectorTerm **What this PR does / why we need it**: **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: part of #61410 **Special notes for your reviewer**: According to the discussion at #61410 , we'd like to introduce a new selector term for node's field. **Release note**: ```release-note Added `MatchFields` to `NodeSelectorTerm`; in 1.11, it only support `metadata.name`. ```
This commit is contained in:
commit
8f20a815e5
14
api/openapi-spec/swagger.json
generated
14
api/openapi-spec/swagger.json
generated
@ -77345,13 +77345,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"io.k8s.api.core.v1.NodeSelectorTerm": {
|
"io.k8s.api.core.v1.NodeSelectorTerm": {
|
||||||
"description": "A null or empty node selector term matches no objects.",
|
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"required": [
|
|
||||||
"matchExpressions"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"matchExpressions": {
|
"matchExpressions": {
|
||||||
"description": "Required. A list of node selector requirements. The requirements are ANDed.",
|
"description": "A list of node selector requirements by node's labels.",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/io.k8s.api.core.v1.NodeSelectorRequirement"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"matchFields": {
|
||||||
|
"description": "A list of node selector requirements by node's fields.",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/io.k8s.api.core.v1.NodeSelectorRequirement"
|
"$ref": "#/definitions/io.k8s.api.core.v1.NodeSelectorRequirement"
|
||||||
|
14
api/swagger-spec/apps_v1.json
generated
14
api/swagger-spec/apps_v1.json
generated
@ -8440,17 +8440,21 @@
|
|||||||
},
|
},
|
||||||
"v1.NodeSelectorTerm": {
|
"v1.NodeSelectorTerm": {
|
||||||
"id": "v1.NodeSelectorTerm",
|
"id": "v1.NodeSelectorTerm",
|
||||||
"description": "A null or empty node selector term matches no objects.",
|
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"required": [
|
|
||||||
"matchExpressions"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"matchExpressions": {
|
"matchExpressions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "v1.NodeSelectorRequirement"
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
},
|
},
|
||||||
"description": "Required. A list of node selector requirements. The requirements are ANDed."
|
"description": "A list of node selector requirements by node's labels."
|
||||||
|
},
|
||||||
|
"matchFields": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
|
},
|
||||||
|
"description": "A list of node selector requirements by node's fields."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
14
api/swagger-spec/apps_v1beta1.json
generated
14
api/swagger-spec/apps_v1beta1.json
generated
@ -6074,17 +6074,21 @@
|
|||||||
},
|
},
|
||||||
"v1.NodeSelectorTerm": {
|
"v1.NodeSelectorTerm": {
|
||||||
"id": "v1.NodeSelectorTerm",
|
"id": "v1.NodeSelectorTerm",
|
||||||
"description": "A null or empty node selector term matches no objects.",
|
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"required": [
|
|
||||||
"matchExpressions"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"matchExpressions": {
|
"matchExpressions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "v1.NodeSelectorRequirement"
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
},
|
},
|
||||||
"description": "Required. A list of node selector requirements. The requirements are ANDed."
|
"description": "A list of node selector requirements by node's labels."
|
||||||
|
},
|
||||||
|
"matchFields": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
|
},
|
||||||
|
"description": "A list of node selector requirements by node's fields."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
14
api/swagger-spec/apps_v1beta2.json
generated
14
api/swagger-spec/apps_v1beta2.json
generated
@ -8440,17 +8440,21 @@
|
|||||||
},
|
},
|
||||||
"v1.NodeSelectorTerm": {
|
"v1.NodeSelectorTerm": {
|
||||||
"id": "v1.NodeSelectorTerm",
|
"id": "v1.NodeSelectorTerm",
|
||||||
"description": "A null or empty node selector term matches no objects.",
|
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"required": [
|
|
||||||
"matchExpressions"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"matchExpressions": {
|
"matchExpressions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "v1.NodeSelectorRequirement"
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
},
|
},
|
||||||
"description": "Required. A list of node selector requirements. The requirements are ANDed."
|
"description": "A list of node selector requirements by node's labels."
|
||||||
|
},
|
||||||
|
"matchFields": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
|
},
|
||||||
|
"description": "A list of node selector requirements by node's fields."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
14
api/swagger-spec/batch_v1.json
generated
14
api/swagger-spec/batch_v1.json
generated
@ -3414,17 +3414,21 @@
|
|||||||
},
|
},
|
||||||
"v1.NodeSelectorTerm": {
|
"v1.NodeSelectorTerm": {
|
||||||
"id": "v1.NodeSelectorTerm",
|
"id": "v1.NodeSelectorTerm",
|
||||||
"description": "A null or empty node selector term matches no objects.",
|
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"required": [
|
|
||||||
"matchExpressions"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"matchExpressions": {
|
"matchExpressions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "v1.NodeSelectorRequirement"
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
},
|
},
|
||||||
"description": "Required. A list of node selector requirements. The requirements are ANDed."
|
"description": "A list of node selector requirements by node's labels."
|
||||||
|
},
|
||||||
|
"matchFields": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
|
},
|
||||||
|
"description": "A list of node selector requirements by node's fields."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
14
api/swagger-spec/batch_v1beta1.json
generated
14
api/swagger-spec/batch_v1beta1.json
generated
@ -3469,17 +3469,21 @@
|
|||||||
},
|
},
|
||||||
"v1.NodeSelectorTerm": {
|
"v1.NodeSelectorTerm": {
|
||||||
"id": "v1.NodeSelectorTerm",
|
"id": "v1.NodeSelectorTerm",
|
||||||
"description": "A null or empty node selector term matches no objects.",
|
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"required": [
|
|
||||||
"matchExpressions"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"matchExpressions": {
|
"matchExpressions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "v1.NodeSelectorRequirement"
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
},
|
},
|
||||||
"description": "Required. A list of node selector requirements. The requirements are ANDed."
|
"description": "A list of node selector requirements by node's labels."
|
||||||
|
},
|
||||||
|
"matchFields": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
|
},
|
||||||
|
"description": "A list of node selector requirements by node's fields."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
14
api/swagger-spec/batch_v2alpha1.json
generated
14
api/swagger-spec/batch_v2alpha1.json
generated
@ -3469,17 +3469,21 @@
|
|||||||
},
|
},
|
||||||
"v1.NodeSelectorTerm": {
|
"v1.NodeSelectorTerm": {
|
||||||
"id": "v1.NodeSelectorTerm",
|
"id": "v1.NodeSelectorTerm",
|
||||||
"description": "A null or empty node selector term matches no objects.",
|
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"required": [
|
|
||||||
"matchExpressions"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"matchExpressions": {
|
"matchExpressions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "v1.NodeSelectorRequirement"
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
},
|
},
|
||||||
"description": "Required. A list of node selector requirements. The requirements are ANDed."
|
"description": "A list of node selector requirements by node's labels."
|
||||||
|
},
|
||||||
|
"matchFields": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
|
},
|
||||||
|
"description": "A list of node selector requirements by node's fields."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
14
api/swagger-spec/extensions_v1beta1.json
generated
14
api/swagger-spec/extensions_v1beta1.json
generated
@ -9082,17 +9082,21 @@
|
|||||||
},
|
},
|
||||||
"v1.NodeSelectorTerm": {
|
"v1.NodeSelectorTerm": {
|
||||||
"id": "v1.NodeSelectorTerm",
|
"id": "v1.NodeSelectorTerm",
|
||||||
"description": "A null or empty node selector term matches no objects.",
|
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"required": [
|
|
||||||
"matchExpressions"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"matchExpressions": {
|
"matchExpressions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "v1.NodeSelectorRequirement"
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
},
|
},
|
||||||
"description": "Required. A list of node selector requirements. The requirements are ANDed."
|
"description": "A list of node selector requirements by node's labels."
|
||||||
|
},
|
||||||
|
"matchFields": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
|
},
|
||||||
|
"description": "A list of node selector requirements by node's fields."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
14
api/swagger-spec/v1.json
generated
14
api/swagger-spec/v1.json
generated
@ -20056,17 +20056,21 @@
|
|||||||
},
|
},
|
||||||
"v1.NodeSelectorTerm": {
|
"v1.NodeSelectorTerm": {
|
||||||
"id": "v1.NodeSelectorTerm",
|
"id": "v1.NodeSelectorTerm",
|
||||||
"description": "A null or empty node selector term matches no objects.",
|
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"required": [
|
|
||||||
"matchExpressions"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"matchExpressions": {
|
"matchExpressions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "v1.NodeSelectorRequirement"
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
},
|
},
|
||||||
"description": "Required. A list of node selector requirements. The requirements are ANDed."
|
"description": "A list of node selector requirements by node's labels."
|
||||||
|
},
|
||||||
|
"matchFields": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "v1.NodeSelectorRequirement"
|
||||||
|
},
|
||||||
|
"description": "A list of node selector requirements by node's fields."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
13
docs/api-reference/apps/v1/definitions.html
generated
13
docs/api-reference/apps/v1/definitions.html
generated
@ -512,7 +512,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>A null or empty node selector term matches no objects.</p>
|
<p>A null or empty node selector term matches no objects. The requirements of them are ANDed.</p>
|
||||||
</div>
|
</div>
|
||||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -534,8 +534,15 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Required. A list of node selector requirements. The requirements are ANDed.</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s labels.</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchFields</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s fields.</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
<td class="tableblock halign-left valign-top"></td>
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
13
docs/api-reference/apps/v1beta1/definitions.html
generated
13
docs/api-reference/apps/v1beta1/definitions.html
generated
@ -623,7 +623,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>A null or empty node selector term matches no objects.</p>
|
<p>A null or empty node selector term matches no objects. The requirements of them are ANDed.</p>
|
||||||
</div>
|
</div>
|
||||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -645,8 +645,15 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Required. A list of node selector requirements. The requirements are ANDed.</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s labels.</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchFields</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s fields.</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
<td class="tableblock halign-left valign-top"></td>
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
13
docs/api-reference/apps/v1beta2/definitions.html
generated
13
docs/api-reference/apps/v1beta2/definitions.html
generated
@ -515,7 +515,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>A null or empty node selector term matches no objects.</p>
|
<p>A null or empty node selector term matches no objects. The requirements of them are ANDed.</p>
|
||||||
</div>
|
</div>
|
||||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -537,8 +537,15 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Required. A list of node selector requirements. The requirements are ANDed.</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s labels.</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchFields</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s fields.</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
<td class="tableblock halign-left valign-top"></td>
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
13
docs/api-reference/batch/v1/definitions.html
generated
13
docs/api-reference/batch/v1/definitions.html
generated
@ -488,7 +488,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>A null or empty node selector term matches no objects.</p>
|
<p>A null or empty node selector term matches no objects. The requirements of them are ANDed.</p>
|
||||||
</div>
|
</div>
|
||||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -510,8 +510,15 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Required. A list of node selector requirements. The requirements are ANDed.</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s labels.</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchFields</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s fields.</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
<td class="tableblock halign-left valign-top"></td>
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
13
docs/api-reference/batch/v1beta1/definitions.html
generated
13
docs/api-reference/batch/v1beta1/definitions.html
generated
@ -488,7 +488,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>A null or empty node selector term matches no objects.</p>
|
<p>A null or empty node selector term matches no objects. The requirements of them are ANDed.</p>
|
||||||
</div>
|
</div>
|
||||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -510,8 +510,15 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Required. A list of node selector requirements. The requirements are ANDed.</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s labels.</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchFields</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s fields.</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
<td class="tableblock halign-left valign-top"></td>
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
13
docs/api-reference/batch/v2alpha1/definitions.html
generated
13
docs/api-reference/batch/v2alpha1/definitions.html
generated
@ -488,7 +488,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>A null or empty node selector term matches no objects.</p>
|
<p>A null or empty node selector term matches no objects. The requirements of them are ANDed.</p>
|
||||||
</div>
|
</div>
|
||||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -510,8 +510,15 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Required. A list of node selector requirements. The requirements are ANDed.</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s labels.</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchFields</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s fields.</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
<td class="tableblock halign-left valign-top"></td>
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -740,7 +740,7 @@ Examples: <code>/foo</code> would allow <code>/foo</code>, <code>/foo/</code> an
|
|||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>A null or empty node selector term matches no objects.</p>
|
<p>A null or empty node selector term matches no objects. The requirements of them are ANDed.</p>
|
||||||
</div>
|
</div>
|
||||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -762,8 +762,15 @@ Examples: <code>/foo</code> would allow <code>/foo</code>, <code>/foo/</code> an
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Required. A list of node selector requirements. The requirements are ANDed.</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s labels.</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchFields</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s fields.</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
<td class="tableblock halign-left valign-top"></td>
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
13
docs/api-reference/v1/definitions.html
generated
13
docs/api-reference/v1/definitions.html
generated
@ -6457,7 +6457,7 @@ Examples:<br>
|
|||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
<h3 id="_v1_nodeselectorterm">v1.NodeSelectorTerm</h3>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>A null or empty node selector term matches no objects.</p>
|
<p>A null or empty node selector term matches no objects. The requirements of them are ANDed.</p>
|
||||||
</div>
|
</div>
|
||||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -6479,8 +6479,15 @@ Examples:<br>
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchExpressions</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Required. A list of node selector requirements. The requirements are ANDed.</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s labels.</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">matchFields</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">A list of node selector requirements by node’s fields.</p></td>
|
||||||
|
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_nodeselectorrequirement">v1.NodeSelectorRequirement</a> array</p></td>
|
||||||
<td class="tableblock halign-left valign-top"></td>
|
<td class="tableblock halign-left valign-top"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -412,6 +412,38 @@ func NodeSelectorRequirementsAsSelector(nsm []core.NodeSelectorRequirement) (lab
|
|||||||
return selector, nil
|
return selector, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NodeSelectorRequirementsAsFieldSelector converts the []NodeSelectorRequirement core type into a struct that implements
|
||||||
|
// fields.Selector.
|
||||||
|
func NodeSelectorRequirementsAsFieldSelector(nsm []core.NodeSelectorRequirement) (fields.Selector, error) {
|
||||||
|
if len(nsm) == 0 {
|
||||||
|
return fields.Nothing(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
selectors := []fields.Selector{}
|
||||||
|
for _, expr := range nsm {
|
||||||
|
switch expr.Operator {
|
||||||
|
case core.NodeSelectorOpIn:
|
||||||
|
if len(expr.Values) != 1 {
|
||||||
|
return nil, fmt.Errorf("unexpected number of value (%d) for node field selector operator %q",
|
||||||
|
len(expr.Values), expr.Operator)
|
||||||
|
}
|
||||||
|
selectors = append(selectors, fields.OneTermEqualSelector(expr.Key, expr.Values[0]))
|
||||||
|
|
||||||
|
case core.NodeSelectorOpNotIn:
|
||||||
|
if len(expr.Values) != 1 {
|
||||||
|
return nil, fmt.Errorf("unexpected number of value (%d) for node field selector operator %q",
|
||||||
|
len(expr.Values), expr.Operator)
|
||||||
|
}
|
||||||
|
selectors = append(selectors, fields.OneTermNotEqualSelector(expr.Key, expr.Values[0]))
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("%q is not a valid node field selector operator", expr.Operator)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fields.AndSelectors(selectors...), nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations
|
// GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations
|
||||||
// and converts it to the []Toleration type in core.
|
// and converts it to the []Toleration type in core.
|
||||||
func GetTolerationsFromPodAnnotations(annotations map[string]string) ([]core.Toleration, error) {
|
func GetTolerationsFromPodAnnotations(annotations map[string]string) ([]core.Toleration, error) {
|
||||||
|
@ -2107,10 +2107,13 @@ type NodeSelector struct {
|
|||||||
NodeSelectorTerms []NodeSelectorTerm
|
NodeSelectorTerms []NodeSelectorTerm
|
||||||
}
|
}
|
||||||
|
|
||||||
// A null or empty node selector term matches no objects.
|
// A null or empty node selector term matches no objects. The requirements of
|
||||||
|
// them are ANDed.
|
||||||
type NodeSelectorTerm struct {
|
type NodeSelectorTerm struct {
|
||||||
//Required. A list of node selector requirements. The requirements are ANDed.
|
// A list of node selector requirements by node's labels.
|
||||||
MatchExpressions []NodeSelectorRequirement
|
MatchExpressions []NodeSelectorRequirement
|
||||||
|
// A list of node selector requirements by node's fields.
|
||||||
|
MatchFields []NodeSelectorRequirement
|
||||||
}
|
}
|
||||||
|
|
||||||
// A node selector requirement is a selector that contains values, a key, and an operator
|
// A node selector requirement is a selector that contains values, a key, and an operator
|
||||||
|
@ -15,6 +15,7 @@ go_test(
|
|||||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -27,6 +28,7 @@ go_library(
|
|||||||
"//pkg/apis/core/helper:go_default_library",
|
"//pkg/apis/core/helper:go_default_library",
|
||||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/selection:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/selection:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/selection"
|
"k8s.io/apimachinery/pkg/selection"
|
||||||
"k8s.io/apimachinery/pkg/util/validation"
|
"k8s.io/apimachinery/pkg/util/validation"
|
||||||
@ -246,6 +247,71 @@ func NodeSelectorRequirementsAsSelector(nsm []v1.NodeSelectorRequirement) (label
|
|||||||
return selector, nil
|
return selector, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NodeSelectorRequirementsAsFieldSelector converts the []NodeSelectorRequirement core type into a struct that implements
|
||||||
|
// fields.Selector.
|
||||||
|
func NodeSelectorRequirementsAsFieldSelector(nsm []v1.NodeSelectorRequirement) (fields.Selector, error) {
|
||||||
|
if len(nsm) == 0 {
|
||||||
|
return fields.Nothing(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
selectors := []fields.Selector{}
|
||||||
|
for _, expr := range nsm {
|
||||||
|
switch expr.Operator {
|
||||||
|
case v1.NodeSelectorOpIn:
|
||||||
|
if len(expr.Values) != 1 {
|
||||||
|
return nil, fmt.Errorf("unexpected number of value (%d) for node field selector operator %q",
|
||||||
|
len(expr.Values), expr.Operator)
|
||||||
|
}
|
||||||
|
selectors = append(selectors, fields.OneTermEqualSelector(expr.Key, expr.Values[0]))
|
||||||
|
|
||||||
|
case v1.NodeSelectorOpNotIn:
|
||||||
|
if len(expr.Values) != 1 {
|
||||||
|
return nil, fmt.Errorf("unexpected number of value (%d) for node field selector operator %q",
|
||||||
|
len(expr.Values), expr.Operator)
|
||||||
|
}
|
||||||
|
selectors = append(selectors, fields.OneTermNotEqualSelector(expr.Key, expr.Values[0]))
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("%q is not a valid node field selector operator", expr.Operator)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fields.AndSelectors(selectors...), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MatchNodeSelectorTerms checks whether the node labels and fields match node selector terms in ORed;
|
||||||
|
// nil or empty term matches no objects.
|
||||||
|
func MatchNodeSelectorTerms(
|
||||||
|
nodeSelectorTerms []v1.NodeSelectorTerm,
|
||||||
|
nodeLabels labels.Set,
|
||||||
|
nodeFields fields.Set,
|
||||||
|
) bool {
|
||||||
|
for _, req := range nodeSelectorTerms {
|
||||||
|
// nil or empty term selects no objects
|
||||||
|
if len(req.MatchExpressions) == 0 && len(req.MatchFields) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(req.MatchExpressions) != 0 {
|
||||||
|
labelSelector, err := NodeSelectorRequirementsAsSelector(req.MatchExpressions)
|
||||||
|
if err != nil || !labelSelector.Matches(nodeLabels) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(req.MatchFields) != 0 {
|
||||||
|
fieldSelector, err := NodeSelectorRequirementsAsFieldSelector(req.MatchFields)
|
||||||
|
if err != nil || !fieldSelector.Matches(nodeFields) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// AddOrUpdateTolerationInPodSpec tries to add a toleration to the toleration list in PodSpec.
|
// AddOrUpdateTolerationInPodSpec tries to add a toleration to the toleration list in PodSpec.
|
||||||
// Returns true if something was updated, false otherwise.
|
// Returns true if something was updated, false otherwise.
|
||||||
func AddOrUpdateTolerationInPodSpec(spec *v1.PodSpec, toleration *v1.Toleration) bool {
|
func AddOrUpdateTolerationInPodSpec(spec *v1.PodSpec, toleration *v1.Toleration) bool {
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -562,3 +563,232 @@ func TestSysctlsFromPodAnnotation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMatchNodeSelectorTerms(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
nodeSelectorTerms []v1.NodeSelectorTerm
|
||||||
|
nodeLabels labels.Set
|
||||||
|
nodeFields fields.Set
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "nil terms",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: nil,
|
||||||
|
nodeLabels: nil,
|
||||||
|
nodeFields: nil,
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "node label matches matchExpressions terms",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchExpressions: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "label_1",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"label_1_val"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodeLabels: map[string]string{"label_1": "label_1_val"},
|
||||||
|
nodeFields: nil,
|
||||||
|
},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "node field matches matchFields terms",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchFields: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host_1"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodeLabels: nil,
|
||||||
|
nodeFields: map[string]string{
|
||||||
|
"metadata.name": "host_1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "invalid node field requirement",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchFields: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host_1, host_2"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodeLabels: nil,
|
||||||
|
nodeFields: map[string]string{
|
||||||
|
"metadata.name": "host_1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "fieldSelectorTerm with node labels",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchFields: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host_1"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodeLabels: map[string]string{
|
||||||
|
"metadata.name": "host_1",
|
||||||
|
},
|
||||||
|
nodeFields: nil,
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "labelSelectorTerm with node fields",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchExpressions: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host_1"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodeLabels: nil,
|
||||||
|
nodeFields: map[string]string{
|
||||||
|
"metadata.name": "host_1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "labelSelectorTerm and fieldSelectorTerm was set, but only node fields",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchExpressions: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "label_1",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"label_1_val"},
|
||||||
|
}},
|
||||||
|
MatchFields: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host_1"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodeLabels: nil,
|
||||||
|
nodeFields: map[string]string{
|
||||||
|
"metadata.name": "host_1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "labelSelectorTerm and fieldSelectorTerm was set, both node fields and labels (both matched)",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchExpressions: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "label_1",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"label_1_val"},
|
||||||
|
}},
|
||||||
|
MatchFields: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host_1"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodeLabels: map[string]string{
|
||||||
|
"label_1": "label_1_val",
|
||||||
|
},
|
||||||
|
nodeFields: map[string]string{
|
||||||
|
"metadata.name": "host_1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "labelSelectorTerm and fieldSelectorTerm was set, both node fields and labels (one mismatched)",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchExpressions: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "label_1",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"label_1_val"},
|
||||||
|
}},
|
||||||
|
MatchFields: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host_1"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodeLabels: map[string]string{
|
||||||
|
"label_1": "label_1_val-failed",
|
||||||
|
},
|
||||||
|
nodeFields: map[string]string{
|
||||||
|
"metadata.name": "host_1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "multi-selector was set, both node fields and labels (one mismatched)",
|
||||||
|
args: args{
|
||||||
|
nodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchExpressions: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "label_1",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"label_1_val"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MatchFields: []v1.NodeSelectorRequirement{{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host_1"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nodeLabels: map[string]string{
|
||||||
|
"label_1": "label_1_val-failed",
|
||||||
|
},
|
||||||
|
nodeFields: map[string]string{
|
||||||
|
"metadata.name": "host_1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := MatchNodeSelectorTerms(tt.args.nodeSelectorTerms, tt.args.nodeLabels, tt.args.nodeFields); got != tt.want {
|
||||||
|
t.Errorf("MatchNodeSelectorTermsORed() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
2
pkg/apis/core/v1/zz_generated.conversion.go
generated
2
pkg/apis/core/v1/zz_generated.conversion.go
generated
@ -2737,6 +2737,7 @@ func Convert_core_NodeSelectorRequirement_To_v1_NodeSelectorRequirement(in *core
|
|||||||
|
|
||||||
func autoConvert_v1_NodeSelectorTerm_To_core_NodeSelectorTerm(in *v1.NodeSelectorTerm, out *core.NodeSelectorTerm, s conversion.Scope) error {
|
func autoConvert_v1_NodeSelectorTerm_To_core_NodeSelectorTerm(in *v1.NodeSelectorTerm, out *core.NodeSelectorTerm, s conversion.Scope) error {
|
||||||
out.MatchExpressions = *(*[]core.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchExpressions))
|
out.MatchExpressions = *(*[]core.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchExpressions))
|
||||||
|
out.MatchFields = *(*[]core.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchFields))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2747,6 +2748,7 @@ func Convert_v1_NodeSelectorTerm_To_core_NodeSelectorTerm(in *v1.NodeSelectorTer
|
|||||||
|
|
||||||
func autoConvert_core_NodeSelectorTerm_To_v1_NodeSelectorTerm(in *core.NodeSelectorTerm, out *v1.NodeSelectorTerm, s conversion.Scope) error {
|
func autoConvert_core_NodeSelectorTerm_To_v1_NodeSelectorTerm(in *core.NodeSelectorTerm, out *v1.NodeSelectorTerm, s conversion.Scope) error {
|
||||||
out.MatchExpressions = *(*[]v1.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchExpressions))
|
out.MatchExpressions = *(*[]v1.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchExpressions))
|
||||||
|
out.MatchFields = *(*[]v1.NodeSelectorRequirement)(unsafe.Pointer(&in.MatchFields))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2997,7 +2997,40 @@ func ValidateNodeSelectorRequirement(rq core.NodeSelectorRequirement, fldPath *f
|
|||||||
default:
|
default:
|
||||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("operator"), rq.Operator, "not a valid selector operator"))
|
allErrs = append(allErrs, field.Invalid(fldPath.Child("operator"), rq.Operator, "not a valid selector operator"))
|
||||||
}
|
}
|
||||||
|
|
||||||
allErrs = append(allErrs, unversionedvalidation.ValidateLabelName(rq.Key, fldPath.Child("key"))...)
|
allErrs = append(allErrs, unversionedvalidation.ValidateLabelName(rq.Key, fldPath.Child("key"))...)
|
||||||
|
|
||||||
|
return allErrs
|
||||||
|
}
|
||||||
|
|
||||||
|
var nodeFieldSelectorValidators = map[string]func(string, bool) []string{
|
||||||
|
core.ObjectNameField: ValidateNodeName,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateNodeFieldSelectorRequirement tests that the specified NodeSelectorRequirement fields has valid data
|
||||||
|
func ValidateNodeFieldSelectorRequirement(req core.NodeSelectorRequirement, fldPath *field.Path) field.ErrorList {
|
||||||
|
allErrs := field.ErrorList{}
|
||||||
|
|
||||||
|
switch req.Operator {
|
||||||
|
case core.NodeSelectorOpIn, core.NodeSelectorOpNotIn:
|
||||||
|
if len(req.Values) != 1 {
|
||||||
|
allErrs = append(allErrs, field.Required(fldPath.Child("values"),
|
||||||
|
"must be only one value when `operator` is 'In' or 'NotIn' for node field selector"))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
allErrs = append(allErrs, field.Invalid(fldPath.Child("operator"), req.Operator, "not a valid selector operator"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if vf, found := nodeFieldSelectorValidators[req.Key]; !found {
|
||||||
|
allErrs = append(allErrs, field.Invalid(fldPath.Child("key"), req.Key, "not a valid field selector key"))
|
||||||
|
} else {
|
||||||
|
for i, v := range req.Values {
|
||||||
|
for _, msg := range vf(v, false) {
|
||||||
|
allErrs = append(allErrs, field.Invalid(fldPath.Child("values").Index(i), v, msg))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3008,6 +3041,11 @@ func ValidateNodeSelectorTerm(term core.NodeSelectorTerm, fldPath *field.Path) f
|
|||||||
for j, req := range term.MatchExpressions {
|
for j, req := range term.MatchExpressions {
|
||||||
allErrs = append(allErrs, ValidateNodeSelectorRequirement(req, fldPath.Child("matchExpressions").Index(j))...)
|
allErrs = append(allErrs, ValidateNodeSelectorRequirement(req, fldPath.Child("matchExpressions").Index(j))...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for j, req := range term.MatchFields {
|
||||||
|
allErrs = append(allErrs, ValidateNodeFieldSelectorRequirement(req, fldPath.Child("matchFields").Index(j))...)
|
||||||
|
}
|
||||||
|
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6048,6 +6048,13 @@ func TestValidatePod(t *testing.T) {
|
|||||||
Values: []string{"value1", "value2"},
|
Values: []string{"value1", "value2"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
MatchFields: []core.NodeSelectorRequirement{
|
||||||
|
{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: core.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host1"},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -6515,6 +6522,83 @@ func TestValidatePod(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"invalid node field selector requirement in node affinity, more values for field selector": {
|
||||||
|
expectedError: "spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchFields[0].values",
|
||||||
|
spec: core.Pod{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "123",
|
||||||
|
Namespace: "ns",
|
||||||
|
},
|
||||||
|
Spec: validPodSpec(&core.Affinity{
|
||||||
|
NodeAffinity: &core.NodeAffinity{
|
||||||
|
RequiredDuringSchedulingIgnoredDuringExecution: &core.NodeSelector{
|
||||||
|
NodeSelectorTerms: []core.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchFields: []core.NodeSelectorRequirement{
|
||||||
|
{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: core.NodeSelectorOpIn,
|
||||||
|
Values: []string{"host1", "host2"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"invalid node field selector requirement in node affinity, invalid operator": {
|
||||||
|
expectedError: "spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchFields[0].operator",
|
||||||
|
spec: core.Pod{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "123",
|
||||||
|
Namespace: "ns",
|
||||||
|
},
|
||||||
|
Spec: validPodSpec(&core.Affinity{
|
||||||
|
NodeAffinity: &core.NodeAffinity{
|
||||||
|
RequiredDuringSchedulingIgnoredDuringExecution: &core.NodeSelector{
|
||||||
|
NodeSelectorTerms: []core.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchFields: []core.NodeSelectorRequirement{
|
||||||
|
{
|
||||||
|
Key: "metadata.name",
|
||||||
|
Operator: core.NodeSelectorOpExists,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"invalid node field selector requirement in node affinity, invalid key": {
|
||||||
|
expectedError: "spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchFields[0].key",
|
||||||
|
spec: core.Pod{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "123",
|
||||||
|
Namespace: "ns",
|
||||||
|
},
|
||||||
|
Spec: validPodSpec(&core.Affinity{
|
||||||
|
NodeAffinity: &core.NodeAffinity{
|
||||||
|
RequiredDuringSchedulingIgnoredDuringExecution: &core.NodeSelector{
|
||||||
|
NodeSelectorTerms: []core.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchFields: []core.NodeSelectorRequirement{
|
||||||
|
{
|
||||||
|
Key: "metadata.namespace",
|
||||||
|
Operator: core.NodeSelectorOpIn,
|
||||||
|
Values: []string{"ns1"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
"invalid preferredSchedulingTerm in node affinity, weight should be in range 1-100": {
|
"invalid preferredSchedulingTerm in node affinity, weight should be in range 1-100": {
|
||||||
expectedError: "must be in the range 1-100",
|
expectedError: "must be in the range 1-100",
|
||||||
spec: core.Pod{
|
spec: core.Pod{
|
||||||
|
7
pkg/apis/core/zz_generated.deepcopy.go
generated
7
pkg/apis/core/zz_generated.deepcopy.go
generated
@ -2547,6 +2547,13 @@ func (in *NodeSelectorTerm) DeepCopyInto(out *NodeSelectorTerm) {
|
|||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if in.MatchFields != nil {
|
||||||
|
in, out := &in.MatchFields, &out.MatchFields
|
||||||
|
*out = make([]NodeSelectorRequirement, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1578
staging/src/k8s.io/api/core/v1/generated.pb.go
generated
1578
staging/src/k8s.io/api/core/v1/generated.pb.go
generated
File diff suppressed because it is too large
Load Diff
@ -1877,10 +1877,16 @@ message NodeSelectorRequirement {
|
|||||||
repeated string values = 3;
|
repeated string values = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A null or empty node selector term matches no objects.
|
// A null or empty node selector term matches no objects. The requirements of
|
||||||
|
// them are ANDed.
|
||||||
message NodeSelectorTerm {
|
message NodeSelectorTerm {
|
||||||
// Required. A list of node selector requirements. The requirements are ANDed.
|
// A list of node selector requirements by node's labels.
|
||||||
|
// +optional
|
||||||
repeated NodeSelectorRequirement matchExpressions = 1;
|
repeated NodeSelectorRequirement matchExpressions = 1;
|
||||||
|
|
||||||
|
// A list of node selector requirements by node's fields.
|
||||||
|
// +optional
|
||||||
|
repeated NodeSelectorRequirement matchFields = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeSpec describes the attributes that a node is created with.
|
// NodeSpec describes the attributes that a node is created with.
|
||||||
|
@ -2322,10 +2322,15 @@ type NodeSelector struct {
|
|||||||
NodeSelectorTerms []NodeSelectorTerm `json:"nodeSelectorTerms" protobuf:"bytes,1,rep,name=nodeSelectorTerms"`
|
NodeSelectorTerms []NodeSelectorTerm `json:"nodeSelectorTerms" protobuf:"bytes,1,rep,name=nodeSelectorTerms"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// A null or empty node selector term matches no objects.
|
// A null or empty node selector term matches no objects. The requirements of
|
||||||
|
// them are ANDed.
|
||||||
type NodeSelectorTerm struct {
|
type NodeSelectorTerm struct {
|
||||||
//Required. A list of node selector requirements. The requirements are ANDed.
|
// A list of node selector requirements by node's labels.
|
||||||
MatchExpressions []NodeSelectorRequirement `json:"matchExpressions" protobuf:"bytes,1,rep,name=matchExpressions"`
|
// +optional
|
||||||
|
MatchExpressions []NodeSelectorRequirement `json:"matchExpressions,omitempty" protobuf:"bytes,1,rep,name=matchExpressions"`
|
||||||
|
// A list of node selector requirements by node's fields.
|
||||||
|
// +optional
|
||||||
|
MatchFields []NodeSelectorRequirement `json:"matchFields,omitempty" protobuf:"bytes,2,rep,name=matchFields"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// A node selector requirement is a selector that contains values, a key, and an operator
|
// A node selector requirement is a selector that contains values, a key, and an operator
|
||||||
|
@ -1034,8 +1034,9 @@ func (NodeSelectorRequirement) SwaggerDoc() map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var map_NodeSelectorTerm = map[string]string{
|
var map_NodeSelectorTerm = map[string]string{
|
||||||
"": "A null or empty node selector term matches no objects.",
|
"": "A null or empty node selector term matches no objects. The requirements of them are ANDed.",
|
||||||
"matchExpressions": "Required. A list of node selector requirements. The requirements are ANDed.",
|
"matchExpressions": "A list of node selector requirements by node's labels.",
|
||||||
|
"matchFields": "A list of node selector requirements by node's fields.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func (NodeSelectorTerm) SwaggerDoc() map[string]string {
|
func (NodeSelectorTerm) SwaggerDoc() map[string]string {
|
||||||
|
@ -2543,6 +2543,13 @@ func (in *NodeSelectorTerm) DeepCopyInto(out *NodeSelectorTerm) {
|
|||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if in.MatchFields != nil {
|
||||||
|
in, out := &in.MatchFields, &out.MatchFields
|
||||||
|
*out = make([]NodeSelectorRequirement, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,21 @@ type Selector interface {
|
|||||||
DeepCopySelector() Selector
|
DeepCopySelector() Selector
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type nothingSelector struct{}
|
||||||
|
|
||||||
|
func (n nothingSelector) Matches(_ Fields) bool { return false }
|
||||||
|
func (n nothingSelector) Empty() bool { return false }
|
||||||
|
func (n nothingSelector) String() string { return "" }
|
||||||
|
func (n nothingSelector) Requirements() Requirements { return nil }
|
||||||
|
func (n nothingSelector) DeepCopySelector() Selector { return n }
|
||||||
|
func (n nothingSelector) RequiresExactMatch(field string) (value string, found bool) { return "", false }
|
||||||
|
func (n nothingSelector) Transform(fn TransformFunc) (Selector, error) { return n, nil }
|
||||||
|
|
||||||
|
// Nothing returns a selector that matches no fields
|
||||||
|
func Nothing() Selector {
|
||||||
|
return nothingSelector{}
|
||||||
|
}
|
||||||
|
|
||||||
// Everything returns a selector that matches all fields.
|
// Everything returns a selector that matches all fields.
|
||||||
func Everything() Selector {
|
func Everything() Selector {
|
||||||
return andTerm{}
|
return andTerm{}
|
||||||
@ -449,6 +464,12 @@ func OneTermEqualSelector(k, v string) Selector {
|
|||||||
return &hasTerm{field: k, value: v}
|
return &hasTerm{field: k, value: v}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OneTermNotEqualSelector returns an object that matches objects where one field/field does not equal one value.
|
||||||
|
// Cannot return an error.
|
||||||
|
func OneTermNotEqualSelector(k, v string) Selector {
|
||||||
|
return ¬HasTerm{field: k, value: v}
|
||||||
|
}
|
||||||
|
|
||||||
// AndSelectors creates a selector that is the logical AND of all the given selectors
|
// AndSelectors creates a selector that is the logical AND of all the given selectors
|
||||||
func AndSelectors(selectors ...Selector) Selector {
|
func AndSelectors(selectors ...Selector) Selector {
|
||||||
return andTerm(selectors)
|
return andTerm(selectors)
|
||||||
|
Loading…
Reference in New Issue
Block a user