kubernetes-csi/external-provisioner

Add PVC Annotations + Labels to PV

speedfl opened this issue · 5 comments

Problem

Correlate PV with a context is almost impossible. The only solution is to create StorageClass with Contextual Data (Cost Center / Customer / Environment) and then correlate the PV with the StorageClass. This results in a duplication of StorageClass while its purpose is the "how to store data" (Azure Disk, AWS EBS...) and not the "for who/what data are stored".

Proposal

We should have an elegant way to Add PVC / Labels annotations on PV such as Cost Center, Customer, Billing ID...
https://github.com/kubernetes-csi/external-provisioner/blob/master/pkg/controller/controller.go

Possible Solution:

  • StorageClass object would contain field to mention the tag to forward to PV (preferred)
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: ebs-sc
provisioner: some-provisionner
fromPVCToPV: # I am bad finding names :D 
  labels:
    - label-one
    - label-two
  annotations:
    - annotation-one
    - annotation-two
parameters:
pv := &v1.PersistentVolume{
    ObjectMeta: metav1.ObjectMeta{
        Name: pvName,
    },
    Spec: v1.PersistentVolumeSpec{
        AccessModes:  options.PVC.Spec.AccessModes,
        MountOptions: options.StorageClass.MountOptions,
        Capacity: v1.ResourceList{
            v1.ResourceName(v1.ResourceStorage): bytesToQuantity(respCap),
        },
        // TODO wait for CSI VolumeSource API
        PersistentVolumeSource: v1.PersistentVolumeSource{
            CSI: result.csiPVSource,
        },
    },
}

if options.StorageClass.fromPVCToPV != nil {
    options.StorageClass.fromPVCToPV.Annotations != nil {
        for _, key := range options.StorageClass.fromPVCToPV.Annotations {

            if options.PVC.ObjectMeta.Annotations != nil && val, ok := appSet.ObjectMeta.Annotations[key]; ok {
                metav1.SetMetaDataAnnotation(&pv.ObjectMeta, key, val)
            }
        }
    }
   // same for labels
}

Other

There is another issue to forward the Annotations/Labels to CreateVolumeRequest which goes in this direction: #86

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.