Design: Storage in Cluster-API architecture
Create Volume
Dynamic provisioning in Guest Cluster

kubectl apply -f pvc.yamlis initiated by user, and the request is sent tokube-api-server.kube-controllercreate thePVC, but its status will be pending.gcCSIwatches the creation ofPVCthen send request to thekube-api-serverinManagement Clusterto create the volume.kube-controllerinManagement Clustercreates thePVC.mgmtCSIwatches the creation ofPVCin turn calls the Storage Infra API to create the volume. Loop on the status checking.5.1 When volume is provisioned,
mgmtCSIwill create thePVinManagement Cluster. ThePVcreation is actually done by theexternal-provisionerwhich runs as a side-car container withincontroller-pluginof themgmtCSI.kube-controllerlistens on the event fromPV. OncePV's status is bound, it binds thePVCto thePV.gcCSIwaits on the status of PVC creation in management cluster and createPVinGuest Clusteraccordingly.kube-controllerinGuest Clusterbinds thePVCtoPVeventually.
Static provisioning in Guest Cluster
The static provisioning in Guest Cluster is a little bit tricky. If we only have one K8S cluster, user needs to create the volume manually first, and then create PV to bind to the volume manually created (Refer to Volume Provisioning for more details).
However, things are different in cluster API picture. First, we have to have the volume provisioned(no matter using dynamic provisioning or static provisioning) under Management Cluster, so it could be used by one or multiple Guest Cluster. The "volume provisioned" means that we have PV and PVC ready in Mangement Cluster. Second, user needs to create the PV in Guest cluster which refers to the PVC in Management Cluster.
The differences between static provisioning in Guest Cluster and the static provisioning in single cluster are:
Single cluster is just one layer, the
PVrefers to the volume user manually created.Guest clusterhas multiple layers, and itsPVrefers to thePVCinManagement Clusterinstead of the volume.TBA
Open questions
How to deal with ReclaimPolicy
You probably noticed that we might have two ReclaimPolicy. One is in Management Cluster, one is in Guest Cluster.
In dynamic provisioning case, they should be the same in StorageClass spec.
In static provisioning case, the ReclaimPolicy in
PVcould be different betweenManagement ClusterandGuest Cluster. IfGuest Clusteruser wants the ReclaimPolicy to bedelete, the ReclaimPolicy inManagement Clusterneeds to bedeleteas well. That is because the user wants the volume to be deleted ifPVgets deleted. IfGuest Clusteruser wants the ReclaimPolicy to beretain, the ReclaimPolicy inManagement Clustercould to bedelete(it does not neccessarily need to bedelete, things could be different based on business logic). That is because user wants the volume to be retained ifPVgets deleted, sogcCSIshould not invoke any API calls tomgmtCSIto remove the volume.
Attach Volume

When a Volume gets created by mgmtCSI from Create Volume Step 5 above, it needs to be attached to the node where the Pod is running.
gcCSIknows where thePodis scheduled and updatesVirtualMachine.Spec.VolumesVM-Operatorrunning on Mangement Cluster watches theVirtualMachine.Spec.Volume, if new Volumes are added,VM-OperatorcreatesVolumeAttachmentinstances accordingly with theNodeUUIDandVolumeName. Those two are the information mgmtCSI needs to attach volumes to node.Once volumes are attached (No matter succeeded or failed), mgmtCSI will update
VolumeAttachmentStatusVM-Operatorwatches the changes fromVolumeAttachmentStatusupdatesVirtualMachine.Status.Volumesaccordingly.gcCSIwatches the changes fromVirtualMachine.Status.Volumesand updates PVC accordingly.
Reference
Last updated
Was this helpful?