|
| 1 | +/* |
| 2 | +Copyright 2023. |
| 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 | + corev1 "k8s.io/api/core/v1" |
| 21 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | + "k8s.io/apimachinery/pkg/util/intstr" |
| 23 | +) |
| 24 | + |
| 25 | +// HardwareProfileSpec defines the desired state of HardwareProfile. |
| 26 | +type HardwareProfileSpec struct { |
| 27 | + // The display name of the hardware profile. |
| 28 | + DisplayName string `json:"displayName"` |
| 29 | + |
| 30 | + // Indicates whether the hardware profile is available for new resources. |
| 31 | + Enabled bool `json:"enabled"` |
| 32 | + |
| 33 | + // A short description of the hardware profile. |
| 34 | + // +optional |
| 35 | + Description string `json:"description,omitempty"` |
| 36 | + |
| 37 | + // The array of identifiers |
| 38 | + // +optional |
| 39 | + Identifiers []HardwareIdentifier `json:"identifiers,omitempty"` |
| 40 | + |
| 41 | + // The node selector available. |
| 42 | + // +optional |
| 43 | + NodeSelector map[string]string `json:"nodeSelector,omitempty"` |
| 44 | + |
| 45 | + // Any number of Kubernetes toleration values that are added to resources when created or updated to this hardware profile. |
| 46 | + // +optional |
| 47 | + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` |
| 48 | +} |
| 49 | + |
| 50 | +type HardwareIdentifier struct { |
| 51 | + // The display name of identifier. |
| 52 | + DisplayName string `json:"displayName"` |
| 53 | + |
| 54 | + // The resource identifier of the hardware device. |
| 55 | + Identifier string `json:"identifier"` |
| 56 | + |
| 57 | + // The minimum count can be an integer or a string. |
| 58 | + MinCount intstr.IntOrString `json:"minCount"` |
| 59 | + |
| 60 | + // The maximum count can be an integer or a string. |
| 61 | + // +optional |
| 62 | + MaxCount *intstr.IntOrString `json:"maxCount,omitempty"` |
| 63 | + |
| 64 | + // The default count can be an integer or a string. |
| 65 | + DefaultCount intstr.IntOrString `json:"defaultCount"` |
| 66 | + |
| 67 | + // The type of identifier. could be "CPU", "Memory", or "Accelerator". Leave it undefined for the other types. |
| 68 | + // +optional |
| 69 | + // +kubebuilder:validation:Enum=CPU;Memory;Accelerator |
| 70 | + ResourceType string `json:"resourceType,omitempty"` |
| 71 | +} |
| 72 | + |
| 73 | +// HardwareProfileStatus defines the observed state of HardwareProfile. |
| 74 | +type HardwareProfileStatus struct { |
| 75 | + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster |
| 76 | + // Important: Run "make" to regenerate code after modifying this file |
| 77 | +} |
| 78 | + |
| 79 | +// +kubebuilder:object:root=true |
| 80 | +//+kubebuilder:subresource:status |
| 81 | + |
| 82 | +// HardwareProfile is the Schema for the hardwareprofiles API. |
| 83 | +type HardwareProfile struct { |
| 84 | + metav1.TypeMeta `json:",inline"` |
| 85 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 86 | + |
| 87 | + Spec HardwareProfileSpec `json:"spec"` |
| 88 | + Status HardwareProfileStatus `json:"status,omitempty"` |
| 89 | +} |
| 90 | + |
| 91 | +// +kubebuilder:object:root=true |
| 92 | + |
| 93 | +// HardwareProfileList contains a list of HardwareProfile. |
| 94 | +type HardwareProfileList struct { |
| 95 | + metav1.TypeMeta `json:",inline"` |
| 96 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 97 | + Items []HardwareProfile `json:"items"` |
| 98 | +} |
| 99 | + |
| 100 | +func init() { |
| 101 | + SchemeBuilder.Register(&HardwareProfile{}, &HardwareProfileList{}) |
| 102 | +} |
0 commit comments