Skip to content

Commit 6264145

Browse files
committed
feat: move HardwareProfile CRD to odh-operator
1 parent a637b92 commit 6264145

14 files changed

+798
-3
lines changed

PROJECT

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,12 @@ resources:
147147
kind: Auth
148148
path: github.com/opendatahub-io/opendatahub-operator/v2/api/services/v1alpha1
149149
version: v1alpha1
150+
- api:
151+
crdVersion: v1
152+
namespaced: true
153+
domain: opendatahub.io
154+
group: infrastructure
155+
kind: HardwareProfile
156+
path: github.com/opendatahub-io/opendatahub-operator/api/infrastructure/v1alpha1
157+
version: v1alpha1
150158
version: "3"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 contains API Schema definitions for the infrastructure v1alpha1 API group.
18+
// +kubebuilder:object:generate=true
19+
// +groupName=infrastructure.opendatahub.io
20+
package v1alpha1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "infrastructure.opendatahub.io", Version: "v1alpha1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
}

api/infrastructure/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)