Skip to content

Commit fef01f7

Browse files
committed
support data disk category
1 parent 2803c85 commit fef01f7

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,51 @@ 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+
dataDisks:
50+
description: DataDisk to be applied to provisioned nodes.
51+
items:
52+
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
59+
device:
60+
description: Mount point of the data disk.
61+
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
77+
size:
78+
description: |-
79+
The size of the data disk. Unit: GiB.
80+
Valid values:
81+
* If you set Category to cloud: 20 to 500.
82+
* If you set Category to other disk categories: 20 to 2048.
83+
format: int32
84+
type: integer
85+
x-kubernetes-validations:
86+
- message: size invalid
87+
rule: self >= 20
88+
type: object
89+
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''))'
4994
imageSelectorTerms:
5095
description: ImageSelectorTerms is a list of or image selector terms.
5196
The terms are ORed.

pkg/apis/v1alpha1/ecsnodeclass.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ type ECSNodeClassSpec struct {
7171
// SystemDisk to be applied to provisioned nodes.
7272
// +optional
7373
SystemDisk *SystemDisk `json:"systemDisk,omitempty"`
74+
// 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'))"
76+
// +optional
77+
DataDisks []DataDisk `json:"dataDisks,omitempty"`
7478
// Tags to be applied on ecs resources like instances and launch templates.
7579
// +kubebuilder:validation:XValidation:message="empty tag keys aren't supported",rule="self.all(k, k != '')"
7680
// +kubebuilder:validation:XValidation:message="tag contains a restricted tag matching ecs:ecs-cluster-name",rule="self.all(k, k !='ecs:ecs-cluster-name')"
@@ -252,6 +256,34 @@ type SystemDisk struct {
252256
PerformanceLevel *string `json:"performanceLevel,omitempty"`
253257
}
254258

259+
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"`
266+
// The size of the data disk. Unit: GiB.
267+
// Valid values:
268+
// * If you set Category to cloud: 20 to 500.
269+
// * If you set Category to other disk categories: 20 to 2048.
270+
//
271+
// +kubebuilder:validation:XValidation:message="size invalid",rule="self >= 20"
272+
Size *int32 `json:"size,omitempty"`
273+
// Mount point of the data disk.
274+
// +optional
275+
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"`
285+
}
286+
255287
// ECSNodeClass is the Schema for the ECSNodeClass API
256288
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
257289
// +kubebuilder:resource:path=ecsnodeclasses,scope=Cluster,categories=karpenter,shortName={ecsnc,ecsncs}

pkg/apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 42 additions & 0 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ func resolveKubeletConfiguration(nodeClass *v1alpha1.ECSNodeClass) *v1alpha1.Kub
465465
return kubeletConfig
466466
}
467467

468+
//nolint:gocyclo
468469
func (p *DefaultProvider) getProvisioningGroup(ctx context.Context, nodeClass *v1alpha1.ECSNodeClass, nodeClaim *karpv1.NodeClaim,
469470
instanceTypes []*cloudprovider.InstanceType, zonalVSwitchs map[string]*vswitch.VSwitch, capacityType string, tags map[string]string,
470471
) (*ecsclient.CreateAutoProvisioningGroupRequest, error) {
@@ -560,6 +561,17 @@ func (p *DefaultProvider) getProvisioningGroup(ctx context.Context, nodeClass *v
560561
}),
561562
}
562563

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,
571+
})
572+
}
573+
createAutoProvisioningGroupRequest.LaunchConfiguration.DataDisk = dataDisks
574+
563575
if capacityType == karpv1.CapacityTypeSpot {
564576
createAutoProvisioningGroupRequest.SpotTargetCapacity = tea.String("1")
565577
createAutoProvisioningGroupRequest.PayAsYouGoTargetCapacity = tea.String("0")

0 commit comments

Comments
 (0)