You will find root-dir in the cmdline of proc kubelet. If it’s not set, the default value /var/lib/kubelet would be used. In the case of CoreOS, the root-dir would be /opt/rke/var/lib/kubelet as shown above.
If kubelet is using a configuration file, you would need to check the configuration file to locate the root-dir parameter.
CSI doesn’t work with CoreOS + RKE before Longhorn v0.4.1. The reason is:
RKE sets argument root-dir=/opt/rke/var/lib/kubelet for kubelet in the case of CoreOS, which is different from the default value /var/lib/kubelet.
For k8s v1.12+
Kubelet will detect the csi.sock according to argument <--kubelet-registration-path> passed in by Kubernetes CSI driver-registrar, and <drivername>-reg.sock (for Longhorn, it’s io.rancher.longhorn-reg.sock) on kubelet path <root-dir>/plugins.
For k8s v1.11
Kubelet will find both sockets on kubelet path /var/lib/kubelet/plugins.
By default, Longhorn CSI driver create and expose these 2 sock files on host path /var/lib/kubelet/plugins.
Then kubelet cannot find <drivername>-reg.sock, so CSI driver doesn’t work.
Furthermore, kubelet will instruct CSI plugin to mount Longhorn volume on <root-dir>/pods/<pod-name>/volumes/kubernetes.io~csi/<volume-name>/mount.
But this path inside CSI plugin container won’t be binded mount on host path. And the mount operation for Longhorn volume is meaningless.
Hence Kubernetes cannot connect to Longhorn using CSI driver.