K8s Volume doesn't detach from host K8s Volume doesn't detach from host kubernetes kubernetes

K8s Volume doesn't detach from host


First, I'll assume your running in tree vsphere disks.

Second, in this case (and more so, with CSI) kubernetes doesn't have control over all volume operations. The VMWare functionality for managing attachment and detachment of a disk is implemented in the volume plugin which you are using. Kubernetes doesn't strictly control all volume attachment/detachment semantics as a generic function.

To see the in-tree implementation details, check out:

https://kubernetes.io/docs/concepts/storage/volumes/#vspherevolume

Overall i think the way you are doing failover is going to mean that when your worker1 pod dies, worker2 can schedule. At that point, worker1 should not be able to grab the same PVC, and it should not schedule until the worker2 pod dies.

However if worker1 is scheduling, it means that Vsphere is trying to (erroneously) let worker1 start, and the kubelet is failing.

There is a chance that this is a bug in the VMWare driver in that it will bind a persistent volume even though it is not ready to.

To further elaborate, details about how worker2 is being launched may be helped. Is it a separate replication controller ? or is it running outside of kubernetes? If the latter, then the volumes wont be managed the same way, and you cant use a the same PVC as the locking mechanism.