kubernetes-sigs / vsphere-csi-driver

vSphere storage Container Storage Interface (CSI) plugin
https://docs.vmware.com/en/VMware-vSphere-Container-Storage-Plug-in/index.html
Apache License 2.0
295 stars 181 forks source link

Add tkc cluster labels on Supervisor PVC objects to help identify orphan Supervisor PVCs #3071

Closed chethanv28 closed 1 week ago

chethanv28 commented 1 month ago

What this PR does / why we need it: This PR adds an identifier on Supervisor PVCs to indicate, which TKC the volume belongs to. By adding the labels, users can identify PVCs that are not associated with any TKC in the namespace but originally requested from TKC cluster.

The solution is to add label to the SV PVCs with the following label format:

/ : Where, GC_Name = Name of the guest cluster GC_distribution = K8s distribution (ex: TKC) GC_ID = Guest cluster ID **List PVCs that belongs to my-prod-k8s-1 cluster:** kubectl get pvc --selector=’/TKGService’ **Which issue this PR fixes** *(optional, in `fixes #(, fixes #, ...)` format, will close that issue when PR gets merged)*: fixes # **Testing done**: ``` kubectl describe pvc -n test-gc-e2e-demo-ns 4e129685-7816-4812-bfd9-a2046620d8ac-c8b6b270-6302-47b4-b345-68a36ea5b0f6 42053753a1271c731ae5bbdd8ad1b4ab: Fri Nov 8 22:03:50 2024 Name: 4e129685-7816-4812-bfd9-a2046620d8ac-c8b6b270-6302-47b4-b345-68a36ea5b0f6 Namespace: test-gc-e2e-demo-ns StorageClass: gc-storage-profile Status: Bound Volume: pvc-d59fa0ba-9f08-48d7-ae49-3ecb83621492 Labels: test-cluster-e2e-script/TKGService=4e129685-7816-4812-bfd9-a2046620d8ac Annotations: pv.kubernetes.io/bind-completed: yes pv.kubernetes.io/bound-by-controller: yes volume.beta.kubernetes.io/storage-provisioner: csi.vsphere.vmware.com volume.kubernetes.io/storage-provisioner: csi.vsphere.vmware.com volumehealth.storage.kubernetes.io/health: accessible volumehealth.storage.kubernetes.io/health-timestamp: Fri Nov 8 21:58:32 UTC 2024 Finalizers: [kubernetes.io/pvc-protection] Capacity: 2Gi Access Modes: RWO VolumeMode: Filesystem ``` ``` # kubectl get pvc --selector='test-cluster-e2e-script/TKGService' -n test-gc-e2e-demo-ns NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE 4e129685-7816-4812-bfd9-a2046620d8ac-c8b6b270-6302-47b4-b345-68a36ea5b0f6 Bound pvc-d59fa0ba-9f08-48d7-ae49-3ecb83621492 2Gi RWO gc-storage-profile 4m17s 4e129685-7816-4812-bfd9-a2046620d8ac-edccfc3f-9803-46fe-94ef-f73fc2e4cef8 Bound pvc-b913aba8-e8fa-4573-a5c0-c7f8402ab8b7 2Gi RWO gc-storage-profile 30h ``` Filtering on CNS UI: ![CNS-UI -PVC-Lables](https://github.com/user-attachments/assets/c19c7ae4-7407-4d8f-89c4-1f448abb18f0) **Release note**: ```release-note Add tkc cluster labels on Supervisor PVC objects to help identify orphan Supervisor PVCs ```
svcbot-qecnsdp commented 1 month ago

Started GC block pre-checkin pipeline... Build Number: 1005

svcbot-qecnsdp commented 1 month ago
Build ID: 1005
GC build status: FAILURE 
Stage before exit: checkout 
nikhilbarge commented 2 weeks ago

/approve

k8s-ci-robot commented 2 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chethanv28, nikhilbarge

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/vsphere-csi-driver/blob/master/OWNERS)~~ [chethanv28] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment