kubernetes-csi / external-provisioner

Sidecar container that watches Kubernetes PersistentVolumeClaim objects and triggers CreateVolume/DeleteVolume against a CSI endpoint
Apache License 2.0
338 stars 327 forks source link

Pass in hostname to create volume request #1285

Open Rishita-Golla opened 5 days ago

Rishita-Golla commented 5 days ago

Is your feature request related to a problem?/Why is this needed To improve performance when provisioning PDs in GCP, we can optimize their placement by using the hostname of the VM. In case of delayed binding, since the VM is already known, we can use this information to pass hostname as a parameter to the driver's create volume requests. For PD creation, the hostname can be included in location hint field in the disks.insert call. This ensure the PD is created as close as possible to the VM, minimizing latency and cross-cell attachments (for Borg).

Describe the solution you'd like in detail During dynamic PV provisioning, the K8s scheduler selects a node and sets [volume.kubernetes.io/selected-node] annotation on the PVC. As a possible solution, we can utilize the existing --extraCreateMetadata flag in external-provisioner, get hostname from the selected node annotation, and pass the hostname as an extra metadata parameter. For PD, the hostname will be set as a part of location hint URI.

Reference CL [link] (https://github.com/kubernetes-csi/external-provisioner/pull/399)

Describe alternatives you've considered We have considered adding hostname as a topology key. But this could lead to a potential scale issue as host name values are unique and the requisite/preferred topology generated could have upto n items, where n is no. of nodes in the cluster.

msau42 commented 5 days ago

To clarify, the problem with the alternative solution is that adding "hostname" as a topology key would pose a problem with Immediate binding mode, where it would generate a topology entry per node.