Skip to content

Commit ea48ecb

Browse files
committed
multiple data disk category
1 parent fef01f7 commit ea48ecb

File tree

4 files changed

+30
-59
lines changed

4 files changed

+30
-59
lines changed

charts/karpenter/crds/karpenter.k8s.alibabacloud_ecsnodeclasses.yaml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,21 @@ spec:
4646
ECSNodeClassSpec is the top level specification for the AlibabaCloud Karpenter Provider.
4747
This will contain the configuration necessary to launch instances in AlibabaCloud.
4848
properties:
49+
dataDiskCategories:
50+
description: |-
51+
The category of the data disk (for example, cloud and cloud_ssd).
52+
Different ECS is compatible with different disk category, using array to maximize ECS creation success.
53+
Valid values:"cloud", "cloud_efficiency", "cloud_ssd", "cloud_essd", "cloud_auto", and "cloud_essd_entry"
54+
items:
55+
type: string
56+
type: array
4957
dataDisks:
5058
description: DataDisk to be applied to provisioned nodes.
5159
items:
5260
properties:
53-
category:
54-
description: |-
55-
The category of the data disk (for example, cloud and cloud_ssd).
56-
Different ECS is compatible with different disk category, using array to maximize ECS creation success.
57-
Valid values:"cloud", "cloud_efficiency", "cloud_ssd", "cloud_essd", "cloud_auto", and "cloud_essd_entry"
58-
type: string
5961
device:
6062
description: Mount point of the data disk.
6163
type: string
62-
performanceLevel:
63-
default: PL0
64-
description: |-
65-
The performance level of the ESSD to use as the data disk. Default value: PL0.
66-
Valid values:
67-
* PL0: A single ESSD can deliver up to 10,000 random read/write IOPS.
68-
* PL1: A single ESSD can deliver up to 50,000 random read/write IOPS.
69-
* PL2: A single ESSD can deliver up to 100,000 random read/write IOPS.
70-
* PL3: A single ESSD can deliver up to 1,000,000 random read/write IOPS.
71-
enum:
72-
- PL0
73-
- PL1
74-
- PL2
75-
- PL3
76-
type: string
7764
size:
7865
description: |-
7966
The size of the data disk. Unit: GiB.
@@ -87,10 +74,6 @@ spec:
8774
rule: self >= 20
8875
type: object
8976
type: array
90-
x-kubernetes-validations:
91-
- message: PerformanceLevel can be set only when Category belongs
92-
to ESSD
93-
rule: '!self.exists(x, has(x.performanceLevel) && ((!has(x.category))||x.category==''cloud''||x.category==''cloud_efficiency''||x.category==''cloud_ssd''))'
9477
imageSelectorTerms:
9578
description: ImageSelectorTerms is a list of or image selector terms.
9679
The terms are ORed.

