Skip to content

Commit 747d448

Browse files
committed
e2e: on aws, tag volumes we want the cluster to mount
Locked down IAM configurations will prevent mounting of arbitrary volumes, so when we create volumes that we intend the cluster to mount, we must set the appropriate EC2 tags.
1 parent 2b795b9 commit 747d448

File tree

1 file changed

+23
-0
lines changed
  • test/e2e/framework/providers/aws

1 file changed

+23
-0
lines changed

test/e2e/framework/providers/aws/aws.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,29 @@ func (p *Provider) CreatePD(zone string) (string, error) {
100100
request.AvailabilityZone = aws.String(zone)
101101
request.Size = aws.Int64(10)
102102
request.VolumeType = aws.String(awscloud.DefaultVolumeType)
103+
104+
// We need to tag the volume so that locked-down IAM configurations can still mount it
105+
if framework.TestContext.CloudConfig.ClusterTag != "" {
106+
clusterID := framework.TestContext.CloudConfig.ClusterTag
107+
108+
legacyTag := &ec2.Tag{
109+
Key: aws.String(awscloud.TagNameKubernetesClusterLegacy),
110+
Value: aws.String(clusterID),
111+
}
112+
113+
newTag := &ec2.Tag{
114+
Key: aws.String(awscloud.TagNameKubernetesClusterPrefix + clusterID),
115+
Value: aws.String(awscloud.ResourceLifecycleOwned),
116+
}
117+
118+
tagSpecification := &ec2.TagSpecification{
119+
ResourceType: aws.String(ec2.ResourceTypeVolume),
120+
Tags: []*ec2.Tag{legacyTag, newTag},
121+
}
122+
123+
request.TagSpecifications = append(request.TagSpecifications, tagSpecification)
124+
}
125+
103126
response, err := client.CreateVolume(request)
104127
if err != nil {
105128
return "", err

0 commit comments

Comments
 (0)