origin icon indicating copy to clipboard operation
origin copied to clipboard

No way to move persistent volumes between namespaces

Open smarterclayton opened this issue 10 years ago • 26 comments

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.

smarterclayton avatar Jan 13 '16 16:01 smarterclayton

changing the namespace on the PVC and PV.Spec.ClaimRef would be all that's needed. What is an appropriate way of doing that?

markturansky avatar Jan 13 '16 19:01 markturansky

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.

liggitt avatar Jan 13 '16 19:01 liggitt

What about the PV backing the PVC? That has to be considered in terms of permissions when doing the migration.

erinboyd avatar Jan 13 '16 19:01 erinboyd

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.

markturansky avatar Jan 13 '16 19:01 markturansky

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.

smarterclayton avatar Jan 13 '16 21:01 smarterclayton

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...

jeffvance avatar Jan 13 '16 22:01 jeffvance

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?

markturansky avatar Jan 13 '16 22:01 markturansky

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?

markturansky avatar Jan 13 '16 22:01 markturansky

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

liggitt avatar Jan 13 '16 22:01 liggitt

Only the people in the namespace would be able to set the variable (probably an annotation). Is that not consent?

markturansky avatar Jan 13 '16 23:01 markturansky

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.

smarterclayton avatar Jan 14 '16 01:01 smarterclayton

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

liggitt avatar Jan 14 '16 01:01 liggitt

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.

markturansky avatar Jan 14 '16 01:01 markturansky

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

liggitt avatar Jan 14 '16 01:01 liggitt

The source PVC is deleted as a result, I presume.

At the very least, unbound... not sure if it is deleted or not

liggitt avatar Jan 14 '16 01:01 liggitt

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

liggitt avatar Jan 14 '16 01:01 liggitt

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?

markturansky avatar Jan 14 '16 01:01 markturansky

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?

liggitt avatar Jan 14 '16 01:01 liggitt

"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.

markturansky avatar Jan 14 '16 01:01 markturansky

Do we have a CLI command like @jeffvance suggested above? It would require a bunch of params. "oc edit pvc [name]"? Post some JSON?

markturansky avatar Jan 14 '16 01:01 markturansky