Optimize attach volume on node

I have a use-case where I want to create and terminate a pod quite frequently and i’m investigating how to optimize that workflow.

So currently it take about ~20 seconds before the pod is up and running and most of that time is spent on waiting for attaching the volume on the node is finished. Without attaching the volume it takes about ~6-7 seconds to get the pod to running state.

Type Reason Age From Message


Normal Scheduled 20s default-scheduler Successfully assigned XXX to XXX
Normal SuccessfulAttachVolume 10s attachdetach-controller AttachVolume.Attach succeeded for volume “XXX”
Normal AddedInterface 3s multus Add eth0 [10.42.3.6/24] from cbr0
Normal AddedInterface 2s multus Add net1 from XXX
Normal Pulled 2s kubelet Container image “XXX” already present on machine
Normal Created 2s kubelet Created container XXX
Normal Started 2s kubelet Started container XXX

Is there any optimizations I could do to improve the attachment step?

It is not any amount of data on the volume (not yet though) so it is not related to this fix. Which I already implemented.

Best regards
Thomas

To be honest, attaching a Longhorn volume would take 5 ~ 10 seconds. Besides, there are extra communication overheads between kubelet and Longhorn components that slow down the launching. It’s hard to decrease the whole flow greatly.