文档首页 > > API参考> Kubernetes API> PersistentVolumeClaim> 获取指定的PersistentVolumeClaim

获取指定的PersistentVolumeClaim

分享
更新时间:2020/09/18 GMT+08:00

功能介绍

该API用于获取指定Namespace下的PersistentVolumeClaim对象。

URI

GET /api/v1/namespaces/{namespace}/persistentvolumeclaims/{name}

表1 描述该API的参数。

表1 参数描述

参数

是否必选

描述

name

Yes

Name of the PersistentVolumeClaim.

namespace

Yes

Object name and auth scope, such as for teams and projects.

pretty

No

If 'true', then the output is pretty printed.

exact

No

Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'.

export

No

Should this value be exported. Export strips fields that a user can not specify.

请求消息

N/A

响应消息

响应参数:

表2 响应参数

参数

参数类型

描述

apiVersion

String

APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values.

kind

String

Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated.

metadata

metadata object

Standard object's metadata.

spec

spec object

Spec defines the desired characteristics of a volume requested by a pod author.

status

status object

Status represents the current information/status of a persistent volume claim. Read-only.

表3 status字段数据结构说明

参数

参数类型

描述

accessModes

Array of strings

AccessModes contains the actual access modes the volume backing the PVC has.

capacity

Object

Represents the actual resources of the underlying volume.

phase

String

Phase represents the current phase of PersistentVolumeClaim.

表4 spec字段数据结构说明

参数

参数类型

描述

volumeName

String

VolumeName is the binding reference to the PersistentVolume backing this claim.

accessModes

Array of strings

AccessModes contains the desired access modes the volume should have.

storageClassName

String

Name of the StorageClass required by the claim.

resources

resources object

Resources represents the minimum resources the volume should have.

selector

selector object

A label query over volumes to consider for binding.

表5 resources字段数据结构说明

参数

参数类型

描述

limits

Object

Limits describes the maximum amount of compute resources allowed.

说明:

Parameter limits is invalid.

requests

Object

Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value.

说明:

Except parameter storage, the other parameters (such as CPU and memory) are invalid.

表6 selector字段数据结构说明

参数

参数类型

描述

matchExpressions

matchExpressions object

MatchExpressions is a list of label selector requirements. The requirements are ANDed.

matchLabels

Object

MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.

表7 matchExpressions字段数据结构说明

参数

参数类型

描述

key

String

Key is the label key that the selector applies to.

operator

String

Operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.

values

Array of strings

Values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.

响应示例:

  • 1.15及以上版本集群,示例如下:
    {
        "kind":"PersistentVolumeClaim",
        "apiVersion":"v1",
        "metadata":{
            "name":"cce-evs-k6m131jj-i1px",
            "namespace":"default",
            "selfLink":"/api/v1/namespaces/default/persistentvolumeclaims/cce-evs-k6m131jj-i1px",
            "uid":"d34f6a93-9eba-4a33-9320-8fa4addd3753",
            "resourceVersion":"2286592",
            "creationTimestamp":"2020-02-14T10:27:43Z",
            "labels":{
                "failure-domain.beta.kubernetes.io/region":"cn-north-5",
                "failure-domain.beta.kubernetes.io/zone":"cn-north-5a"
            },
            "annotations":{
                "everest.io/disk-volume-type":"SATA",
                "pv.kubernetes.io/bind-completed":"yes",
                "pv.kubernetes.io/bound-by-controller":"yes",
                "volume.beta.kubernetes.io/storage-provisioner":"everest-csi-provisioner"
            },
            "finalizers":[
                "kubernetes.io/pvc-protection"
            ]
        },
        "spec":{
            "accessModes":[
                "ReadWriteOnce"
            ],
            "resources":{
                "requests":{
                    "storage":"10Gi"
                }
            },
            "volumeName":"pvc-d34f6a93-9eba-4a33-9320-8fa4addd3753",
            "storageClassName":"csi-disk",
            "volumeMode":"Filesystem"
        },
        "status":{
            "phase":"Bound",
            "accessModes":[
                "ReadWriteOnce"
            ],
            "capacity":{
                "storage":"10Gi"
            }
        }
    }
  • 1.13及之前集群版本示例:
    {
        "kind": "PersistentVolumeClaim",
        "apiVersion": "v1",
        "metadata": {
            "name": "db-mysql",
            "namespace": "default",
            "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql",
            "uid": "ac34af93-8cdd-11e8-8ee0-fa163e49263c",
            "resourceVersion": "4197709",
            "creationTimestamp": "2018-07-21T12:00:33Z",
            "labels": {
                "failure-domain.beta.kubernetes.io/region": "cn-north-4",
                "failure-domain.beta.kubernetes.io/zone": "cn-north-4a"
            },
            "annotations": {
                "pv.kubernetes.io/bind-completed": "yes",
                "pv.kubernetes.io/bound-by-controller": "yes",
                "volume.beta.kubernetes.io/storage-class": "sata",
                "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol"
            }
        },
        "spec": {
            "accessModes": [
                "ReadWriteMany"
            ],
            "resources": {
                "requests": {
                    "storage": "10Gi"
                }
            },
            "volumeName": "pvc-ac34af93-8cdd-11e8-8ee0-fa163e49263c",
            "volumeNamespace": "default"
        },
        "status": {
            "phase": "Bound",
            "accessModes": [
                "ReadWriteMany"
            ],
            "capacity": {
                "storage": "10Gi"
            }
        }
    }

状态码

表8描述API的状态码。

表8 状态码

状态码

描述

200

This operation succeeds, and a PersistentVolumeClaim resource object is returned.

异常状态码请参见状态码

分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!非常感谢您的反馈,我们会继续努力做到更好!
反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

智能客服提问云社区提问