|
| 1 | +/* |
| 2 | +Copyright 2024. |
| 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 v1 |
| 18 | + |
| 19 | +import ( |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | +) |
| 22 | + |
| 23 | +// DpuNetworkSpec defines the desired state of DpuNetwork. |
| 24 | +type DpuNetworkSpec struct { |
| 25 | + // NodeSelector specifies which nodes this DpuNetwork should apply to. |
| 26 | + // If empty, the DpuNetwork will apply to all nodes. |
| 27 | + // +optional |
| 28 | + NodeSelector *metav1.LabelSelector `json:"nodeSelector,omitempty"` |
| 29 | + |
| 30 | + // DpuSelector specifies which DPUs (and their VFs) this DpuNetwork targets. |
| 31 | + // |
| 32 | + // Note: Today this is treated as an opaque selector definition; the controller |
| 33 | + // parses vfId ranges from matchExpressions (if present) but does not yet |
| 34 | + // validate against a per-VF inventory. |
| 35 | + // +optional |
| 36 | + DpuSelector *metav1.LabelSelector `json:"dpuSelector,omitempty"` |
| 37 | + |
| 38 | + // IsAccelerated indicates whether the network should be treated as accelerated |
| 39 | + // by downstream components. |
| 40 | + // +optional |
| 41 | + IsAccelerated bool `json:"isAccelerated,omitempty"` |
| 42 | +} |
| 43 | + |
| 44 | +// DpuNetworkStatus defines the observed state of DpuNetwork. |
| 45 | +type DpuNetworkStatus struct { |
| 46 | + // Conditions is the status of the DpuNetwork. |
| 47 | + // +optional |
| 48 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 49 | + |
| 50 | + // ResourceName is the Kubernetes extended resource name generated for this network. |
| 51 | + // +optional |
| 52 | + ResourceName string `json:"resourceName,omitempty"` |
| 53 | + |
| 54 | + // SelectedVFs is the list of VF IDs parsed from vfId ranges. |
| 55 | + // +optional |
| 56 | + SelectedVFs []int32 `json:"selectedVFs,omitempty"` |
| 57 | +} |
| 58 | + |
| 59 | +//+kubebuilder:object:root=true |
| 60 | +//+kubebuilder:subresource:status |
| 61 | +//+kubebuilder:resource:scope=Cluster,shortName=dpunet |
| 62 | +//+kubebuilder:printcolumn:name="Resource",type="string",JSONPath=".status.resourceName" |
| 63 | +//+kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" |
| 64 | + |
| 65 | +// DpuNetwork is the Schema for the dpunetworks API. |
| 66 | +type DpuNetwork struct { |
| 67 | + metav1.TypeMeta `json:",inline"` |
| 68 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 69 | + |
| 70 | + Spec DpuNetworkSpec `json:"spec,omitempty"` |
| 71 | + Status DpuNetworkStatus `json:"status,omitempty"` |
| 72 | +} |
| 73 | + |
| 74 | +//+kubebuilder:object:root=true |
| 75 | + |
| 76 | +// DpuNetworkList contains a list of DpuNetwork. |
| 77 | +type DpuNetworkList struct { |
| 78 | + metav1.TypeMeta `json:",inline"` |
| 79 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 80 | + Items []DpuNetwork `json:"items"` |
| 81 | +} |
| 82 | + |
| 83 | +func init() { |
| 84 | + SchemeBuilder.Register(&DpuNetwork{}, &DpuNetworkList{}) |
| 85 | +} |
0 commit comments