pkg/apis/v1alpha1/ecsnodeclass.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,14 @@ type ECSNodeClassSpec struct {
7272
// +optional
7373
SystemDisk *SystemDisk `json:"systemDisk,omitempty"`
7474
// DataDisk to be applied to provisioned nodes.
75-
// +kubebuilder:validation:XValidation:message="PerformanceLevel can be set only when Category belongs to ESSD",rule="!self.exists(x, has(x.performanceLevel) && ((!has(x.category))||x.category=='cloud'||x.category=='cloud_efficiency'||x.category=='cloud_ssd'))"
7675
// +optional
7776
DataDisks []DataDisk `json:"dataDisks,omitempty"`
77+
// The category of the data disk (for example, cloud and cloud_ssd).
78+
// Different ECS is compatible with different disk category, using array to maximize ECS creation success.
79+
// Valid values:"cloud", "cloud_efficiency", "cloud_ssd", "cloud_essd", "cloud_auto", and "cloud_essd_entry"
80+
// +kubebuilder:validation:Items=Enum=cloud;cloud_efficiency;cloud_ssd;cloud_essd;cloud_auto;cloud_essd_entry
81+
// +optional
82+
DataDisksCategories []string `json:"dataDiskCategories,omitempty"`
7883
// Tags to be applied on ecs resources like instances and launch templates.
7984
// +kubebuilder:validation:XValidation:message="empty tag keys aren't supported",rule="self.all(k, k != '')"
8085
// +kubebuilder:validation:XValidation:message="tag contains a restricted tag matching ecs:ecs-cluster-name",rule="self.all(k, k !='ecs:ecs-cluster-name')"
@@ -257,12 +262,6 @@ type SystemDisk struct {
257262
}
258263

259264
type DataDisk struct {
260-
// The category of the data disk (for example, cloud and cloud_ssd).
261-
// Different ECS is compatible with different disk category, using array to maximize ECS creation success.
262-
// Valid values:"cloud", "cloud_efficiency", "cloud_ssd", "cloud_essd", "cloud_auto", and "cloud_essd_entry"
263-
// +kubebuilder:validation:Items=Enum=cloud;cloud_efficiency;cloud_ssd;cloud_essd;cloud_auto;cloud_essd_entry
264-
// +optional
265-
Category *string `json:"category,omitempty"`
266265
// The size of the data disk. Unit: GiB.
267266
// Valid values:
268267
// * If you set Category to cloud: 20 to 500.
@@ -273,15 +272,6 @@ type DataDisk struct {
273272
// Mount point of the data disk.
274273
// +optional
275274
Device *string `json:"device,omitempty"`
276-
// The performance level of the ESSD to use as the data disk. Default value: PL0.
277-
// Valid values:
278-
// * PL0: A single ESSD can deliver up to 10,000 random read/write IOPS.
279-
// * PL1: A single ESSD can deliver up to 50,000 random read/write IOPS.
280-
// * PL2: A single ESSD can deliver up to 100,000 random read/write IOPS.
281-
// * PL3: A single ESSD can deliver up to 1,000,000 random read/write IOPS.
282-
// +kubebuilder:validation:Enum:={PL0,PL1,PL2,PL3}
283-
// +kubebuilder:default:=PL0
284-
PerformanceLevel *string `json:"performanceLevel,omitempty"`
285275
}
286276

287277
// ECSNodeClass is the Schema for the ECSNodeClass API

pkg/apis/v1alpha1/zz_generated.deepcopy.go

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

pkg/providers/instance/instance.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,16 +561,19 @@ func (p *DefaultProvider) getProvisioningGroup(ctx context.Context, nodeClass *v
561561
}),
562562
}
563563

564-
var dataDisks []*ecsclient.CreateAutoProvisioningGroupRequestLaunchConfigurationDataDisk
565-
for _, dataDisk := range nodeClass.Spec.DataDisks {
566-
dataDisks = append(dataDisks, &ecsclient.CreateAutoProvisioningGroupRequestLaunchConfigurationDataDisk{
567-
Category: dataDisk.Category,
568-
Size: dataDisk.Size,
569-
Device: dataDisk.Device,
570-
PerformanceLevel: dataDisk.PerformanceLevel,
564+
if nodeClass.Spec.DataDisks != nil && nodeClass.Spec.DataDisksCategories != nil {
565+
createAutoProvisioningGroupRequest.LaunchConfiguration.DataDisk = lo.Map(nodeClass.Spec.DataDisks, func(dataDisk v1alpha1.DataDisk, index int) *ecsclient.CreateAutoProvisioningGroupRequestLaunchConfigurationDataDisk {
566+
return &ecsclient.CreateAutoProvisioningGroupRequestLaunchConfigurationDataDisk{
567+
Size: dataDisk.Size,
568+
Device: dataDisk.Device,
569+
}
570+
})
571+
createAutoProvisioningGroupRequest.DataDiskConfig = lo.Map(nodeClass.Spec.DataDisksCategories, func(category string, index int) *ecsclient.CreateAutoProvisioningGroupRequestDataDiskConfig {
572+
return &ecsclient.CreateAutoProvisioningGroupRequestDataDiskConfig{
573+
DiskCategory: &category,
574+
}
571575
})
572576
}
573-
createAutoProvisioningGroupRequest.LaunchConfiguration.DataDisk = dataDisks
574577

575578
if capacityType == karpv1.CapacityTypeSpot {
576579
createAutoProvisioningGroupRequest.SpotTargetCapacity = tea.String("1")

0 commit comments

Comments
 (0)