mirror of https://github.com/kubernetes/kops.git
Ensure volumes are always tagged
This commit is contained in:
parent
15f3141bdb
commit
ec595a361c
|
|
@ -130,6 +130,9 @@ func (b *MasterVolumeBuilder) addAWSVolume(c *fi.ModelBuilderContext, name strin
|
|||
// This says "only mount on a master"
|
||||
tags[awsup.TagNameRolePrefix+"master"] = "1"
|
||||
|
||||
// We always add an owned tags (these can't be shared)
|
||||
tags["kubernetes.io/cluster/"+b.Cluster.ObjectMeta.Name] = "owned"
|
||||
|
||||
encrypted := fi.BoolValue(m.EncryptedVolume)
|
||||
|
||||
t := &awstasks.EBSVolume{
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package awstasks
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
|
|
@ -141,6 +142,19 @@ func (_ *EBSVolume) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *EBSVolume) e
|
|||
Encrypted: e.Encrypted,
|
||||
}
|
||||
|
||||
if len(e.Tags) != 0 {
|
||||
request.TagSpecifications = []*ec2.TagSpecification{
|
||||
{ResourceType: aws.String(ec2.ResourceTypeVolume)},
|
||||
}
|
||||
|
||||
for k, v := range e.Tags {
|
||||
request.TagSpecifications[0].Tags = append(request.TagSpecifications[0].Tags, &ec2.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(v),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
response, err := t.Cloud.EC2().CreateVolume(request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating PersistentVolume: %v", err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue