华为云用户手册

  • URI POST /api/v1/namespaces/{namespace}/pods 表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.
  • 请求示例 创建普通Pod,使用redis镜像,Pod资源占用CPU为0.5,内存为1024Mi。 { "apiVersion" : "v1", "kind" : "Pod", "metadata" : { "labels" : { "name" : "pod-test" }, "name" : "pod-test" }, "spec" : { "containers" : [ { "image" : "redis", "imagePullPolicy" : "Always", "name" : "test", "resources" : { "limits" : { "cpu" : "0.5", "memory" : "1024Mi" }, "requests" : { "cpu" : "0.5", "memory" : "1024Mi" } } } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "priority" : 0, "restartPolicy" : "Always" } } 创建GPU型Pod,使用gpu-418.126版本显示驱动,使用redis镜像,Pod资源占用CPU为4,内存为32Gi。 说明: “华北-北京四”区域,仅支持NVIDIA TeslaV100 32G显卡。“华东-上海一”可支持NVIDIA TeslaV100 32G、NVIDIA TeslaV100 16G显卡。 { "apiVersion" : "v1", "kind" : "Pod", "metadata" : { "annotations" : { "cri.cci.io/gpu-driver" : "gpu-418.126" }, "labels" : { "name" : "pod-test" }, "name" : "pod-test" }, "spec" : { "containers" : [ { "image" : "redis", "imagePullPolicy" : "Always", "name" : "test", "resources" : { "limits" : { "cpu" : "4", "memory" : "32Gi", "nvidia.com/gpu-tesla-v100-16GB" : "1" }, "requests" : { "cpu" : "4", "memory" : "32Gi", "nvidia.com/gpu-tesla-v100-16GB" : "1" } } } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "priority" : 0, "restartPolicy" : "Always" } } 通过LVM方式创建本地卷的Pod,容器内卷的挂载路径为“/tmp/log”。 { "apiVersion" : "v1", "kind" : "Pod", "metadata" : { "labels" : { "app" : "localvolume" }, "name" : "localvolume", "namespace" : "cci-namespace-12192721" }, "spec" : { "containers" : [ { "command" : [ "/bin/sh", "-c", "sleep 10000" ], "image" : "redis:v1", "imagePullPolicy" : "Always", "lifecycle" : { }, "name" : "container-0", "resources" : { "limits" : { "cpu" : "500m", "memory" : "1024Mi" }, "requests" : { "cpu" : "500m", "memory" : "1024Mi" } }, "terminationMessagePath" : "/dev/termination-log", "terminationMessagePolicy" : "File", "volumeMounts" : [ { "mountPath" : "/tmp/log", "name" : "innerevs123" } ] } ], "dnsPolicy" : "Default", "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "restartPolicy" : "Always", "schedulerName" : "default-scheduler", "volumes" : [ { "emptyDir" : { "sizeLimit" : "100Gi" }, "name" : "innerevs123" } ] } }
  • 响应示例 状态码: 201 Created { "apiVersion" : "v1", "kind" : "Pod", "metadata" : { "annotations" : { "cri.cci.io/container-type" : "secure-container" }, "creationTimestamp" : "2022-08-30T03:14:15Z", "finalizers" : [ "billing.kubernetes.io/podbilling-finalizer" ], "labels" : { "name" : "pod-test", "tenant.kubernetes.io/domain-id" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, "name" : "pod-test", "namespace" : "test", "resourceVersion" : "33742743", "selfLink" : "/api/v1/namespaces/test/pods/pod-test", "uid" : "c0f9820e-188c-4612-be69-b9c65c8bdb5a" }, "spec" : { "containers" : [ { "image" : "redis", "imagePullPolicy" : "Always", "name" : "test", "resources" : { "limits" : { "cpu" : "500m", "memory" : "1Gi" }, "requests" : { "cpu" : "500m", "memory" : "1Gi" } }, "terminationMessagePath" : "/dev/termination-log", "terminationMessagePolicy" : "File" } ], "dnsPolicy" : "Default", "enableServiceLinks" : false, "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "nodeSelector" : { "node.cci.io/default-cpu-choice" : "true", "node.cci.io/flavor" : "general-computing" }, "priority" : 0, "restartPolicy" : "Always", "runtimeClassName" : "kata", "schedulerName" : "volcano", "securityContext" : { }, "terminationGracePeriodSeconds" : 30, "tolerations" : [ { "effect" : "NoExecute", "key" : "node.kubernetes.io/not-ready", "operator" : "Exists", "tolerationSeconds" : 300 }, { "effect" : "NoExecute", "key" : "node.kubernetes.io/unreachable", "operator" : "Exists", "tolerationSeconds" : 300 }, { "effect" : "NoSchedule", "key" : "node.cci.io/occupied", "operator" : "Equal", "value" : "default" }, { "effect" : "NoSchedule", "key" : "node.cci.io/allowed-on-shared-node", "operator" : "Exists" }, { "effect" : "NoSchedule", "key" : "node.kubernetes.io/memory-pressure", "operator" : "Exists" } ] }, "status" : { "phase" : "Pending", "qosClass" : "Guaranteed" } }
  • 响应示例 状态码: 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" } } } }
  • 状态码 状态码 描述 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
  • 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.
  • 功能介绍 创建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" : "Endpoints", "metadata" : { "creationTimestamp" : "2023-03-28T13:55:52Z", "name" : "test-endpoint", "namespace" : "test-namespace", "resourceVersion" : "263538673", "selfLink" : "/api/v1/namespaces/test-namespace/endpoints/test-endpoint", "uid" : "3907aa64-c3f3-4de0-b938-9d23e8d12f94" }, "subsets" : [ { "addresses" : [ { "ip" : "192.168.226.222", "targetRef" : { "kind" : "Pod", "name" : "nginx-686bccd6f-ccsqb", "namespace" : "test-namespace", "resourceVersion" : "262055491", "uid" : "ae417968-4f69-40da-9228-2434671e9c66" } } ], "ports" : [ { "name" : "service0", "port" : 80, "protocol" : "TCP" } ] } ] }
  • URI POST /api/v1/namespaces/{namespace}/endpoints 表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.
  • 请求示例 创建Endpoint,端口名称为"service0",端口号"80",端口的IP协议为默认的TCP协议。 { "apiVersion" : "v1", "kind" : "Endpoints", "metadata" : { "name" : "test-endpoint", "namespace" : "test-namespace" }, "subsets" : [ { "addresses" : [ { "ip" : "192.168.226.222", "targetRef" : { "kind" : "Pod", "name" : "nginx-686bccd6f-ccsqb", "namespace" : "test-namespace", "resourceVersion" : "262055491", "uid" : "ae417968-4f69-40da-9228-2434671e9c66" } } ], "ports" : [ { "name" : "service0", "port" : 80, "protocol" : "TCP" } ] } ] }
  • 状态码 状态码 描述 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
  • 状态码 状态码 描述 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
  • 响应示例 状态码: 200 OK { "apiVersion" : "v1", "data" : { "property_1" : "test" }, "kind" : "ConfigMap", "metadata" : { "creationTimestamp" : "2018-09-04T03:11:29Z", "name" : "configmap-test", "namespace" : "namespace-test", "resourceVersion" : "5170290", "selfLink" : "/api/v1/namespaces/namespace-test/configmaps/configmap-test", "uid" : "379519a3-aff0-11e8-8f17-c81fbe371a17" } }
  • URI POST /api/v1/namespaces/{namespace}/configmaps 表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.
  • 请求示例 创建GPU加速型命名空间。 { "apiVersion" : "v1", "kind" : "Namespace", "metadata" : { "annotations" : { "namespace.kubernetes.io/flavor" : "gpu-accelerated" }, "labels" : { "sys_enterprise_project_id" : "0" }, "name" : "namespace-test" } }
  • 状态码 状态码 描述 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
  • URI POST /api/v1/namespaces 表1 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.
  • 功能介绍 创建一个Namespace。 当前云容器实例提供“通用计算型”和“GPU加速型”两种类型的资源,创建命名空间时需要选择资源类型,后续创建的负载中容器就运行在此类型的集群上。调用接口时必须指定metadata.annotations中namespace.kubernetes.io/flavor字段为如下值。 general-computing:通用计算型,基本水平的计算、存储和网络资源,适用于通用工作负载场景。 gpu-accelerated:GPU加速型,突出的图形计算能力,适用于AI等高性能场景。 Namespace下必须要创建一个Network,用于定义kubernetes中一个namespace内的网络与华为云虚拟私有云服务的子网和vpc的映射关系,具体请参见Namespace和Network。
  • 响应示例 状态码: 201 Created { "metadata" : { "annotations" : { "namespace.kubernetes.io/flavor" : "gpu-accelerated", "pv.kubernetes.io/enable-dynamic-provisioning" : "true", "tenant.kubernetes.io/domain-id" : "aadb43c0b14c4cafbccfff483d075987", "tenant.kubernetes.io/domain-name" : "cci", "tenant.kubernetes.io/project-id" : "51bf52609f2a49c68bfda3398817b376", "tenant.kubernetes.io/project-name" : "southchina" }, "creationTimestamp" : "2018-09-03T11:20:48Z", "labels" : { "sys_enterprise_project_id" : "0503dda897000fed2f78c00909158a4d" }, "name" : "namespace-test", "resourceVersion" : "5016746", "selfLink" : "/api/v1/namespaces/namespace-test", "uid" : "68a68c5a-af6b-11e8-8f17-c81fbe371a17" }, "spec" : { "finalizers" : [ "kubernetes" ] }, "status" : { "phase" : "Active" } }
  • URI POST /apis/batch.volcano.sh/v1alpha1/namespaces/{namespace}/jobs 表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.
  • 响应示例 状态码: 201 Created { "apiVersion" : "batch.volcano.sh/v1alpha1", "kind" : "Job", "metadata" : { "creationTimestamp" : "2019-06-26T06:24:50Z", "generation" : 1, "name" : "openmpi-hello-3-com", "namespace" : "cci-namespace-42263891", "resourceVersion" : "7681331", "selfLink" : "/apis/batch.volcano.sh/v1alpha1/namespaces/cci-namespace-42263891/jobs/openmpi-hello-3-com", "uid" : "1a32a8c4-97db-11e9-9d09-dc9914fb58e0" }, "spec" : { "minAvailable" : 1, "plugins" : { "env" : [ ], "ssh" : [ ], "svc" : [ ] }, "queue" : "default", "schedulerName" : "volcano", "tasks" : [ { "name" : "mpimaster", "policies" : [ { "action" : "CompleteJob", "event" : "TaskCompleted" } ], "replicas" : 1, "template" : { "spec" : { "containers" : [ { "command" : [ "/bin/sh", "-c", "MPI_HOST=`cat /etc/volcano/mpiworker.host | tr \"\\n\" \",\"`;\nmkdir -p /var/run/sshd; /usr/sbin/sshd;\nmpiexec --allow-run-as-root --host ${MPI_HOST} -np 2 mpi_hello_world 003e /home/re" ], "image" : "*.*.*.*:20202/swr/openmpi-hello:3.28", "name" : "mpimaster", "ports" : [ { "containerPort" : 22, "name" : "mpijob-port" } ], "resources" : { "limits" : { "cpu" : "250m", "memory" : "1Gi" }, "requests" : { "cpu" : "250m", "memory" : "1Gi" } }, "workingDir" : "/home" } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "restartPolicy" : "OnFailure" } } }, { "name" : "mpiworker", "replicas" : 2, "template" : { "spec" : { "containers" : [ { "command" : [ "/bin/sh", "-c", "mkdir -p /var/run/sshd; /usr/sbin/sshd -D;" ], "image" : "*.*.*.*:20202/swr/openmpi-hello:3.28", "name" : "mpiworker", "ports" : [ { "containerPort" : 22, "name" : "mpijob-port" } ], "resources" : { "limits" : { "cpu" : "250m", "memory" : "1Gi" }, "requests" : { "cpu" : "250m", "memory" : "1Gi" } }, "workingDir" : "/home" } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "restartPolicy" : "OnFailure" } } } ] } }
  • 状态码 状态码 描述 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
  • 状态码 状态码 描述 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
  • URI POST /apis/batch/v1/namespaces/{namespace}/jobs 表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.
  • 请求示例 创建普通Job,计算π到2000位并打印输出。 { "apiVersion" : "batch/v1", "kind" : "Job", "metadata" : { "name" : "pi" }, "spec" : { "template" : { "metadata" : { "name" : "pi" }, "spec" : { "containers" : [ { "command" : [ "perl", "-Mbignum=bpi", "-wle", "print bpi(2000)" ], "image" : "perl", "name" : "pi", "resources" : { "limits" : { "cpu" : "500m", "memory" : "1024Mi" }, "requests" : { "cpu" : "500m", "memory" : "1024Mi" } } } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "priority" : 0, "restartPolicy" : "Never" } } } } 创建使用GPU的Job,gpu-418.126版本显示驱动。 { "apiVersion" : "batch/v1", "kind" : "Job", "metadata" : { "annotations" : { "cri.cci.io/gpu-driver" : "gpu-418.126", "description" : "" }, "labels" : { }, "name" : "gpu-job-test", "namespace" : "cci-namespace-44173581" }, "spec" : { "template" : { "metadata" : { "annotations" : { "cri.cci.io/gpu-driver" : "gpu-418.126" }, "name" : "gpu-job-test" }, "spec" : { "containers" : [ { "command" : [ "sleep", "3600" ], "image" : "library/nginx:latest", "lifecycle" : { }, "name" : "container-0", "resources" : { "limits" : { "cpu" : 4, "memory" : "32Gi", "nvidia.com/gpu-tesla-v100-16GB" : 1 }, "requests" : { "cpu" : 4, "memory" : "32Gi", "nvidia.com/gpu-tesla-v100-16GB" : 1 } } } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "restartPolicy" : "Never" } } } }
  • 响应示例 状态码: 200 OK { "apiVersion" : "batch/v1", "kind" : "Job", "metadata" : { "creationTimestamp" : "2018-09-05T01:10:59Z", "labels" : { "controller-uid" : "8c923079-b0a8-11e8-8bcb-f898ef6c78b4", "job-name" : "pi" }, "name" : "pi", "namespace" : "namespace-test", "resourceVersion" : "5391201", "selfLink" : "/apis/batch/v1/namespaces/namespace-test/jobs/pi", "uid" : "8c923079-b0a8-11e8-8bcb-f898ef6c78b4" }, "spec" : { "backoffLimit" : 6, "completions" : 1, "parallelism" : 1, "selector" : { "matchLabels" : { "controller-uid" : "8c923079-b0a8-11e8-8bcb-f898ef6c78b4" } }, "template" : { "metadata" : { "annotations" : { "cri.cci.io/container-type" : "secure-container" }, "creationTimestamp" : null, "labels" : { "controller-uid" : "8c923079-b0a8-11e8-8bcb-f898ef6c78b4", "job-name" : "pi" }, "name" : "pi" }, "spec" : { "containers" : [ { "command" : [ "perl", "-Mbignum=bpi", "-wle", "print bpi(2000)" ], "image" : "perl", "imagePullPolicy" : "Always", "name" : "pi", "resources" : { "limits" : { "cpu" : "500m", "memory" : "1Gi" }, "requests" : { "cpu" : "500m", "memory" : "1Gi" } }, "terminationMessagePath" : "/dev/termination-log", "terminationMessagePolicy" : "File" } ], "dnsPolicy" : "ClusterFirst", "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "priority" : 0, "restartPolicy" : "Never", "schedulerName" : "default-scheduler", "securityContext" : { } } } }, "status" : { } }
  • 响应示例 状态码: 200 OK { "apiVersion" : "apps/v1", "kind" : "StatefulSet", "metadata" : { "creationTimestamp" : "2018-09-04T07:13:00Z", "generation" : 1, "labels" : { "app" : "statefulset-test" }, "name" : "statefulset-test", "namespace" : "namespace-test", "resourceVersion" : "5207623", "selfLink" : "/apis/apps/v1/namespaces/namespace-test/statefulsets/statefulset-test", "uid" : "f4a35f35-b011-11e8-b6ef-f898ef6c78b4" }, "spec" : { "podManagementPolicy" : "OrderedReady", "replicas" : 3, "revisionHistoryLimit" : 10, "selector" : { "matchLabels" : { "app" : "statefulset-test" } }, "serviceName" : "", "template" : { "metadata" : { "annotations" : { "cri.cci.io/container-type" : "secure-container" }, "creationTimestamp" : null, "labels" : { "app" : "statefulset-test" } }, "spec" : { "containers" : [ { "image" : "redis", "imagePullPolicy" : "IfNotPresent", "name" : "container-0", "resources" : { "limits" : { "cpu" : "500m", "memory" : "1Gi" }, "requests" : { "cpu" : "500m", "memory" : "1Gi" } }, "terminationMessagePath" : "/dev/termination-log", "terminationMessagePolicy" : "File" } ], "dnsPolicy" : "ClusterFirst", "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "restartPolicy" : "Always", "schedulerName" : "default-scheduler", "securityContext" : { } } }, "updateStrategy" : { "type" : "OnDelete" } }, "status" : { "replicas" : 0 } }
  • 请求示例 创建一个名为“statefulset-test”的StatefuiSet负载,使用redis镜像创建3个Pod。 { "apiVersion" : "apps/v1", "kind" : "StatefulSet", "metadata" : { "name" : "statefulset-test" }, "spec" : { "replicas" : 3, "selector" : { "matchLabels" : { "app" : "statefulset-test" } }, "serviceName" : "statefulset-test", "template" : { "metadata" : { "labels" : { "app" : "statefulset-test" } }, "spec" : { "containers" : [ { "image" : "redis", "name" : "container-0", "resources" : { "limits" : { "cpu" : "500m", "memory" : "1024Mi" }, "requests" : { "cpu" : "500m", "memory" : "1024Mi" } } } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "priority" : 0 } } } }
  • URI POST /apis/apps/v1/namespaces/{namespace}/statefulsets 表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.
共100000条