Skip to content

Commit 2349528

Browse files
committed
Upgrade the inferencePool selector to a struct from a map.
1 parent 69dfa9b commit 2349528

File tree

7 files changed

+129
-53
lines changed

7 files changed

+129
-53
lines changed

api/v1/inferencepool_types.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,16 @@ type InferencePoolList struct {
5151

5252
// InferencePoolSpec defines the desired state of InferencePool
5353
type InferencePoolSpec struct {
54-
// Selector defines a map of labels to watch model server Pods
55-
// that should be included in the InferencePool.
56-
// In some cases, implementations may translate this field to a Service selector, so this matches the simple
57-
// map used for Service selectors instead of the full Kubernetes LabelSelector type.
58-
// If specified, it will be applied to match the model server pods in the same namespace as the InferencePool.
59-
// Cross namesoace selector is not supported.
54+
// Selector determines which Pods are members of this inference pool.
55+
// It matches Pods by their labels only within the same namespace; cross-namespace
56+
// selection is not supported.
57+
//
58+
// The structure of this LabelSelector is intentionally simple to be compatible
59+
// with Kubernetes Service selectors, as some implementations may translate
60+
// this configuration into a Service resource.
6061
//
6162
// +kubebuilder:validation:Required
62-
Selector map[LabelKey]LabelValue `json:"selector"`
63+
Selector LabelSelector `json:"selector"`
6364

6465
// TargetPortNumber defines the port number to access the selected model server Pods.
6566
// The number must be in the range 1 to 65535.

api/v1/shared_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,13 @@ type LabelKey string
127127
// +kubebuilder:validation:MaxLength=63
128128
// +kubebuilder:validation:Pattern=`^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$`
129129
type LabelValue string
130+
131+
// LabelSelector defines a query for resources based on their labels.
132+
// This simplified version uses only the matchLabels field.
133+
type LabelSelector struct {
134+
// matchLabels contains a set of required {key,value} pairs.
135+
// An object must match every label in this map to be selected.
136+
// The matching logic is an AND operation on all entries.
137+
// +optional
138+
MatchLabels map[LabelKey]LabelValue `json:"matchLabels,omitempty" protobuf:"bytes,1,rep,name=matchLabels"`
139+
}

api/v1/zz_generated.deepcopy.go

Lines changed: 23 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfiguration/api/v1/inferencepoolspec.go

Lines changed: 7 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfiguration/api/v1/labelselector.go

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfiguration/utils.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/inference.networking.k8s.io_inferencepools.yaml

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,38 @@ spec:
9696
- name
9797
type: object
9898
selector:
99-
additionalProperties:
100-
description: |-
101-
LabelValue is the value of a label. This is used for validation
102-
of maps. This matches the Kubernetes label validation rules:
103-
* must be 63 characters or less (can be empty),
104-
* unless empty, must begin and end with an alphanumeric character ([a-z0-9A-Z]),
105-
* could contain dashes (-), underscores (_), dots (.), and alphanumerics between.
99+
description: |-
100+
Selector determines which Pods are members of this inference pool.
101+
It matches Pods by their labels only within the same namespace; cross-namespace
102+
selection is not supported.
103+
104+
The structure of this LabelSelector is intentionally simple to be compatible
105+
with Kubernetes Service selectors, as some implementations may translate
106+
this configuration into a Service resource.
107+
properties:
108+
matchLabels:
109+
additionalProperties:
110+
description: |-
111+
LabelValue is the value of a label. This is used for validation
112+
of maps. This matches the Kubernetes label validation rules:
113+
* must be 63 characters or less (can be empty),
114+
* unless empty, must begin and end with an alphanumeric character ([a-z0-9A-Z]),
115+
* could contain dashes (-), underscores (_), dots (.), and alphanumerics between.
106116
107-
Valid values include:
117+
Valid values include:
108118
109-
* MyValue
110-
* my.name
111-
* 123-my-value
112-
maxLength: 63
113-
minLength: 0
114-
pattern: ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$
115-
type: string
116-
description: |-
117-
Selector defines a map of labels to watch model server Pods
118-
that should be included in the InferencePool.
119-
In some cases, implementations may translate this field to a Service selector, so this matches the simple
120-
map used for Service selectors instead of the full Kubernetes LabelSelector type.
121-
If specified, it will be applied to match the model server pods in the same namespace as the InferencePool.
122-
Cross namesoace selector is not supported.
119+
* MyValue
120+
* my.name
121+
* 123-my-value
122+
maxLength: 63
123+
minLength: 0
124+
pattern: ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$
125+
type: string
126+
description: |-
127+
matchLabels contains a set of required {key,value} pairs.
128+
An object must match every label in this map to be selected.
129+
The matching logic is an AND operation on all entries.
130+
type: object
123131
type: object
124132
targetPortNumber:
125133
description: |-

0 commit comments

Comments
 (0)