<p>From a certain PVC, I'm trying to get the volume id from the metadata of the PV associated with the PVC using <a href="https://github.com/kubernetes-client/python" rel="nofollow noreferrer">Kubernetes Python Api</a>.</p>
<p>I'm able to describe PVC with <code>read_namespaced_persistent_volume_claim</code> function and obtain the PV name <code>spec.volume_name</code>. Now I need to go deeper and get the <code>Source.VolumeHandle</code> attribute from the PV metadata to get de EBS Volume Id and obtain the volume status from aws, but I can't find a method to describe pv from the python api.</p>
<p>Any help?</p>
<p>Thanks</p>

<p>While <code>PersistentVolumeClaims</code> are namedspaced, <code>PersistentVolumes</code> are not. Looking at the available methods in the V1 API...</p>
<pre><code>&gt;&gt;&gt; v1 = client.CoreV1Api()
&gt;&gt;&gt; print('\n'.join([x for x in dir(v1) if x.startswith('read') and 'volume' in x]))
read_namespaced_persistent_volume_claim
read_namespaced_persistent_volume_claim_status
read_namespaced_persistent_volume_claim_status_with_http_info
read_namespaced_persistent_volume_claim_with_http_info
read_persistent_volume
read_persistent_volume_status
read_persistent_volume_status_with_http_info
read_persistent_volume_with_http_info
</code></pre>
<p>...it looks like <code>read_persistent_volume</code> is probably what we want. Running <code>help(v1.read_persistent_volume)</code> gives us:</p>
<pre><code>read_persistent_volume(name, **kwargs) method of kubernetes.client.api.core_v1_api.CoreV1Api instance
    read_persistent_volume

    read the specified PersistentVolume
    This method makes a synchronous HTTP request by default. To make an
    asynchronous HTTP request, please pass async_req=True
    &gt;&gt;&gt; thread = api.read_persistent_volume(name, async_req=True)
    &gt;&gt;&gt; result = thread.get()

    :param async_req bool: execute request asynchronously
    :param str name: name of the PersistentVolume (required)
    :param str pretty: If 'true', then the output is pretty printed.
    :param _preload_content: if False, the urllib3.HTTPResponse object will
                             be returned without reading/decoding response
                             data. Default is True.
    :param _request_timeout: timeout setting for this request. If one
                             number provided, it will be total request
                             timeout. It can also be a pair (tuple) of
                             (connection, read) timeouts.
    :return: V1PersistentVolume
             If the method is called asynchronously,
             returns the request thread.

</code></pre>
