云服务器内容精选

  • 状态码 状态码 描述 200 OK 201 Created 202 Accepted 400 BadRequest 401 Unauthorized 403 Forbidden 404 NotFound 405 MethodNotAllowed 406 NotAcceptable 409 AlreadyExists 415 UnsupportedMediaType 422 Invalid 429 TooManyRequests 500 InternalError 503 ServiceUnavailable 504 ServerTimeout
  • 功能介绍 创建PersistentVolumeClaim,主要适用于动态创建存储的场景,即存储资源未创建时,创建PVC会根据请求内容创建一个存储资源。 当前支持创建EVS(云硬盘卷,块存储)和SFS(文件存储卷),使用时 spec.storageClassName 参数的取值如下: sata:普通I/O云硬盘卷 sas:高I/O云硬盘卷 ssd:超高I/O云硬盘卷 csi-disk-gpssd:通用型SSD云硬盘卷 csi-disk-gpssd2:通用型SSD V2云硬盘卷 nfs-rw:标准文件协议类型文件存储卷 csi-sfs:SFS 3.0容量型弹性文件服务 csi-sfsturbo-hpc:HPC型弹性文件服务 若不指定spec.storageClassName,可在metadata.annotations中指定volume.beta.kubernetes.io/storage-class,取值含义与spec.storageClassName 相同,这两个参数选择其中一个即可。 若需要创建加密类型存储卷,对于云硬盘存储卷需要在metadata.annotations中增加paas.storage.io/cryptKeyId字段;对于文件存储卷需要增加paas.storage.io/cryptKeyId、paas.storage.io/cryptAlias和paas.storage.io/cryptDomainId字段。 若需要创建通用型SSD V2云硬盘卷, 卷需要在metadata.annotations中增加 everest.io/disk-iops 和 everest.io/disk-throughput 字段,IOPS和吞吐量大小范围可见EVS文档。
  • 响应示例 状态码: 200 OK { "apiVersion" : "v1", "kind" : "PersistentVolumeClaim", "metadata" : { "annotations" : { "paas.storage.io/cryptKeyId" : "ee9b610c-e356-11e9-aadc-d0efc1b3bb6b", "pv.kubernetes.io/bind-completed" : "yes", "pv.kubernetes.io/bound-by-controller" : "yes", "volume.beta.kubernetes.io/storage-provisioner" : "flexvolume-huawei.com/fuxivol" }, "creationTimestamp" : "2018-11-24T07:48:35Z", "finalizers" : [ "kubernetes.io/pvc-protection" ], "labels" : { "app" : "evs" }, "name" : "pvc-test", "namespace" : "test-namespace", "resourceVersion" : "28156856", "selfLink" : "/api/v1/namespaces/ns-test/persistentvolumeclaims/pvc-test", "uid" : "58d15f3e-efbd-11e8-8950-501d934409f3" }, "spec" : { "accessModes" : [ "ReadWriteMany" ], "resources" : { "requests" : { "storage" : "10Gi" } }, "storageClassName" : "sata", "volumeName" : "pvc-58d15f3e-efbd-11e8-8950-501d934409f3" }, "status" : { "accessModes" : [ "ReadWriteMany" ], "capacity" : { "storage" : "10Gi" }, "phase" : "Bound" } }
  • 请求示例 创建一个大小为10G的加密云硬盘,类型为sata { "apiVersion" : "v1", "kind" : "PersistentVolumeClaim", "metadata" : { "annotations" : { "paas.storage.io/cryptKeyId" : "ee9b610c-e356-11e9-aadc-d0efc1b3bb6b", "volume.beta.kubernetes.io/storage-class" : "sata" }, "name" : "pvc-test", "namespace" : "test-namespace" }, "spec" : { "accessModes" : [ "ReadWriteMany" ], "resources" : { "requests" : { "storage" : "10Gi" } } } } 创建一个大小为10G的加密文件存储卷 { "apiVersion" : "v1", "kind" : "PersistentVolumeClaim", "metadata" : { "annotations" : { "paas.storage.io/cryptAlias" : "sfs/default", "paas.storage.io/cryptDomainId" : "xxxxxx", "paas.storage.io/cryptKeyId" : "xxxxxx", "volume.beta.kubernetes.io/storage-class" : "nfs-rw" }, "name" : "pvc-test", "namespace" : "test-namespace" }, "spec" : { "accessModes" : [ "ReadWriteMany" ], "resources" : { "requests" : { "storage" : "10Gi" } } } }
  • URI POST /api/v1/namespaces/{namespace}/persistentvolumeclaims 表1 路径参数 参数 是否必选 参数类型 描述 namespace 是 String object name and auth scope, such as for teams and projects 表2 Query参数 参数 是否必选 参数类型 描述 dryRun 否 String When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed fieldManager 否 String fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. pretty 否 String If 'true', then the output is pretty printed.
  • 状态码 状态码 描述 200 OK 202 Accepted 400 BadRequest 401 Unauthorized 403 Forbidden 404 NotFound 405 MethodNotAllowed 406 NotAcceptable 409 Conflict 415 UnsupportedMediaType 422 Invalid 429 TooManyRequests 500 InternalError 503 ServiceUnavailable 504 ServerTimeout
  • 请求参数 表3 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用 IAM 服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 Content-Type 是 String 消息体的类型(格式),默认取值为“application/json” 缺省值:application/json 表4 请求Body参数 参数 是否必选 参数类型 描述 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. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources dryRun 否 Array of strings When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed gracePeriodSeconds 否 Long The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately. 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. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds orphanDependents 否 Boolean Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. preconditions 否 io.k8s.apimachinery.pkg.apis.meta.v1.Preconditions object Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. propagationPolicy 否 String Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground. 表5 io.k8s.apimachinery.pkg.apis.meta.v1.Preconditions 参数 是否必选 参数类型 描述 resourceVersion 否 String Specifies the target ResourceVersion uid 否 String Specifies the target UID.
  • 响应示例 状态码: 200 OK { "apiVersion" : "v1", "kind" : "PersistentVolumeClaim", "metadata" : { "annotations" : { "volume.beta.kubernetes.io/storage-class" : "sata", "volume.beta.kubernetes.io/storage-provisioner" : "flexvolume-huawei.com/fuxivol" }, "creationTimestamp" : "2018-09-06T07:27:47Z", "deletionGracePeriodSeconds" : 0, "deletionTimestamp" : "2018-09-06T07:51:51Z", "finalizers" : [ "kubernetes.io/pvc-protection" ], "name" : "pvc-test", "namespace" : "namespace-test", "resourceVersion" : "5669396", "selfLink" : "/api/v1/namespaces/namespace-test/persistentvolumeclaims/pvc-test", "uid" : "5a9ab4c1-b1a6-11e8-8b84-c88d83be759f" }, "spec" : { "accessModes" : [ "ReadWriteMany" ], "resources" : { "requests" : { "storage" : "10Gi" } } }, "status" : { "phase" : "Pending" } }
  • URI DELETE /api/v1/namespaces/{namespace}/persistentvolumeclaims/{name} 表1 路径参数 参数 是否必选 参数类型 描述 name 是 String name of the PersistentVolumeClaim namespace 是 String object name and auth scope, such as for teams and projects 表2 Query参数 参数 是否必选 参数类型 描述 dryRun 否 String When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed gracePeriodSeconds 否 Integer The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately. orphanDependents 否 Boolean Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. propagationPolicy 否 String Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground. pretty 否 String If 'true', then the output is pretty printed.