No way to move persistent volumes between namespaces
When a user wants to migrate an application across namespaces, there needs to be an easy way to accomplish that (something that can be explained to a user in a few CLI steps). An admin really shouldn't have to be involved if the user has access to both PVCs. I.e. a "release to" annotation or similar.
changing the namespace on the PVC and PV.Spec.ClaimRef would be all that's needed. What is an appropriate way of doing that?
changing the namespace on the PVC and PV.Spec.ClaimRef would be all that's needed
Well, the PVC is namespaced, so you can't "change" the namespace on it... the new one with a different namespace is a different PVC. The trick is getting the PV to be ok with switching to a PVC in a different namespace without admin intervention.
What about the PV backing the PVC? That has to be considered in terms of permissions when doing the migration.
the PV has the same permissions as before. We need only change pv.Spec.ClaimRef to point to the new PVC.
If we're not changing the existing PVC and instead pointing the PV at a new one, this can be accomplished in a single transaction. We just need to change the reference on the PV.
But PVs are admin objects and not available to mere mortals. The user's client would get rejected on update, even if the user has access to the various namespaces involved.
Either the user has to set something on the existing PVC that gives it to something else, or there has to be an interface on the PVC that gives it up to someone else. Would have to be bound first.
What about an oc migrate(or move) project <old-proj> <new-proj> command? I did some upstream searching and didn't find a plan for this. Initially the command could just deal with moving PVCs but later there may be other pieces to move...
We have a controller that handles claims. Seems easy enough to check for some var on the claim to trigger the move in the controller, which is an admin account.
How do we know the request to move from namespace $foo to namespace $bar is valid for that user?
Nevermind. If the user can update the PVC in a namespace, (s)he has access to that namespace. Giving it to another is a choice, which should be allowed. Is that agreeable?
Still need a way to signal the controller that the currently bound PVC concurs with trnsferring the PV to the new PVC, so the PV controller knows it is ok to update the PV binding
Only the people in the namespace would be able to set the variable (probably an annotation). Is that not consent?
The security implication is whether the remote user wants that PV. I think the sending user would have to set name and uid for safety at a minimum.
I feel like we'll have this pattern in multiple places (cross-namespace references, with a request and a confirmation)... should think broadly about what we'd want this to look like
ok, so, the destination PVC must exist and the receiver would supply name/uid to the sender. This would otherwise be secret information and by supplying it, both parties agree to the transfer of ownership.
The source PVC is deleted as a result, I presume.
no, both source and destination PVC need to indicate they want the transfer. I could have view-only access to a PVC in a namespace... that doesn't mean I should be able to push a PV to it
The source PVC is deleted as a result, I presume.
At the very least, unbound... not sure if it is deleted or not
Definitely want to lay this out as a state machine, and think about how it interacts with other bits of the system, to make sure something doesn't try to provision/assign a PV to the destination PVC while you're in the process of transferring a PV to it
source and destination PVCs would have corresponding annotations. The former with the name/uid of the destination and the latter with the name/uid of the source? If they match both ways, transfer ownership.
Another annotation on the source PVC that indicates delete vs. unbind?
just thinking aloud. maybe something like this:
on the source PVC:
kubernetes.io/transfer.destination.namespace=myns2
kubernetes.io/transfer.destination.name=mypvc2
kubernetes.io/transfer.destination.uid=234234-234234-234234
kubernetes.io/transfer.onsuccess=[delete | unbind]
kubernetes.io/transfer.status=... filled in by controller with any errors, etc ...
on the destination PVC:
kubernetes.io/transfer.source.namespace=myns1
kubernetes.io/transfer.source.name=mypvc1
kubernetes.io/transfer.source.uid=123123-123123-123123
kubernetes.io/transfer.status=... filled in by controller with any errors, etc ...
I would expect the controller to ignore PVCs that have both source and destination annotations set
remind me what annotation on the PV lets you create a PV to satisfy a specific PVC?
"volumes.alpha.kubernetes.io/storage-class" is the annotation to trigger dynamic provisioning.
If the destination PVC has any of your proposed annotations (which all look good to me), then it shouldn't attempt to bind or be provisioned. That is easy to enforce.
Do we have a CLI command like @jeffvance suggested above? It would require a bunch of params. "oc edit pvc [name]"? Post some JSON?