云容器引擎 CCE云容器引擎 CCE

计算
弹性云服务器 ECS
裸金属服务器 BMS
云手机 CPH
专属主机 DeH
弹性伸缩 AS
镜像服务 IMS
函数工作流 FunctionGraph
云耀云服务器 HECS
VR云渲游平台 CVR
特惠算力专区
存储
对象存储服务 OBS
云硬盘 EVS
云备份 CBR
弹性文件服务 SFS
存储容灾服务 SDRS
云硬盘备份 VBS
云服务器备份 CSBS
数据快递服务 DES
专属企业存储服务
云存储网关 CSG
专属分布式存储服务 DSS
CDN与智能边缘
内容分发网络 CDN
智能边缘云 IEC
智能边缘平台 IEF
人工智能
AI开发平台ModelArts
华为HiLens
图引擎服务 GES
图像识别 Image
文字识别 OCR
自然语言处理 NLP
内容审核 Moderation
图像搜索 ImageSearch
医疗智能体 EIHealth
园区智能体 CampusGo
企业级AI应用开发专业套件 ModelArts Pro
人脸识别服务 FRS
对话机器人服务 CBS
视频分析服务 VAS
语音交互服务 SIS
知识图谱 KG
人证核身服务 IVS
IoT物联网
设备接入 IoTDA
设备管理 IoTDM(联通用户专用)
全球SIM联接 GSL
IoT开发者服务
IoT数据分析
车联网服务 IoV
路网数字化服务 DRIS
IoT边缘 IoTEdge
设备发放 IoTDP
开发与运维
软件开发平台 DevCloud
项目管理 ProjectMan
代码托管 CodeHub
流水线 CloudPipeline
代码检查 CodeCheck
编译构建 CloudBuild
部署 CloudDeploy
云测 CloudTest
发布 CloudRelease
移动应用测试 MobileAPPTest
CloudIDE
Classroom
开源镜像站 Mirrors
应用魔方 AppCube
云性能测试服务 CPTS
应用管理与运维平台 ServiceStage
视频
实时音视频 SparkRTC
视频直播 Live
视频点播 VOD
媒体处理 MPC
视频接入服务 VIS
管理与监管
统一身份认证服务 IAM
消息通知服务 SMN
云监控服务 CES
应用运维管理 AOM
应用性能管理 APM
云日志服务 LTS
云审计服务 CTS
标签管理服务 TMS
资源管理服务 RMS
应用身份管理服务 OneAccess
区块链
区块链服务 BCS
可信跨链数据链接服务 TCDAS
智能协作
IdeaHub
开发者工具
SDK开发指南
API签名指南
DevStar
HCloud CLI
Terraform
Ansible
云生态
云市场
合作伙伴中心
华为云培训中心
其他
管理控制台
消息中心
产品价格详情
系统权限
我的凭证
客户关联华为云合作伙伴须知
公共问题
宽限期保留期
奖励推广计划
活动
容器
云容器引擎 CCE
云容器实例 CCI
容器镜像服务 SWR
应用编排服务 AOS
多云容器平台 MCP
基因容器 GCS
容器洞察引擎 CIE
云原生服务中心 OSC
容器批量计算 BCE
容器交付流水线 ContainerOps
应用服务网格 ASM
网络
虚拟私有云 VPC
弹性公网IP EIP
弹性负载均衡 ELB
NAT网关 NAT
云专线 DC
虚拟专用网络 VPN
云连接 CC
VPC终端节点 VPCEP
数据库
云数据库 RDS
数据复制服务 DRS
文档数据库服务 DDS
分布式数据库中间件 DDM
云数据库 GaussDB (for openGauss)
云数据库 GaussDB(for MySQL)
云数据库 GaussDB NoSQL
数据管理服务 DAS
数据库和应用迁移 UGO
大数据
MapReduce服务 MRS
数据湖探索 DLI
表格存储服务 CloudTable
可信智能计算服务 TICS
推荐系统 RES
云搜索服务 CSS
数据可视化 DLV
数据湖治理中心 DGC
数据接入服务 DIS
数据仓库服务 GaussDB(DWS)
应用中间件
微服务引擎 CSE
分布式消息服务Kafka版
分布式消息服务RabbitMQ版
API网关 APIG
分布式缓存服务 DCS
分布式消息服务RocketMQ版
企业应用
域名注册服务 Domains
云解析服务 DNS
云速建站 CloudSite
网站备案
华为云WeLink
会议
隐私保护通话 PrivateNumber
语音通话 VoiceCall
消息&短信 MSGSMS
云管理网络
SD-WAN 云服务
边缘数据中心管理 EDCM
云桌面 Workspace
应用与数据集成平台 ROMA Connect
ROMA资产中心 ROMAExchange
API全生命周期管理 ROMA API
安全与合规
安全技术与应用
DDoS防护 ADS
Web应用防火墙 WAF
云防火墙 CFW
应用信任中心 ATC
企业主机安全 HSS
容器安全服务 CGS
云堡垒机 CBH
数据库安全服务 DBSS
数据加密服务 DEW
数据安全中心 DSC
云证书管理服务 CCM
SSL证书管理 SCM
漏洞扫描服务 VSS
态势感知 SA
威胁检测服务 MTD
管理检测与响应 MDR
迁移
主机迁移服务 SMS
对象存储迁移服务 OMS
云数据迁移 CDM
专属云
专属计算集群 DCC
解决方案
高性能计算 HPC
SAP
游戏云
混合云灾备
价格
成本优化最佳实践
专属云商业逻辑
用户服务
帐号中心
费用中心
成本中心
资源中心
企业管理
工单管理
客户运营能力
国际站常见问题
支持计划
专业服务
合作伙伴支持计划
更新时间:2021/07/27 GMT+08:00
分享

