WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Automation / Mapping between vSphere Container Volume to Persistent Volume Claim (PVC) in vSphere 7.0 Update 1 using PowerCLI

Mapping between vSphere Container Volume to Persistent Volume Claim (PVC) in vSphere 7.0 Update 1 using PowerCLI

11.04.2020 by William Lam // Leave a Comment

With the introduction of the vSphere Container Storage Interface (CSI) 2.1, it looks like the previous method outlined by Cormac Hogan no longer applies when looking to map between a vSphere Container Volume (CV), which is a vSphere construct to the underlying Persistent Volume Claim (PVC), which is a Kubernetes construct.


William Arroyo, a K8s Solution Engineer recently noticed this behavior change and was asking if there was a way to use PowerCLI to still perform this look up. Given I had provided the original PowerCLI snippet on Cormac's blog, I was curious myself and since I had just rebuilt my vSphere with Tanzu environment, I figured I take a quick look to see where this new information might now be placed.

I did also want to mention that you can easily find this information using the vSphere UI by just clicking on the "Details" box next to the PVC


With the latest PowerCLI 12.1 release, we have a number of Cloud Native Storage (CNS) cmdlets that we can leverage and after a quick minute of poking around, this new information can be found using the Get-CnsVolume cmdlet and using the ExtensionData property to get more detailed properties.

You can specify either the filename and/or ID to the cmdlet. In my example, the vSphere CV has label of pvc-31fc30d4-a5a2-438d-9f07-b90e0a67d3ab and we just need to pass that using the following command:

(Get-CnsVolume -Name pvc-31fc30d4-a5a2-438d-9f07-b90e0a67d3ab).ExtensionData.Metadata


The Metadata.EntityMetadata is what we are after and as you can see from the output, we can see both the PVC ID which is pvc-f8777fc1-8408-423b-8cd0-e30907512270 and even the PVC Label which is called pvc-test

If we now take a look from the Kubernetes perspective and using kubectl to retrieve our PVC using:

kubectl get pvc


We can see that the information matches.

If we wanted to get information about the the exact VMDK path, we can use the Get-VDisk cmdlet and pass in the vSphere CV

Get-VDisk | select Name, Filename

More from my site

  • How to clean up stale vSphere Container Volumes & First Class Disks?
  • How to simulate Persistent Memory (PMem) in vSphere 6.7 for educational purposes? 
  • How to manually install Folding @ Home on VMware Photon OS?
  • Quick Tip - Setting up Kubernetes using Containerd on Photon OS
  • Using vSphere Auto Deploy to Netboot ESXi onto Apple Mac Hardware

Categories // Automation, Cloud Native, PowerCLI Tags // CSI, Persistent Memory, vSphere Container Volume

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC) across Private, Hybrid and Public Cloud

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • Disabling vCenter Lifecycle Manager automatic download using vSphere API 10/02/2023
  • ESXi on Lenovo ThinkStation P3 Ultra 09/29/2023
  • Quick Tip - vSphere 7.0 Update 3o also supports disabling/enabling vSphere Cluster Services (vCLS) in vSphere UI 09/29/2023
  • Heads Up - New image identifier required by VM Service in vSphere 8.0 Update 2 09/27/2023
  • How to setup private GitLab on a Synology for Project Keswick? 09/26/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023

 

Loading Comments...