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 a5c32013f90..3b3dbac1f63 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 896b0ffacf8..b38847f2659 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 {