-
Notifications
You must be signed in to change notification settings - Fork 159
Allow to label PD disk with k8s cluster ID #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to label PD disk with k8s cluster ID #693
Conversation
Welcome @tsmetana! |
Hi @tsmetana. 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 Once the patch is verified, the new status will be reflected by the 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. |
@jsafrane: FYI... |
Thanks Thomas. I haven't had a chance to look at this yet. Have you seen #566? The author We were basically happy with that PR, but the author seems to have dropped out. We want to get that in soon though. If we had the ability of that CL (to label the PD disk via storage class parameters), would that fit your use case? That might be more flexible than a flag with a hardcoded label. |
/ok-to-test |
I think the main downside is then people can't use the default storageclass, unless we had a way to generate default storageclasses and inject the cluster name into it (k8s doesn't have a first class concept of cluster name) |
Since this proposal involves a command-line flag for the driver, anyone who can install the driver can also change the default storageclass to have whatever label they want. Since this label isn't going to match the AWS EBS label anyway due to the slash-vs-underscore issue, there probably needs to be flexibility for the operator to tweak the label to what is most convenient for their tools. Doing that via the storageclass parameter seems nicer than via a driver command-line argument. My $0.02 at least. |
previous discussion: #469 |
The users able to install drivers and those able to create storage classes might be different. The aim is to be able to create an environment where the clusters get automatically set-up (click in a browser) and torn-down (another click) and don't leave any leftovers while still not require any additional responsibilities from their admins (not forget to label StorageClasses). |
Okay, that makes sense. I think fixing the label format here will be too restrictive. I'd support a change that was something like --additional-pd-label, eg --additional-pd-label=k8s-cluster-id-112233. The flag could even be given multiple times, for multiple labels. |
AWS has |
+1 to both the name as well as labeling snapshots in addition to disks. |
2d73433
to
0b51c07
Compare
Changed to allow generic disk labelling. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of nits.
Thanks!
expectParams: DiskParameters{ | ||
DiskType: "pd-standard", | ||
ReplicationType: "none", | ||
DiskEncryptionKMSKey: "", | ||
Tags: map[string]string{tagKeyCreatedForClaimName: "testPVCName", tagKeyCreatedForClaimNamespace: "testPVCNamespace", tagKeyCreatedForVolumeName: "testPVName", tagKeyCreatedBy: "testDriver"}, | ||
Labels: make(map[string]string), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did I miss it or shouldn't there be a test case for the new labels?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the code since ExtractAndDefaultParameter
now takes more parameters and to have the parameteres structure complete. There's nothing much to test with the labels though -- they're only being copied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they're only we being copied we should test that---these also serve as regression tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the test in the latest commit.
@@ -476,9 +476,6 @@ github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | |||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= | |||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= | |||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | |||
github.com/kubernetes-csi/csi-proxy v0.2.2 h1:LqablYFEGw7FYBjwoh5TeXFzlcx8C+YQjKfGy6fFWJs= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to remove the csi-proxy? It's used by windows. At any rate we should clean this up in a separate PR.
@jingxu97 We seem to have both 0.2.1 and 0.2.2 of the proxy here, not sure what's going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At any rate this PR should not be changing go.mod (sorry I wasn't clear on that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I'll fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above is a result of go mod tidy
. I use k8s.io/component-base/cli/flag
for the CLI parsing and it was not vendored yet so I actually have to update go.mod for this patch. I think the removal of the (older) csi-proxy v0.2.1 is correct and the v0.2.2 is listed twice in go.sum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fair enough. I'm not going to argue with go mod tidy.
0b51c07
to
68cdfa9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
Thanks for working through this!
@@ -476,9 +476,6 @@ github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | |||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= | |||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= | |||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | |||
github.com/kubernetes-csi/csi-proxy v0.2.2 h1:LqablYFEGw7FYBjwoh5TeXFzlcx8C+YQjKfGy6fFWJs= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fair enough. I'm not going to argue with go mod tidy.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mattcary, tsmetana The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/kind feature
What this PR does / why we need it:
Inspired by the similar feature of AWS EBS CSI driver: allow to optionally label the PD disk with cluster ID to denote the disk ownership. This allows e.g. better automated resource cleanup on cluster teardown.
Special notes for your reviewer:
The label was meant to be named
kubernetes.io/cluster/<cluster ID>
(again, taken from the EBS CSI driver) however GCE API does not allow '/' or '.' characters in the label, so I swapped them for underscores. I can change it to anything else, I'm more interested in comments on the general approach.Does this PR introduce a user-facing change?: