Skip to content

Commit dfe9926

Browse files
committed
inference extension support
Signed-off-by: Nitishkumar Singh <nitishkumarsingh71@gmail.com>
1 parent bacb6b9 commit dfe9926

File tree

12 files changed

+353
-30
lines changed

12 files changed

+353
-30
lines changed

gateway-api/src/apis/experimental/extension/inference/inferencepools.rs

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// WARNING! generated file do not edit
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// WARNING: generated file - manual changes will be overriden
2+
3+
#[derive(Debug, PartialEq, Eq)]
4+
pub enum InferencePoolEndpointPickerRefFailureMode {
5+
FailOpen,
6+
FailClose,
7+
}
8+
9+
impl std::fmt::Display for InferencePoolEndpointPickerRefFailureMode {
10+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
11+
write!(f, "{:?}", self)
12+
}
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use super::common::*;
2+
// WARNING: generated file - manual changes will be overriden
3+
4+
impl Default for InferencePoolEndpointPickerRefFailureMode {
5+
fn default() -> Self {
6+
InferencePoolEndpointPickerRefFailureMode::FailOpen
7+
}
8+
}
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
// WARNING: generated by kopium - manual changes will be overwritten
2+
// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3+
// kopium version: 0.22.5
4+
5+
#[allow(unused_imports)]
6+
mod prelude {
7+
pub use kube_derive::CustomResource;
8+
pub use schemars::JsonSchema;
9+
pub use serde::{Serialize, Deserialize};
10+
pub use std::collections::BTreeMap;
11+
pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
12+
}
13+
use self::prelude::*;
14+
15+
/// Spec defines the desired state of the InferencePool.
16+
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
17+
#[kube(group = "inference.networking.k8s.io", version = "v1", kind = "InferencePool", plural = "inferencepools")]
18+
#[kube(namespaced)]
19+
#[kube(status = "InferencePoolStatus")]
20+
#[kube(derive="Default")]
21+
#[kube(derive="PartialEq")]
22+
pub struct InferencePoolSpec {
23+
/// EndpointPickerRef is a reference to the Endpoint Picker extension and its
24+
/// associated configuration.
25+
#[serde(rename = "endpointPickerRef")]
26+
pub endpoint_picker_ref: InferencePoolEndpointPickerRef,
27+
/// Selector determines which Pods are members of this inference pool.
28+
/// It matches Pods by their labels only within the same namespace; cross-namespace
29+
/// selection is not supported.
30+
///
31+
/// The structure of this LabelSelector is intentionally simple to be compatible
32+
/// with Kubernetes Service selectors, as some implementations may translate
33+
/// this configuration into a Service resource.
34+
pub selector: InferencePoolSelector,
35+
/// TargetPorts defines a list of ports that are exposed by this InferencePool.
36+
/// Currently, the list may only include a single port definition.
37+
#[serde(rename = "targetPorts")]
38+
pub target_ports: Vec<InferencePoolTargetPorts>,
39+
}
40+
41+
/// EndpointPickerRef is a reference to the Endpoint Picker extension and its
42+
/// associated configuration.
43+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
44+
pub struct InferencePoolEndpointPickerRef {
45+
/// FailureMode configures how the parent handles the case when the Endpoint Picker extension
46+
/// is non-responsive. When unspecified, defaults to "FailClose".
47+
#[serde(default, skip_serializing_if = "Option::is_none", rename = "failureMode")]
48+
pub failure_mode: Option<InferencePoolEndpointPickerRefFailureMode>,
49+
/// Group is the group of the referent API object. When unspecified, the default value
50+
/// is "", representing the Core API group.
51+
#[serde(default, skip_serializing_if = "Option::is_none")]
52+
pub group: Option<String>,
53+
/// Kind is the Kubernetes resource kind of the referent.
54+
///
55+
/// Required if the referent is ambiguous, e.g. service with multiple ports.
56+
///
57+
/// Defaults to "Service" when not specified.
58+
///
59+
/// ExternalName services can refer to CNAME DNS records that may live
60+
/// outside of the cluster and as such are difficult to reason about in
61+
/// terms of conformance. They also may not be safe to forward to (see
62+
/// CVE-2021-25740 for more information). Implementations MUST NOT
63+
/// support ExternalName Services.
64+
#[serde(default, skip_serializing_if = "Option::is_none")]
65+
pub kind: Option<String>,
66+
/// Name is the name of the referent API object.
67+
pub name: String,
68+
/// Port is the port of the Endpoint Picker extension service.
69+
///
70+
/// Port is required when the referent is a Kubernetes Service. In this
71+
/// case, the port number is the service port number, not the target port.
72+
/// For other resources, destination port might be derived from the referent
73+
/// resource or this field.
74+
#[serde(default, skip_serializing_if = "Option::is_none")]
75+
pub port: Option<InferencePoolEndpointPickerRefPort>,
76+
}
77+
78+
/// EndpointPickerRef is a reference to the Endpoint Picker extension and its
79+
/// associated configuration.
80+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
81+
pub enum InferencePoolEndpointPickerRefFailureMode {
82+
FailOpen,
83+
FailClose,
84+
}
85+
86+
/// Port is the port of the Endpoint Picker extension service.
87+
///
88+
/// Port is required when the referent is a Kubernetes Service. In this
89+
/// case, the port number is the service port number, not the target port.
90+
/// For other resources, destination port might be derived from the referent
91+
/// resource or this field.
92+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
93+
pub struct InferencePoolEndpointPickerRefPort {
94+
/// Number defines the port number to access the selected model server Pods.
95+
/// The number must be in the range 1 to 65535.
96+
pub number: i32,
97+
}
98+
99+
/// Selector determines which Pods are members of this inference pool.
100+
/// It matches Pods by their labels only within the same namespace; cross-namespace
101+
/// selection is not supported.
102+
///
103+
/// The structure of this LabelSelector is intentionally simple to be compatible
104+
/// with Kubernetes Service selectors, as some implementations may translate
105+
/// this configuration into a Service resource.
106+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
107+
pub struct InferencePoolSelector {
108+
/// MatchLabels contains a set of required {key,value} pairs.
109+
/// An object must match every label in this map to be selected.
110+
/// The matching logic is an AND operation on all entries.
111+
#[serde(rename = "matchLabels")]
112+
pub match_labels: BTreeMap<String, String>,
113+
}
114+
115+
/// Port defines the network port that will be exposed by this InferencePool.
116+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
117+
pub struct InferencePoolTargetPorts {
118+
/// Number defines the port number to access the selected model server Pods.
119+
/// The number must be in the range 1 to 65535.
120+
pub number: i32,
121+
}
122+
123+
/// Status defines the observed state of the InferencePool.
124+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
125+
pub struct InferencePoolStatus {
126+
/// Parents is a list of parent resources, typically Gateways, that are associated with
127+
/// the InferencePool, and the status of the InferencePool with respect to each parent.
128+
///
129+
/// A controller that manages the InferencePool, must add an entry for each parent it manages
130+
/// and remove the parent entry when the controller no longer considers the InferencePool to
131+
/// be associated with that parent.
132+
///
133+
/// A maximum of 32 parents will be represented in this list. When the list is empty,
134+
/// it indicates that the InferencePool is not associated with any parents.
135+
#[serde(default, skip_serializing_if = "Option::is_none")]
136+
pub parents: Option<Vec<InferencePoolStatusParents>>,
137+
}
138+
139+
/// ParentStatus defines the observed state of InferencePool from a Parent, i.e. Gateway.
140+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
141+
pub struct InferencePoolStatusParents {
142+
/// Conditions is a list of status conditions that provide information about the observed
143+
/// state of the InferencePool. This field is required to be set by the controller that
144+
/// manages the InferencePool.
145+
///
146+
/// Supported condition types are:
147+
///
148+
/// * "Accepted"
149+
/// * "ResolvedRefs"
150+
#[serde(default, skip_serializing_if = "Option::is_none")]
151+
pub conditions: Option<Vec<Condition>>,
152+
/// ParentRef is used to identify the parent resource that this status
153+
/// is associated with. It is used to match the InferencePool with the parent
154+
/// resource, such as a Gateway.
155+
#[serde(rename = "parentRef")]
156+
pub parent_ref: InferencePoolStatusParentsParentRef,
157+
}
158+
159+
/// ParentRef is used to identify the parent resource that this status
160+
/// is associated with. It is used to match the InferencePool with the parent
161+
/// resource, such as a Gateway.
162+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
163+
pub struct InferencePoolStatusParentsParentRef {
164+
/// Group is the group of the referent API object. When unspecified, the referent is assumed
165+
/// to be in the "gateway.networking.k8s.io" API group.
166+
#[serde(default, skip_serializing_if = "Option::is_none")]
167+
pub group: Option<String>,
168+
/// Kind is the kind of the referent API object. When unspecified, the referent is assumed
169+
/// to be a "Gateway" kind.
170+
#[serde(default, skip_serializing_if = "Option::is_none")]
171+
pub kind: Option<String>,
172+
/// Name is the name of the referent API object.
173+
pub name: String,
174+
/// Namespace is the namespace of the referenced object. When unspecified, the local
175+
/// namespace is inferred.
176+
///
177+
/// Note that when a namespace different than the local namespace is specified,
178+
/// a ReferenceGrant object is required in the referent namespace to allow that
179+
/// namespace's owner to accept the reference. See the ReferenceGrant
180+
/// documentation for details: <https://gateway-api.sigs.k8s.io/api-types/referencegrant/>
181+
#[serde(default, skip_serializing_if = "Option::is_none")]
182+
pub namespace: Option<String>,
183+
}
184+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// WARNING! generated file do not edit
2+
pub mod inferencepools;
3+
mod enum_defaults;
4+
pub mod constants;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#### Pass 1
2+
InferencePoolEndpointPickerRefPort->EndPointPort
3+
InferencePoolTargetPorts->EndPointPort
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Condition
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Condition
2+
EndPointPort
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Rename only
2+
InferencePoolStatusParents->InferencePoolStatusParent
3+
InferencePoolStatusParentsParentRef->ParentRef

0 commit comments

Comments
 (0)