google-cloud-platformgoogle-kubernetes-engine

How do I propagate resource labels to my GKE application's GCE disks backing its PVCs?


I use the standard-rwo storage class for persistent and ephemeral volumes for my applications. So there are GCE disks backing my k8s volumes. I want to do cost allocation of these and track the storage usage of my GKE applications using these volumes, but I cannot figure out how to propagate resource labels to them.

For example:

  volumes:
    - name: scratch-volume
      ephemeral:
        volumeClaimTemplate:
          metadata:
            # Apply these labels to the GCE disk
            labels:
              app: my-app-name
          spec:
            accessModes: [ "ReadWriteOnce" ]
            storageClassName: "standard-rwo"
            resources:
              requests:
                storage: 1Gi

The only label I see on the actual GCE disks is goog-gke-volume.

I'm having trouble finding docs saying this is or is not supported. The docs for the driver make zero mention of this, not even to say if it's supported by any means or not: https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/gce-pd-csi-driver

Edit

Per answer this is the related Github Issue.

I asked about this and a contributor explained where this feature would need to be implemented.

The issue was raised on the external-provisioner, as that would be the right kubernetes layer to do this (the pd csi driver doesn't see the k8s objects so can't see annotations).

kubernetes-csi/external-provisioner#760.

Looks like it got auto-closed but I'm sure if you're interested in working on it it could be re-opened.


Solution

  • Unfortunately that's not supported by the driver. There is an issue open with the driver to support this https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues/1018