From 3bad31b531e6d69a5185e9099116e2c020b583ec Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Tue, 13 Apr 2021 22:31:32 +0200 Subject: [PATCH] Add allowAutoIOPSPerGBIncrease to translated AWS EBS StorageClasses By default, AWS EBS CSI driver does not increase IOPS of a volume to the minimal value supported by AWS - such increase results in increased costs, which might be surprising. It returns an error instead (increase IOPSPerGB or volume size). In-tree volume plugin does increase the IOPS. In order to preserve this behavior of volumes migrated to CSI, the translated StorageClasses should include "allowAutoIOPSPerGBIncrease" option that allows the driver to increase IOPS as the in-tree volume plugin would do. --- .../k8s.io/csi-translation-lib/plugins/aws_ebs.go | 14 ++++++++++++++ .../csi-translation-lib/plugins/aws_ebs_test.go | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs.go b/staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs.go index db00283a68d..2fc0c8a04d5 100644 --- a/staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs.go +++ b/staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs.go @@ -36,6 +36,14 @@ const ( AWSEBSInTreePluginName = "kubernetes.io/aws-ebs" // AWSEBSTopologyKey is the zonal topology key for AWS EBS CSI driver AWSEBSTopologyKey = "topology." + AWSEBSDriverName + "/zone" + // iopsPerGBKey is StorageClass parameter name that specifies IOPS + // Per GB. + iopsPerGBKey = "iopspergb" + // allowIncreaseIOPSKey is parameter name that allows the CSI driver + // to increase IOPS to the minimum value supported by AWS when IOPS + // Per GB is too low for a given volume size. This preserves current + // in-tree volume plugin behavior. + allowIncreaseIOPSKey = "allowautoiopspergbincrease" ) var _ InTreePlugin = &awsElasticBlockStoreCSITranslator{} @@ -62,6 +70,12 @@ func (t *awsElasticBlockStoreCSITranslator) TranslateInTreeStorageClassToCSI(sc generatedTopologies = generateToplogySelectors(AWSEBSTopologyKey, []string{v}) case zonesKey: generatedTopologies = generateToplogySelectors(AWSEBSTopologyKey, strings.Split(v, ",")) + case iopsPerGBKey: + // Keep iopsPerGBKey + params[k] = v + // Preserve current in-tree volume plugin behavior and allow the CSI + // driver to bump volume IOPS when volume size * iopsPerGB is too low. + params[allowIncreaseIOPSKey] = "true" default: params[k] = v } diff --git a/staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs_test.go b/staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs_test.go index c02ff54660e..20872cc3c5d 100644 --- a/staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs_test.go +++ b/staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs_test.go @@ -102,6 +102,11 @@ func TestTranslateEBSInTreeStorageClassToCSI(t *testing.T) { sc: NewStorageClass(map[string]string{"fstype": "ext3"}, nil), expSc: NewStorageClass(map[string]string{"csi.storage.k8s.io/fstype": "ext3"}, nil), }, + { + name: "translate with iops", + sc: NewStorageClass(map[string]string{"iopsPerGB": "100"}, nil), + expSc: NewStorageClass(map[string]string{"iopsPerGB": "100", "allowautoiopspergbincrease": "true"}, nil), + }, } for _, tc := range cases {