-
Notifications
You must be signed in to change notification settings - Fork 159
Allow cross project snapshots and volumes #782
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 cross project snapshots and volumes #782
Conversation
Welcome @christian-roggia! |
Hi @christian-roggia. 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. |
/ok-to-test |
At any rate it is confusing that as written we will silently change the project given in a snapshot id. @jingxu97 it looks like you implemented this, do you have any background? |
Service accounts can normally have cross-project permissions. This is actually a very common scenario. I believe that the CSI driver has a dedicated "Service Agent" service account, but it should behave like any other service account. Additionally, the CSI driver in GKE is mounting a Kubernetes service account. That Kubernetes-native SA can be used as a Workload Identity binding it to a GCP IAM service account managed by the project owner instead of GCP (i.e. this allows to avoid granting permissions directly to the "Service Agent" service account). In both cases allowing the right IAM permissions cross-project should be possible. |
@mattcary it is worth mentioning that the proposed PR solves the issue only for the lookup operation (i.e. GetSnapshot), but actually all operations currently performed by the driver have an hardcoded project. I believe that in all cases where a fully qualified path is provided to the driver it should attempt to perform the operation with the project given in the path instead of silently replacing it. I can update the PR with changes to all operations that should be provided with the project name. |
+1 let's do that. Even if for some reason the cross-project roles don't work out (I think you're right but I want to double-check), we should not be changing the project name. eg a user may have different resources in two different projects sharing the same name. It would be much better to fail in that situation than silently switch projects.... |
Cross-project snapshots are a thing :-) https://cloud.google.com/compute/docs/disks/create-snapshots#sharing_snapshots It works without any additional roles being necessary when run as a user that is owner of two different projects. I don't see why a service account couldn't be given the same roles on two different projects either. However, in GKE, as Michelle said, which service account is used by master pods to authenticate to GCP is a little obscure. I'm still digging into that. However, since cross-project snapshots work so smoothly I don't see any reason for the pd csi driver not to support them:
|
I should be able to find some time to work on it this week, do you have any clue why integration tests failed? |
Yes, this looks like the same issue as #102077, but on the pd csi driver
side. I'll take a look. It's not your fault :-)
```
W0521 02:25:46.569] F0521 02:25:46.566914 91994 helpers.go:116] error:
unable to recognize
"/tmp/gcp-compute-persistent-disk-csi-driver-specs-generated.yaml": no
matches for kind "CSIDriver" in version "storage.k8s.io/v1beta1"
```
…On Sun, May 23, 2021 at 9:43 AM Christian Roggia ***@***.***> wrote:
I should be able to find some time to work on it this week, do you have
any clue why integration tests failed?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#782 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIJCBAFVLSNQCESNQAKYPE3TPEWBPANCNFSM45DZG42A>
.
|
/test pull-gcp-compute-persistent-disk-csi-driver-kubernetes-integration I think (hope) that #783 fixed this. |
81f218a
to
1364a18
Compare
Even though the tests are all green, I feel like new tests should be added (especially e2e) to verify that the CSI driver can import snapshots and volumes from another project. It is also important to verify which service account requires additional permission when performing cross-project operations, and which IAM permissions should be granted. As described in my original issue, the candidate service accounts are the following:
and maybe workload identity might be required for the CSI SA:
finally, I would expect the SA to require at least the following IAM permissions for snapshots:
with additional permissions on disks that might be necessary:
|
Thanks! I think that's a great point. However, the logistics of that get complicated. I think it should be possible to do it by renting another project, but then that would have to be plumbed through to the e2e test which is breaking new ground and is therefore complicated? So I'd be okay both with holding this change until those e2e tests are done, or pushing this out and relying on the VolumeIdToKey unit tests for now. It's my understanding that on GKE, it will be enough to give the container-engine-robot service accounts roles in the cross-project---that's the account plumbed to the pd csi cloud provider. That of course requires running on GKE, which we do in our internal tests, and so that would also require more plumbing in the k8s-integration tests. For GCE (ie, kube-up) we'd have to check in the /etc/gke.conf that's installed on the master node. We're in the middle of making the pd csi driver on by default for kube-up which might clarify this issue a bit. WDYT? In any case thanks again for noticing & clearing up this cross-project problem. |
I was expecting that this setup wouldn't be simple, I would suggest pushing into master then and manually verify that cross-project VolumeSnapshots work without major issues, the Velero community might help to test this feature out too.
You are more than welcome! The CSI driver is a very powerful tool and I am happy to be able to help out. |
@@ -306,7 +303,7 @@ func ValidateDiskParameters(disk *CloudDisk, params common.DiskParameters) error | |||
return nil | |||
} | |||
|
|||
func (cloud *CloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key, params common.DiskParameters, capBytes int64, capacityRange *csi.CapacityRange, replicaZones []string, snapshotID string, multiWriter bool) error { | |||
func (cloud *CloudProvider) InsertDisk(ctx context.Context, project string, volKey *meta.Key, params common.DiskParameters, capBytes int64, capacityRange *csi.CapacityRange, replicaZones []string, snapshotID string, multiWriter bool) error { |
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.
Since disks cannot be used cross-project, why are we plumbing the project around everywhere? Wouldn't it be easier & less toil to use cloud.project for everything except the snapshot api?
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.
My understanding was that we didn't want to override the original project provided in the resource's names.
I can revert these changes if they don't make sense to you as they provide no additional functionalities.
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.
Ah, good point. Thank you, I've spent too long between reviewing sessions.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christian-roggia, mattcary 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 |
Thanks for the PR. In order to consume snapshots between GCP projects, should we use |
@husunal yes, that would be the expected use of cross-projects snapshots. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR allows using CSI snapshots across projects.
This feature enables GKE users to create VolumeSnapshots in a project FOO and import them in a project BAR.
This enhancement simplifies the migration process from between projects and improves the user experience with tools like Velero.
Which issue(s) this PR fixes:
Fixes #781
Special notes for your reviewer:
Does this PR introduce a user-facing change?: