Add tags to snapshot based on VolumeSnapshotClass
Is this a bug fix or adding new feature?
Adds support for adding tags to snapshots based on the parameters from VolumeSnapshotClasses, similar to support for tags for volumes in StorageClasses.
What is this PR about? / Why do we need it?
Fixes #1261
What testing is done?
Added test case for VSC-based tags
Hi @ConnorJC3. Thanks for your PR.
I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
/ok-to-test
/hold want to implement some template parameters such as volume name/snapshot name (similar to how it works for SC-based tags)
Tested changes, this revision lgtm.
storageclass.yaml >
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: csi-aws-vsc
driver: ebs.csi.aws.com
parameters:
tagSpecification: "key1=value1"
deletionPolicy: Delete
$ kubectl apply -f manifests/classes/
volumesnapshotclass.snapshot.storage.k8s.io/csi-aws-vsc created
storageclass.storage.k8s.io/ebs-sc created
$ kubectl apply -f manifests/app/
persistentvolumeclaim/ebs-claim created
pod/app created
$ kubectl apply -f manifests/snapshot/
volumesnapshot.snapshot.storage.k8s.io/ebs-volume-snapshot created
$ kubectl describe volumesnapshotclass.snapshot.storage.k8s.io/csi-aws-vsc
Name: csi-aws-vsc
Namespace:
Labels: <none>
Annotations: <none>
API Version: snapshot.storage.k8s.io/v1
Deletion Policy: Delete
Driver: ebs.csi.aws.com
Kind: VolumeSnapshotClass
Metadata:
Generation: 1
Managed Fields:
API Version: snapshot.storage.k8s.io/v1
Fields Type: FieldsV1
fieldsV1:
f:deletionPolicy:
f:driver:
f:metadata:
f:annotations:
.:
f:kubectl.kubernetes.io/last-applied-configuration:
f:parameters:
.:
f:tagSpecification:
Manager: kubectl-client-side-apply
Operation: Update
Resource Version: 3172
UID: a4a0999f-cdbc-4729-afba-7cd38ec92ea1
Parameters:
Tag Specification: key1=value1
Events: <none>
$ aws ec2 describe-snapshots --snapshot-ids snap-09db3ada9aa69712f --region=us-east-2
{
"Snapshots": [
{
"Description": "Created by AWS EBS CSI driver for volume vol-00d90794c7e6f7321",
"Encrypted": true,
"Progress": "100%",
"SnapshotId": "snap-09db3ada9aa69712f",
"State": "completed",
"VolumeId": "vol-00d90794c7e6f7321",
"VolumeSize": 4,
"Tags": [
{
"Key": "CSIVolumeSnapshotName",
"Value": "snapshot-f7036108-ae3a-43bf-88bf-89c96baf0518"
},
{
"Key": "ebs.csi.aws.com/cluster",
"Value": "true"
},
{
"Key": "key1",
"Value": "value1"
}
],
"StorageTier": "standard"
}
]
}
/remove-hold CreateSnapshotRequest does not contain information about the PVC/PV other than the volume ID so none of the existing parameters can be used, so this PR is ready for review.
/lgtm /unhold
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: ConnorJC3, gtxu, torredil
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [gtxu,torredil]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/retest