创建PersistentVolume

功能介绍

该API用于创建一个PersistentVolume。

URI

POST /api/v1/persistentvolumes

表1 描述该API的参数。

表1 参数描述

参数

是否必选

描述

pretty

No

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

请求消息

请求参数:

请求参数如表2所示。

表2 请求参数

参数

是否必选

参数类型

描述

apiVersion

Yes

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

Yes

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. In CamelCase.

metadata

Yes

metadata object

Standard object's metadata.

spec

Yes

spec object

Spec defines a specification of a persistent volume owned by the cluster. Provisioned by an administrator.

status

No

status object

Status represents the current information/status for the persistent volume. Populated by the system. Read-only.

表3 spec字段数据结构说明

参数

是否必选

参数类型

描述

accessModes

Yes

Array of strings

Access mode.

Options:

ReadWriteOnce: can be read and written by a single node.

ReadOnlyMany: can only be read by multiple nodes.

ReadWriteMany: can be read and written by multiple nodes.

capacity

Yes

Object

A description of the persistent volume's resources and capacity.

claimRef

No

claimRef object

ClaimRef is part of a bi-directional binding between PersistentVolume and PersistentVolumeClaim. Expected to be non-nil when bound. claim. VolumeName is the authoritative bind between PV and PVC.

hostPath

No

hostPath object

HostPath represents a directory on the host. Provisioned by a developer or tester. This is useful for single-node development and testing only! On-host storage is not supported in any way and WILL NOT WORK in a multi-node cluster.

nfs

No

nfs object

NFS represents an NFS mount on the host. Provisioned by an admin.

persistentVolumeReclaimPolicy

No

String

What happens to a persistent volume when released from its claim. Valid options are Retain (default) and Recycle. Recycling must be supported by the volume plugin underlying this persistent volume.

storageClassName

No

String

Name of StorageClass to which this persistent volume belongs. Empty value means that this volume does not belong to any StorageClass.

flexVolume

No

flexVolume

object

FlexVolume represents a generic volume resource that is

provisioned/attached using an exec based plugin. The cluster earlier than v1.15(v1.9/v1.11/v1.13) which use CCE FlexVolume fuxi driver must fill in this field.

CSI

No

CSI

object

CSI represents storage that is handled by an external CSI driver. The cluster of v1.15 or later which use CCE SCI everest must fill in this filed.

表4 status字段数据结构说明

参数

是否必选

参数类型

描述

message

No

String

A human-readable message indicating details about why the volume is in this state.

phase

No

String

Phase indicates if a volume is available, bound to a claim, or released by a claim.

reason

No

String

Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.

表5 claimRef字段数据结构说明

参数

是否必选

参数类型

描述

apiVersion

No

String

API version of the referent.

fieldPath

No

String

If referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. For example, if the object reference is to a container within a pod, this would take on a value like: "spec.containers{name}" (where "name" refers to the name of the container that triggered the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object.

kind

No

String

Kind of the referent.

name

No

String

Name of the referent.

namespace

No

String

Namespace of the referent.

resourceVersion

No

String

Specific resourceVersion to which this reference is made, if any.

uid

No

String

UID of the referent.

表6 hostPath字段数据结构说明

参数

是否必选

参数类型

描述

path

No

String

Path of the directory on the host.

表7 nfs字段数据结构说明

参数

是否必选

参数类型

描述

path

No

String

Path that is exported by the NFS server.

readOnly

No

Boolean

ReadOnly here will force the NFS export to be mounted with read-only permissions. Defaults to false.

server

No

String

Server is the hostname or IP address of the NFS server.

表8 flexVolume 字段结构说明

名称

是否必选

参数类型

描述

driver

Yes

String

Driver is the name of the driver to use for this volume.
If the storage type is EVS, set this parameter to huawei.com/fuxivol.
If the storage type is SFS, set this parameter to huawei.com/fuxinfs.
If the storage type is OBS, set this parameter to huawei.com/fuxiobs.
If the storage type is SFS-Turboe, set this parameter to
huawei.com/fuxiefs

fsType

Yes

String

Required: Filesystem type to mount. Must be a filesystem type supported by the host operating system.

If the storage type is EVS, set this parameter to ext4.

If the storage type is SFS, set this parameter to nfs.

If the storage type is OBS, set this parameter to obs.

If the storage type is SFS-Turbo, set this parameter to efs.

options

No

map

Map of string keys and values that can be used to record extra command options. The option key values are showed below, in the table 10.

表9 options 字段结构说明

名称

是否必选

参数类型

描述

disk-mode

No

String

This parameter is required only when the storage type is EVS, the value can be "SCSI" or "VBD".

fsType

Yes

String

If the storage type is EVS, set this parameter to ext4.

If the storage type is SFS, set this parameter to nfs.

If the storage type is OBS, set this parameter to s3fs.(≥v1.15)

If the storage type is OBS, set this parameter to obs.(≤v1.13)

If the storage type is SFS-Turbo, set this parameter to efs.

volumeID

Yes

String

For EVS\SFS\SFS-Turbo storages, fill the ID of the iaas resource, for OBS, fill the name of obs.

storage_class

No

String

This parameter is required when the storage type is OBS, used to specify OBS type. If there is no obs type, set the default value "STANDARD".

OBS bucket type, standard storage (STANDARD), Low frequency access storage(WARM).

region

No

String

This parameter is required when the storage type is OBS, used to specify the region of OBS resource.

deviceMountPath

No

String

This parameter is required when the storage type is SFS or SFS-Turbo, used to specify the shared path of iaas resource.

表10 CSI 字段结构说明

名称

是否必选

参数类型

描述

driver

Yes

String

Driver is the name of the driver to use for this volume.
If the storage type is EVS, set this parameter to disk.csi.everest.io.
If the storage type is SFS, set this parameter to nas.csi.everest.io.
If the storage type is OBS, set this parameter to obs.csi.everest.io.
If the storage type is SFS-Turboe, set this parameter to
sfsturbo.csi.everest.io.

fsType

Yes

String

Required: Filesystem type to mount. Must be a filesystem type supported by the host operating system.

If the storage type is EVS, set this parameter to ext4.

If the storage type is SFS, set this parameter to nfs.

If the storage type is OBS, set this parameter to s3fs/obsfs.

If the storage type is SFS-Turbo, set this parameter to nfs.

volumeAttributes

No

map

Map of string keys and values that can be used to record extra command options. The option key values are showed below, in the table 12.

volumeHandle

Yes

string

VolumeHandle is the unique volume name returned by the CSI volume plugin’s CreateVolume to refer to the volume on all subsequent calls. For EVS\SFS\SFS-Turbo, fill the ID of the iaas resource, for OBS, fill the name of obs.

表11 volumeAttributes 字段结构说明

名称

是否必选

参数类型

描述

storage.kubernetes.io/csiProvisionerIdentity

Yes

String

For all types of storages, this parameter should be set to "Set everest-csi-provisioner".

everest.io/disk-mode

No

String

This parameter is required only when the storage type is EVS, the value can be "SCSI" or "VBD". But for everest, this value can only be set to "SCSI".

everest.io/disk-volume-type

No

String

This parameter is required only when the storage type is EVS,

used to specify the type of EVS disk to be used.

EVS disk type, high I/O (SAS), ultra-high I/O (SSD).

everest.io/obs-volume-type

No

String

This parameter is required when the storage type is OBS, used to specify OBS type. If there is no obs type, set the default value "STANDARD".

OBS bucket type, standard storage (STANDARD), Low frequency access storage(WARM).

everest.io/region

No

String

This parameter is required when the storage type is OBS, used to specify the region of OBS resource.

everest.io/share-export-location

No

String

This parameter is required when the storage type is SFS or SFS-Turbo, used to specify the shared path of iaas resource.

请求示例:

1.15及以上版本集群,示例如下:

{
    "apiVersion": "v1",
    "kind": "PersistentVolume",
    "metadata": {
        "annotations": {
            "pv.kubernetes.io/provisioned-by": "everest-csi-provisioner"
        },
        "labels": {
            "failure-domain.beta.kubernetes.io/region": "cn-north-4",
            "failure-domain.beta.kubernetes.io/zone": "cn-north-4a"
        },
        "name": "pvc-efe92ec5-fb39-4e17-bb26-c5d336ce5c14"
    },
    "spec": {
        "accessModes": [
            "ReadWriteOnce"
        ],
        "capacity": {
            "storage": "20Gi"
        },
        "csi": {
            "driver": "disk.csi.everest.io",
            "fsType": "ext4",
            "volumeAttributes": {
                "everest.io/disk-mode": "SCSI",
                "everest.io/disk-volume-type": "SAS",
                "storage.kubernetes.io/csiProvisionerIdentity": "everest-csi-provisioner"
            },
            "volumeHandle": "9c44d068-42ab-4fcf-bb8f-1609823da5bb"
        },
        "persistentVolumeReclaimPolicy": "Delete",
        "storageClassName": "csi-disk"
    }
}

1.13及之前版本示例:

{
  "apiVersion": "v1",
  "kind": "PersistentVolume",
  "metadata": {
    "labels": {
      "failure-domain.beta.kubernetes.io/region": "cn-north-4",
      "failure-domain.beta.kubernetes.io/zone": "cn-north-4a"
    },
    "annotations": {
      "pv.kubernetes.io/provisioned-by": "flexvolume-huawei.com/fuxivol"
    },
    "name": "pv-evs-example"
  },
  "spec": {
    "accessModes": [
      "ReadWriteMany"
    ],
    "capacity": {
      "storage": "10Gi"
    },
    "flexVolume": {
      "driver": "huawei.com/fuxivol",
      "fsType": "ext4",
      "options": {
        "disk-mode": "SCSI",
        "fsType": "ext4",
        "volumeID": "0992dbda-6340-470e-a74e-4f0db288ed82"
      }
    },
    "persistentVolumeReclaimPolicy": "Delete",
    "storageClassName": "SAS"
  }
}

响应消息

响应参数:

响应参数的详细描述请参见15.2-Table2 Request parameter.

响应示例:

1.15及以上版本集群,示例如下:

{
    "apiVersion": "v1",
    "kind": "PersistentVolume",
    "metadata": {
        "annotations": {
            "pv.kubernetes.io/provisioned-by": "everest-csi-provisioner"
        },
        "creationTimestamp": "2020-01-08T02:00:31Z",
        "deletionGracePeriodSeconds": 0,
        "deletionTimestamp": "2020-01-13T02:04:12Z",
        "finalizers": [
            "everest-csi-attacher/disk-csi-everest-io"
        ],
        "labels": {
            "failure-domain.beta.kubernetes.io/region": "cn-north-4",
            "failure-domain.beta.kubernetes.io/zone": "cn-north-4a"
        },
        "name": "pvc-efe92ec5-fb39-4e17-bb26-c5d336ce5c14"
    },
    "spec": {
        "accessModes": [
            "ReadWriteOnce"
        ],
        "capacity": {
            "storage": "20Gi"
        },
        "csi": {
            "driver": "disk.csi.everest.io",
            "fsType": "ext4",
            "volumeAttributes": {
                "everest.io/disk-mode": "SCSI",
                "everest.io/disk-volume-type": "SAS",
                "storage.kubernetes.io/csiProvisionerIdentity": "everest-csi-provisioner"
            },
            "volumeHandle": "9c44d068-42ab-4fcf-bb8f-1609823da5bb"
        },
        "persistentVolumeReclaimPolicy": "Delete",
        "storageClassName": "csi-disk",
        "volumeMode": "Filesystem"
    }
}

1.13及之前集群版本示例:

{
    "kind": "PersistentVolume",
    "apiVersion": "v1",
    "metadata": {
        "name": "pv-test-02",
        "namespace": "default",
        "selfLink": "/api/v1/namespaces/default/persistentvolumes/pv-test-02",
        "uid": "98efd6aa-920a-11e8-81cc-fa163e49263c",
        "resourceVersion": "5672675",
        "creationTimestamp": "2018-07-28T02:04:44Z",
        "labels": {
            "failure-domain.beta.kubernetes.io/region": "cn-north-4",
            "failure-domain.beta.kubernetes.io/zone": "cn-north-4a",
            "name": "pv-test-02"
        },
        "annotations": {
            "volume.beta.kubernetes.io/storage-class": "SAS",
            "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol"
        }
    },
    "spec": {
        "capacity": {
            "storage": "10Gi"
        },
        "hostPath": {
            "path": "/home",
            "type": ""
        },
        "accessModes": [
            "ReadWriteMany"
        ],
        "persistentVolumeReclaimPolicy": "Delete"
    },
    "status": {
        "phase": "Pending"
    }
}

状态码

表12描述API的状态码。

表12 状态码

状态码

描述

201

The request has been fulfilled, resulting in the creation of a new resource.

异常状态码请参见状态码

分享:

    相关文档

    相关产品