|
| 1 | +/* |
| 2 | +Copyright 2025 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | + |
| 22 | + v1 "sigs.k8s.io/gateway-api-inference-extension/api/v1" |
| 23 | +) |
| 24 | + |
| 25 | +// InferencePoolImport is the Schema for the InferencePoolImports API. |
| 26 | +// |
| 27 | +// +kubebuilder:object:root=true |
| 28 | +// +kubebuilder:resource:shortName=infpimp |
| 29 | +// +kubebuilder:subresource:status |
| 30 | +// +kubebuilder:storageversion |
| 31 | +// +genclient |
| 32 | +type InferencePoolImport struct { |
| 33 | + metav1.TypeMeta `json:",inline"` |
| 34 | + |
| 35 | + // +optional |
| 36 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 37 | + |
| 38 | + // Spec defines the desired state of the InferencePoolImport. |
| 39 | + // |
| 40 | + // +required |
| 41 | + Spec InferencePoolImportSpec `json:"spec,omitzero"` |
| 42 | + |
| 43 | + // Status defines the observed state of the InferencePoolImport. |
| 44 | + // |
| 45 | + // +optional |
| 46 | + //nolint:kubeapilinter // status should not be a pointer. |
| 47 | + Status InferencePoolImportStatus `json:"status,omitempty"` |
| 48 | +} |
| 49 | + |
| 50 | +// InferencePoolImportList contains a list of InferencePoolImports. |
| 51 | +// |
| 52 | +// +kubebuilder:object:root=true |
| 53 | +type InferencePoolImportList struct { |
| 54 | + metav1.TypeMeta `json:",inline"` |
| 55 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 56 | + Items []InferencePoolImport `json:"items"` |
| 57 | +} |
| 58 | + |
| 59 | +// InferencePoolImportSpec defines the desired state of the InferencePoolImport. |
| 60 | +type InferencePoolImportSpec struct {} |
| 61 | + |
| 62 | +// InferencePoolImportStatus defines the observed state of the InferencePoolImport. |
| 63 | +type InferencePoolImportStatus struct { |
| 64 | + // Controllers is a list of controllers that are responsible for managing the InferencePoolImport. |
| 65 | + // |
| 66 | + // +listType=map |
| 67 | + // +listMapKey=name |
| 68 | + // +kubebuilder:validation:MaxItems=8 |
| 69 | + // +kubebuilder:validation:Required |
| 70 | + Controllers []ImportController `json:"controllers"` |
| 71 | +} |
| 72 | + |
| 73 | +// ImportController defines a controller that is responsible for managing the InferencePoolImport. |
| 74 | +type ImportController struct { |
| 75 | + // Name is a domain/path string that indicates the name of the controller that manages the |
| 76 | + // InferencePoolImport. Name corresponds to the GatewayClass controllerName field when the |
| 77 | + // controller will manage parents of type "Gateway". Otherwise, the name is implementation-specific. |
| 78 | + // |
| 79 | + // Example: "example.net/import-controller". |
| 80 | + // |
| 81 | + // The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are valid Kubernetes |
| 82 | + // names (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names). |
| 83 | + // |
| 84 | + // A controller MUST populate this field when writing status and ensure that entries to status |
| 85 | + // populated with their controller name are removed when they are no longer necessary. |
| 86 | + // |
| 87 | + // +required |
| 88 | + Name ControllerName `json:"name"` |
| 89 | + |
| 90 | + // ExportingClusters is a list of clusters that exported the InferencePool(s) that back the |
| 91 | + // InferencePoolImport. Required when the controller is responsible for CRUD'ing the InferencePoolImport |
| 92 | + // from the exported InferencePool(s). |
| 93 | + // |
| 94 | + // +optional |
| 95 | + ExportingClusters []ExportingCluster `json:"exportingClusters,omitempty"` |
| 96 | + |
| 97 | + // Parents is a list of parent resources, typically Gateways, that are associated with the |
| 98 | + // InferencePoolImport, and the status of the InferencePoolImport with respect to each parent. |
| 99 | + // |
| 100 | + // Ancestor would be a more accurate name, but Parent is consistent with InferencePool terminology. |
| 101 | + // |
| 102 | + // Required when the controller manages the InferencePoolImport as an HTTPRoute backendRef. The controller |
| 103 | + // must add an entry for each parent it manages and remove the parent entry when the controller no longer |
| 104 | + // considers the InferencePoolImport to be associated with that parent. |
| 105 | + // |
| 106 | + // +optional |
| 107 | + // +listType=atomic |
| 108 | + Parents []v1.ParentStatus `json:"parents,omitempty"` |
| 109 | + |
| 110 | + // Conditions track the state of the InferencePoolImport. |
| 111 | + // |
| 112 | + // Known condition types are: |
| 113 | + // |
| 114 | + // * "Accepted" |
| 115 | + // |
| 116 | + // +optional |
| 117 | + // +listType=map |
| 118 | + // +listMapKey=type |
| 119 | + // +kubebuilder:validation:MaxItems=8 |
| 120 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 121 | +} |
| 122 | + |
| 123 | +// ControllerName is the name of a controller that manages a resource. It must be a domain prefixed path. |
| 124 | +// |
| 125 | +// Valid values include: |
| 126 | +// |
| 127 | +// * "example.com/bar" |
| 128 | +// |
| 129 | +// Invalid values include: |
| 130 | +// |
| 131 | +// * "example.com" - must include path |
| 132 | +// * "foo.example.com" - must include path |
| 133 | +// |
| 134 | +// +kubebuilder:validation:MinLength=1 |
| 135 | +// +kubebuilder:validation:MaxLength=253 |
| 136 | +// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/[A-Za-z0-9\/\-._~%!$&'()*+,;=:]+$` |
| 137 | +type ControllerName string |
| 138 | + |
| 139 | +// ExportingCluster defines a cluster that exported the InferencePool associated to this InferencePoolImport. |
| 140 | +type ExportingCluster struct { |
| 141 | + // Name of the exporting cluster (must be unique within the list). |
| 142 | + // |
| 143 | + // +kubebuilder:validation:Required |
| 144 | + Name string `json:"name"` |
| 145 | +} |
0 commit comments