Skip to content

Commit 78841be

Browse files
authored
Add gpu type to cluster spec (#84)
* Add gpu type to cluster spec * Fix typos * Do not mark constants as unused in Goland. They are used in other projects.
1 parent f61710a commit 78841be

File tree

9 files changed

+118
-3
lines changed

9 files changed

+118
-3
lines changed

api/v1/qdrantcluster_types.go

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import (
99
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1010
)
1111

12+
//goland:noinspection GoUnusedConst
1213
const (
1314
KindQdrantCluster = "QdrantCluster"
1415
ResourceQdrantCluster = "qdrantclusters"
1516
)
1617

18+
//goland:noinspection GoUnusedConst
1719
const (
1820
// RestartedAtAnnotationKey is the annotation key to trigger a restart.
1921
// The annotation should be placed on the QdrantCluster instance.
@@ -72,6 +74,14 @@ func GetQdrantClusterCrdForHash(qc QdrantCluster) QdrantCluster {
7274
return result
7375
}
7476

77+
type GPUType string
78+
79+
//goland:noinspection GoUnusedConst
80+
const (
81+
GPUTypeNvidia GPUType = "nvidia"
82+
GPUTypeAmd GPUType = "amd"
83+
)
84+
7585
// QdrantClusterSpec defines the desired state of QdrantCluster
7686
// +kubebuilder:pruning:PreserveUnknownFields
7787
type QdrantClusterSpec struct {
@@ -125,6 +135,9 @@ type QdrantClusterSpec struct {
125135
// Service specifies the configuration of the Qdrant Kubernetes Service.
126136
// +optional
127137
Service *KubernetesService `json:"service,omitempty"`
138+
// GPU specifies GPU configuration for the cluster. If this field is not set, no GPU will be used.
139+
// +optional
140+
GPU *GPU `json:"gpu,omitempty"`
128141
// StatefulSet specifies the configuration of the Qdrant Kubernetes StatefulSet.
129142
// +optional
130143
StatefulSet *KubernetesStatefulSet `json:"statefulSet,omitempty"`
@@ -151,7 +164,7 @@ type QdrantClusterSpec struct {
151164
StartupDelaySeconds *int `json:"startupDelaySeconds,omitempty"`
152165
}
153166

154-
// Validates if there are incorrect settings in the CRD
167+
// Validate if there are incorrect settings in the CRD
155168
func (s QdrantClusterSpec) Validate() error {
156169
if err := s.Resources.Validate("Spec.Resources"); err != nil {
157170
return err
@@ -167,6 +180,19 @@ func (s QdrantClusterSpec) GetServicePerNode() bool {
167180
return *s.ServicePerNode
168181
}
169182

183+
type GPU struct {
184+
// GPUType specifies the type of the GPU to use.
185+
// +kubebuilder:validation:Enum=nvidia;amd
186+
GPUType GPUType `json:"gpuType"`
187+
}
188+
189+
func (g *GPU) GetGPUType() GPUType {
190+
if g == nil {
191+
return ""
192+
}
193+
return g.GPUType
194+
}
195+
170196
type KubernetesService struct {
171197
// Type specifies the type of the Service: "ClusterIP", "NodePort", "LoadBalancer".
172198
// +kubebuilder:default="ClusterIP"
@@ -296,7 +322,7 @@ type Resources struct {
296322
Requests ResourceRequests `json:"requests,omitempty"`
297323
}
298324

299-
// Validates if there are incorrect settings in the CRD
325+
// Validate if there are incorrect settings in the CRD
300326
func (s Resources) Validate(base string) error {
301327
if _, err := resource.ParseQuantity(s.CPU); err != nil {
302328
return fmt.Errorf("%s.CPU error: %w", base, err)
@@ -336,7 +362,7 @@ type ResourceRequests struct {
336362
Memory string `json:"memory,omitempty"`
337363
}
338364

339-
// Validates if there are incorrect settings in the CRD
365+
// Validate if there are incorrect settings in the CRD
340366
func (s ResourceRequests) Validate(base string) error {
341367
if s.CPU != "" {
342368
if _, err := resource.ParseQuantity(s.CPU); err != nil {
@@ -688,6 +714,7 @@ func (n *StorageClassNames) GetSnapshots() *string {
688714

689715
type ClusterPhase string
690716

717+
//goland:noinspection GoUnusedConst
691718
const (
692719
ClusterActiveStateSuffix = "ing"
693720
ClusterFailedStatePrefix = "FailedTo"
@@ -716,6 +743,7 @@ const (
716743

717744
type ClusterCondition string
718745

746+
//goland:noinspection GoUnusedConst
719747
const (
720748
ClusterConditionAcceptingConnection ClusterCondition = "AcceptingConnection"
721749
ClusterConditionRecoveryMode ClusterCondition = "RecoveryMode"

api/v1/qdrantclusterrestore_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package v1
22

33
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
44

5+
//goland:noinspection GoUnusedConst
56
const (
67
KindQdrantClusterRestore = "QdrantClusterRestore"
78
ResourceQdrantClusterRestore = "qdrantclusterrestores"
@@ -31,6 +32,7 @@ type RestoreDestination struct {
3132

3233
type RestorePhase string
3334

35+
//goland:noinspection GoUnusedConst
3436
const (
3537
RestoreRunning RestorePhase = "Running"
3638
RestoreSkipped RestorePhase = "Skipped"

api/v1/qdrantclusterscheduledsnapshot_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package v1
22

33
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
44

5+
//goland:noinspection GoUnusedConst
56
const (
67
KindQdrantClusterScheduledSnapshot = "QdrantClusterScheduledSnapshot"
78
ResourceQdrantClusterScheduledSnapshot = "qdrantclusterscheduledsnapshots"
@@ -25,6 +26,7 @@ type QdrantClusterScheduledSnapshotSpec struct {
2526

2627
type ScheduledSnapshotPhase string
2728

29+
//goland:noinspection GoUnusedConst
2830
const (
2931
ScheduleActive ScheduledSnapshotPhase = "Active"
3032
ScheduleDisabled ScheduledSnapshotPhase = "Disabled"

api/v1/qdrantclustersnapshot_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package v1
22

33
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
44

5+
//goland:noinspection GoUnusedConst
56
const (
67
KindQdrantClusterSnapshot = "QdrantClusterSnapshot"
78
ResourceQdrantClusterSnapshot = "qdrantclustersnapshots"
@@ -28,6 +29,7 @@ type QdrantClusterSnapshotSpec struct {
2829

2930
type QdrantClusterSnapshotPhase string
3031

32+
//goland:noinspection GoUnusedConst
3133
const (
3234
SnapshotRunning QdrantClusterSnapshotPhase = "Running"
3335
SnapshotSkipped QdrantClusterSnapshotPhase = "Skipped"

api/v1/region_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
77
)
88

9+
//goland:noinspection GoUnusedConst
910
const (
1011
KindQdrantCloudRegion = "QdrantCloudRegion"
1112
ResourceQdrantCloudRegion = "qdrantcloudregions"
@@ -62,6 +63,7 @@ type HelmRelease struct {
6263

6364
type RegionPhase string
6465

66+
//goland:noinspection GoUnusedConst
6567
const (
6668
RegionPhaseReady RegionPhase = "Ready"
6769
RegionPhaseNotReady RegionPhase = "NotReady"
@@ -70,6 +72,7 @@ const (
7072

7173
type MetricSource string
7274

75+
//goland:noinspection GoUnusedConst
7376
const (
7477
KubeletMetricSource MetricSource = "kubelet"
7578
ApiMetricSource MetricSource = "api"
@@ -189,6 +192,7 @@ type RegionCapabilities struct {
189192

190193
type KubernetesDistribution string
191194

195+
//goland:noinspection GoUnusedConst
192196
const (
193197
K8sDistributionUnknown KubernetesDistribution = "unknown"
194198
K8sDistributionAWS KubernetesDistribution = "aws"
@@ -208,6 +212,7 @@ const (
208212

209213
type ComponentPhase string
210214

215+
//goland:noinspection GoUnusedConst
211216
const (
212217
ComponentPhaseReady ComponentPhase = "Ready"
213218
ComponentPhaseNotReady ComponentPhase = "NotReady"

api/v1/zz_generated.deepcopy.go

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

charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclusters.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,19 @@ spec:
296296
type: object
297297
type: object
298298
type: object
299+
gpu:
300+
description: GPU specifies GPU configuration for the cluster. If this
301+
field is not set, no GPU will be used.
302+
properties:
303+
gpuType:
304+
description: GPUType specifies the type of the GPU to use.
305+
enum:
306+
- nvidia
307+
- amd
308+
type: string
309+
required:
310+
- gpuType
311+
type: object
299312
id:
300313
description: Id specifies the unique identifier of the cluster
301314
type: string

crds/qdrant.io_qdrantclusters.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,19 @@ spec:
295295
type: object
296296
type: object
297297
type: object
298+
gpu:
299+
description: GPU specifies GPU configuration for the cluster. If this
300+
field is not set, no GPU will be used.
301+
properties:
302+
gpuType:
303+
description: GPUType specifies the type of the GPU to use.
304+
enum:
305+
- nvidia
306+
- amd
307+
type: string
308+
required:
309+
- gpuType
310+
type: object
298311
id:
299312
description: Id specifies the unique identifier of the cluster
300313
type: string

docs/api.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,35 @@ _Appears in:_
9292
| `message` _string_ | Message specifies the info explaining the current phase of the component | | |
9393

9494

95+
#### GPU
96+
97+
98+
99+
100+
101+
102+
103+
_Appears in:_
104+
- [QdrantClusterSpec](#qdrantclusterspec)
105+
106+
| Field | Description | Default | Validation |
107+
| --- | --- | --- | --- |
108+
| `gpuType` _[GPUType](#gputype)_ | GPUType specifies the type of the GPU to use. | | Enum: [nvidia amd] <br /> |
109+
110+
111+
#### GPUType
112+
113+
_Underlying type:_ _string_
114+
115+
116+
117+
118+
119+
_Appears in:_
120+
- [GPU](#gpu)
121+
122+
123+
95124
#### HelmRelease
96125

97126

@@ -663,6 +692,7 @@ _Appears in:_
663692
| `config` _[QdrantConfiguration](#qdrantconfiguration)_ | Config specifies the Qdrant configuration setttings for the clusters. | | |
664693
| `ingress` _[Ingress](#ingress)_ | Ingress specifies the ingress for the cluster. | | |
665694
| `service` _[KubernetesService](#kubernetesservice)_ | Service specifies the configuration of the Qdrant Kubernetes Service. | | |
695+
| `gpu` _[GPU](#gpu)_ | GPU specifies GPU configuration for the cluster. If this field is not set, no GPU will be used. | | |
666696
| `statefulSet` _[KubernetesStatefulSet](#kubernetesstatefulset)_ | StatefulSet specifies the configuration of the Qdrant Kubernetes StatefulSet. | | |
667697
| `storageClassNames` _[StorageClassNames](#storageclassnames)_ | StorageClassNames specifies the storage class names for db and snapshots. | | |
668698
| `topologySpreadConstraints` _[TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#topologyspreadconstraint-v1-core)_ | TopologySpreadConstraints specifies the topology spread constraints for the cluster. | | |

0 commit comments

Comments
 (0)