linode / linode-blockstorage-csi-driver

Container Storage Interface (CSI) Driver for Linode Block Storage
Apache License 2.0
66 stars 55 forks source link

initial RPC_GET_VOLUME_STAT support #113

Closed BeryJu closed 1 year ago

BeryJu commented 1 year ago

closes #62

Implement CSI RPC to support GET_VOLUME_STATS, which allows the kubelet to monitor PVC usage, which is most often used with prometheus and/or kube-prometheus-stack, and can be used to alert when a PVC is close to being full

based off of https://github.com/digitalocean/csi-digitalocean/pull/197

haven't added tests yet, but I built ghcr.io/beryju/linode-blockstorage-csi-driver:v0.5.2-0-ge8e0af0-dirty and am testing that in my LKE cluster, which seems to work fine

General:

Pull Request Guidelines:

  1. [x] Does your submission pass tests?
  2. [x] Have you added tests?
  3. [x] Are you addressing a single feature in this PR?
  4. [x] Are your commits atomic, addressing one change per commit?
  5. [x] Are you following the conventions of the language?
  6. [x] Have you saved your large formatting changes for a different PR, so we can focus on your work?
  7. [x] Have you explained your rationale for why this feature is needed?
  8. [x] Have you linked your PR to an open issue
luthermonson commented 1 year ago

@BeryJu your code reads well and should be mergeable, we are spinning up a test to validate just to be thorough. for those who find this in the future and are curious on how this works... this PR enables the GRPC endpoint which is used with volume health monitoring. more documentation can be found in the csi docs

tchinmai7 commented 1 year ago

I tested that it works - and was able to get stats out of Kubelet

kubelet_volume_stats_available_bytes{namespace="monitoring",persistentvolumeclaim="storage-loki-in-cluster-0"} 1.043943424e+10
kubelet_volume_stats_capacity_bytes{namespace="monitoring",persistentvolumeclaim="storage-loki-in-cluster-0"} 1.0464022528e+10
kubelet_volume_stats_inodes{namespace="monitoring",persistentvolumeclaim="storage-loki-in-cluster-0"} 655360
kubelet_volume_stats_inodes_free{namespace="monitoring",persistentvolumeclaim="storage-loki-in-cluster-0"} 655331
kubelet_volume_stats_inodes_used{namespace="monitoring",persistentvolumeclaim="storage-loki-in-cluster-0"} 29
kubelet_volume_stats_used_bytes{namespace="monitoring",persistentvolumeclaim="storage-loki-in-cluster-0"} 7.811072e+06

needed to pass --feature-gates=[CSIVolumeHealth=true] for kubelet to get this to work.