api · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22...

987
云容器引擎 API 参考 文档版本 01 发布日期 2020-03-12 华为技术有限公司

Upload: others

Post on 12-Mar-2020

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

云容器引擎

API 参考

文档版本 01

发布日期 2020-03-12

华为技术有限公司

Page 2: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

版权所有 © 华为技术有限公司 2020。 保留一切权利。

非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,并不得以任何形式传播。 商标声明

和其他华为商标均为华为技术有限公司的商标。本文档提及的其他所有商标或注册商标,由各自的所有人拥有。 注意

您购买的产品、服务或特性等应受华为公司商业合同和条款的约束,本文档中描述的全部或部分产品、服务或特性可能不在您的购买或使用范围之内。除非合同另有约定,华为公司对本文档内容不做任何明示或默示的声明或保证。

由于产品版本升级或其他原因,本文档内容会不定期进行更新。除非另有约定,本文档仅作为使用指导,本文档中的所有陈述、信息和建议不构成任何明示或暗示的担保。

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 i

Page 3: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

目 录

1 使用前必读.................................................................................................................................. 11.1 概述.............................................................................................................................................................................................. 11.2 调用说明......................................................................................................................................................................................21.3 终端节点......................................................................................................................................................................................21.4 约束限制......................................................................................................................................................................................31.5 基本概念......................................................................................................................................................................................3

2 API 概览...................................................................................................................................... 5

3 如何调用 API............................................................................................................................ 213.1 构造请求................................................................................................................................................................................... 213.2 认证鉴权................................................................................................................................................................................... 243.3 返回结果................................................................................................................................................................................... 25

4 快速入门....................................................................................................................................274.1 创建游戏工作负载.................................................................................................................................................................. 27

5 API............................................................................................................................................. 345.1 集群管理................................................................................................................................................................................... 345.1.1 创建集群................................................................................................................................................................................ 345.1.2 获取指定的集群................................................................................................................................................................... 485.1.3 获取指定项目下的集群...................................................................................................................................................... 525.1.4 更新指定的集群................................................................................................................................................................... 545.1.5 删除集群................................................................................................................................................................................ 575.1.6 获取集群证书....................................................................................................................................................................... 595.1.7 创建节点................................................................................................................................................................................ 635.1.8 获取指定的节点................................................................................................................................................................... 805.1.9 获取集群下所有节点.......................................................................................................................................................... 835.1.10 更新指定的节点................................................................................................................................................................ 865.1.11 删除节点............................................................................................................................................................................. 885.1.12 查询作业进度.....................................................................................................................................................................915.1.13 获取集群下所有节点池................................................................................................................................................... 955.2 存储管理................................................................................................................................................................................... 985.2.1 创建 PersistentVolumeClaim.......................................................................................................................................... 985.2.2 删除 PersistentVolumeClaim........................................................................................................................................1035.2.3 创建 PersistentVolume................................................................................................................................................... 107

云容器引擎API 参考 目 录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 ii

Page 4: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

5.2.4 删除 PersistentVolume................................................................................................................................................... 1155.3 插件管理................................................................................................................................................................................. 1195.3.1 创建 AddonInstance........................................................................................................................................................1195.3.2 查询 AddonTemplates 信息.......................................................................................................................................... 1255.3.3 更新 AddonInstance........................................................................................................................................................1325.3.4 删除 AddonInstance........................................................................................................................................................1375.3.5 获取 AddonInstance 详情.............................................................................................................................................. 1425.3.6 获取 AddonInstance 列表.............................................................................................................................................. 147

6 Kubernetes API.................................................................................................................... 1536.1 Node........................................................................................................................................................................................1536.1.1 获取指定的 Node............................................................................................................................................................. 1536.1.2 列出指定的 Node............................................................................................................................................................. 1576.1.3 更新指定的 Node............................................................................................................................................................. 1616.2 Namespace........................................................................................................................................................................... 1656.2.1 创建 Namespace.............................................................................................................................................................. 1656.2.2 删除 Namespace.............................................................................................................................................................. 1686.2.3 获取指定的 Namespace................................................................................................................................................. 1716.2.4 替换指定的 Namespace................................................................................................................................................. 1736.2.5 替换指定的 Namespace 的状态................................................................................................................................... 1756.2.6 替换指定的 Namespace 的 Finalize 值...................................................................................................................... 1766.2.7 列出 Namespace.............................................................................................................................................................. 1786.2.8 更新指定的 Namespace................................................................................................................................................. 1816.3 Resourcequotas................................................................................................................................................................... 1836.3.1 获取 Resourcequotas...................................................................................................................................................... 1836.4 Pod........................................................................................................................................................................................... 1976.4.1 创建 Pod............................................................................................................................................................................. 1976.4.2 删除 Pod............................................................................................................................................................................. 1996.4.3 删除所有的 Pod................................................................................................................................................................ 2036.4.4 获取指定的 Pod................................................................................................................................................................ 2066.4.5 替换指定的 Pod................................................................................................................................................................ 2086.4.6 替换指定的 Pod 的状态.................................................................................................................................................. 2126.4.7 列出指定 Namespaces 下的所有 Pod.........................................................................................................................2156.4.8 列出 Pod............................................................................................................................................................................. 2186.4.9 更新指定的 Pod................................................................................................................................................................ 2226.5 Deployment.......................................................................................................................................................................... 2256.5.1 创建 Deployment............................................................................................................................................................. 2256.5.2 创建 Deployment 的回滚操作...................................................................................................................................... 2336.5.3 删除 Deployment............................................................................................................................................................. 2356.5.4 删除所有的 Deployment................................................................................................................................................ 2376.5.5 获取指定的 Deployment................................................................................................................................................ 2396.5.6 获取指定的 Deployment 的状态..................................................................................................................................2416.5.7 获取指定的 Deployment 的伸缩操作......................................................................................................................... 244

云容器引擎API 参考 目 录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 iii

Page 5: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.5.8 替换指定的 Deployment................................................................................................................................................ 2456.5.9 替换指定的 Deployment 的状态..................................................................................................................................2496.5.10 替换指定的 Deployment 的伸缩操作.......................................................................................................................2536.5.11 列出指定 Namespace 下的 Deployment................................................................................................................ 2556.5.12 列出指定的 Deployment............................................................................................................................................. 2576.5.13 更新指定的 Deployment............................................................................................................................................. 2686.5.14 更新指定的 Deployment 的状态............................................................................................................................... 2726.5.15 更新指定的 Deployment 的伸缩操作.......................................................................................................................2746.6 StatefulSet.............................................................................................................................................................................2766.6.1 创建 StatefulSet............................................................................................................................................................... 2766.6.2 删除 StatefulSet............................................................................................................................................................... 2836.6.3 删除所有的 StatefulSet.................................................................................................................................................. 2856.6.4 获取指定的 StatefulSet.................................................................................................................................................. 2896.6.5 获取指定的 StatefulSet 的状态.................................................................................................................................... 2926.6.6 替换指定的 StatefulSet.................................................................................................................................................. 2946.6.7 替换指定的 StatefulSet 的状态.................................................................................................................................... 2976.6.8 列出指定 Namespace 下的 StatefulSet..................................................................................................................... 3006.6.9 列出指定的 StatefulSet.................................................................................................................................................. 3036.6.10 更新指定的 StatefulSet................................................................................................................................................ 3066.6.11 更新指定的 StatefulSet 的状态.................................................................................................................................. 3096.7 DaemonSet........................................................................................................................................................................... 3116.7.1 创建 DaemonSet.............................................................................................................................................................. 3116.7.2 删除 DaemonSet.............................................................................................................................................................. 3176.7.3 删除所有的 Daemonset................................................................................................................................................. 3216.7.4 获取指定的 DaemonSet................................................................................................................................................. 3236.7.5 获取指定的 DaemonSet 的状态................................................................................................................................... 3256.7.6 更新指定的 DaemonSet................................................................................................................................................. 3276.7.7 更新指定的 DaemonSet 的状态................................................................................................................................... 3306.7.8 列出指定的 DaemonSet................................................................................................................................................. 3326.7.9 列出指定 Namespace 下的 DaemonSet....................................................................................................................3376.7.10 替换指定的 DaemonSet...............................................................................................................................................3406.7.11 替换指定的 DaemonSet 的状态................................................................................................................................ 3436.8 Job............................................................................................................................................................................................ 3466.8.1 创建 Job.............................................................................................................................................................................. 3466.8.2 删除 Job.............................................................................................................................................................................. 3536.8.3 删除所有的 Job................................................................................................................................................................. 3586.8.4 获取指定的 Job................................................................................................................................................................. 3616.8.5 获取指定的 Job 的状态................................................................................................................................................... 3636.8.6 替换指定的 Job................................................................................................................................................................. 3656.8.7 替换指定的 Job 的状态................................................................................................................................................... 3686.8.8 列出指定 Namespace 下的 Job.................................................................................................................................... 3716.8.9 列出所有 Job...................................................................................................................................................................... 373

云容器引擎API 参考 目 录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 iv

Page 6: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.8.10 更新指定的 Job 的状态................................................................................................................................................. 3756.8.11 更新指定的 Job............................................................................................................................................................... 3776.9 CronJob.................................................................................................................................................................................. 3806.9.1 创建 CronJob..................................................................................................................................................................... 3806.9.2 删除 CronJob..................................................................................................................................................................... 3846.9.3 删除所有的 CronJob........................................................................................................................................................ 3876.9.4 获取指定的 CronJob........................................................................................................................................................ 3916.9.5 获取指定的 CronJob 的状态.......................................................................................................................................... 3946.9.6 替换指定的 CronJob........................................................................................................................................................ 3966.9.7 替换指定的 CronJob 的状态.......................................................................................................................................... 3996.9.8 列出指定 Namespace 下的 CronJob........................................................................................................................... 4026.9.9 列出所有的 CronJob........................................................................................................................................................ 4086.9.10 更新指定的 CronJob 的状态........................................................................................................................................4146.9.11 更新指定的 CronJob...................................................................................................................................................... 4166.10 ReplicSet.............................................................................................................................................................................. 4186.10.1 列出指定的 ReplicaSet................................................................................................................................................. 4186.10.2 获取指定的 ReplicaSet................................................................................................................................................. 4226.10.3 获取 Replicasets............................................................................................................................................................. 4276.11 ReplicationController...................................................................................................................................................... 4346.11.1 创建 ReplicationController......................................................................................................................................... 4346.11.2 删除 ReplicationController......................................................................................................................................... 4376.11.3 删除所有的 ReplicationController............................................................................................................................ 4406.11.4 获取指定 Namespace 下的 ReplicationController...............................................................................................4436.11.5 替换指定 Namespace 下的 ReplicationController...............................................................................................4456.11.6 替换指定 Namespace 下的 ReplicationController 状态..................................................................................... 4486.11.7 列出指定 Namespace 下的 ReplicationController...............................................................................................4506.11.8 列出 ReplicationController......................................................................................................................................... 4526.11.9 更新指定的 ReplicationController............................................................................................................................ 4556.12 Endpoints............................................................................................................................................................................ 4576.12.1 创建 Endpoints............................................................................................................................................................... 4586.12.2 删除 Endpoints............................................................................................................................................................... 4636.12.3 删除所有的 Endpoints.................................................................................................................................................. 4676.12.4 获取指定的 Endpoints.................................................................................................................................................. 4696.12.5 替换指定的 Endpoints.................................................................................................................................................. 4706.12.6 列出 Endpoints............................................................................................................................................................... 4736.12.7 列出指定 Namespace 下的 Endpoints.....................................................................................................................4766.12.8 更新指定的 Endpoints.................................................................................................................................................. 4786.13 Service.................................................................................................................................................................................. 4806.13.1 创建 Service..................................................................................................................................................................... 4816.13.2 删除 Service..................................................................................................................................................................... 4976.13.3 获取指定的 Service........................................................................................................................................................ 4986.13.4 替换指定的 Service........................................................................................................................................................ 509

云容器引擎API 参考 目 录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 v

Page 7: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.13.5 列出指定 Namespace 下的 Service.......................................................................................................................... 5116.13.6 列出 Service..................................................................................................................................................................... 5156.13.7 更新指定的 Service........................................................................................................................................................ 5176.14 Ingress.................................................................................................................................................................................. 5206.14.1 创建 Ingress..................................................................................................................................................................... 5206.14.2 更新指定的 Ingress........................................................................................................................................................ 5306.14.3 替换指定的 Ingress........................................................................................................................................................ 5336.14.4 删除 Ingress..................................................................................................................................................................... 5356.14.5 删除所有的 Ingress........................................................................................................................................................ 5376.14.6 获取指定的 Ingress........................................................................................................................................................ 5416.14.7 列出指定 Namespace 下的 Ingress.......................................................................................................................... 5436.14.8 获取 Ingress 列表........................................................................................................................................................... 5466.14.9 获取指定 Namespace 下的某个 Ingress 对象的状态........................................................................................... 5506.14.10 替换指定 Namespace 下的某个 Ingress 对象的状态........................................................................................ 5526.14.11 更新指定 Namespace 下的某个 Ingress 对象的状态........................................................................................ 5546.15 NetworkPolicy................................................................................................................................................................... 5576.15.1 创建 networkpolicy....................................................................................................................................................... 5576.15.2 更新指定的 networkpolicy.......................................................................................................................................... 5696.15.3 替换指定的 networkpolicy.......................................................................................................................................... 5716.15.4 删除 networkpolicy....................................................................................................................................................... 5736.15.5 批量删除 networkpolicy.............................................................................................................................................. 5746.15.6 获取指定的 networkpolicy.......................................................................................................................................... 5776.15.7 列出指定 namespace 下的 networkpolicy............................................................................................................. 5786.15.8 获取 networkpolicy 列表............................................................................................................................................. 5826.16 PersistentVolume..............................................................................................................................................................5856.16.1 创建 PersistentVolume................................................................................................................................................ 5856.16.2 删除指定的 PersistentVolume................................................................................................................................... 5926.16.3 删除所有的 PersistentVolume................................................................................................................................... 5956.16.4 获取指定的 PersistentVolume................................................................................................................................... 5976.16.5 替换指定的 PersistentVolume................................................................................................................................... 5996.16.6 替换指定的 PersistentVolume 的状态..................................................................................................................... 6016.16.7 列出所有的 PersistentVolume................................................................................................................................... 6036.16.8 更新指定的 PersistentVolume................................................................................................................................... 6066.17 PersistentVolumeClaim.................................................................................................................................................. 6076.17.1 创建 PersistentVolumeClaim..................................................................................................................................... 6076.17.2 删除指定的 PersistentVolumeClaim........................................................................................................................ 6156.17.3 删除所有的 PersistentVolumeClaim........................................................................................................................ 6176.17.4 获取指定的 PersistentVolumeClaim........................................................................................................................ 6206.17.5 替换指定的 PersistentVolumeClaim........................................................................................................................ 6266.17.6 替换指定的 PersistentVolumeClaim 的状态.......................................................................................................... 6296.17.7 列出指定的 Namespace 下的 PersistentVolumeClaim...................................................................................... 6336.17.8 列出所有的 PersistentVolumeClaim........................................................................................................................ 637

云容器引擎API 参考 目 录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 vi

Page 8: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.17.9 更新指定的 PersistentVolumeClaim........................................................................................................................ 6416.18 ConfigMap.......................................................................................................................................................................... 6436.18.1 创建 ConfigMap............................................................................................................................................................. 6436.18.2 删除 ConfigMap............................................................................................................................................................. 6456.18.3 删除所有的 ConfigMap................................................................................................................................................ 6496.18.4 获取指定的 ConfigMap................................................................................................................................................ 6516.18.5 替换指定 ConfigMap.................................................................................................................................................... 6536.18.6 列出指定 Namespace 下的 ConfigMap.................................................................................................................. 6556.18.7 列出指定的 ConfigMap................................................................................................................................................ 6566.18.8 更新指定的 ConfigMap................................................................................................................................................ 6596.19 Secret.................................................................................................................................................................................... 6606.19.1 创建 Secret.......................................................................................................................................................................6616.19.2 删除 Secret.......................................................................................................................................................................6696.19.3 删除所有的 Secret......................................................................................................................................................... 6746.19.4 获取 Secret 信息............................................................................................................................................................. 6766.19.5 替换指定的 Secret......................................................................................................................................................... 6836.19.6 列出指定 Namespace 下的 Secret............................................................................................................................ 6856.19.7 列出集群下的 Secret..................................................................................................................................................... 6886.20 RBAC..................................................................................................................................................................................... 6926.20.1 ClusterRole...................................................................................................................................................................... 6926.20.1.1 创建 ClusterRole......................................................................................................................................................... 6936.20.1.2 更新指定的 ClusterRole............................................................................................................................................7016.20.1.3 替换指定的 ClusterRole............................................................................................................................................7036.20.1.4 删除指定的 ClusterRole............................................................................................................................................7046.20.1.5 批量删除 ClusterRole................................................................................................................................................ 7066.20.1.6 获取指定的 ClusterRole............................................................................................................................................7086.20.1.7 获取 ClusterRole 列表............................................................................................................................................... 7096.20.2 ClusterRoleBinding....................................................................................................................................................... 7126.20.2.1 创建 ClusterRoleBinding.......................................................................................................................................... 7126.20.2.2 更新指定的 ClusterRoleBinding............................................................................................................................. 7226.20.2.3 替换指定的 ClusterRoleBinding............................................................................................................................. 7236.20.2.4 删除指定的 ClusterRoleBinding............................................................................................................................. 7256.20.2.5 批量删除 ClusterRoleBinding................................................................................................................................. 7266.20.2.6 获取指定的 ClusterRoleBinding............................................................................................................................. 7296.20.2.7 获取 ClusterRoleBinding 列表................................................................................................................................ 7306.20.3 Role....................................................................................................................................................................................7336.20.3.1 创建 Role...................................................................................................................................................................... 7336.20.3.2 更新指定的 Role......................................................................................................................................................... 7426.20.3.3 替换指定的 Role......................................................................................................................................................... 7436.20.3.4 删除指定的 Role......................................................................................................................................................... 7456.20.3.5 批量删除 Role.............................................................................................................................................................. 7476.20.3.6 获取指定的 Role......................................................................................................................................................... 749

云容器引擎API 参考 目 录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 vii

Page 9: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.20.3.7 获取指定 namespace 下的 Role 列表................................................................................................................... 7516.20.3.8 获取 Role 列表.............................................................................................................................................................7536.20.4 RoleBinding..................................................................................................................................................................... 7596.20.4.1 创建 RoleBinding........................................................................................................................................................7596.20.4.2 更新指定的 RoleBinding...........................................................................................................................................7686.20.4.3 替换指定的 RoleBinding...........................................................................................................................................7696.20.4.4 删除指定的 RoleBinding...........................................................................................................................................7716.20.4.5 批量删除 RoleBinding............................................................................................................................................... 7736.20.4.6 获取指定的 RoleBinding...........................................................................................................................................7766.20.4.7 获取指定 namespace 下 RoleBinding 列表........................................................................................................ 7776.20.4.8 获取 RoleBinding 列表.............................................................................................................................................. 7806.21 API groups.......................................................................................................................................................................... 7866.21.1 列出 APIVersions............................................................................................................................................................7866.21.2 列出 APIGroups.............................................................................................................................................................. 7886.21.3 listing APIResources of GroupVersion apiregistration.k8s.io/v1beta1........................................................ 7946.21.4 listing APIResources of GroupVersion extensions/v1beta1............................................................................ 7966.21.5 listing APIResources of GroupVersion apps/v1beta1........................................................................................8016.21.6 listing APIResources of GroupVersion authentication.k8s.io/v1................................................................... 8046.21.7 listing APIResources of GroupVersion authentication.k8s.io/v1beta1........................................................ 8076.21.8 listing APIResources of GroupVersion authorization.k8s.io/v1..................................................................... 8096.21.9 listing APIResources of GroupVersion authorization.k8s.io/v1beta1.......................................................... 8116.21.10 listing APIResources of GroupVersion autoscaling/v1................................................................................... 8136.21.11 listing APIResources of GroupVersion batch/v1...............................................................................................8166.21.12 listing APIResources of GroupVersion certificates.k8s.io/v1beta1............................................................. 8186.21.13 listing APIResources of GroupVersion networking.k8s.io/v1....................................................................... 8216.21.14 listing APIResources of GroupVersion policy/v1beta1................................................................................... 8236.21.15 listing APIResources of GroupVersion rbac.authorization.k8s.io/v1beta1.............................................. 8256.21.16 listing APIResources of GroupVersion storage.k8s.io/v1............................................................................... 8286.21.17 listing APIResources of GroupVersion storage.k8s.io/v1beta1....................................................................8306.21.18 listing APIResources of GroupVersion apiextensions.k8s.io/v1beta1........................................................8326.21.19 listing APIResources of GroupVersion v1........................................................................................................... 8356.22 Event..................................................................................................................................................................................... 8436.22.1 获取 Event........................................................................................................................................................................8446.22.2 列出指定的 Event...........................................................................................................................................................861

7 数据结构................................................................................................................................. 8667.1 请求数据结构........................................................................................................................................................................ 8667.2 响应数据结构........................................................................................................................................................................ 919

8 权限和授权项..........................................................................................................................954

9 附录......................................................................................................................................... 9599.1 PATCH 请求方法操作说明................................................................................................................................................. 9599.2 PATCH 请求方法操作示例................................................................................................................................................. 960

云容器引擎API 参考 目 录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 viii

Page 10: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

9.3 状态码..................................................................................................................................................................................... 9649.4 获取项目 ID........................................................................................................................................................................... 9669.5 获取账号 ID........................................................................................................................................................................... 9679.6 集群中使用 ELB 的操作方法............................................................................................................................................. 9689.7 如何获取接口 URI 中参数.................................................................................................................................................. 9709.8 API 授权项列表..................................................................................................................................................................... 9729.9 创建 VPC 和子网.................................................................................................................................................................. 9749.10 创建高速网络(可选).................................................................................................................................................... 9759.11 创建密钥对.......................................................................................................................................................................... 976

云容器引擎API 参考 目 录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 ix

Page 11: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

1 使用前必读

本文档提供了云容器引擎(Cloud Container Engine,简称CCE)API的描述、语法、参数说明及样例等内容。您可以根据表1-1查找您需要的内容。

表 1-1 文档导读

章节 说明

接口简介 了解CCE接口组成及接口列表。

环境准备 了解使用接口前的必须准备工作,包括创建VPC、获取请求证书等。

接口使用方法 了解REST API消息体组成、调用方法及示例。

API CCE提供的API接口,包含集群管理、存储管理、Secret等。

公共参数 包含CCE接口用到的公共参数、状态码、错误码等内容。

1.1 概述欢迎使用云容器引擎(Cloud Container Engine,简称CCE)。云容器引擎提供高度可扩展的、高性能的企业级Kubernetes集群,支持运行Docker容器。借助云容器引擎,您可以在华为云上轻松部署、管理和扩展容器化应用程序。

云容器引擎深度整合华为云高性能的计算(ECS/BMS)、网络(VPC/EIP/ELB)、存储(EVS/SFS)等服务,并支持GPU、ARM、FPGA等异构计算架构,支持多可用区(Available zone,简称AZ)、多区域(Region)容灾等技术构建高可用Kubernetes集群。

您可以使用本文档提供API对云容器引擎进行相关操作,如创建、删除、变更规格、添加网卡等。支持的全部操作请参见2 API概览。

在调用云容器引擎API之前,请确保已经充分了解云容器引擎相关概念,详细信息请参见产品介绍。

另外,云容器引擎所提供的接口分为CCE接口与Kubernetes原生接口。通过配合使用,您可以完整的使用云容器引擎的所有功能。Kubernetes相关概念请参见https://

云容器引擎API 参考 1 使用前必读

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 1

Page 12: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

kubernetes.io/docs/concepts/。Kubernetes原生接口版本级别的相关概念请参见https://kubernetes.io/docs/concepts/overview/kubernetes-api/。此外:

● 当前版本调用Kubernetes接口不支持HTTP长链接。

● 当前版本调用的Kubernetes接口包含Beta级别的接口,即版本名称包含了beta(例如: v1beta1)的接口。此类接口会根据Kubernetes原生接口的变化而变化,因此推荐在非重要的情况下使用,例如,短期测试集群等。

须知

使用kubectl或SDK等,非本指导书中提供的方法调用接口,不能保证调用后接口功能正常,因此请按照本指导书中的方法调用接口。

1.2 调用说明云容器引擎提供了REST(Representational State Transfer)风格API,支持您通过HTTPS请求调用,调用方法请参见3 如何调用API。

1.3 终端节点终端节点即调用API的请求地址,不同服务不同区域的终端节点不同,您可以从地区和终端节点中查询服务的终端节点。

云容器引擎的终端节点如下表所示,请您根据业务需要选择对应区域的终端节点。

表 1-2 云容器引擎的终端节点

区域名称 区域 终端节点

华北-北京四

cn-north-4 cce.cn-north-4.myhuaweicloud.com

华北-北京一

cn-north-1 cce.cn-north-1.myhuaweicloud.com

华东-上海二

cn-east-2 cce.cn-east-2.myhuaweicloud.com

华南-广州 cn-south-1 cce.cn-south-1.myhuaweicloud.com

南非-约翰内斯堡

af-south-1 cce.af-south-1.myhuaweicloud.com

西南-贵阳一

cn-southwest-2

cce.cn-southwest-2.myhuaweicloud.com

亚太-曼谷 ap-southeast-2

cce.ap-southeast-2.myhuaweicloud.com

亚太-香港 ap-southeast-1

cce.ap-southeast-1.myhuaweicloud.com

云容器引擎API 参考 1 使用前必读

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 2

Page 13: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

区域名称 区域 终端节点

亚太-新加坡

ap-southeast-3

cce.ap-southeast-3.myhuaweicloud.com

1.4 约束限制● 云容器引擎对单个用户的资源数量和容量限定了配额,默认情况下,您 多可以

创建5个集群(每个Region下),每个集群中 多可以添加 50 个节点。如果您需要创建更多的集群或添加更多的节点,请提交工单申请。配额的详细信息请参见关于配额。

● 更详细的限制请参见具体API的说明。

1.5 基本概念● 账号

用户注册华为云时的账号,账号对其所拥有的资源及云服务具有完全的访问权限,可以重置用户密码、分配用户权限等。由于账号是付费主体,为了确保账号安全,建议您不要直接使用账号进行日常管理工作,而是创建用户并使用他们进行日常管理工作。

● 用户

由账号在IAM中创建的用户,是云服务的使用人员,具有身份凭证(密码和访问密钥)。

在我的凭证下,您可以查看账号ID和用户ID。通常在调用API的鉴权过程中,您需要用到账号、用户和密码等信息。

● 区域(Region)

从地理位置和网络时延维度划分,同一个Region内共享弹性计算、块存储、对象存储、VPC网络、弹性公网IP、镜像等公共服务。Region分为通用Region和专属Region,通用Region指面向公共租户提供通用云服务的Region;专属Region指只承载同一类业务或只面向特定租户提供业务服务的专用Region。

● 可用区(AZ,Availability Zone)

一个AZ是一个或多个物理数据中心的集合,有独立的风火水电,AZ内逻辑上再将计算、网络、存储等资源划分成多个集群。一个Region中的多个AZ间通过高速光纤相连,以满足用户跨AZ构建高可用性系统的需求。

● 项目

华为云的区域默认对应一个项目,这个项目由系统预置,用来隔离物理区域间的资源(计算资源、存储资源和网络资源),以默认项目为单位进行授权,用户可以访问您账号中该区域的所有资源。如果您希望进行更加精细的权限控制,可以在区域默认的项目中创建子项目,并在子项目中购买资源,然后以子项目为单位进行授权,使得用户仅能访问特定子项目中资源,使得资源的权限控制更加精确。

云容器引擎API 参考 1 使用前必读

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 3

Page 14: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

图 1-1 项目隔离模型

云容器引擎API 参考 1 使用前必读

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 4

Page 15: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

2 API 概览

云容器引擎所提供的接口分为CCE接口与Kubernetes原生接口。通过配合使用CCE接口和Kubernetes原生接口,您可以完整的使用云容器引擎的所有功能,包括创建集群和节点,使用Kubernetes接口创建容器工作负载,使用CCE接口监控工作负载的使用数据等。

类型 子类型 说明

CCE接口 集群管理 集群和节点管理接口,包括创建、删除集群和节点的接口等。

通过这些接口,您可以创建集群、为集群添加节点、获取已创建集群和节点的信息。

须知在创建、删除、扩容和缩容集群的操作中,请不要在统一身份认证服务(IAM)中执行权限变更或修改的操作,可能会导致创建、删除、扩容和缩容集群执行失败。

存储管理 存储管理接口,包括PersistentVolumeClaim、PersistentVolume的创建、删除。

插件管理 插件管理接口,包括AddonTemplates的查询,AddonInstance的创建、更新、删除和获取。

Kubernetes原生接口

Secret Secret对象管理接口,包括Sercret对象的创建,查询,修改,删除等接口。

ReplicationController

ReplicationController对象管理接口,包括ReplicationController对象的创建,查询,修改,删除等接口。

Service Service对象管理接口,包括Service对象的创建,查询,修改,删除等接口。

Pod Pod对象管理接口,包括Pod对象的创建,查询,修改,删除等接口。

Namespace Namespace对象管理接口,包括Namespace对象的创建,查询,修改,删除等接口。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 5

Page 16: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

类型 子类型 说明

Endpoints Endpoint对象管理接口,包括Endpoint对象的创建,查询,修改,删除等接口。

PersistentVolumeClaim

PersistentVolumeClaim对象管理接口,包括PersistentVolumeClaim对象的创建,查询,修改,删除等接口。

PersistentVolume

PersistentVolume对象管理接口,包括PersistentVolume对象的创建,查询,修改,删除等接口。

Deployment Deployment对象管理接口,包括Deployment对象的创建,查询,修改,删除等接口。

Daemonset Daemonset对象管理接口,包括Daemonset对象的创建,查询,修改,删除等接口。

Statefulset Statefulset对象管理接口,包括Statefulset对象的创建,查询,修改,删除等接口。

Job Job对象管理接口,包括Job对象的创建,查询,修改,删除等接口。

CronJob CronJob对象管理接口,包括CronJob对象的创建,查询,修改,删除等接口。

ConfigMap ConfigMap对象管理接口,包括ConfigMap对象的创建,查询,修改,删除等接口。

Node Node对象管理接口,包括Node对象的获取,查询和更新。

说明CCE仅支持使用5.1 集群管理中的接口创建、删除节点,不能使用Kubernetes原生接口来创建、删除节点。

Replicset Replicset对象的查询。

Event Event对象管理的查询。

API groups API group对象管理接口,包括列出API group和APIVersion。

Ingress Ingress对象管理接口,包括Ingress对象的创建,更新,删除等接口。

NetworkPolicy NetworkPolicy对象管理接口,包括NetworkPolicy对象的创建,更新,删除等接口。

RBAC 通过权限设置可以让不同的用户或用户组拥有操作不同Kubernetes资源的权限。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 6

Page 17: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

说明

当前版本调用Kubernetes接口不支持HTTP长链接。

集群管理

表 2-1 集群管理

API 说明

创建集群 创建一个空集群(即只有控制节点Master,没有工作节点Node)。

获取指定的集群 获取指定集群的详细信息。

获取指定项目下的集群 获取指定项目下所有集群的详细信息。

更新指定的集群 更新指定的集群。

删除集群 删除一个指定的集群。

获取集群证书 获取指定集群的证书信息。

创建节点 在指定集群下创建节点。

获取指定的节点 通过节点ID获取指定节点的详细信息。

获取集群下所有节点 通过集群ID获取指定集群下所有节点的详细信息。

更新指定的节点 更新指定的节点。

删除节点 删除指定的节点。

查询作业进度 查询作业进度,通过某一作业请求下发后返回的jobID来查询指定作业的进度。

获取集群下所有节点池 获取集群下所有节点池。

存储管理

表 2-2 存储管理

API 说明

创建PersistentVolumeClaim 在指定的Namespace下通过华为云存储服务中的云存储(EVS、SFS、OBS)去创建PersistentVolumeClaim。

删除PersistentVolumeClaim 删除指定Namespace下的PersistentVolumeClaim对象,并可以选择保留后端的云存储。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 7

Page 18: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

API 说明

创建PersistentVolume 通过指定华为云存储服务中的云存储(如EVS、SFS、OBS)去创建PersistentVolume。

删除PersistentVolume 删除指定Namespace下的PersistentVolume对象,并可以选择是否保留后端云存储。

插件管理

表 2-3 插件管理

API 说明

查询AddonTemplates信息 插件模板查询接口,查询插件信息。

创建AddonInstance 根据提供的插件模板,安装插件实例。

更新AddonInstance 更新插件实例的功能。

删除AddonInstance 删除插件实例的功能。

获取AddonInstance详情 获取插件实例详情。

获取AddonInstance列表 获取集群所有已安装插件实例。

Secret

表 2-4 Secret

API 说明

创建Secret 创建Secret资源类型。

删除Secret 删除指定Namespace下的Secret对象。

删除所有的Secret 批量删除Secret。

获取Secret信息 获取指定Secret的详细信息。

替换指定的Secret 替换指定Namespace下的Secret对象。

列出指定Namespace下的Secret 在指定的Namespace下列出Secret对象。

列出集群下的Secret 列出集群中的所有Secret对象。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 8

Page 19: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

ReplicationController

表 2-5 ReplicationController

API 说明

创建ReplicationController 创建ReplicationController资源类型。

删除ReplicationController 删除一个ReplicationController对象。

删除所有的ReplicationController 批量删除ReplicationController。

获取指定Namespace下的ReplicationController

获取指定Namespace下的ReplicationController对象。

替换指定Namespace下的ReplicationController

替换指定Namespace下的ReplicationController对象。

替换指定Namespace下的ReplicationController状态

替换指定Namespace下的某个ReplicationController对象的状态,即修改ReplicationController对象status各字段的值。

列出指定Namespace下的ReplicationController

列出指定Namespace下的所有ReplicationController。

列出ReplicationController 获取ReplicationController列表。

更新指定的ReplicationController 更新指定Namespace下的ReplicationController对象。

Service

表 2-6 Service

API 说明

创建Service 创建一个Service对象。

删除Service 删除一个Service对象。

获取指定的Service 获取指定的Service对象。

替换指定的Service 替换指定的Service对象。

列出指定Namespace下的Service 列出指定Namespace下的Service对象。

列出Service 获取集群中的Service列表。

更新指定的Service 替换指定的Service对象。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 9

Page 20: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

Pod

表 2-7 Pod

API 说明

创建Pod 在指定Namespace下创建一个Pod对象。

删除Pod 删除指定Namespace下的某个Pod对象。

删除所有的Pod 删除所有Pod对象。

获取指定的Pod 获取指定Namespace下指定Pod的详细信息。

替换指定的Pod 替换指定Namespace下的一个Pod对象。

替换指定的Pod的状态 替换指定Namespace下的一个Pod对象的status,即修改Pod对象status各字段的值。

列出指定Namespaces下的所有Pod 列出指定Namespaces下面的所有Pod资源对象。

列出Pod 获取一个Pod列表。

更新指定的Pod 更新指定Namespace下一个Pod对象。

Namespace

表 2-8 Namespace

API 说明

创建Namespace 创建一个Namespace。

删除Namespace 删除一个Namespace。

获取指定的Namespace 获取指定的Namespace的详细信息。

替换指定的Namespace 替换指定的Namespace的部分信息。

替换指定的Namespace的状态 更新指定Namespace的状态信息,即修改namespace对象status各字段的值。

替换指定的Namespace的Finalize值 替换指定Namespce的finalize的值。

列出Namespace 获取集群中所有Namespace的详细信息。

更新指定的Namespace 更新指定Namespace部分信息。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 10

Page 21: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

Endpoints

表 2-9 Endpoints

API 说明

创建Endpoints 创建一个Endpoints资源对象。

删除Endpoints 删除一个Endpoints资源对象。

删除所有的Endpoints 删除所有Endpoints资源对象。

获取指定的Endpoints 获取某个Namespace下指定的Endpoints对象。

替换指定的Endpoints 替换指定Namespace下指定的Endpoints资源对象。

列出Endpoints 列出所有的Endpoints资源对象。

列出指定Namespace下的Endpoints 获取指定Namespace下的所有Endpoints对象。

更新指定的Endpoints 更新指定Namespace下的Endpoints对象。

PersistentVolumeClaim

表 2-10 PersistentVolumeClaim

API 说明

创建PersistentVolumeClaim 在指定的Namespace下创建PersistentVolumeClaim。

删除指定的PersistentVolumeClaim 删除指定Namespace下的PersistentVolumeClaim对象。

删除所有的PersistentVolumeClaim 删除所有的PersistentVolumeClaim资源对象。

获取指定的PersistentVolumeClaim 获取指定Namespace下的PersistentVolumeClaim对象。

替换指定的PersistentVolumeClaim 替换指定Namespace下的PersistentVolumeClaim对象。

替换指定的PersistentVolumeClaim的状态

替换指定的Namespace下指定的PersistentVolumeClaim对象的状态。

列出指定的Namespace下的PersistentVolumeClaim

列出指定Namespace下的所有PersistentVolumeClaim资源对象。

列出所有的PersistentVolumeClaim 列出所有PersistentVolumeClaim资源对象。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 11

Page 22: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

API 说明

更新指定的PersistentVolumeClaim 更新PersistentVolumeClaim对象。

PersistentVolume

表 2-11 PersistentVolume

API 说明

创建PersistentVolume 创建一个PersistentVolume。

删除指定的PersistentVolume 删除指定的PersistentVolume对象。

删除所有的PersistentVolume 删除所有的PersistentVolume对象。

获取指定的PersistentVolume 获取指定的PersistentVolume对象。

替换指定的PersistentVolume 替换指定的PersistentVolume对象。

替换指定的PersistentVolume的状态 替换指定的PersistentVolume对象的状态。

列出所有的PersistentVolume 列出所有PersistentVolume资源对象。

更新指定的PersistentVolume 更新PersistentVolume对象。

Deployment

表 2-12 Deployment

API 说明

创建Deployment 创建一个Deployment资源对象。

创建Deployment的回滚操作 创建一个Deployment资源对象的回滚操作。

删除Deployment 删除一个Deployment资源对象。

删除所有的Deployment 删除所有的Deployment资源对象。

获取指定的Deployment 获取某个Namespace下指定的Deployment对象。

获取指定的Deployment的状态 获取某个Namespace下指定的Deployment对象的状态。

获取指定的Deployment的伸缩操作 获取指定的Deployment的伸缩操作。

替换指定的Deployment 替换指定的Deployment对象。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 12

Page 23: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

API 说明

替换指定的Deployment的状态 替换指定命名空间下指定Deployment的状态,即修改Deployment的status字段的值。

替换指定的Deployment的伸缩操作 替换指定的Deployment的伸缩操作。

列出指定Namespace下的Deployment 列出指定命名空间下的所有Deployment资源对象。

列出指定的Deployment 列出指定的Deployment资源对象。

更新指定的Deployment 更新指定Namespace下的Deployment对象。

更新指定的Deployment的状态 更新指定Namespace下指定Deployment对象的状态。

更新指定的Deployment的伸缩操作 更新指定的Deployment的伸缩操作。

创建 DaemonSet

表 2-13 创建 DaemonSet

API 说明

创建DaemonSet 创建一个DaemonSet资源对象。

删除DaemonSet 删除一个DaemonSet资源对象。

删除所有的Daemonset 删除所有DaemonSet资源对象。

获取指定的DaemonSet 读取指定Namespace下的DaemonSet对象。

获取指定的DaemonSet的状态 读取指定Namespace下指定DaemonSet对象的状态。

更新指定的DaemonSet 更新指定Namespace下的DaemonSet对象。

更新指定的DaemonSet的状态 更新指定Namespace下指定DaemonSet对象的状态。

列出指定的DaemonSet 列出所有DemonSet资源对象。

列出指定Namespace下的DaemonSet 列出指定Namespace下的所有DaemonSet资源对象。

替换指定的DaemonSet 替换指定Namespace下的DaemonSet对象。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 13

Page 24: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

API 说明

替换指定的DaemonSet的状态 替换指定Namespace下指定DaemonSet对象的状态,即修改DaemonSet对象的status字段的值。

StatefulSet

表 2-14 StatefulSet

API 说明

创建StatefulSet 创建一个StatefulSet资源对象。

删除StatefulSet 删除一个StatefulSet资源对象。

删除所有的StatefulSet 删除所有的StatefulSet资源对象。

获取指定的StatefulSet 获取指定Namespace下的StatefulSet对象。

获取指定的StatefulSet的状态 获取指定Namespace下指定StatefulSet对象的状态。

替换指定的StatefulSet 替换指定Namespace下的StatefulSet对象。

替换指定的StatefulSet的状态 替换指定Namespace下指定StatefulSet对象的状态,即修改StatefulSet对象的status字段的值。

列出指定Namespace下的StatefulSet 列出指定Namespace下的所有StatefulSet资源对象。

列出指定的StatefulSet 列出所有的StatefulSet资源对象。

更新指定的StatefulSet 更新指定Namespace下的StatefulSet对象。

更新指定的StatefulSet的状态 更新指定Namespace下指定StatefulSet对象的状态。

Job

表 2-15 Job

API 说明

创建Job 创建Job资源对象。

删除Job 删除Job资源对象。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 14

Page 25: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

API 说明

删除所有的Job 删除所有的Job资源对象。

获取指定的Job 获取指定的Job资源对象。

获取指定的Job的状态 获取指定Job的状态信息。

替换指定的Job 替换指定Job。

替换指定的Job的状态 替换指定Job的状态。

列出指定Namespace下的Job 列出指定Namespace下的所有Jod资源对象。

列出所有Job 用于获取Job列表。

更新指定的Job的状态 更新指定Namespace下指定Job的状态。

更新指定的Job 更新指定的Job。

CronJob

表 2-16 CronJob

API 说明

创建CronJob 创建CronJob资源对象。

删除CronJob 删除CronJob资源对象。

删除所有的CronJob 删除所有CronJob资源对象。

获取指定的CronJob 获取指定的CronJob资源对象。

获取指定的CronJob的状态 获取指定的CronJob的状态。

替换指定的CronJob 替换指定的CronJob资源对象。

替换指定的CronJob的状态 替换指定CronJob的状态。

列出指定Namespace下的CronJob 列出指定Namespace下的所有CronJod资源对象。

列出所有的CronJob 列出所有的CronJob资源对象。

更新指定的CronJob的状态 更新指定Namespace下指定CronJob的状态。

更新指定的CronJob 更新指定的CronJob资源对象。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 15

Page 26: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

ConfigMap

表 2-17 ConfigMap

API 说明

创建ConfigMap 创建ConfigMap资源对象。

删除ConfigMap 删除ConfigMap资源对象。

删除所有的ConfigMap 删除所有ConfigMap资源对象。

获取指定的ConfigMap 获取指定的ConfigMap资源对象。

替换指定ConfigMap 替换指定的ConfigMap资源对象。

列出指定Namespace下的ConfigMap 列出指定Namespace下的所有ConfigMap资源对象。

列出指定的ConfigMap 获取ConfigMap列表。

更新指定的ConfigMap 更新指定的ConfigMap资源对象。

Node

表 2-18 Node

API 说明

获取指定的Node 获取指定的Node。

列出指定的Node 获取指定的Node列表。

更新指定的Node 更新指定的Node。

ReplicSet

表 2-19 ReplicSet

API 说明

列出指定的ReplicaSet 列出指定Namespace下的所有ReplicaSet资源对象。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 16

Page 27: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

Event

表 2-20 Event

API 说明

列出指定的Event 列出指定Namespace下的所有Event资源对象。

API groups

表 2-21 API groups

API 说明

列出APIVersions 列出APIVersions。

列出APIGroups 列出 APIGroups。

listing APIResources of GroupVersionapiregistration.k8s.io/v1beta1

列出 APIGroups。

listing APIResources of GroupVersionextensions/v1beta1

列出 APIGroups。

listing APIResources of GroupVersionapps/v1beta1

列出APIResources of Group Version"apps/v1beta1"。

listing APIResources of GroupVersionauthentication.k8s.io/v1

列出APIResources of GroupVersion"authentication.kubernetes.io/v1"

listing APIResources of GroupVersionauthentication.k8s.io/v1beta1

列出APIResources of GroupVersion"authentication.k8s.io/v1beta1"。

listing APIResources of GroupVersionauthorization.k8s.io/v1

列出APIResources of GroupVersion"authorization.k8s.io/v1"。

listing APIResources of GroupVersionauthorization.k8s.io/v1beta1

列出APIResources of GroupVersion"authorization.k8s.io/v1beta1"。

listing APIResources of GroupVersionautoscaling/v1

列出APIResources of GroupVersion"autoscaling/v1"。

listing APIResources of GroupVersionbatch/v1

列出APIResources of GroupVersion"batch/v1"。

listing APIResources of GroupVersioncertificates.k8s.io/v1beta1

列出GroupVersion "certificates.k8s.io/v1beta1"。

listing APIResources of GroupVersionnetworking.k8s.io/v1

列出APIResources of GroupVersion"networking.k8s.io/v1"。

listing APIResources of GroupVersionpolicy/v1beta1

列出APIResources of GroupVersion"policy/v1beta1"。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 17

Page 28: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

API 说明

listing APIResources of GroupVersionrbac.authorization.k8s.io/v1beta1

列出APIResources of GroupVersion"rbac.authorization.k8s.io/v1beta1"。

listing APIResources of GroupVersionstorage.k8s.io/v1

列出APIResources of GroupVersion"storage.k8s.io/v1"。

listing APIResources of GroupVersionstorage.k8s.io/v1beta1

列出APIResources of GroupVersion"storage.k8s.io/v1beta1"。

listing APIResources of GroupVersionapiextensions.k8s.io/v1beta1

列出APIResources of GroupVersion"apiextensions.k8s.io/v1beta1"。

listing APIResources of GroupVersionv1

列出APIResources of GroupVersion"v1"。

Ingress

表 2-22 Ingress

API 说明

创建Ingress 创建一个Ingress。

更新指定的Ingress 对指定的Ingress进行局部更新。

替换指定的Ingress 替换指定的Ingress。

删除Ingress 删除Ingress。

删除所有的Ingress 删除所有的Ingress。

获取指定的Ingress 获取指定的Ingress。

列出指定Namespace下的Ingress 列出指定Namespace下的Ingress。

获取Ingress列表 获取Ingress列表。

获取指定Namespace下的某个Ingress对象的状态

获取指定Namespace下的某个Ingress对象的状态。

替换指定Namespace下的某个Ingress对象的状态

替换指定Namespace下的某个Ingress对象的状态。

更新指定Namespace下的某个Ingress对象的状态

更新指定Namespace下的某个Ingress对象的状态。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 18

Page 29: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

NetworkPolicy

表 2-23 NetworkPolicy

API 说明

创建networkpolicy 创建networkpolicy。

更新指定的networkpolicy 部分更新指定的NetworkPolicy。

替换指定的networkpolicy 替换指定的networkpolicy。

删除networkpolicy 删除networkpolicy。

批量删除networkpolicy 批量删除networkpolicy。

获取指定的networkpolicy 获取指定的networkpolicy。

列出指定namespace下的networkpolicy

列出指定namespace下的networkpolicy。

获取networkpolicy列表 获取networkpolicy列表。

RBAC

表 2-24 RBAC

API 说明

创建ClusterRole 创建ClusterRole。

更新指定的ClusterRole 部分更新指定的ClusterRole。

替换指定的ClusterRole 替换指定的ClusterRole。

删除指定的ClusterRole 删除指定的ClusterRole。

批量删除ClusterRole 批量删除ClusterRole。

获取指定的ClusterRole 获取指定的ClusterRole。

获取ClusterRole列表 获取ClusterRole列表。

创建ClusterRoleBinding 创建ClusterRoleBinding。

更新指定的ClusterRoleBinding 部分更新指定的ClusterRoleBinding。

替换指定的ClusterRoleBinding 替换指定的ClusterRoleBinding。

删除指定的ClusterRoleBinding 删除指定的ClusterRoleBinding。

批量删除ClusterRoleBinding 批量删除ClusterRoleBinding。

获取指定的ClusterRoleBinding 获取指定的ClusterRoleBinding。

获取ClusterRoleBinding列表 获取ClusterRoleBinding列表。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 19

Page 30: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

API 说明

创建Role 创建Role。

更新指定的Role 部分更新指定的Role。

替换指定的Role 替换指定的Role。

删除指定的Role 删除指定的Role。

批量删除Role 批量删除Role。

获取指定的Role 获取指定的Role。

获取指定namespace下的Role列表 列出指定namespace下的Role列表。

获取Role列表 获取Role列表。

创建RoleBinding 创建RoleBinding。

更新指定的RoleBinding 部分更新指定的RoleBinding。

替换指定的RoleBinding 替换指定的RoleBinding。

删除指定的RoleBinding 删除指定的RoleBinding。

批量删除RoleBinding 批量删除RoleBinding。

获取指定的RoleBinding 获取指定的RoleBinding。

获取指定namespace下RoleBinding列表

列出指定namespace下的RoleBinding列表。

获取RoleBinding列表 获取RoleBinding列表。

云容器引擎API 参考 2 API 概览

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 20

Page 31: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

3 如何调用 API

3.1 构造请求本节介绍如何构造REST API的请求,并以调用IAM服务的获取用户Token说明如何调用API,该API获取用户的Token,Token可以用于调用其他API时鉴权。

REST从资源的角度观察整个网络,分布在各处的资源由URI(Uniform ResourceIdentifier)确定,客户端的应用通过URL(Unified Resource Locator)获取资源。

● CCE接口(5.1 集群管理)的URL格式为:https://Endpoint/uri。其中uri为资源路径,也即API访问的路径。

● Kubernetes原生接口、5.2 存储管理、5.3 插件管理的URL格式为:https://{clusterid}.Endpoint/uri。其中{clusterid}为集群ID,uri为资源路径,也即API访问的路径。

表 3-1 URL 中的参数说明

参数 描述

{clusterid} 集群ID,创建集群后,调用5.1.3 获取指定项目下的集群接口获取。

Endpoint Web服务入口点的URL,可以从使用前必读中获取。

uri 资源路径,也即API访问路径。从具体接口的URI模块获取,例如“获取用户Token”API的resource-path为“v3/auth/tokens”。

请求 URI

请求URI由如下部分组成。

{URI-scheme} :// {Endpoint} / {resource-path} ? {query-string}

尽管请求URI包含在请求消息头中,但大多数语言或框架都要求您从请求消息中单独传递它,所以在此单独强调。

云容器引擎API 参考 3 如何调用 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 21

Page 32: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● URI-scheme:

表示用于传输请求的协议,当前所有API均采用HTTPS协议。

● Endpoint:指定承载REST服务端点的服务器域名或IP,不同服务不同区域的Endpoint不同,您可以从地区和终端节点获取。

例如IAM服务在“华北-北京一”区域的Endpoint为“iam.cn-north-1.myhuaweicloud.com”。

● resource-path:

资源路径,也即API访问路径。从具体API的URI模块获取,例如“获取用户Token”API的resource-path为“/v3/auth/tokens”。

● query-string:

查询参数,是可选部分,并不是每个API都有查询参数。查询参数前面需要带一个“?”,形式为“参数名=参数取值”,例如“limit=10”,表示查询不超过10条数据。

例如您需要获取IAM在“华北-北京一”区域的Token,则需使用“华北-北京一”区域的Endpoint(iam.cn-north-1.myhuaweicloud.com),并在获取用户Token的URI部分找到resource-path(/v3/auth/tokens),拼接起来如下所示。

https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens

图 3-1 URI 示意图

说明

为查看方便,在每个具体API的URI部分,只给出resource-path部分,并将请求方法写在一起。这是因为URI-scheme都是HTTPS,同一个服务的Endpoint在同一个区域也相同,所以简洁起见将这两部分省略。

请求方法

HTTP请求方法(也称为操作或动词),它告诉服务你正在请求什么类型的操作。

● GET:请求服务器返回指定资源。

● PUT:请求服务器更新指定资源。

● POST:请求服务器新增资源或执行特殊操作。

● DELETE:请求服务器删除指定资源,如删除对象等。

● HEAD:请求服务器资源头部。

● PATCH:请求服务器更新资源的部分内容。当资源不存在的时候,PATCH可能会去创建一个新的资源。

在获取用户Token的URI部分,您可以看到其请求方法为“POST”,则其请求为:

POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens

云容器引擎API 参考 3 如何调用 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 22

Page 33: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息头

附加请求头字段,如指定的URI和HTTP方法所要求的字段。例如定义消息体类型的请求头“Content-Type”,请求鉴权信息等。

如下公共消息头需要添加到请求中。

● Content-Type:消息体的类型(格式),必选,默认取值为“application/json”,有其他取值时会在具体接口中专门说明。

● X-Auth-Token:用户Token,可选,当使用Token方式认证时,必须填充该字段。用户Token也就是调用获取用户Token接口的响应值,该接口是唯一不需要认证的接口。

说明

公有云API同时支持使用AK/SK认证,AK/SK认证是使用SDK对请求进行签名,签名过程会自动往请求中添加Authorization(签名认证信息)和X-Sdk-Date(请求发送的时间)请求头。

AK/SK认证的详细说明请参见AK/SK认证。

对于获取用户Token接口,由于不需要认证,所以只添加“Content-Type”即可,添加消息头后的请求如下所示。

POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokensContent-Type: application/json

请求消息体

请求消息体通常以结构化格式发出,与请求消息头中Content-type对应,传递除请求消息头之外的内容。若请求消息体中参数支持中文,则中文字符必须为UTF-8编码。

每个接口的请求消息体内容不同,也并不是每个接口都需要有请求消息体(或者说消息体为空),GET、DELETE操作类型的接口就不需要消息体,消息体具体内容需要根据具体接口而定。

对于获取用户Token接口,您可以从接口的请求部分看到所需的请求参数及参数说明。将消息体加入后的请求如下所示,加粗的斜体字段需要根据实际值填写,其中username为用户名,domainname为用户所属的账号名称,********为用户的登录密码,xxxxxxxx为project的名称,如cn-north-1,您可以从地区和终端节点中获取。

说明

scope参数定义了Token的作用域,下面示例中获取的Token仅能访问project下的资源。您还可以设置Token作用域为某个账号下所有资源或账号的某个project下的资源,详细定义请参见获取用户Token。

POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokensContent-Type: application/json

{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "********", "domain": { "name": "domainname" }

云容器引擎API 参考 3 如何调用 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 23

Page 34: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} } }, "scope": { "project": { "name": "xxxxxxxxxxxxxxxxxx" } } }}

到这里为止这个请求需要的内容就具备齐全了,您可以使用curl、Postman或直接编写代码等方式发送请求调用API。对于获取用户Token接口,返回的响应消息头中“x-subject-token”就是需要获取的用户Token。有了Token之后,您就可以使用Token认证调用其他API。

3.2 认证鉴权调用接口有如下两种认证方式,您可以选择其中一种进行认证鉴权。

● Token认证:通过Token认证通用请求。

● AK/SK认证:通过AK(Access Key ID)/SK(Secret Access Key)加密调用请求。推荐使用AK/SK认证,其安全性比Token认证要高。

Token 认证

Token在计算机系统中代表令牌(临时)的意思,拥有Token就代表拥有某种权限。Token认证就是在调用API的时候将Token加到请求消息头,从而通过身份认证,获得操作API的权限。

说明

Token的有效期为24小时,需要使用同一个Token鉴权时,可以缓存起来,避免频繁调用。

在构造请求中以调用获取用户Token接口为例,说明了如何调用API。获取Token后,再调用其他接口时,您需要在请求消息头中添加“X-Auth-Token”,其值即为获取到的Token。例如Token值为“ABCDEFJ....”,则调用接口时将“X-Auth-Token:ABCDEFJ....”加到请求消息头即可,如下所示:

GET https://iam.cn-north-1.myhuaweicloud.com/v3/auth/projectsContent-Type: application/jsonX-Auth-Token: ABCDEFJ....

AK/SK 认证

AK/SK认证就是使用AK/SK对请求进行签名,在请求时将签名信息添加到消息头,从而通过身份认证。

● AK(Access Key ID):访问密钥ID。与私有访问密钥关联的唯一标识符;访问密钥ID和私有访问密钥一起使用,对请求进行加密签名。

● SK(Secret Access Key):与访问密钥ID结合使用的密钥,对请求进行加密签名,可标识发送方,并防止请求被修改。

使用AK/SK认证时,您可以基于签名算法使用AK/SK对请求进行签名,也可以使用专门的签名SDK对请求进行签名。详细的签名方法和SDK使用方法请参见API签名指南。

云容器引擎API 参考 3 如何调用 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 24

Page 35: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

须知

● 签名SDK只提供签名功能,与服务提供的SDK不同,使用时请注意。

● AK/SK签名认证方式仅支持消息体大小12MB以内,12MB以上的请求请使用Token认证。

3.3 返回结果

状态码

请求发送以后,您会收到响应,包含状态码、响应消息头和消息体。

状态码是一组从1xx到5xx的数字代码,状态码表示了请求响应的状态,完整的状态码列表请参见9.3 状态码。

对于获取用户Token接口,如果调用后返回状态码为“201”,则表示请求成功。

响应消息头

对应请求消息头,响应同样也有消息头,如“Content-type”。

对于获取用户Token接口,返回如图3-2所示的消息头,其中“x-subject-token”就是需要获取的用户Token。有了Token之后,您就可以使用Token认证调用其他API。

图 3-2 获取用户 Token 响应消息头

响应消息体

响应消息体通常以结构化格式返回,与响应消息头中Content-type对应,传递除响应消息头之外的内容。

对于获取用户Token接口,返回如下消息体。为篇幅起见,这里只展示部分内容。

云容器引擎API 参考 3 如何调用 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 25

Page 36: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "token": { "expires_at": "2019-02-13T06:52:13.855000Z", "methods": [ "password" ], "catalog": [ { "endpoints": [ { "region_id": "cn-north-1",......

当接口调用出错时,会返回错误码及错误信息说明,错误响应的Body体格式如下所示。

{ "error_msg": "The format of message is error", "error_code": "AS.0001"}

其中,error_code表示错误码 ,error_msg表示错误描述信息。

云容器引擎API 参考 3 如何调用 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 26

Page 37: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

4 快速入门

4.1 创建游戏工作负载本节通过调用一系列API使用2048镜像创建一个游戏工作负载为例,介绍使用CCE API的基本流程,创建出来的工作负载如下所示。

云容器引擎API 参考 4 快速入门

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 27

Page 38: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

图 4-1 使用 2048 镜像创建工作负载

创建2048工作负载的流程如下:

1. 首先调用Token认证获取用户的token,因为在后续的请求中需要将token放到请求消息头中作为认证。

2. 其次创建集群并获取集群UUID。

说明

如果您已经创建集群,可以跳过创建集群的步骤,直接使用获取已创建的集群UUID。

云容器引擎API 参考 4 快速入门

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 28

Page 39: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

a. 调用CCE的5.1.1 创建集群接口,创建一个集群。

b. 调用CCE的5.1.7 创建节点接口,为集群添加一个节点。

3. 调用kubernetes接口创建工作负载。

a. 调用6.5.1 创建Deployment接口,使用2048镜像创建工作负载。

b. 调用6.13.1 创建Service创建一个Service,Service创建后,用户就可以从外部访问这个工作负载。

前提条件● 已获取Token,具体请参见Token认证。

● 已创建VPC和子网,并获取VPC和子网的ID,具体请参见9.9 创建VPC和子网。

● 已创建密钥对,并获取密钥对的名称具体请参见9.11 创建密钥对。

● 已获取IAM和CCE的Endpoint,具体请参见地区和终端节点。

● 已经上传用于创建工作负载的2048镜像,具体方法请参考客户端上传镜像,并获取镜像地址。

创建集群

假设已获取前提条件中的信息为如下值(实际操作中您需要根据实际情况替换):

● IAM的Endpoint:下面示例中以iam_endpoint代替。

● CCE的Endpoint:下面示例中以cce_endpoint代替。

● VPC的ID:219ab8a0-1272-4049-a383-8ad0b770fa11● 子网的ID:d23ef2e9-8b90-49b3-bc4a-fd7d6bea6bec● 密钥对的名称:keypair-cce● 区域的名称:cn-north-1● 项目ID:下面示例中以project_id代替,获取方式请参见9.7 如何获取接口URI中

参数。

则可以通过如下步骤创建一个带有单个节点的集群。

1. 调用其他接口前,需要调用Token认证获取token,并设置成环境变量。

其中加粗的部分,需要替换为真实的数据。

– username:华为云的用户帐号。

– password:华为云的用户密码。

– domainname:若是子帐号,请填写对应的主帐号名称。若不是子帐号,请与username保持一致。

– cn-north-1:此处以中国华北区1为例。curl -H "Content-Type:application/json" https://{iam_endpoint}/v3/auth/tokens -X POST -d '{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "******", "domain": { "name": "domainname" }

云容器引擎API 参考 4 快速入门

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 29

Page 40: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} } }, "scope": { "project": { "name": "cn-north-1" } } } }' -v

响应Header中“X-Subject-Token”的值即为Token:X-Subject-Token:******

使用如下命令将token设置为环境变量,方便后续事项。

export Token={X-Subject-Token}X-Subject-Token即为上一步骤获取到的token。

2. 调用5.1.1 创建集群接口创建一个不带节点的空集群。curl -H "X-Auth-Token:$Token" -H "Content-Type:application/json;charset=utf-8" -X POST https://{cce_endpoint}/api/v3/projects/{project_id}/clusters -d '{ "kind": "Cluster", "apiVersion": "v3", "metadata": { "name": "cluster-sample" }, "spec": { "type": "VirtualMachine", "flavor": "cce.s1.small", "version": "v1.9.7-r0", "hostNetwork": { "vpc": "219ab8a0-1272-4049-a383-8ad0b770fa11", "subnet": "d23ef2e9-8b90-49b3-bc4a-fd7d6bea6bec" }, "containerNetwork": { "mode": "overlay_l2" } }}'

响应消息体中items数组中metadata.uid参数即为集群ID。"uid":"d8cbca81-889a-11e8-88e9-0255ac10212d"

为方便后续事项,使用如下命令将集群ID设置为环境变量,后续使用中{cluster_id}即为集群ID。export cluster_id=d8cbca81-889a-11e8-88e9-0255ac10212d

3. 集群创建成功后,调用5.1.7 创建节点接口为该集群创建一个节点。curl -H "X-Auth-Token:$Token" -H "Content-Type:application/json;charset=utf-8" -X POST https://{cce_endpoint}/api/v3/projects/{project_id}/clusters/{cluster_id}/nodes -d '{ "kind": "Node", "apiVersion": "v3", "metadata": { "name": "node-sample" }, "spec": { "flavor": "c3.large.2", "az": "cn-north-1a", "login": { "sshKey": "keypair-cce" }, "rootVolume": { "size": 40, "volumetype": "SATA" }, "dataVolumes": [ { "size": 100,

云容器引擎API 参考 4 快速入门

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 30

Page 41: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"volumetype": "SATA" } ], "publicIP": { "count": 1, "eip": { "iptype": "5_bgp", "bandwidth": { "chargemode": "traffic", "size": 10, "sharetype": "PER" } } }, "count": 1 }}'

创建工作负载

假设已获取前提条件中的信息为如下值(实际操作中您需要根据实际情况替换):

私有docker镜像地址:swr.cn-north-1.myhuaweicloud.com/full/2048-demo:v1.2(此地址为示例,获取方法请参见客户端上传镜像)。

则可以通过如下步骤创建一个工作负载。

1. 调用6.5.1 创建Deployment使用镜像创建2048工作负载。

创建一个Deployment,名称为deployment-test,且添加一个标签name:deployment-test。使用镜像为 swr.cn-north-1.myhuaweicloud.com/full/2048-demo:v1.2 (此地址为示例)。curl -X POST -H "Content-Type:application/json" -H "X-Cluster-ID:$UUID" -H "X-Auth-Token:$Token" -d '{ "apiVersion": "extensions/v1beta1", "kind": "Deployment", "metadata": { "labels": { "app": "deployment-test" }, "name": "deployment-test" }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "deployment-test" } }, "template": { "metadata": { "labels": { "app": "deployment-test" } }, "spec": { "containers": [ { "image": "swr.cn-north-1.myhuaweicloud.com/full/2048-demo:v1.2", "imagePullPolicy": "IfNotPresent", "name": "deployment-test" } ], "imagePullSecrets": [{ "name": "default-secret" }] } }

云容器引擎API 参考 4 快速入门

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 31

Page 42: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} }' https://{集群id}.{cce_endpoint}/apis/extensions/v1beta1/namespaces/default/deployments -k -v

2. 调用6.5.5 获取指定的Deployment获取某个Namespace下指定的Deployment对象查询Deployment是否创建成功。curl -X GET -H 'Content-Type:application/json;charset=utf-8' -H "X-Cluster-ID:$UUID" -H "X-Auth-Token:$Token" https://{集群id}.{cce_endpoint}/apis/extensions/v1beta1/namespaces/default/deployments/deployment-test -k -v

如果返回的响应显示availableReplicas的数量为1,则说明创建成功,即代表工作负载创建成功。 "status": { "observedGeneration ": 1, "replicas ": 1, "updatedReplicas ": 1, "availableReplicas": 1 }

您还可以从CCE控制台中查看工作负载是否创建成功,登录CCE控制台,单击左侧“工作负载”,即可看到“deployment-test”工作负载。

3. Deployment创建成功后,调用6.13.1 创建Service创建Service,我们可以通过Service访问到Deployment里面的Pod。

Service的名称为service-test,访问类型选择NodePort,访问协议为TCP。curl -X POST -H "Content-Type:application/json" -H "X-Cluster-UUID:$UUID" -H "X-Auth-Token:$Token" -d '{ "kind":"Service", "apiVersion":"v1", "metadata":{ "name":"service-test", "creationTimestamp":null, "labels":{ "app":"deployment-test" } }, "spec":{ "ports":[{ "name":"http", "nodePort":30023, "port":80, "protocol":"TCP", "targetPort":80 }], "selector":{ "app":"deployment-test" }, "type":"NodePort" } }' https://{集群id}.{cce_endpoint} /api/v1/namespaces/default/services -k -v

若返回状态码201,说明命令执行成功。

4. 调用6.13.3 获取指定的Service查询Service的状态,确定是否创建成功。curl -X GET -H 'Content-Type:application/json;charset=utf-8' -H "X-Cluster-ID:$UUID" -H "X-Auth-Token:$Token" https://{集群id}.{cce_endpoint} /api/v1/namespaces/default/services/service-test -k -v

响应如下,表示创建成功:{ "kind": "Service", "apiVersion": "v1", "metadata": { "name": "service-test", "namespace": "default", "selfLink": "/api/v1/namespaces/default/services/service-test", "uid": "cb932657-214a-11e8-b486-fa163ecd089c", "resourceVersion": "340196", "creationTimestamp": "2018-03-06T14:29:36Z", "labels": { "app": "deployment-test"

云容器引擎API 参考 4 快速入门

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 32

Page 43: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "enable": true }, "spec": { "ports": [{ "name": "http", "protocol": "TCP", "port": 80, "targetPort": 80, "nodePort": 30023 }], "selector": { "app": "deployment-test " }, "clusterIP": "10.247.90.130", "type": "NodePort", "sessionAffinity": "None", "externalTrafficPolicy": "Cluster" }, "status": { "loadBalancer": {} }}

您还可以从CCE控制台查看创建的服务,登录CCE控制台,单击左侧“工作负载”,单击deployment-test工作负载,进入工作负载详情,在“访问方式”页签中,可查看到访问地址,nodePort为30023。

若该访问节点绑定了弹性IP,可通过弹性IP地址:nodePort从外部访问工作负载。

云容器引擎API 参考 4 快速入门

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 33

Page 44: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

5 API

5.1 集群管理

5.1.1 创建集群

功能描述

该API用于创建一个空集群(即只有控制节点Master,没有工作节点Node)。请在调用本接口完成集群创建之后,通过5.1.7 创建节点添加节点。

说明

● 调用该接口创建集群时,默认不安装ICAgent。ICAgent是应用性能管理APM的采集代理,运行在应用所在的服务器上,用于实时采集探针所获取的数据,安装ICAgent是使用应用性能管理APM的前提。若需安装ICAgent,请参照安装ICAgent。

● 创建集群之前,要预先创建虚拟私有云VPC和子网,若已经创建可重复使用。

● 默认情况下,一个账户只能创建 5 个集群(每个Region下),如果您需要创建更多的集群,请提交工单申请增加配额。

URIPOST /api/v3/projects/{project_id}/clusters

表5-1描述该API的参数。

表 5-1 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 34

Page 45: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求参数如表5-2、表5-3所示。

表 5-2 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

表 5-3 请求 Body 参数说明

参数 是否必选

参数类型 描述

kind 是 String API类型,固定值“Cluster”,该值不可修改。

apiVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 是 metadataobject

集群的基本信息,为集合类的元素类型,包含一组由不同名称定义的属性。

spec 是 spec object spec是集合类的元素类型,您对需要管理的集群对象进行详细描述的主体部分都在spec中给出。CCE通过spec的描述来创建或更新对象。

表 5-4 metadata 字段数据结构说明

参数 是否必选

参数类型 描述

name 是 String 集群名称。

命名规则:以小写字母开头,由小写字母、数字、中划线(-)组成,长度范围4-128位,且不能以中划线(-)结尾。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 35

Page 46: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

labels 否 Object 集群标签,key/value对格式。

标签可用于选择对象并查找满足某些条件的对象集合。

示例:"labels": { "key" : "value"}

annotations 否 Object 集群注解,如标签一样,也是由key/value组成:"annotations": { "key1" : "value1", "key2" : "value2"}

说明Annotations不用于标识和选择对象。Annotations中的元数据可以是small 或large,structured 或unstructured,并且可以包括标签不允许使用的字符。

表 5-5 spec 字段数据结构说明

参数 是否必选

参数类型 描述

type 是 String 集群类型:

● VirtualMachine:混合集群混合集群基于Kubernetes来管理一组节点资源,支持虚拟机和裸金属的管理,Kubernetes将自动调度容器运行在可用节点上。在创建容器工作负载前,您需要存在一个可用集群。

● BareMetal:裸金属集群裸金属私有集群基于裸金属服务提供高计算和高网络性能的kubernetes容器集群,如需使用,请创建裸金属服务器。裸金属集群为保证高速的容器网络性能,要求您在创建裸金属服务器时,添加一块高速网卡。添加步骤请参见管理高速网络。

● ARM64:鲲鹏集群鲲鹏容器集群(ARM指令集)提供了容器在鲲鹏(ARM架构)服务器上的运行能力,提供与X86服务器相同的调度伸缩和快速部署能力。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 36

Page 47: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

flavor 是 String 集群规格,集群创建完成后规格不可再变更,请按实际业务需求进行选择。

● cce.s1.small: 小规模单控制节点混合集群( 大50节点)

● cce.s1.medium: 中等规模单控制节点混合集群( 大200节点)

● cce.s1.large: 大规模单控制节点混合集群( 大1000节点)

● cce.t1.small: 小规模单控制节点裸金属集群( 大10节点)

● cce.t1.medium: 中等规模单控制节点裸金属集群( 大100节点)

● cce.t1.large: 大规模单控制节点裸金属集群( 大500节点)

● cce.s2.small: 小规模高可用混合集群( 大50节点)

● cce.s2.medium: 中等规模高可用混合集群( 大200节点)

● cce.s2.large: 大规模高可用混合集群( 大1000节点)

● cce.t2.small: 小规模高可用裸金属集群( 大10节点)

● cce.t2.medium: 中等规模高可用裸金属集群( 大100节点)

● cce.t2.large: 大规模高可用裸金属集群( 大500节点)

说明

● s1:单控制节点混合集群。

● s2:高可用混合集群。

● t1:单控制节点裸金属集群。

● t2:高可用裸金属集群。

● dec:专属混合集群规格。如cce.dec.s1.small为小规模单控制节点专属混合集群( 大50节点)。

● 大节点数:当前集群支持管理的 大节点规模,请根据业务需求选择。

● 单控制节点集群:普通集群是单控制节点,控制节点故障后,集群将不可用,但已运行工作负载不受影响。

● 高可用集群:高可用集群是多控制节点,单控制节点故障,集群仍然可用。查看集群模式请参见如何排查已创建的集群是否为高可用集群?

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 37

Page 48: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

version 否 String 集群版本,与Kubernetes社区基线版本保持一致,建议选择 新版本。

● 在CCE控制台中支持创建两种 新版本的集群。可登录CCE控制台,单击“总览 > 购买Kubernetes集群”,在“版本”处获取到集群版本。

● 其它集群版本,当前仍可通过api创建,但后续会逐渐下线,具体下线策略请关注CCE官方公告。

说明若不配置,默认创建 新版本的集群。

description 否 String 集群描述,对于集群使用目的的描述,可根据实际情况自定义,默认为空。集群创建成功后可通过接口更新指定的集群来做出修改,也可在CCE控制台中对应集群的“集群详情”下的“描述”处进行修改。

hostNetwok 是 hostNetwork object

节点网络参数,包含了虚拟私有云VPC和子网的ID信息,而VPC是集群内节点之间的通信依赖,所以是必选的参数集。

containerNetwork

是 containerNetwork object

容器网络参数,包含了容器网络类型和容器网段的信息。

authentication

否 authentication object

集群认证方式相关配置。

kubernetesSvcIpRange

否 String 服务网段参数,kubernetes clusterIp取值范围,1.11.7版本及以上支持。

billingMode 否 Integer 集群的计费方式,当前接口只支持创建“按需计费”的集群。

计费方式为“按需计费”时,取值为“0”。若不填,则默认为“0”。

extendParam 否 extendParam object

扩展字段,key/value对格式。

可配置多可用区集群、专属混合集群,以及将集群创建在特定的企业项目下,字段说明请参见表5-9。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 38

Page 49: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-6 hostNetwork 字段数据结构说明

参数 是否必选

参数类型 描述

vpc 是 String 用于创建控制节点的VPC的ID。该值在9.9 创建VPC和子网中获取。

获取方法如下:

● 方法1:登录虚拟私有云服务的控制台界面,在虚拟私有云的详情页面查找VPC ID。

● 方法2:通过虚拟私有云服务的API接口查询,具体操作可参考查询VPC列表

subnet 是 String 子网的Network ID。获取方法如下:

● 方法1:登录虚拟私有云服务的控制台界面,单击VPC下的子网,进入子网详情页面,查找网络ID。

● 方法2:通过虚拟私有云服务的API接口查询,具体操作可参考查询子网列表。

highwaySubnet

否 String 用于创建裸金属节点的高速网络的子网ID。该值在9.10 创建高速网络(可选)中获取。创建裸金属集群时该参数为必选参数。

表 5-7 authentication 字段数据结构说明

参数 是否必选

参数类型 描述

mode 否 String 集群认证模式。

● kubernetes 1.11及之前版本的集群支持“x509”、“rbac”和“authenticating_proxy”,默认取值为“x509”。

● kubernetes 1.13及以上版本的集群支持“rbac”和“authenticating_proxy”,默认取值为“rbac”。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 39

Page 50: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-8 containerNetwork 字段数据结构说明

参数 是否必选

参数类型 描述

mode 是 String 容器网络类型(只可选择其一)

● overlay_l2:容器隧道网络,通过OVS(OpenVSwitch)为容器构建的overlay_l2网络。

● underlay_ipvlan:裸金属服务器使用ipvlan构建的Underlay的l2网络。

● vpc-router:VPC网络,使用ipvlan和自定义VPC路由为容器构建的Underlay的l2网络。

● eni:Yangtse,深度整合VPC原生ENI弹性网卡能力,采用VPC网段分配容器地址,支持ELB直通容器,享有高性能。

cidr 否 String 容器网络网段,建议使用网段10.0.0.0/12~19,172.16.0.0/16~19,192.168.0.0/16~19,如存在网段冲突,将自动重新选择。

当节点 大实例数为默认值110时,当前容器网段至少支持582个节点,此参数在集群创建后不可更改,请谨慎选择。

表 5-9 extendParam 字段数据结构说明

参数 参数类型 描述

clusterAZ String 集群控制节点可用区配置。

● multi_az:多可用区,可选。仅使用高可用集群时才可以配置多可用区。

● 专属云计算池可用区:用于指定专属云可用区部署集群控制节点。如果需配置专属混合集群,该字段为必选。例如“华北四-可用区一”取值为:cn-north-4a。更多信息请参见什么是专属计算集群?

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 40

Page 51: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

dssMasterVolumes

String 用于指定控制节点的系统盘和数据盘使用专属分布式存储,未指定或者值为空时,默认使用EVS云硬盘。

如果配置专属混合集群,该字段为必选,请按照如下格式设置:

<rootVol.dssPoolID>.<rootVol.volType>;<dataVol.dssPoolID>.<dataVol.volType>字段说明:rootVol为系统盘;dataVol为数据盘;dssPoolID为专属分布式存储池ID;volType为专属分布式存储池的存储类型,如SAS、SSD。获取方法请参见获取单个专属分布式存储池详情中“表3 响应参数”的字段说明。

样例:c950ee97-587c-4f24-8a74-3367e3da570f.sas;6edbc2f4-1507-44f8-ac0d-eed1d2608d38.ssd非专属混合集群不支持配置该字段。

enterpriseProjectId

String 如果需要将集群创建在特定的企业项目下,请设置{"enterpriseProjectId":"xxx"}的key/value对。

说明

● 需要开通企业项目功能后才可配置企业项目,具体请参见如何进入企业管理页面 。

● 集群所属的企业项目与集群下所关联的其他云服务资源所属的企业项目必须保持一致。

kubeProxyMode String 服务转发模式,支持以下两种实现:

● iptables:社区传统的kube-proxy模式,完全以iptables规则的方式来实现service负载均衡。该方式 主要的问题是在服务多的时候产生太多的iptables规则,非增量式更新会引入一定的时延,大规模情况下有明显的性能问题。

● ipvs:主导开发并在社区获得广泛支持的kube-proxy模式,采用增量式更新,吞吐更高,速度更快,并可以保证service更新期间连接保持不断开,适用于大规模场景。

请求示例:

● 创建混合集群:{ "kind": "Cluster", "apiVersion": "v3", "metadata": { "name": "mycluster",

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 41

Page 52: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"labels": { "foo": "bar" }, "annotations": { "foo2": "bar2" } }, "spec": { "type": "VirtualMachine", "flavor": "cce.s1.small", "version": "v1.7.3-r13", "description": "this is a demo cluster", "hostNetwork": { "vpc": "0d1e5edf-5f58-4394-bb07-5c0dd4f3a0d5", "subnet": "a235a126-1cde-4766-b67d-a2bb3123c5ef" }, "containerNetwork": { "mode": "overlay_l2", "cidr": "172.16.0.0/16" }, "billingMode": 0, "extendParam": { "foo": "bar" } }}

● 创建裸金属集群:{ "kind":"Cluster", "apiVersion":"v3", "metadata":{ "name":"mycluster-baremetal", "labels":{ "foo":"bar" }, "annotations":{ "foo2":"bar2" } }, "spec":{ "type":"BareMetal", "flavor":"cce.t1.small", "version":"v1.7.3-r13", "description":"this is a demo cluster", "hostNetwork":{ "vpc":"09f9ee41-6a1e-475b-977b-a16adf0b14c5", "subnet":"2ca132cd-cddf-4c01-9abc-373610c8d5f6", "highwaySubnet":"a95d96e3-1f13-442a-8f06-f9cb4211eaa4" }, "containerNetwork":{ "mode":"underlay_ipvlan", "cidr":"10.1.0.0/16" }, "billingMode":0, "extendParam":{ "foo":"bar" } }}

响应消息

响应参数:

响应参数如表5-10所示。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 42

Page 53: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-10 响应参数

参数 参数类型 描述

kind String API类型,固定值“Cluster”,该值不可修改。

apiVersion String API版本,固定值“v3”,该值不可修改。

metadata metadataobject

集群对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

spec spec object 集合类的元素类型,用户对需要管理的集群对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

status status object 集合类的元素类型,用于记录对象在系统中的当前状态信息,包含了集群状态和本次创建集群作业的jobID

表 5-11 metadata 字段数据结构说明

参数 参数类型 描述

name String 集群名称

uid String 集群ID

creationTimestamp

String 集群创建时间

updateTimestamp String 集群更新时间

labels Object 集群标签,key/value对格式,对应请求体中metadata.labels下参数的值

annotations Object 集群注解,key/value对格式,对应请求体中metadata.annotations下参数的值

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 43

Page 54: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-12 spec 字段数据结构说明

参数 参数类型 描述

type String 集群类型:

● VirtualMachine:混合集群混合集群基于Kubernetes来管理一组节点资源,支持虚拟机和裸金属的管理,Kubernetes将自动调度容器运行在可用节点上。在创建容器工作负载前,您需要存在一个可用集群。

● BareMetal:裸金属集群裸金属私有集群基于裸金属服务提供高计算和高网络性能的kubernetes容器集群,如需使用,请创建裸金属服务器。裸金属集群为保证高速的容器网络性能,要求您在创建裸金属服务器时,添加一块高速网卡。添加步骤请参见管理高速网络。

● ARM64:鲲鹏集群鲲鹏容器集群(ARM指令集)提供了容器在鲲鹏(ARM架构)服务器上的运行能力,提供与X86服务器相同的调度伸缩和快速部署能力。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 44

Page 55: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

flavor String 集群规格,集群创建完成后规格不可再变更,请按实际业务需求进行选择。

● cce.s1.small: 小规模单控制节点混合集群( 大50节点)

● cce.s1.medium: 中等规模单控制节点混合集群( 大200节点)

● cce.s1.large: 大规模单控制节点混合集群( 大1000节点)

● cce.t1.small: 小规模单控制节点裸金属集群( 大10节点)

● cce.t1.medium: 中等规模单控制节点裸金属集群( 大100节点)

● cce.t1.large: 大规模单控制节点裸金属集群( 大500节点)

● cce.s2.small: 小规模高可用混合集群(大50节点)

● cce.s2.medium: 中等规模高可用混合集群( 大200节点)

● cce.s2.large: 大规模高可用混合集群( 大1000节点)

● cce.t2.small: 小规模高可用裸金属集群( 大10节点)

● cce.t2.medium: 中等规模高可用裸金属集群( 大100节点)

● cce.t2.large: 大规模高可用裸金属集群(大500节点)

说明

● s1表示单控制节点混合集群。

● s2表示高可用混合集群。

● t1表示单控制节点裸金属集群。

● t2表示高可用裸金属集群。

● dec:专属混合集群规格。如cce.dec.s1.small为小规模单控制节点专属混合集群( 大50节点)。

● 大节点数为当前集群支持管理的 大节点规模,请根据业务需求选择。

● 单控制节点集群:普通集群是单控制节点,控制节点故障后,集群将不可用,但已运行工作负载不受影响。

● 高可用集群:高可用集群是多控制节点,单控制节点故障,集群仍然可用。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 45

Page 56: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

version String 集群版本,与Kubernetes社区基线版本保持一致,建议选择 新版本。

可在CCE控制台中点击总览>购买Kubernets集群,可以在“版本”处获取到集群版本。例:v1.11.3。

说明若不配置,默认创建 新版本的集群。

description String 集群描述

hostNetwok hostNetworkobject

节点网络参数

containerNetwork

containerNetwork object

容器网络参数

authentication authentication object

集群认证方式相关配置

billingMode Integer 集群的计费方式,当前接口只支持创建“按需计费”的集群。

计费方式为“按需计费”时,取值为“0”。若不填,则默认为“0”。

extendParam - 扩展字段,key/value对格式

表 5-13 authentication 字段数据结构说明

参数 参数类型 描述

mode String 集群认证模式。

● kubernetes 1.11及之前版本的集群支持的取值为:“x509”、"rbac"和“authenticating_proxy”,默认取值为:“x509”。

● kubernetes 1.13及以上版本的集群支持的取值为:"rbac"和“authenticating_proxy”,默认取值为:“rbac”。

authenticatingProxy

authenticatingProxy object

Authenticating Proxy认证模式相关配置。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 46

Page 57: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-14 authenticatingProxy 字段数据结构说明

参数 参数类型 描述

ca String Authenticating Proxy认证模式下需提供的CA根证书内容,值必须经过base64编码。

表 5-15 status 字段数据结构说明

参数 参数类型 描述

phase String 集群状态,取值如下

● Available:可用,表示集群处于正常状态。

● Unavailable:不可用,表示集群异常,需手动删除或联系管理员删除。

● ScalingUp:扩容中,表示集群正处于扩容过程中。

● ScalingDown:缩容中,表示集群正处于缩容过程中。

● Creating:创建中,表示集群正处于创建过程中。

● Deleting:删除中,表示集群正处于删除过程中。

● Upgrading:升级中,表示集群正处于升级过程中。

● Empty:集群无任何资源。

jobID String 本次创建集群作业的ID,可用于查询作业进度,获取到创建过程中集群创建的信息变化。

响应示例:

{ "kind": "Cluster", "apiVersion": "v3", "metadata": { "name": "mycluster", "uid": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "creationTimestamp": "2018-08-02 03:48:58.968214406 +0000 UTC", "updateTimestamp": "2018-08-02 03:48:58.968214406 +0000 UTC", "labels": { "foo": "bar" }, "annotations": { "foo2": "bar2" } }, "spec": { "type": "VirtualMachine", "flavor": "cce.s1.small",

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 47

Page 58: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"version": "v1.7.3-r13", "description": "this is a demo cluster", "az": "az01", "hostNetwork": { "vpc": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "subnet": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb" }, "containerNetwork": { "mode": "overlay_l2", "cidr": "172.16.0.0/16" }, "authentication": { "mode": "rbac", "authenticatingProxy": {} }, "kubernetesSvcIpRange": "10.247.0.0/16", "kubeProxyMode": "iptables", "billingMode": 0, "extendParam": { "foo": "bar" } }, "status": { "phase": "Creating", "jobID": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb" }}

状态码

表5-16描述API的状态码。

表 5-16 状态码

状态码 描述

201 表示创建集群作业下发成功。

异常状态码请参见9.3 状态码。

5.1.2 获取指定的集群

功能描述

该API用于获取指定集群的详细信息。

URIGET /api/v3/projects/{project_id}/clusters/{cluster_id}

表5-17描述该API的参数。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 48

Page 59: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-17 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

请求参数如表5-18所示。

表 5-18 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

NA

响应消息

响应参数:

响应参数如表5-19所示。

表 5-19 响应参数

参数 参数类型 描述

kind String API类型,固定值 “Cluster”,该值不可修改。

apiVersion String API版本,固定值“v3”,该值不可修改。

metadata metadata object 集群对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 49

Page 60: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

spec spec object 集合类的元素类型,用户对需要管理的集群对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

status status object 集合类的元素类型,用于记录对象在系统中的当前状态信息,包含了集群状态和本次获取指定的集群作业的jobID。

表 5-20 status 字段数据结构说明

参数 参数类型 描述

phase String 集群状态,取值如下

● Available:可用,表示集群处于正常状态。

● Unavailable:不可用,表示集群异常,需手动删除或联系管理员删除。

● ScalingUp:扩容中,表示集群正处于扩容过程中。

● ScalingDown:缩容中,表示集群正处于缩容过程中。

● Creating:创建中,表示集群正处于创建过程中。

● Deleting:删除中,表示集群正处于删除过程中。

● Upgrading:升级中,表示集群正处于升级过程中。

● Resizing:规格变更中,表示集群正处于变更规格中。

● Empty:集群无任何资源

reason String 集群变为当前状态的原因,在集群在非“Available”状态下时,会返回此参数。

message String 集群变为当前状态的原因的详细信息,在集群在非“Available”状态下时,会返回此参数。

endpoints endpoint object 集群中 kube-apiserver 的访问地址。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 50

Page 61: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-21 endpoint 数据结构说明

参数 参数类型 描述

url String 集群中 kube-apiserver 的访问地址的路由

type String 集群中 kube-apiserver 的访问地址的类型:

● Internal:用户子网内访问的地址

● External:公网访问的地址

响应示例:

{ "kind": "Cluster", "apiVersion": "v3", "metadata": { "name": "mycluster", "uid": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "creationTimestamp": "2018-08-02 03:48:58.968214406 +0000 UTC", "updateTimestamp": "2018-08-02 04:05:29.386391813 +0000 UTC" }, "spec": { "type": "VirtualMachine", "flavor": "cce.s1.small", "version": "v1.7.3-r13", "description": "this is a demo cluster", "hostNetwork": { "vpc": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "subnet": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb" }, "containerNetwork": { "mode": "overlay_l2", "cidr": "172.16.0.0/16" }, "authentication": { "mode": "rbac", "authenticatingProxy": {} }, "billingMode": 0, "kubernetesSvcIpRange": "10.247.0.0/16" }, "status": { "phase": "Available", "endpoints": [ { "url": "https://192.168.0.11:5443", "type": "Internal" } ] }}

状态码

表 3 状态码描述API的状态码。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 51

Page 62: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-22 状态码

状态码 描述

200 表示获取指定集群成功。

异常状态码请参见9.3 状态码。

5.1.3 获取指定项目下的集群

功能描述

该API用于获取指定项目下所有集群的详细信息。

URIGET /api/v3/projects/{project_id}/clusters

表5-23描述该API的参数。

表 5-23 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数

请求消息

请求参数:

请求参数如表5-24所示。

表 5-24 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

NA

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 52

Page 63: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数如表5-25所示。

表 5-25 响应参数

参数 参数类型 描述

kind String API类型,固定值“Cluster”,该值不可修改。

apiVersion String API版本,固定值“v3”,该值不可修改。

items items object 集群对象列表,包含了当前项目下所有集群的详细信息。您可通过items.metadata.name下的值来找到对应的集群。

表 5-26 items 字段数据结构说明

参数 参数类型 描述

kind String API类型,固定值 “Cluster”,该值不可修改。

apiVersion String API版本,固定值“v3”,该值不可修改。

metadata metadata object 集群对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

spec spec object 集合类的元素类型,用户对需要管理的集群对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

status status object 集合类的元素类型,用于记录对象在系统中的当前状态信息,包含了集群状态和本次获取指定项目下的集群作业的jobID。

响应示例:{ "kind": "Cluster", "apiVersion": "v3", "items": [ { "kind": "Cluster", "apiVersion": "v3", "metadata": { "name": "mycluster", "uid": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb",

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 53

Page 64: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"creationTimestamp": "2018-08-02 03:48:58.968214406 +0000 UTC", "updateTimestamp": "2018-08-02 04:05:29.386391813 +0000 UTC" }, "spec": { "type": "VirtualMachine", "flavor": "cce.s1.small", "version": "v1.7.3-r13", "description": "awesome cluster", "hostNetwork": { "vpc": "f0c12911-4fdb-4284-9230-7ffb0860826a", "subnet": "ac274229-fd2e-4695-9f01-a0c1372b8006" }, "containerNetwork": { "mode": "overlay_l2", "cidr": "172.16.0.0/16" }, "authentication": { "mode": "rbac", "authenticatingProxy": {} }, "billingMode": 0, }, "status": { "phase": "Available", "endpoints": [ { "url": "https://192.168.0.11:5443", "type": "Internal" } ] } } ]}

状态码

表 3 状态码描述API的状态码。

表 5-27 状态码

状态码 描述

200 表示获取集群列表成功。

异常状态码请参见9.3 状态码。

5.1.4 更新指定的集群

功能描述

该API用于更新指定的集群。

说明

● 当前仅支持更新spec下的description字段,即集群的描述。

URIPUT /api/v3/projects/{project_id}/clusters/{cluster_id}

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 54

Page 65: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表5-28描述该API的参数。

表 5-28 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

请求参数如表5-29、表5-30所示。

表 5-29 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

表 5-30 请求 Body 参数说明

参数 是否必选

参数类型 描述

spec 是 spec object spec是集合类的元素类型,用户对需要管理的集群对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

表 5-31 spec 字段数据结构说明

参数 是否必选

参数类型 描述

description 否 String 集群描述

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 55

Page 66: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求示例:

{ "spec": { "description": "new description" }}

响应消息

响应参数:

响应参数如表5-19所示。

响应示例:

{ "kind": "Cluster", "apiVersion": "v3", "metadata": { "name": "mycluster", "uid": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "creationTimestamp": "2018-08-02 03:48:58.968214406 +0000 UTC", "updateTimestamp": "2018-08-02 06:39:36.844676088 +0000 UTC", }, "spec": { "type":"VirtualMachine", "flavor": "cce.s1.small", "version": "v1.7.3-r13", "description": "new description", "hostNetwork": { "vpc": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "subnet": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb" }, "containerNetwork": { "mode": "overlay_l2", "cidr": "172.17.0.0/16" }, "authentication": { "mode": "rbac", "authenticatingProxy": {} }, "billingMode": 0, }, "status": { "phase": "Available", "endpoints": [ { "url": "https://192.168.0.11:5443", "type": "Internal" } ] }}

状态码

表5-32描述API的状态码。

表 5-32 状态码

状态码 描述

200 表示更新指定集群成功。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 56

Page 67: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

5.1.5 删除集群

功能描述

该API用于删除一个指定的集群。

URIDELETE /api/v3/projects/{project_id}/clusters/{cluster_id}

表5-33描述该API的参数。

表 5-33 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

请求参数如表5-34所示。

表 5-34 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

NA

响应消息

响应参数:

响应参数如表5-35所示。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 57

Page 68: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-35 响应参数

参数 参数类型 描述

kind String API类型,固定值“Cluster”,该值不可修改。

apiVersion String API版本,固定值“v3”,该值不可修改。

metadata metadataobject

metadata是集群对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

spec spec object spec是集合类的元素类型,用户对需要管理的集群对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

status statusobject status是集合类的元素类型,用于记录对象在系统中的当前状态信息,包含了集群状态和本次删除集群作业的jobID。

表 5-36 status 字段数据结构说明

参数 参数类型 描述

phase String 集群状态,取值如下

● Available:可用,表示集群处于正常状态。

● Unavailable:不可用,表示集群异常,需手动删除或联系管理员删除。

● ScalingUp:扩容中,表示集群正处于扩容过程中。

● ScalingDown:缩容中,表示集群正处于缩容过程中。

● Creating:创建中,表示集群正处于创建过程中。

● Deleting:删除中,表示集群正处于删除过程中。

● Upgrading:升级中,表示集群正处于升级过程中。

● Resizing:规格变更中,表示集群正处于变更规格中。

● Empty:集群无任何资源。

jobID String 本次删除集群作业的ID,可用于查询作业进度,获取到删除过程中集群的信息变化。

endpoints endpointobject

集群中 kube-apiserver 的访问地址。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 58

Page 69: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "kind": "Cluster", "apiVersion": "v3", "metadata": { "name": "mycluster", "uid": "fc563b3c-9552-11e8-8beb-0255ac106311", "creationTimestamp": "2018-08-01 06:20:28.81667161 +0000 UTC", "updateTimestamp": "2018-08-01 09:23:38.944333282 +0000 UTC" }, "spec": { "type": "VirtualMachine", "flavor": "cce.s1.small", "version": "v1.7.3-r13", "description": "new description", "hostNetwork": { "vpc": "cbed56e8-03e7-4304-a477-b54bef0857c3", "subnet": "5de50062-2be2-4a52-893e-e0906e3e9c9d" }, "containerNetwork": { "mode": "overlay_l2", "cidr": "172.16.0.0/16" }, "authentication": { "mode": "rbac", "authenticatingProxy": {} }, "billingMode": 0 }, "status": { "phase": "Available", "jobID": "e8ebf96c-956d-11e8-a949-0255ac10575d", "endpoints": [ { "url": "https://192.168.0.16:5443", "type": "Internal" } ] }}

状态码

表 3 状态码描述API的状态码。

表 5-37 状态码

状态码 描述

200 表示删除指定集群作业下发成功。

异常状态码请参见9.3 状态码。

5.1.6 获取集群证书

功能描述

该API用于获取指定集群的证书信息。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 59

Page 70: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URI

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/clustercert

表5-38描述该API的参数。

表 5-38 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

请求参数如表5-39所示。

表 5-39 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

NA

响应消息

响应参数:

响应参数如表 2 响应参数所示。

表 5-40 响应参数

参数 参数类型 描述

kind String API类型,固定值为“Config”,该值不可修改。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 60

Page 71: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

apiVersion String API版本,固定值“v1”,该值不可修改。

preferences - 当前未使用该字段,当前默认为空。

clusters clustersobject

集群列表。

users users object -

contexts contextsobject

上下文列表。

current-context String 当前上下文。

表 5-41 clusters 字段数据结构说明

参数 参数类型 描述

name String 集群名字。

● 若不存在publicIp(虚拟机弹性IP),则集群列表的集群数量为1,该字段值为“internalCluster”。

● 若存在publicIp,则集群列表的集群数量大于1,所有扩展的cluster的name的值为“externalCluster”。

cluster cluster object 集群信息。

表 5-42 cluster 字段数据结构说明

参数 参数类型 描述

server String 服务器地址。

certificate-authority-data

String 证书授权数据。

表 5-43 users 字段数据结构说明

参数 参数类型 描述

name String 当前为固定值“user“。

user user object 存放了指定用户的一些证书信息和ClientKey信息。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 61

Page 72: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-44 user 字段数据结构说明

参数 参数类型 描述

client-certificate-data

String 客户端证书。

client-key-data String 包含来自TLS客户端密钥文件的PEM编码数据。

表 5-45 contexts 字段数据结构说明

参数 参数类型 描述

name String 上下文的名称。

● 若不存在publicIp(虚拟机弹性IP),则集群列表的集群数量为1,该字段值为“internal”。

● 若存在publicIp,则集群列表的集群数量大于1,所有扩展的context的name的值为“external”。

context contextobject

上下文信息。

表 5-46 context 字段数据结构说明

参数 参数类型 描述

cluster String 上下文cluster信息。

user String 上下文user信息。

响应示例:

{ "kind": "Config", "apiVersion": "v1", "preferences": {}, "clusters": [ { "name": "internalCluster", "cluster": { "server": "https://192.168.1.7:5443", "certificate-authority-data": "" } } ], "users": [ { "name": "user", "user": { "client-certificate-data": "", "client-key-data": ""

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 62

Page 73: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} } ], "contexts": [ { "name": "internal", "context": { "cluster": "internalCluster", "user": "user" } } ], "current-context": "internal"}

状态码

表 9 状态码描述API的状态码。

表 5-47 状态码

状态码 描述

200 表示成功获取指定集群的证书。

异常状态码请参见9.3 状态码。

5.1.7 创建节点

功能描述

该API用于在指定集群下创建节点。

说明

若无集群,请先创建集群。

URI

POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes

表5-48描述该API的参数。

表 5-48 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 63

Page 74: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数

请求参数如表5-49 、表5-50所示。

表 5-49 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

表 5-50 请求 Body 参数说明

参数 是否必选

参数类型 描述

kind 是 String API类型,固定值“Node”,该值不可修改。

apiVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 是 metadataobject

metadata是节点对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

spec 是 spec object spec是集合类的元素类型,用户对需要管理的节点对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

表 5-51 metadata 字段数据结构说明

参数 是否必选

参数类型 描述

name 否 String 节点名称

说明命名规则:以小写字母开头,由小写字母、数字、中划线(-)组成,长度范围4-32位,且不能以中划线(-)结尾。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 64

Page 75: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

labels 否 Object CCE自有节点标签,非Kubernetes原生labels。标签可用于选择对象并查找满足某些条件的对象集合,格式为key/value键值对。

示例:"labels": { "key" : "value"}

annotations 否 Object CCE自有节点注解,非Kubernetes原生annotations,格式为key/value键值对。

示例:"annotations": { "key1" : "value1", "key2" : "value2"}

说明Annotations不用于标识和选择对象。Annotations中的元数据可以是small 或large,structured 或unstructured,并且可以包括标签不允许使用的字符。

表 5-52 spec 字段数据结构说明

参数 是否必选

参数类型 描述

flavor 是 String 节点的规格,取值请参见创建云服务器中“flavorRef”参数的描述。

az 是 String 节点所在的可用区名,取值请参见创建云服务器 中“availability_zone”参数的描述。

os 否 String 节点的操作系统类型。

● 对于虚拟机节点,可以配置为“EulerOS”或“CentOS”。

– 1.11及以下版本的集群,支持的操作系统版本为:EulerOS 2.2、CentOS 7.4。

– 1.13及以上版本的集群,支持的操作系统版本为:EulerOS 2.5、CentOS 7.6。

● 对于自动付费包周期的裸金属节点,当前仅支持:EulerOS 2.3。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 65

Page 76: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

dedicatedHostId

否 String 指定DeH主机的ID,将节点调度到自己的DeH上。

login 是 login object 节点的登录方式,提供密钥对和密码两种登录方式。

rootVolume 是 Volumeobject

节点的系统盘参数。

● 针对裸金属节点:当flavor是快速发放时,该参数必选;如果不是,则禁止指定系统盘。您可以通过这里查看裸金属服务规格描述信息,确定此规格是否支持快速发放。

● 针对专属云节点:支持专属分布式存储DSS或者云硬盘EVS,选择DSS时cluster_type和cluster_id字段为必填。限制条件:系统盘和数据盘不支持两种云存储类型混选。

示例如下:

EVS:{"volumetype":"SATA", "size":40}DSS:{"volumetype":"SATA","size": 40, "cluster_type":"dss","cluster_id":"<dssPoolID>" }

dataVolumes 是 Volumeobject

节点的数据盘参数(目前已支持通过控制台为CCE节点添加第二块数据盘)。

针对专属云节点,参数解释与rootVolume一致。

publicIP 否 publicIPobject

节点的弹性IP参数,用于该节点的公网访问。

billingMode 否 Integer 节点的计费模式:取值为 0(按需付费)、2(自动付费包周期)

自动付费包周期支持普通用户token。

count 是 Integer 批量创建时节点的个数,必须为大于等于1,小于等于 大限额的正整数,若需要更多,可提交工单申请扩大配额。

nodeNicSpec 否 nodeNicSpec object

节点网卡的描述信息。

extendParam 否 extendParam object

扩展参数,key/value对格式。

创建自动付费包周期的裸金属节点时必须配置相应参数。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 66

Page 77: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

ecsGroupId 否 String 云服务器组UUID。

通过云服务器组功能,弹性云服务器在创建时,将尽量分散地创建在不同的主机上,提高业务的可靠性。具体请参见创建云服务器组。

userTags 否 Object 格式为key/value键值对。

如果您需要使用同一标签标识多种云资源,即所有服务均可在标签输入框下拉选择同一标签,建议在TMS中创建预定义标签。具体请参见创建预定义标签。

k8sTags 否 Object 格式为key/value键值对。键值对个数不超过20条。

● Key:必须以字母或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符;另外可以使用DNS子域作为前缀,例如example.com/my-key, DNS子域长253个字符。

● Value:可以为空或者非空字符串,非空字符串必须以字符或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符。

示例:"k8sTags": { "key": "value"}

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 67

Page 78: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

taints 否 Object 支持给创建出来的节点加Taints来设置反亲和性,每条Taints包含以下3个参数:

● Key:必须以字母或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符;另外可以使用DNS子域作为前缀。

● Value:必须以字符或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符。

● Effect:只可选NoSchedule,PreferNoSchedule或NoExecute。

示例:"taints": [{ "key": "status", "value": "unavailable", "effect": "NoSchedule"}, { "key": "looks", "value": "bad", "effect": "NoSchedule"}]

表 5-53 nodeNicSpec 字段数据结构说明

参数 是否必选 参数类型 描述

primaryNic 否 primaryNicobject

主网卡的描述信息。

表 5-54 primaryNic 字段数据结构说明

参数 是否必选 参数类型 描述

subnetId 否 String 网卡所在子网的ID。

表 5-55 login 字段数据结构说明

参数 是否必选 参数类型 描述

sshKey 否 String 选择密钥对方式登录时的密钥对名称,可通过创建密钥对。

userPassword 否 userPassword object

选择密码方式登录时的帐号密码信息,之后可通过此账号密码登录节点。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 68

Page 79: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

说明

sshKey、userPassword两种登录方式只支持二选一,即sshKey、userPassword参数只能有一个配置为“是”。

表 5-56 userPassword 字段数据结构说明

参数 是否必选 参数类型 描述

username 是 String 登录帐号,默认为“root”

password 是 String 登录密码,取值请参见创建云服务器 中“adminPass”参数的描述。

说明创建节点时password字段需要加盐加密,Python示例如下:

1. 生成加密盐值:python -c "import crypt, getpass,pwd;print crypt.mksalt()"执行结果:

$6$KZ2u71CD4JjQneAy2. 根据盐值生成密文密码(在盐字符串的

$符号前加上\符号):python -c "import crypt, getpass,pwd;print crypt.crypt('test@123','\$6\$KZ2u71CD4JjQneAy')"执行结果:

$6$KZ2u71CD4JjQneAy$WF5dsoOjTgc9RD46i46cCL3H92LMEo78s0rHdfSLDE8PW7ylE2ICcxUGF7/8RBbnxW0crgA3ZGNFA0LLgFaYD0

3. 使用base64 encode(即为password字段值):echo -n '$6$KZ2u71CD4JjQneAy$WF5dsoOjTgc9RD46i46cCL3H92LMEo78s0rHdfSLDE8PW7ylE2ICcxUGF7/8RBbnxW0crgA3ZGNFA0LLgFaYD0' |base64 | tr "\n" " " | sed s/[[:space:]]//g执行结果:

JDYkS1oydTcxQ0Q0SmpRbmVBeSRXRjVkc29PalRnYzlSRDQ2aTQ2Y0NMM0g5MkxNRW83OHMwckhkZlNMREU4UFc3eWxFMklDY3hVR0Y3LzhSQmJueFcwY3JnQTNaR05GQTBMTGdGYVlEMA==

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 69

Page 80: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-57 Volume 字段数据结构说明

参数 是否必选 参数类型 描述

size 是 Integer 磁盘大小,单位为GB● 系统盘取值范围:40~1024● 数据盘取值范围:100~32678

cluster_type 否 String 仅用作专属云集群,固定取值为dss。

cluster_id 否 String 仅用作专属云集群,专属分布式存储DSS的存储池ID,即dssPoolID。

获取方法请参见获取单个专属分布式存储池详情中“表3 响应参数”的ID字段。

volumetype 是 String 磁盘类型,取值请参见创建云服务器 中“root_volume字段数据结构说明”。

● SATA:普通IO,是指由SATA存储提供资源的磁盘类型。

● SAS:高IO,是指由SAS存储提供资源的磁盘类型。

● SSD:超高IO,是指由SSD存储提供资源的磁盘类型。

extendParam 否 String 磁盘扩展参数,取值请参见创建云服务器 中“extendparam”参数的描述。

表 5-58 publicIP 字段数据结构说明

参数 是否必选 参数类型 描述

ids 否 Array ofstrings

已有的弹性IP的ID列表

须知若已配置ids参数,则无需配置count和eip参数。

count 否 Integer 要动态创建的弹性IP个数

须知count参数与eip参数必须同时配置。

eip 否 eip object 弹性IP参数

须知count参数与eip参数必须同时配置。

说明

当未创建弹性IP时,建议使用“count”+“eip”的参数组合进行配置,此时系统会根据提供的参数自动创建弹性IP。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 70

Page 81: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-59 eip 字段数据结构说明

参数 是否必选

参数类型 描述

iptype 是 String 弹性IP类型,取值请参见“创建云服务器 > eip字段数据结构说明”表中“iptype”参数的描述。

bandwidth 是 bandwidthobject

弹性IP的带宽参数。

表 5-60 bandwidth 字段数据结构说明

参数 是否必选

参数类型 描述

chargemode 否 String 带宽的计费类型:

● 未传该字段,表示按带宽计费。

● 字段值为空,表示按带宽计费。

● 字段值为“traffic”,表示按流量计费。

● 字段为其它值,会导致创建云服务器失败。

说明

● 按带宽计费:按公网传输速率(单位为Mbps)计费。当您的带宽利用率高于10%时,建议优先选择按带宽计费。

● 按流量计费:按公网传输的数据总量(单位为GB)计费。当您的带宽利用率低于10%时,建议优先选择按流量计费。

size 是 Integer 带宽大小,取值请参见“创建云服务器> bandwidth字段数据结构说明”表中“size”参数的描述。

sharetype 是 String 带宽的共享类型,取值请参见“创建云服务器 > bandwidth字段数据结构说明”表中“sharetype”参数的描述。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 71

Page 82: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-61 extendParam 字段数据结构说明

参数 是否必选

参数类型 描述

periodType 否 String 订购周期类型,取值范围:

● month:月

● year:年

说明billingMode为2(自动付费包周期)时生效,且为必选。

periodNum 否 Integer 订购周期数,取值范围:

● periodType=month(周期类型为月)时,取值为[1-9]。

● periodType=year(周期类型为年)时,取值为1。

说明billingMode为2时生效,且为必选。

isAutoPay 否 String 是否自动付费。

● “true”:自动付费

● “false”:不自动付费。

如果要使用优惠券方式,必须填“false”。

isAutoRenew 否 String 是否自动续订

● “true”:自动续订

● “false”:不自动续订

说明billingMode为2时生效,且为必选。

alpha.cce/preInstall

否 String 安装前执行脚本

说明输入的值需要经过Base64编码,方法为echo -n "待编码内容" | base64。

alpha.cce/postInstall

否 String 安装后执行脚本

说明输入的值需要经过Base64编码,方法为echo -n "待编码内容" | base64。

alpha.cce/NodeImageID

否 String 如果创建裸金属节点,需要使用自定义镜像时用此参数。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 72

Page 83: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

DockerLVMConfigOverride

否 String Docker数据盘配置项。默认配置示例如下:"DockerLVMConfigOverride":"dockerThinpool=vgpaas/90%VG;kubernetesLV=vgpaas/10%VG;diskType=evs;lvType=linear"

包含如下字段:

● userLV:用户空间的大小,示例格式:vgpaas/20%VG

● userPath:用户空间挂载路径,示例格式:/home/wqt-test

● diskType:磁盘类型,支持evs、hdd和ssd,分别指云硬盘evs、本地sata盘和本地nvme盘三种类型。

● lvType:逻辑卷的类型,目前支持linear和striped两种,示例格式:striped

● dockerThinpool:Docker盘的空间大小,示例格式:vgpaas/60%VG

● kubernetesLV:Kubelet空间大小,示例格式:vgpaas/20%VG

请求示例

● 创建按需的弹性云服务器节点:{ "kind": "Node", "apiVersion": "v3", "metadata": { "name": "myhost", "labels": { "foo": "bar" }, "annotations": { "annotation1": "abc" } }, "spec": { "flavor": "s1.medium", "az": "az1.dc1", "login": { "sshKey": "myKeypair" }, "rootVolume": { "size": 40, "volumetype": "SATA" }, "dataVolumes": [ { "size": 100, "volumetype": "SATA" } ], "publicIP": { "count": 2,

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 73

Page 84: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"eip": { "iptype": "5_bgp", "bandwidth": { "chargemode": "traffic", "size": 10, "sharetype": "PER" } } }, "count": 2 }}

● 创建自动付费的裸金属包周期节点:{ "kind": "Node", "apiVersion": "v3", "metadata": { "name": "myhost", "labels": { "foo": "bar" }, "annotations": { "annotation1": "abc" } }, "spec": { "flavor": "physical.s4.medium", "az": "az1.dc1", "login": { "sshKey": "myKeypair" }, "rootVolume": { "size": 200, "volumetype": "SATA" }, "dataVolumes": [ { "size": 100, "volumetype": "SATA" } ], "publicIP": { "count": 2, "eip": { "iptype": "5_bgp", "bandwidth": { "chargemode": "traffic", "size": 10, "sharetype": "PER" } } }, "count": 2, "billingMode": 2, "os": "EulerOS 2.3", "extendParam": { "periodType": "month", "periodNum": 2, "isAutoRenew": "true" } }}

响应消息

响应参数:

响应参数如表5-62所示。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 74

Page 85: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-62 响应参数

参数 参数类型 描述

kind String API类型,固定值“Node”,该值不可修改。

apiVersion String API版本,固定值“v3”,该值不可修改。

metadata metadataobject

metadata是节点对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

spec spec object spec是集合类的元素类型,用户对需要管理的节点对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

status status object status是集合类的元素类型,用于记录对象在系统中的当前状态信息,包含了节点状态和本次创建节点作业的jobID。

表 5-63 spec 字段数据结构说明

参数 参数类型 描述

flavor String 节点的规格,取值请参见创建云服务器 中“flavorRef”参数的描述。

az String 节点所在的可用区名,取值请参见创建云服务器 中“availability_zone”参数的描述。

os 否 String节点的操作系统类型。

● 对于虚拟机节点,可以配置为“EulerOS”或“CentOS”。

– 1.11及以下版本的集群,支持的操作系统版本为:EulerOS 2.2、CentOS 7.4。

– 1.13及以上版本的集群,支持的操作系统版本为:EulerOS 2.5、CentOS 7.6。

● 对于自动付费包周期的裸金属节点,当前仅支持:EulerOS 2.3。

login login object 节点的登录方式,提供密钥对和密码两种登录方式。

rootVolume Volume object 节点的系统盘参数。

须知针对裸金属节点:当flavor是快速发放时,该参数必选;如果不是,则禁止指定系统盘。您可以通过这里查看裸金属服务规格描述信息,确定此规格是否支持快速发放。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 75

Page 86: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

dataVolumes Object 节点的数据盘参数(目前已支持通过控制台为CCE节点添加第二块数据盘)。

publicIP publicIP object 节点的弹性IP参数。

billingMode Integer 节点的计费模式:取值为 0(按需付费)、2(自动付费包周期)

须知自动付费包周期支持普通用户token。

count Integer 批量创建时节点的个数,必须为大于等于1,小于等于 大限额的正整数,若需要更多,可提交工单申请扩大配额。

nodeNicSpec nodeNicSpecobject

节点网卡的描述信息。

extendParam extendParamobject

扩展参数,key/value对格式。

须知创建自动付费包周期的裸金属节点时必须配置。

表 5-64 nodeNicSpec 字段数据结构说明

参数 是否必选 参数类型 描述

primaryNic 否 primaryNicobject

主网卡的描述信息。

表 5-65 primaryNic 字段数据结构说明

参数 是否必选 参数类型 描述

subnetId 否 String 网卡所在子网的ID。

表 5-66 extendParam 字段数据结构说明

参数 参数类型 描述

chargingMode Integer 节点的计费模式。按需计费,取值为“0”,若不填,则默认为“0”。

ecs:performancetype

String 云服务器规格的分类。裸金属节点无该字段。

orderID String 订单ID,节点付费类型为自动付费包周期类型时必选。

productID String 产品ID。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 76

Page 87: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

maxPods Integer 节点允许创建的 大实例数。

periodType String 订购周期类型,取值范围:

● month:月

● year:年

说明billingMode为2(自动付费包周期)时生效,且为必选。

periodNum Integer 订购周期数,取值范围:

● periodType=month(周期类型为月)时,取值为[1-9]。

● periodType=year(周期类型为年)时,取值为1。

说明billingMode为2时生效,且为必选。

isAutoRenew String 是否自动续订

● “true”:自动续订

● “false”:不自动续订

说明billingMode为2时生效,且为必选。

DockerLVMConfigOverride

String Docker数据盘配置项。默认配置示例如下:"DockerLVMConfigOverride":"dockerThinpool=vgpaas/90%VG;kubernetesLV=vgpaas/10%VG;diskType=evs;lvType=linear"

包含如下字段:

● userLV:用户空间的大小,示例格式:vgpaas/20%VG

● userPath:用户空间挂载路径,示例格式:/home/wqt-test

● diskType:磁盘类型,目前只有evs、hdd和ssd三种格式

● lvType:逻辑卷的类型,目前支持linear和striped两种,示例格式:striped

● dockerThinpool:Docker盘的空间大小,示例格式:vgpaas/60%VG

● kubernetesLV:Kubelet空间大小,示例格式:vgpaas/20%VG

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 77

Page 88: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-67 status 字段数据结构说明

参数 参数类型 描述

jobID String 本次创建节点作业的ID,可用于查询作业进度,获取到创建过程中节点创建的信息变化。

响应示例:

● 创建按需的弹性云服务器节点:{ "kind": "Node", "apiVersion": "v3", "metadata": { "name": "myhost", "uid": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "labels": { "foo": "bar" }, "annotations": { "annotation1": "abc" } }, "spec": { "flavor": "s1.medium", "az": "az1.dc1", "os": "EulerOS 2.2", "login": { "sshKey": "myKeypair", "userPassword": {} }, "rootVolume": { "volumetype": "SATA", "size": 40 }, "dataVolumes": [ { "volumetype": "SATA", "size": 100 } ], "publicIP": { "count": 2, "eip": { "iptype": "5_bgp", "bandwidth": { "size": 10, "sharetype": "PER", "chargemode": "traffic" } } }, "count": 2, "billingMode": 0, "extendParam": { "chargingMode": 0, "ecs:performancetype": "normal", "orderID": "", "productID": "" } }, "status": { "jobID": "2ec9b78d-9368-46f3-8f29-d1a95622a568"

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 78

Page 89: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}}

● 创建自动付费的裸金属包周期节点:{ "kind": "Node", "apiVersion": "v3", "metadata": { "name": "myhost", "labels": { "foo": "bar" }, "annotations": { "annotation1": "abc" } }, "spec": { "flavor": "s1.medium", "az": "az1.dc1", "os": "EulerOS 2.2", "login": { "sshKey": "myKeypair", "userPassword": {} }, "rootVolume": { "volumetype": "SATA", "size": 40 }, "dataVolumes": [ { "volumetype": "SATA", "size": 100 } ], "publicIP": { "count": 2, "eip": { "iptype": "5_bgp", "bandwidth": { "size": 10, "sharetype": "PER", "chargemode": "traffic" } } }, "count": 2, "billingMode": 2, "extendParam": { "alpha.cce/NodeImageID": "2006bc00-5f00-449f-b2a3-a6b1a7ac03e5", "chargingMode": 1, "init-node-password": "JDYkV0djSDc3JGZRcmwxWkFqcWw4bkRmdGJPUm8xR1NEQWYyOE1xNVN6dHpmSWhTdTFjMG1CdDN2ZEZ0VWdPalIxNVpnVFQ5Z2EyVjhlTVJMYS5HQlVMak5ocC9kY2Iv", "DockerLVMConfigOverride": "dockerThinpool=vgpaas/90%VG;kubernetesLV=vgpaas/10%VG;userLV=vgpaas/0%VG;userPath=/home/mnt/user;lvType=linear", "orderID": "", "productID": "" "publicKey": "", "regionID": "", "userID": "299b876bc79745b9803763af74479180" } }, "status": { "jobID": "2ec9b78d-9368-46f3-8f29-d1a95622a568" }}

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 79

Page 90: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表5-68描述API的状态码。

表 5-68 状态码

状态码 描述

201 表示在指定集群下创建节点的作业下发成功。

异常状态码请参见9.3 状态码。

5.1.8 获取指定的节点

功能描述

该API用于通过节点ID获取指定节点的详细信息。

URIGET /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/{node_id}

表5-69描述该API的参数。

表 5-69 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

node_id 是 节点ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

请求参数如表5-70所示。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 80

Page 91: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-70 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

NA

响应消息

响应参数:

响应参数如表5-71所示。

表 5-71 响应参数

参数 参数类型 描述

kind String API类型,固定值“Node”,该值不可修改。

apiVersion String API版本,固定值v3,该值不可修改。

metadata metadataobject

metadata是节点对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

spec spec object spec是集合类的元素类型,用户对需要管理的节点对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

status status object status是集合类的元素类型,用于记录对象在系统中的当前状态信息,包含了节点状态和本次创建节点作业的jobID。

表 5-72 metadata 字段数据结构说明

参数 参数类型 描述

name String 节点名称

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 81

Page 92: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

uid String 节点ID

creationTimestamp

String 节点创建时间

updateTimestamp String 节点更新时间

annotations Object 节点注解,key/value对格式

表 5-73 status 字段数据结构说明

参数 参数类型 描述

phase String 节点所在的状态。

● Build:创建中,表示节点虚拟机处于创建中。

● Active:正常,表示节点处于可用状态。

● Abnormal:异常,表示节点处于不可用状态。

● Deleting:删除中,表示节点正处于删除过程中。

● Installing:安装中,表示节点正处于安装过程中。

● Upgrading:升级中,表示正处于升级过程中。

serverId String 节点在ECS的虚拟机ID

publicIP String 节点的弹性IP,用于在公网中访问的IP。

privateIP String 节点的私有IP,用于在与集群所处同一vpc的节点互通的IP。

响应示例:

{ "kind": "Node", "apiVersion": "v3", "metadata": { "name": "myhost", "uid": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "creationTimestamp": "2018-08-02 08:12:40.124294439 +0000 UTC", "updateTimestamp": "2018-08-02 08:18:20.221871842 +0000 UTC", "annotations": { "kubernetes.io/node-pool.id": "az1.dc1#s1.medium#EulerOS 2.2" } }, "spec": { "flavor": "s1.medium", "az": "az1.dc1", "os": "EulerOS 2.2", "login": {

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 82

Page 93: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"sshKey": "myKeypair", "userPassword": {} }, "rootVolume": { "volumetype": "SATA", "size": 40 }, "dataVolumes": [ { "volumetype": "SATA", "size": 100 } ], "publicIP": { "eip": { "bandwidth": {} } }, "billingMode": 0 }, "status": { "phase": "Active", "serverId": "456789abc-9368-46f3-8f29-d1a95622a568", "publicIP": "10.34.56.78", "privateIP": "192.168.1.23" }}

状态码

表 3 状态码描述API的状态码。

表 5-74 状态码

状态码 描述

200 表示获取集群下指定的节点成功。

异常状态码请参见9.3 状态码。

5.1.9 获取集群下所有节点

功能描述

该API用于通过集群ID获取指定集群下所有节点的详细信息。

URIGET /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes

表5-75描述该API的参数。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 83

Page 94: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-75 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

请求参数如表5-76所示。

表 5-76 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

NA

响应消息

响应参数:

响应参数如表5-77所示。

表 5-77 响应参数

参数 参数类型 描述

kind String API类型,固定值“List”

apiVersion String API版本,固定值“v3”

items Object 节点对象列表,包含了当前集群下所有节点的详细信息。可通过items.metadata.name下的值来找到对应的节点。具体请参见表5-71。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 84

Page 95: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "kind": "List", "apiVersion": "v3", "items": [ { "kind": "Node", "apiversion": "v3", "metadata": { "name": "myhost", "uid": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "creationTimestamp": "2018-08-02 07:37:24.005071325 +0000 UTC", "updateTimestamp": "2018-08-02 07:44:04.965500815 +0000 UTC", "annotations": { "kubernetes.io/node-pool.id": "az1.dc1#s1.medium#EulerOS 2.2" } }, "spec": { "flavor": "s1.medium", "az": "az1.dc1", "os": "EulerOS 2.2", "login": { "sshKey": "KeyPair-0405", "userPassword": {} }, "rootVolume": { "volumetype": "SATA", "size": 40 }, "dataVolumes": [ { "volumetype": "SATA", "size": 100 } ], "publicIP": { "eip": { "bandwidth": {} } }, "billingMode": 0 }, "status": { "phase": "Active", "serverId": "456789abc-9368-46f3-8f29-d1a95622a568", "publicIP": "10.34.56.78", "privateIP": "192.168.1.23" } } ]}

状态码

表 3 状态码描述API的状态码。

表 5-78 状态码

状态码 描述

200 表示获取集群下的节点列表成功。

异常状态码请参见9.3 状态码。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 85

Page 96: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

5.1.10 更新指定的节点

功能描述

该API用于更新指定的节点。

说明

当前仅支持更新metadata下的name字段,即节点的名字。

URIPUT /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/{node_id}

表5-79描述该API的参数。

表 5-79 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

node_id 是 节点ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

请求参数如表5-80、表5-81所示。

表 5-80 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 86

Page 97: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-81 请求 Body 参数说明

参数 是否必选 参数类型 描述

metadata 否 metadataobject

metadata是节点对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

表 5-82 metadata 数据结构参数解释

参数 是否必选 参数类型 描述

name 否 String 节点名称,修改后将同步修改ECS中虚拟机名称

请求示例:

{ "metadata": { "name": "new-hostname" }}

响应消息

响应参数:

响应参数如表5-71所示。

响应示例:

{ "kind": "Node", "apiVersion": "v3", "metadata": { "name": "new-hostname", "uid": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "creationTimestamp": " 2017-08-20T21:11:09Z", "updateTimestamp": "2017-08-20T21:11:09Z", "annotations": { "kubernetes.io/node-pool.id": "az1.dc1#s1.medium#EulerOS 2.2" } }, "spec": { "flavor": "s1.medium", "az": "az1.dc1", "os": "EulerOS 2.2", "login": { "sshKey": "KeyPair-0405", "userPassword": {} }, "rootVolume": { "volumeType": "SATA", "diskSize": 40 }, "dataVolumes": [ { "volumeType": "SATA", "diskSize": 100 }

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 87

Page 98: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

], "publicIP": { "eip": { } }, "billingMode": 0 }, "status": { "phase": "Active", "serverId": "456789abc-9368-46f3-8f29-d1a95622a568", "publicIP": "10.34.56.78", "privateIP": "192.168.1.23" }}

状态码

表 3 状态码描述API的状态码。

表 5-83 状态码

状态码 描述

200 表示更新指定节点成功。

异常状态码请参见9.3 状态码。

5.1.11 删除节点

功能描述

该API用于删除指定的节点。

URI

DELETE /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/{node_id}

表5-84描述该API的参数。

表 5-84 参数解释

参数 是否必选 描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

node_id 是 节点ID,获取方式请参见9.7 如何获取接口URI中参数。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 88

Page 99: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数:

请求参数如表5-85所示。

表 5-85 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

NA

响应消息

响应参数:

响应参数如表5-86 所示。

表 5-86 响应参数

参数 参数类型 描述

kind String API类型,固定值“Node”,该值不可修改。

apiVersion String API版本,固定值v3,该值不可修改。

metadata metadataobject

metadata是节点对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

spec spec object spec是集合类的元素类型,用户对需要管理的节点对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

status status object status是集合类的元素类型,用于记录对象在系统中的当前状态信息,包含了节点状态和本次删除节点作业的jobID。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 89

Page 100: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-87 status 字段数据结构说明

参数 参数类型 描述

phase String 节点所在的状态。

● Build:创建中,表示节点虚拟机处于创建中。

● Active:正常,表示节点处于可用状态。

● Abnormal:异常,表示节点处于不可用状态。

● Deleting:删除中,表示节点正处于删除过程中。

● Installing:安装中,表示节点正处于安装过程中。

● Upgrading:升级中,表示正处于升级过程中。

jobID String 本次删除节点作业的ID,可用于查询作业进度,获取到删除过程中节点的信息变化

serverId String 节点在ECS的虚拟机ID。

publicIP String 节点的弹性IP,用于在公网中访问的IP。

privateIP String 节点的私有IP,用于在与集群所处同一vpc的节点互通的IP。

响应示例:

{ "kind": "Node", "apiVersion": "v3", "metadata": { "name": "new-hostname", "uid": "cc697ad9-9563-11e8-8ea7-0255ac106311", "creationTimestamp": "2018-08-01 08:20:49.944664515 +0000 UTC", "updateTimestamp": "2018-08-01 09:20:05.644032347 +0000 UTC", "annotations": { "kubernetes.io/node-pool.id": "az1.dc1#s1.medium#EulerOS 2.2" } }, "spec": { "flavor": "s1.medium", "az": "az1.dc1", "os": "EulerOS 2.2", "login": { "sshKey": "KeyPair-0405", "userPassword": {} }, "rootVolume": { "volumetype": "SATA", "size": 40 }, "dataVolumes": [ { "volumetype": "SATA", "size": 100 }

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 90

Page 101: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

], "publicIP": { "eip": { "bandwidth": {} } }, "billingMode": 0 }, "status": { "phase": "Active", "jobID": "661f6f7d-956c-11e8-a916-0255ac10575d", "serverId": "5b504f8d-33f1-4ab7-a600-b62dac967d72", "privateIP": "192.168.0.69", "publicIP": "10.154.194.59" }}

状态码

表 3 状态码描述API的状态码。

表 5-88 状态码

状态码 描述

200 表示删除节点作业下发成功。

异常状态码请参见9.3 状态码。

5.1.12 查询作业进度

功能描述

该API用于查询作业进度。通过某一作业请求下发后返回的jobID来查询指定作业的进度。

说明

通常使用场景为:

● 创建、删除集群时,查询相应作业的进度。

● 创建、删除节点时,查询相应作业的进度。

URI

GET /api/v3/projects/{project_id}/jobs/{job_id}

表5-89描述该API的参数。

表 5-89 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 91

Page 102: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

描述

job_id 是 作业ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

请求参数如表5-90所示。

表 5-90 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

NA

响应消息

响应参数:

响应参数如表5-91所示。

表 5-91 响应参数

参数 参数类型 描述

kind String API类型,固定值“Job”

apiVersion String API版本,固定值“v3”

metadata metadata object 节点元数据

spec spec object 节点详细参数

status status object 节点状态信息

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 92

Page 103: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-92 metadata 字段数据结构说明

参数 参数类型 描述

uid String 作业的ID

creationTimestamp

String 作业的创建时间

updateTimestamp String 作业的更新时间

表 5-93 spec 字段数据结构说明

参数 参数类型 描述

type String 作业的类型,例:“CreateCluster”-创建集群

clusterUID String 作业所在的集群的ID

resourceID String 作业操作的资源ID

resourceName String 作业操作的资源名称

extendParam String 扩展参数

subJobs Object 子作业的列表,具体请参见表5-91。

● 包含了所有子作业的详细信息

● 在创建集群、节点等场景下,通常会由多个子作业共同组成创建作业,在子作业都完成后,作业才会完成

表 5-94 status 字典数据结构说明

参数 参数类型 描述

phase String 作业的状态,有如下四种状态:

● JobPhaseInitializing JobPhase ="Initializing"

● JobPhaseRunning JobPhase ="Running"

● JobPhaseFailed JobPhase ="Failed"

● JobPhaseSuccess JobPhase ="Success"

reason String 作业变为当前状态的原因

响应示例:

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 93

Page 104: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "kind": "Job", "apiVersion": "v3", "metadata": { "uid": "354331b2c-229a-11e8-9c75-0255ac100ceb", "creationTimestamp": "2018-08-02 08:12:40.672772389 +0000 UTC", "updateTimestamp": "2018-08-02 08:21:50.478108569 +0000 UTC" }, "spec": { "type": "CreateCluster", "clusterUID": "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "resourceID": "6f4dcb2c-229a-11e8-9c75-0255ac100ceb", "resourceName": "cluster-name", "extendParam": { "serverID": "bc467e3a-2338-11e8-825b-0255ac100c13" }, "subJobs": [ { "kind": "Job", "apiVersion": "v3", "metadata": { "uid": "fd474fab-9606-11e8-baa9-0255ac10215d", "creationTimestamp": "2018-08-02 03:52:34.615819618 +0000 UTC", "updateTimestamp": "2018-08-02 04:05:29.196243031 +0000 UTC" }, "spec": { "type": "InstallMaster", "clusterUID": "fcc72de0-9606-11e8-baa8-0255ac10215d", "resourceID": "fd3b4ac0-9606-11e8-baa8-0255ac10215d", "extendParam": { "serverID": "fd3b4ac0-9606-11e8-baa8-0255ac10215d" } }, "status": { "phase": "Success" } }, { "kind": "Job", "apiVersion": "v3", "metadata": { "uid": "fd474f82-9606-11e8-baa8-0255ac10215d", "creationTimestamp": "2018-08-02 03:52:33.859150791 +0000 UTC", "updateTimestamp": "2018-08-02 03:52:34.615655429 +0000 UTC" }, "spec": { "type": "CreatePSMCert", "clusterUID": "fcc72de0-9606-11e8-baa8-0255ac10215d" }, "status": { "phase": "Success" } } ], }, "status": { "phase": "Running", "reason": "" }}

状态码

表 3 状态码描述API的状态码。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 94

Page 105: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-95 状态码

状态码 描述

200 表示获取作业信息成功。

异常状态码请参见9.3 状态码。

5.1.13 获取集群下所有节点池

功能描述

该API用于获取集群下所有节点池。

说明

nodepool是集群中具有相同配置的节点实例的子集。

URI

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/nodepools

表5-96描述该API的参数。

表 5-96 参数解释

参数 是否必选

描述

project_id 是 项目ID,获取方式请参见9.7 如何获取接口URI中参数。

cluster_id 是 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

请求消息

请求参数:

请求参数如表5-97所示。

表 5-97 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 95

Page 106: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

X-Auth-Token 是 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

NA

响应消息

响应参数:

响应参数如表5-98所示。

表 5-98 响应参数

参数 参数类型 描述

kind String API类型,固定值“List”

apiVersion String API版本,固定值“v3”

items items object -

表 5-99 items 字段数据结构说明

参数 参数类型 描述

kind String API类型,固定值“NodePool”

apiVersion String API版本,固定值“v3”

metadata metadata object 节点池元数据

spec spec object 节点池详细参数

status status object 节点池状态信息

表 5-100 metadata 字段数据结构说明

参数 参数类型 描述

name String 节点池名称

uid String 节点池的ID

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 96

Page 107: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-101 spec 字段数据结构说明

参数 参数类型 描述

nodeTemplate spec object 节点池模板详细参数

initialNodeCount Integer 节点池初始化节点个数

autoscaling autoscaling object 自动扩容参数

表 5-102 status 字典数据结构说明

参数 参数类型 描述

currentNode Integer 当前节点池中节点个数

表 5-103 autoscaling 字典数据结构说明

参数 参数类型 描述

enable Boolean 是否开启自动扩缩容

minNodeCount Integer 若开启自动扩缩容, 小能缩容的节点个数

maxNodeCount Integer 若开启自动扩缩容, 大能扩容的节点个数

响应示例:

{ "kind": "List", "apiVersion": "v3", "items": [ { "kind": "NodePool", "apiVersion": "v3", "metadata": { "name": "az1.dc1#s1.large#EulerOS 2.2", "uid": "az1.dc1#s1.large#EulerOS 2.2" }, "spec": { "nodeTemplate": { "flavor": "s1.large", "az": "az1.dc1", "os": "EulerOS 2.2", "login": { "userPassword": {} }, "rootVolume": {}, "publicIP": { "eip": { "bandwidth": {} } }, "billingMode": 0 },

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 97

Page 108: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"autoscaling": { "enable": true, "maxNodeCount": 50 }, }, "status": { "currentNode": 1 } } ]}

状态码

表5-104描述API的状态码。

表 5-104 状态码

状态码 描述

200 表示获取集群下所有节点池成功。

异常状态码请参见9.3 状态码。

5.2 存储管理

5.2.1 创建 PersistentVolumeClaim

功能描述

该API用于在指定的Namespace下通过云存储服务中的云存储(EVS、SFS、OBS)去创建PersistentVolumeClaim。

URIPOST /api/v1/namespaces/{namespace}/cloudpersistentvolumeclaims

表5-105描述该API的参数。

表 5-105 参数解释

参数 是否必选

描述

namespace 是 Namespace是对一组资源和对象的抽象集合,用来将系统内部的对象划分为不同的项目组或用户组。字符串必须满足正则表达式 [a-z0-9]([-a-z0-9]*[a-z0-9])?。可以任选其一使用:

● 用户自定义的namespace,使用前必须先创建Namespace。

● 系统自带的namespace:default或kube-system。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 98

Page 109: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数:

请求参数如表5-106、表5-107所示。

表 5-106 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),可任选其一使用。

● application/json;charset=utf-8● application/json

X-Auth-Token 使用token认证时必选

调用接口的一种认证方式,使用时需要获取token.

表 5-107 请求 Body 参数说明

参数 是否必选 参数类型 描述

apiVersion 是 String API版本,固定值"v1"

kind 是 String API类型,固定值"PersistentVolumeClaim"

metadata 是 metadataobject

metadata是集群对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。

spec 是 spec object spec是集合类的元素类型,用户对需要管理的集群对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。

status 否 status object status是当前persistent volumeclaim的状态信息,创建时不需要添加status参数。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 99

Page 110: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-108 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

name 是 String PersistentVolumeClaim名称,可以包含小写字母、数字、连字符和点,开头和结尾必须是字母或数字, 长253个字符,同一namespace下name不能重复。例:my-pvc

labels 否 String PersistentVolumeClaim标签,key/value对格式。

● Key:必须以字母或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符;另外可以使用DNS子域作为前缀,例如example.com/my-key, DNS子域 长253个字符。

● Value:可以为空或者非空字符串,非空字符串必须以字符或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符。

示例:"foo": "bar"

表 5-109 spec 字段数据结构说明

参数 是否必选 参数类型 描述

volumeName 否 String 绑定引用的PersistentVolume名称

说明若“volumeID”被指定,则该字段指定的值无效。

volumeID 否 String 云存储卷ID(云硬盘的ID)

storageType 否 String 云存储的类型,和volumeID搭配使用。即volumeID和storageType必须同时被配置。

● bs:EVS云存储,详情可参见使用云硬盘存储卷 。

● nfs:SFS弹性文件存储,详情可参见使用文件存储卷 。

● obs:OBS对象存储,详情可参见使用对象存储卷 。

● efs:SFS Turbo极速文件存储,详情可参见使用极速文件存储卷。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 100

Page 111: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

accessModes 是 Array ofstrings

指定volume应该具有的访问模式。

● ReadWriteOnce:该卷可以被单个节点以读/写模式挂载

说明集群版本为v1.13.10且storage-driver版本为1.0.19时,才支持此功能。

● ReadOnlyMany:该卷可以被多个节点以只读模式挂载

● ReadWriteMany:该卷可以被多个节点以读/写模式挂载

表 5-110 status 字段数据结构说明

参数 是否必选 参数类型 描述

accessModes 否 Array ofstrings

显示volume实际具有的访问模式。

capacity 否 Object 底层卷的实际资源

phase 否 String PersistentVolumeClaim当前所处的状态

请求示例:

● 指定EVS云硬盘ID创建PersistentVolumeClaim{ "apiVersion": "v1", "kind": "PersistentVolumeClaim", "metadata": { "name": "csms-dev-create", "namespace": "default" }, "spec": { "volumeID": "86b29e16-23db-11e7-9c83-fa163ec08232", "storageType": "bs", "accessModes": [ "ReadWriteMany" ] }}

● 指定SFS文件存储ID创建PersistentVolumeClaim{ "apiVersion": "v1", "kind": "PersistentVolumeClaim", "metadata": { "name": "csms-dev-create", "namespace": "default" }, "spec": { "volumeID": "86b29e16-23db-11e7-9c83-fa163ec08232",

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 101

Page 112: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"storageType": "nfs", "accessModes": [ "ReadWriteMany" ] }}

● 指定OBS对象存储ID创建PersistentVolumeClaim{ "apiVersion": "v1", "kind": "PersistentVolumeClaim", "metadata": { "name": "csms-dev-create", "namespace": "default" }, "spec": { "volumeID": "obs-storage-id", "storageType": "obs", "accessModes": [ "ReadWriteMany" ] }}

● 指定SFS Turbo极速文件存储ID创建PersistentVolumeClaim{ "apiVersion": "v1", "kind": "PersistentVolumeClaim", "metadata": { "name": "csms-dev-create", "namespace": "default" }, "spec": { "volumeID": "86b29e16-23db-11e7-9c83-fa163ec08232", "storageType": "efs", "accessModes": [ "ReadWriteMany" ] }}

响应消息

响应参数:

响应参数如表5-107所示。

响应示例:

{ "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": " csms-dev-create ", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "86b29e16-23db-11e7-9c83-fa163ec08232", "resourceVersion": "1793115", "creationTimestamp": "2017-04-18T02:05:42Z" }, "spec": { "volumeName": "csms-dev-create ", "accessModes": [ "ReadWriteMany" ], "resources": { "requests": { "storage": "1Gi" }

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 102

Page 113: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} }, "status": { "phase": "Pending", "accessModes": [ "ReadWriteMany" ] }}

状态码

表 3 状态码描述API的状态码。

表 5-111 状态码

状态码 描述

201 创建PersistentVolumeClaim作业下发成功。

5.2.2 删除 PersistentVolumeClaim

功能描述

该API用于删除指定Namespace下的PersistentVolumeClaim对象,并可以选择保留后端的云存储。

URIDELETE /api/v1/namespaces/{namespace}/cloudpersistentvolumeclaims/{name}

表5-112描述该API的参数。

表 5-112 参数解释

参数 是否必选

描述

namespace 是 指定PersistentVolumeClaim所在的命名空间。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 103

Page 114: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

描述

name 是 需要删除的PersistentVolumClaim的名称。

name格式为:Volume名称[?deleteVolume=BOOLEAN&storageType=云存储类型],中括号内可省略,示例:

● volume-49f1?deleteVolume=true&storageType=bs● volume-49f1其中:

● deleteVolume:删除PersistentVolumeClaim后是否保留后端关联的云存储。false表示不删除,ture表示删除,默认为false。

说明当为efs时,不支持删除存储,所以不能设为true。

● storageType:云存储的类型,和deleteVolume搭配使用。即deleteVolume和storageType必须同时配置。

– bs:EVS云存储

– nfs:SFS弹性文件存储

– obs:OBS对象存储

– efs:SFS Turbo极速文件存储

请求消息

请求参数:

请求参数如表5-113所示。

表 5-113 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),可任选其一使用。

● application/json;charset=utf-8● application/json

X-Auth-Token 使用token认证时必选

调用接口的一种认证方式,使用时需要获取token.

请求示例:

NA

响应消息

响应参数:

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 104

Page 115: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应参数如表5-114所示。

表 5-114 参数描述

参数 是否必选 参数类型 描述

apiVersion 是 String API版本,固定值"v1"

kind 是 String API类型,固定值"PersistentVolumeClaim"

metadata 是 metadata object -

spec 是 spec object -

status 否 status object -

表 5-115 metadata 字段数据结构说明

参数 是否必选

参数类型 描述

name 是 String PersistentVolumeClaim名称,可以包含小写字母、数字、连字符和点,开头和结尾必须是字母或数字, 长253个字符,同一namespace下name不能重复。

labels 否 String PersistentVolumeClaim标签,key/value对格式。

● Key:必须以字母或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符;另外可以使用DNS子域作为前缀,例如example.com/my-key, DNS子域长253个字符。

● Value:可以为空或者非空字符串,非空字符串必须以字符或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符。

示例:"foo": "bar"

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 105

Page 116: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-116 spec 字段数据结构说明

参数 是否必选

参数类型 描述

volumeName

否 String 绑定引用的PersistentVolume名称

accessModes

是 Array ofstrings

指定volume应该具有的访问模式。

● ReadWriteOnce:该卷可以被单个节点以读/写模式挂载

说明集群版本为v1.13.10且storage-driver版本为1.0.19时,才支持此功能。

● ReadOnlyMany:该卷可以被多个节点以只读模式挂载

● ReadWriteMany:该卷可以被多个节点以读/写模式挂载

表 5-117 status 字段数据结构说明

参数 是否必选 参数类型 描述

accessModes 否 Array ofstrings

显示volume实际具有的访问模式

capacity 否 Object 底层卷的实际存储空间大小,例:"storage": "1Gi"

phase 否 String PersistentVolumeClaim当前所处的状态

响应示例:

{ "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": " csms-dev-create ", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "86b29e16-23db-11e7-9c83-fa163ec08232", "resourceVersion": "1793115", "creationTimestamp": "2017-04-18T02:05:42Z" }, "spec": { "volumeName": "csms-dev-create ", "accessModes": [ "ReadWriteMany" ], "resources": { "requests": { "storage": "1Gi" } } },

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 106

Page 117: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"status": { "phase": "Pending", "accessModes": [ "ReadWriteMany" ] }}

状态码

表 3 状态码描述API的状态码。

表 5-118 状态码

状态码 描述

200 删除指定PersistentVolumeClaim作业下发成功。

5.2.3 创建 PersistentVolume

功能描述

该API用于通过指定云存储服务中的云存储(如EVS、SFS、OBS)去创建PersistentVolume。

URI

POST /api/v1/cloudpersistentvolumes

请求消息

请求参数:

请求参数如表5-119、表5-120所示。

表 5-119 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),可任选其一使用。

● application/json;charset=utf-8● application/json

X-Auth-Token 使用token认证时必选

调用接口的一种认证方式,使用时需要获取token.

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 107

Page 118: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-120 请求 body 参数说明

参数 是否必选 参数类型 描述

apiVersion 是 String API版本,固定值"v1"

kind 是 String API类型,固定值"PersistentVolume"

metadata 是 metadataobject

-

spec 是 spec object -

status 否 status object -

表 5-121 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

name 是 String PersistentVolume名称,可以包含小写字母、数字、连字符和点,开头和结尾必须是字母或数字, 长253个字符,同一namespace下name不能重复。

labels 否 String PersistentVolume标签,key/value对格式。

● Key:必须以字母或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符;另外可以使用DNS子域作为前缀,例如example.com/my-key, DNS子域 长253个字符。

● Value:可以为空或者非空字符串,非空字符串必须以字符或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符。

示例:"foo": "bar"

表 5-122 spec 字段数据结构说明

参数 是否必选 参数类型 描述

flexVolume 是 flexVolumeobject

Kubernetes的flexvolume存储插件

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 108

Page 119: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

accessModes 是 Array ofstrings

指定volume应该具有的访问模式。

● ReadWriteOnce:该卷可以被单个节点以读/写模式挂载

说明集群版本为v1.13.10且storage-driver版本为1.0.19时,才支持此功能。

● ReadOnlyMany:该卷可以被多个节点以只读模式挂载

● ReadWriteMany:该卷可以被多个节点以读/写模式挂载

persistentVolumeReclaimPolicy

否 String PersistentVolume的回收策略,包括:

● Retain:保留策略允许手动回收资源。当PersistentVolumeClaim 被删除时,PersistentVolume 仍然存在,volume 被视为“已释放”。

● Recycle:回收策略会在volume上执行基本擦除(rm -rf / thevolume / *),可被再次声明使用。

● Delete:对于支持删除回收策略的卷插件,删除操作将从Kubernetes 中删除PersistentVolume 对象,并删除外部基础架构中的关联存储资产。动态配置的卷继承其StorageClass,默认为Delete。

表 5-123 status 字段数据结构说明

参数 是否必选 参数类型 描述

accessModes 否 Array ofstrings

显示volume实际具有的访问模式

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 109

Page 120: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

phase 否 String PersistentVolume当前所处的状态,包括:

● Available(可用):还是空闲资源,没有被任何PVC绑定

● Bound(已绑定):卷已经被PVC绑定

● Released(已释放):之前绑定的PVC被删除,但是资源还未被集群重新声明

● Failed(失败):该卷的自动回收失败

表 5-124 flexVolume 字段数据结构说明

参数 是否必选 参数类型 描述

driver 是 String Flexvolume插件名称,请根据使用的存储类型填写:

● huawei.com/fuxivol (EVS)● huawei.com/fuxinfs (SFS)● huawei.com/fuxiobs (OBS)● huawei.com/fuxiefs (SFS Turbo)

fsType 是 String 文件系统类型,请根据使用的存储类型填写:

● ext4: EVS云硬盘存储,详情可参见使用云硬盘存储卷 。

● nfs:SFS弹性文件存储,详情可参见使用文件存储卷 。

● obs:OBS对象存储,详情可参见使用对象存储卷 。

● efs:SFS Turbo极速文件存储,详情可参见使用极速文件存储卷。

options 是 options object -

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 110

Page 121: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-125 options 字段数据结构说明

参数 是否必选 参数类型 描述

fsType 是 String 文件系统类型,请根据使用的存储类型填写:

● ext4 (EVS)● nfs (SFS)● obs (OBS)● efs (SFS Turbo)

region 是 String 云存储所在的region。

volumeID

是 String 云存储的UUID,如果是OBS-bucket则填入名称

storageType

是 String 指定云存储的类型。

● bs (EVS)● nfs (SFS)● obs (OBS)● efs (SFS Turbo)

请求示例:

● 指定EVS云硬盘ID创建PersistentVolume1.9版本的集群样例:{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "labels": { "name": "pv-test" }, "name": "pv-test" }, "spec": { "accessModes": [ "ReadWriteMany" ], "flexVolume": { "driver": "huawei.com/fuxivol", "fsType": "ext4", "options": { "fsType": "ext4", "kubernetes.io/namespace": "default", "region": "southchina", "volumeID": "76e01b29-08b9-11e8-9ca5-1051722006ec", "storageType": "bs" } }, "persistentVolumeReclaimPolicy": "Delete" } }

1.11及以上版本集群样例:{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": {

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 111

Page 122: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"labels": { "name": "pv-test" }, "name": "pv-test" }, "spec": { "accessModes": [ "ReadWriteMany" ], "flexVolume": { "driver": "huawei.com/fuxivol", "fsType": "ext4", "options": { "fsType": "ext4", "region": "southchina", "volumeID": "76e01b29-08b9-11e8-9ca5-1051722006ec", "storageType": "bs" } }, "persistentVolumeReclaimPolicy": "Delete" } }

● 指定SFS文件存储ID创建PersistentVolume1.9版本的集群样例:{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "labels": { "name": "pv-test" }, "name": "pv-test" }, "spec": { "accessModes": [ "ReadWriteMany" ], "flexVolume": { "driver": "huawei.com/fuxinfs", "fsType": "nfs", "options": { "fsType": "nfs ", "kubernetes.io/namespace": "default", "region": "southchina", "volumeID": "56e01b29-02b9-128-9ca5-1051722006ec", "storageType": "nfs" } }, "persistentVolumeReclaimPolicy": "Delete" } }

1.11及以上版本集群样例:{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "labels": { "name": "pv-test" }, "name": "pv-test" }, "spec": { "accessModes": [ "ReadWriteMany" ], "flexVolume": { "driver": "huawei.com/fuxinfs", "fsType": "nfs",

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 112

Page 123: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"options": { "fsType": "nfs ", "region": "southchina", "volumeID": "56e01b29-02b9-128-9ca5-1051722006ec", "storageType": "nfs" } }, "persistentVolumeReclaimPolicy": "Delete" } }

● 指定OBS对象存储ID创建PersistentVolume1.9版本的集群样例:{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "labels": { "name": "pv-test" }, "name": "pv-test" }, "spec": { "accessModes": [ "ReadWriteMany" ], "flexVolume": { "driver": "huawei.com/fuxiobs", "fsType": "obs", "options": { "fsType": "obs", "kubernetes.io/namespace": "default", "region": "southchina", "volumeID": "76e01b29-08b9-11e8-9ca5-1051722006ec", "storageType": "obs" } }, "persistentVolumeReclaimPolicy": "Delete" } }

1.11及以上版本集群样例:{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "labels": { "name": "pv-test" }, "name": "pv-test" }, "spec": { "accessModes": [ "ReadWriteMany" ], "flexVolume": { "driver": "huawei.com/fuxiobs", "fsType": "obs", "options": { "fsType": "obs", "region": "southchina", "volumeID": "76e01b29-08b9-11e8-9ca5-1051722006ec", "storageType": "obs" } }, "persistentVolumeReclaimPolicy": "Delete" } }

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 113

Page 124: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● 指定SFS Turbo极速文件存储ID创建PersistentVolume(不支持1.11版本之前的集群){ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "labels": { "name": "pv-test" }, "name": "pv-test" }, "spec": { "accessModes": [ "ReadWriteMany" ], "flexVolume": { "driver": "huawei.com/fuxiefs", "fsType": "efs", "options": { "fsType": "efs", "region": "southchina", "volumeID": "76e01b29-08b9-11e8-9ca5-1051722006ec", "storageType": "efs" } }, "persistentVolumeReclaimPolicy": "Delete" } }

响应消息

响应参数:

响应参数如表5-120所示。

响应示例:

{ "kind": "PersistentVolume", "apiVersion": "v1", "metadata": { "name": "pv-test", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumes/pv-test", "uid": "e174188f-ff21-11e7-855b-fa163eaf5675", "resourceVersion": "174229", "creationTimestamp": "2018-01-22T03:11:03Z", "labels": { "name": "pv-test" }, "enable": true }, "spec": { "capacity": { "storage": "1Gi" }, "accessModes": [ "ReadWriteMany" ], "flexVolume": { "driver": "huawei.com/fuxivol", "fsType": "ext4", "options": { "fsType": "ext4", "kubernetes.io/namespace": "default", "volumeID": "0781b22f-4d89-4e9c-b026-80e545cea16c" } },

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 114

Page 125: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"persistentVolumeReclaimPolicy": "Delete" }, "status": { "phase": "Pending" }}

状态码

表 3 状态码描述API的状态码。

表 5-126 状态码

状态码 描述

201 创建PersistentVolume作业下发成功。

5.2.4 删除 PersistentVolume

功能描述

该API用于删除指定Namespace下的PersistentVolume对象,并可以选择是否保留后端云存储。

URIDELETE /api/v1/cloudpersistentvolumes/{name}

表5-127描述该API的参数。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 115

Page 126: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-127 参数解释

参数 是否必选

描述

name 是 需要删除的PersistentVolume的名称

name格式为:Volume名称[?deleteVolume=BOOLEAN&storageType=云存储类型],中括号内可省略,示例:

● volume-49f1?deleteVolume=true&storageType=bs● volume-49f1其中:

● deleteVolume:删除PersistentVolume后是否保留后端关联的云存储。false表示不删除,ture表示删除,默认为false。

说明当为efs时,不支持删除存储,所以不能设为true。

● storageType:云存储的类型,和deleteVolume搭配使用。即deleteVolume和storageType必须同时配置。

– bs:EVS云存储

– nfs:SFS弹性文件存储

– obs:OBS对象存储

– efs:SFS Turbo极速文件存储

请求消息

请求参数:

请求参数如表5-128所示。

表 5-128 请求 Header 参数说明

参数 是否必选 描述

Content-Type 是 消息体的类型(格式),可任选其一使用。

● application/json;charset=utf-8● application/json

X-Auth-Token 使用token认证时必选

调用接口的一种认证方式,使用时需要获取token.

请求示例:

NA

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 116

Page 127: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数如表5-129所示。

表 5-129 参数描述

参数 是否必选 参数类型 描述

apiVersion 是 String API版本,固定值"v1"

kind 是 String API类型,固定值"PersistentVolume"

metadata 是 metadataobject

-

spec 是 spec object -

status 否 status object -

表 5-130 metadata 字段数据结构说明

参数 是否必选

参数类型 描述

name 是 String PersistentVolume名称,可以包含小写字母、数字、连字符和点,开头和结尾必须是字母或数字, 长253个字符,同一namespace下name不能重复。

labels 否 String PersistentVolume标签,key/value对格式。

● Key:必须以字母或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符;另外可以使用DNS子域作为前缀,例如example.com/my-key, DNS子域长253个字符。

● Value:可以为空或者非空字符串,非空字符串必须以字符或数字开头,可以包含字母、数字、连字符、下划线和点, 长63个字符。

示例:"foo": "bar"

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 117

Page 128: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-131 spec 字段数据结构说明

参数 是否必选 参数类型 描述

volumeName 否 String 绑定引用的PersistentVolume名称。

说明若“volumeID”配置为“是”,该字段取值无效。

accessModes 是 Array ofstrings

指定volume应该具有的访问模式。

● ReadWriteOnce:该卷可以被单个节点以读/写模式挂载

说明集群版本为v1.13.10且storage-driver版本为1.0.19时,才支持此功能。

● ReadOnlyMany:该卷可以被多个节点以只读模式挂载

● ReadWriteMany:该卷可以被多个节点以读/写模式挂载

表 5-132 status 字段数据结构说明

参数 是否必选 参数类型 描述

accessModes 否 Array ofstrings

显示volume实际具有的访问模式

capacity 否 Object 底层卷的实际存储空间大小,例:"storage": "1Gi"

phase 否 String PersistentVolume当前所处的状态,包括:

● Available(可用):还是空闲资源,没有被任何PVC绑定

● Bound(已绑定):卷已经被PVC绑定

● Released(已释放):之前绑定的PVC被删除,但是资源还未被集群重新声明

● Failed(失败):该卷的自动回收失败

响应示例:

{ "kind": "PersistentVolume", "apiVersion": "v1",

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 118

Page 129: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"metadata": { "name": "pv-test", "selfLink": "/api/v1/persistentvolumes/pv-test", "uid": "0d93181d-3628-11e7-9093-fa163e8c373b", "resourceVersion": "180886", "creationTimestamp": "2017-05-11T08:58:51Z", "labels": { "app": "test" } }, "spec": { "flexVolume": { "driver": "huawei.com/fuxivol", "fsType": "ext4", "options": { "fsType": "ext4", "kubernetes.io/namespace": "default", "volumeID": "0781b22f-4d89-4e9c-b026-80e545cea16c" } }, "capacity": { "storage": "1Gi" }, "accessModes": [ "ReadWriteMany" ], "persistentVolumeReclaimPolicy": "Delete" }, "status": { "phase": "Available" }}

状态码

表 3 状态码描述API的状态码。

表 5-133 状态码

状态码 描述

200 删除指定PersistentVolume作业下发成功。

5.3 插件管理

5.3.1 创建 AddonInstance

功能描述

根据提供的插件模板,安装插件实例。

URI

POST /api/v3/addons

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 119

Page 130: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数:

请求参数如表5-134所示。

表 5-134 请求 Header 参数

参数 是否必选

参数类型 描述

Content-Type

是 String 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

X-Auth-Token

是 String 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

表 5-135 请求 Body 参数

参数 是否必选 参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 是 Object 安装:固定值为{"addon.install/type":"install"}升级:固定值为{"addon.upgrade/type":"upgrade"}

spec 是 instancerequestspecobject

spec是集合类的元素类型,内容为插件实例安装/升级的具体请求信息。

表 5-136 instancerequestspec

参数 是否必选 参数类型 描述

version 是 String 待安装、升级插件的具体版本版本号,例如1.0.0

clusterID 是 String 集群id

values 是 Object 待安装或升级模板的具体请求参数,一般为配置文件,各插件不同

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 120

Page 131: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

addonTemplateName

是 String 待安装插件模板名称,如coredns

请求示例:

{ "apiVersion": "string", "kind": "string", "metadata": {}, "spec": { "clusterID": "string", "version": "string", "addonTemplateName": "string", "values": {} }}

响应消息

响应参数:

响应参数请参见表5-137。

表 5-137 响应 Body 参数

参数 是否必选 参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apiVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 否 metadataobject

基本信息,为集合类的元素类型,包含一组由不同名称定义的属性。

spec 是 instanceSpec object

spec是集合类的元素类型,内容为插件实例具体信息,实例的详细描述主体部分都在spec中给出。

status 是 statusobject

插件实例状态。

表 5-138 status

参数 是否必选

参数类型 描述

status 是 String 插件实例状态

reason 是 String 插件安装失败原因

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 121

Page 132: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

message 是 String 安装错误详情

targetVersions

是 Array ofstrings

此插件版本,支持升级的集群版本

currentVersion

是 versionsobject

当前插件实例使用的具体插件版本信息

表 5-139 versions

参数 是否必选 参数类型 描述

version 是 String 插件版本号

input 是 Object 插件安装参数

stable 是 Boolean 是否为稳定版本

translate 是 Object 供界面使用的翻译信息

supportVersions

是 Array ofsupportVersions objects

支持集群版本号

creationTimestamp

否 String 插件创建时间

updateTimestamp

是 String 插件更新时间

表 5-140 supportVersions

参数 是否必选 参数类型 描述

clusterType 是 String 支持的集群类型

clusterVersion

是 Array ofstrings

支持的集群版本(正则表达式)

表 5-141 instanceSpec

参数 是否必选 参数类型 描述

clusterID 是 String 集群id

version 是 String 插件模板版本号,如1.0.0

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 122

Page 133: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

addonTemplateName

是 String 插件模板名称,如coredns

addonTemplateType

是 String 插件模板类型

addonTemplateLabels

否 Array of strings 插件模板所属类型

description 是 String 插件模板描述

values 是 Object 插件模板安装参数(各插件不同)

表 5-142 metadata

参数 是否必选

参数类型 描述

uid 是 String 插件唯一id标识

name 是 String 插件名称

labels 否 Object 插件标签,key/value对格式

annotations 否 Object 插件注解,由key/value组成

updateTimestamp

是 String 插件更新时间

creationTimestamp

是 String 插件创建时间

响应示例:

● 状态码为 200 时{ "metadata":{ "uid":"24b23108-55c0-11e9-926f-0255ac101a31", "name":"gpu-beta", "creationTimestamp":"2019-04-03T03:25:34Z", "updateTimestamp":"2019-04-03T03:25:34Z" }, "apiVersion":"v3", "kind":"Addon", "spec":{ "addonTemplateName":"gpu-beta", "addonTemplateLogo":"", "addonTemplateType":"helm", "values":{ "basic":{ "rbac_enabled":true, "swr_user":"hwofficial", "swr_addr":"10.125.6.246:20202" } }, "description":"A device plugin for nvidia.com/gpu resource on nvidia driver",

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 123

Page 134: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"addonTemplateLabels":[ "Accelerator" ], "clusterID":"0c0e4a63-5539-11e9-95f7-0255ac10177e", "version":"1.0.0" }, "status":{ "message":"", "Reason":"", "currentVersion":{ "input":{ "basic":{ "swr_user":"hwofficial", "swr_addr":"10.125.6.246:20202" }, "parameters":{ } }, "stable":true, "creationTimestamp":"2018-10-23T13:14:55Z", "version":"1.0.0", "translate":{ "en_US":{ "addon":{ "changeLog":"A device plugin for nvidia.com/gpu resource on nvidia driver", "description":"A device plugin for nvidia.com/gpu resource on nvidia driver" } }, "zh_CN":{ "addon":{ "changeLog":"支持容器里使用GPU显卡的设备管理插件,仅支持nvidia驱动", "description":"支持容器里使用GPU显卡的设备管理插件,仅支持nvidia驱动" } } }, "updateTimestamp":"2018-12-07T09:40:24Z" }, "status":"installing" }}

● 状态码为 500 时{ "code":"SVCSTG.CCE-ADDONMGR.500", "message":"internal error"}

状态码

表 5-143 状态码

状态码 描述

200 OK

500 Internal Server Error

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 124

Page 135: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

错误码

表 5-144 错误码

错误码 描述 解决方法

400 Bad request -

401 Authenticate failed -

403 Unauthorized -

404 Addon template not exist -

500 Service internal error -

5.3.2 查询 AddonTemplates 信息

功能描述

插件模板查询接口,查询插件信息。

URI

GET /api/v3/addontemplates

表 5-145 Query 参数

参数 是否必选 参数类型 描述

addon_template_name

否 String 模板名称。

请求消息

请求参数:

请求参数如表5-146所示。

表 5-146 请求 Header 参数

参数 是否必选 参数类型 描述

Content-Type 是 String 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 125

Page 136: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

X-Auth-Token 是 String 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

响应消息

响应参数如表5-147所示。

表 5-147 响应 Body 参数

参数 是否必选 参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apiVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 是 String 基本信息,为集合类的元素类型,包含一组由不同名称定义的属性

items 是 Array ofaddontemplateobjects

插件模板列表

表 5-148 addontemplate

参数 是否必选 参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apiVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 是 metadataobject

基本信息,为集合类的元素类型,包含一组由不同名称定义的属性。

spec 是 templatespec object

spec是集合类的元素类型,内容为插件模板具体信息,插件模板的详细描述主体部分都在spec中给出。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 126

Page 137: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-149 templatespec

参数 是否必选 参数类型 描述

type 是 String 模板类型(helm,static)

labels 是 Array ofstrings

模板所属分组

logoURL 是 String Logo图片地址

readmeURL 是 String Logo图片地址

description 是 String 模板描述

versions 是 Array ofversionsobjects

模板具体版本详情

supportVersions

是 Array ofsupportVersions objects

支持集群版本号

creationTimestamp

是 String 模板创建时间

updateTimestamp

是 String 模板更新时间

表 5-150 supportVersions

参数 是否必选 参数类型 说明

clusterType 是 String 支持的集群类型

clusterVersion

是 Array ofstrings

支持的集群版本(正则表达式)

表 5-151 versions

参数 是否必选 参数类型 说明

version 是 String 插件版本号

input 是 Object 插件安装参数

stable 是 Boolean 是否为稳定版本

translate 是 Object 供界面使用的翻译信息

supportVersions

是 Array ofsupportVersions objects

支持集群版本号

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 127

Page 138: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 说明

creationTimestamp

否 String 插件创建时间

updateTimestamp

是 String 插件更新时间

表 5-152 supportVersions

参数 是否必选 参数类型 说明

clusterType

是 String 支持的集群类型

clusterVersion

是 Array ofstrings

支持的集群版本(正则表达式)

表 5-153 metadata

参数 是否必选 参数类型 描述

uid 是 String 插件唯一id标识

name 是 String 插件名称

labels 否 Object 插件标签,key/value对格式

annotations

否 Object 插件注解,由key/value组成

updateTimestamp

是 String 插件更新时间

creationTimestamp

是 String 插件创建时间

响应示例:

● 状态码为 200 时:{ "apiVersion": "v3", "kind": "Addon", "items": [ { "metadata": { "uid": "web-terminal", "name": "web-terminal", "creationTimestamp": "2019-01-07T13:22:48Z", "updateTimestamp": "2019-03-28T06:52:58Z" },

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 128

Page 139: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "v3", "kind": "Addon", "spec": { "readmeURL": "https://192.168.48.66/cce-addon-y24tcmvhzg1l/web-terminalcn-readme.md##https://192.168.48.66/cce-addon-zw4tcmvhzg1l/web-terminalen-readme.md", "versions": [ { "input": { "basic": { "swr_user": "hwofficial", "euleros_version": "2.2.5", "swr_addr": "10.125.6.246:20202" }, "parameters": { "flavor1": { "replicas": 1, "name": "Single", "description": "Has only one instance", "resources": [ { "limitsCpu": "200m", "name": "web-terminal", "limitsMem": "512Mi", "requestsMem": "256Mi", "requestsCpu": "100m" } ] }, "custom": { "password": "hwcloud_cce" } } }, "stable": true, "supportVersions": [ { "clusterType": "VirtualMachine", "clusterVersion": [ "v1.(9|11).*" ] }, { "clusterType": "BareMetal", "clusterVersion": [ "v1.(9|11).*" ] } ], "creationTimestamp": "2019-01-07T13:22:48Z", "version": "1.0.0", "translate": { "en_US": { "addon": { "changeLog": "none", "description": "A plug-in that allows users to run kubectl commands using a web browser." }, "description": { "Parameters.flavor1.name": "Single", "Parameters.flavor1.description": "Deploy with one instance" }, "key": { "Parameters.custom.password": "password" } }, "zh_CN": { "addon": { "changeLog": "", "description": ""

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 129

Page 140: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "description": { "Parameters.flavor1.name": "", "Parameters.flavor1.description": "" }, "key": { "Parameters.custom.password": "" } } }, "updateTimestamp": "2019-02-22T07:01:16Z" }, { "input": { "basic": { "rbac_enabled": true, "swr_user": "hwofficial", "euleros_version": "2.2.5", "swr_addr": "10.125.6.246:20202" }, "parameters": { "flavor1": { "replicas": 1, "name": "Single", "description": "Has only one instance", "resources": [ { "limitsCpu": "200m", "name": "web-terminal", "limitsMem": "512Mi", "requestsMem": "256Mi", "requestsCpu": "100m" } ] }, "custom": { "serviceType": "NodePort", "password": "hwcloud_cce", "loadBalancerIP": "127.0.0.1", "port": 3000, "elbID": 0, "elbClass": "union", "targetPort": 3000 } } }, "stable": true, "supportVersions": [ { "clusterType": "VirtualMachine", "clusterVersion": [ "v1.(9|11).*" ] }, { "clusterType": "BareMetal", "clusterVersion": [ "v1.(9|11).*" ] } ], "creationTimestamp": "2019-03-28T06:52:57Z", "version": "1.0.1", "translate": { "en_US": { "addon": { "changeLog": "1.include service creation 2.simplify operation 3.support access via elb", "description": "A plug-in that allows users to run kubectl commands using a

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 130

Page 141: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

web browser." }, "description": { "Parameters.custom.serviceType": "Service type for accessing web-terminal", "Parameters.flavor1.name": "Single", "Parameters.flavor1.description": "Deploy with one instance" }, "key": { "Parameters.custom.serviceType": "Access type" } }, "zh_CN": { "addon": { "changeLog": "", "description": "" }, "description": { "Parameters.custom.serviceType": "", "Parameters.flavor1.name": "", "Parameters.flavor1.description": "" }, "key": { "Parameters.custom.serviceType": "" } } }, "updateTimestamp": "2019-03-28T06:52:57Z" } ], "description": "A plug-in that allows users to run kubectl commands using a web browser.", "type": "helm", "logoURL": "https://192.168.48.66/cce-addon-southchina-aw1hz2u/web-terminallogo.svg", "labels": [ "Maintenance" ] } } ]

● 状态码为 500 时:{ "code":"SVCSTG.CCE-ADDONMGR.500", "message":"Internal error"}

状态码

表5-154描述API的状态码。

表 5-154 状态码

状态码 描述

200 OK

500 Internal Server Error

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 131

Page 142: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

错误码

表 5-155 错误码

错误码 描述 解决方法

400 Bad request -

401 Authenticate failed -

403 Unauthorized -

404 Addon template not exist -

500 Service internal error -

5.3.3 更新 AddonInstance

功能描述

更新插件实例的功能。

URI

PUT /api/v3/addons/{id}

表 5-156 路径参数

参数 是否必选 参数类型 描述

id 是 String 插件实例ID,获取方式请参见表5-196。

请求消息

请求参数:

请求参数如表5-157、表5-158所示。

表 5-157 请求 Header 参数

参数 是否必选 参数类型 描述

Content-Type

是 String 消息体的类型(格式),下方类型可任选其一使用:

● application/json;charset=utf-8● application/json

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 132

Page 143: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

X-Auth-Token

是 String 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

表 5-158 请求 Body 参数

参数 是否必选 参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apVersion

是 String API版本,固定值“v3”,该值不可修改。

metadata 是 Object 安装:固定值为{"addon.install/type":"install"}升级:固定值为{"addon.upgrade/type":"upgrade"}

spec 是 instancerequestspec object

spec是集合类的元素类型,内容为插件实例安装/升级的具体请求信息

表 5-159 instancerequestspec

参数 是否必选 参数类型 描述

version 是 String 待安装、升级插件的具体版本版本号,例如1.0.0

clusterID 是 String 集群id

values 是 Object 待安装或升级模板的具体请求参数,一般为配置文件,各插件不同

addonTemplateName

是 String 待安装插件模板名称,如coredns

请求示例:

{ "apiVersion": "string", "kind": "string", "metadata": {}, "spec": { "clusterID": "string", "version": "string", "addonTemplateName": "string", "values": {} }}

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 133

Page 144: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数如表5-160所示。

表 5-160 响应 Body 参数

参数 是否必选 参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apiVersion

是 String API版本,固定值“v3”,该值不可修改。

metadata 否 metadataobject

基本信息,为集合类的元素类型,包含一组由不同名称定义的属性

spec 是 instanceSpec object

spec是集合类的元素类型,内容为插件实例具体信息,实例的详细描述主体部分都在spec中给出

status 是 statusobject

插件实例状态

表 5-161 status

参数 是否必选 参数类型 描述

status 是 String 插件实例状态

reason 是 String 插件安装失败原因

message 是 String 安装错误详情

targetVersions

是 Array ofstrings

此插件版本,支持升级的集群版本

currentVersion

是 versionsobject

当前插件实例使用的具体插件版本信息

表 5-162 versions

参数 是否必选 参数类型 描述

version 是 String 插件版本号

input 是 Object 插件安装参数

stable 是 Boolean 是否为稳定版本

translate 是 Object 供界面使用的翻译信息

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 134

Page 145: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

supportVersions

是 Array ofsupportVersions objects

支持集群版本号

creationTimestamp

否 String 创建时间

updateTimestamp

是 String 更新时间

表 5-163 supportVersions

参数 是否必选

参数类型 描述

clusterType 是 String 支持的集群类型

clusterVersion

是 Array ofstrings

支持的集群版本(正则表达式)

表 5-164 instanceSpec

参数 是否必选 参数类型 描述

clusterID 是 String 集群id

version 是 String 插件模板版本号,如1.0.0

addonTemplateName

是 String 插件模板名称,如coredns

addonTemplateType

是 String 插件模板类型

addonTemplateLabels

否 Array ofstrings

插件模板所属类型

description 是 String 插件模板描述

values 是 Object 插件模板安装参数(各插件不同)

表 5-165 metadata

参数 是否必选 参数类型 描述

uid 是 String 唯一id标识

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 135

Page 146: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

name 是 String 插件名称

labels 否 Object 插件标签,key/value对格式

annotations 否 Object 插件注解,由key/value组成

updateTimestamp

是 String 更新时间

creationTimestamp

是 String 创建时间

响应示例:

● 状态码为 200 时{ "metadata": { "uid": "24b23108-55c0-11e9-926f-0255ac101a31", "name": "gpu-beta", "creationTimestamp": "2019-04-03T03:25:34Z", "updateTimestamp": "2019-04-03T03:25:34Z" }, "apiVersion": "v3", "kind": "Addon", "spec": { "addonTemplateName": "gpu-beta", "addonTemplateLogo": "", "addonTemplateType": "helm", "values": { "basic": { "rbac_enabled": true, "swr_user": "hwofficial", "swr_addr": "10.125.6.246:20202" } }, "description": "A device plugin for nvidia.com/gpu resource on nvidia driver", "addonTemplateLabels": [ "Accelerator" ], "clusterID": "0c0e4a63-5539-11e9-95f7-0255ac10177e", "version": "1.0.0" }, "status": { "message": "", "Reason": "", "currentVersion": { "input": { "basic": { "swr_user": "hwofficial", "swr_addr": "10.125.6.246:20202" }, "parameters": {} }, "stable": true, "creationTimestamp": "2018-10-23T13:14:55Z", "version": "1.0.0", "translate": { "en_US": { "addon": { "changeLog": "A device plugin for nvidia.com/gpu resource on nvidia driver", "description": "A device plugin for nvidia.com/gpu resource on nvidia driver" }

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 136

Page 147: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "zh_CN": { "addon": { "changeLog": "", "description": "" } } }, "updateTimestamp": "2018-12-07T09:40:24Z" }, "status": "installing" }}

● 状态码为 500 时{ "code":"SVCSTG.CCE-ADDONMGR.500", "message":"internal error"}

状态码

表 5-166 状态码

状态码 描述

200 OK

500 Internal Server Error

错误码

表 5-167 错误码

错误码 描述 解决方法

400 Bad request -

401 Authenticate failed -

403 Unauthorized -

404 Addon template not exist -

500 Service internal error -

5.3.4 删除 AddonInstance

功能描述

删除插件实例的功能。

URIDELETE /api/v3/addons/{id}?cluster_id={cluster_id}

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 137

Page 148: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-168 路径参数

参数 是否必选 参数类型 描述

cluster_id 是 String 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

id 是 String 插件实例ID,获取方式请参见表5-196。

请求消息

请求参数:

请求参数如表5-169、表5-170所示。

表 5-169 请求 Header 参数

参数 是否必选 参数类型 描述

Content-Type

是 String 消息体的类型(格式),下方类型可任选其一使用

● application/json;charset=utf-8● application/json

X-Auth-Token

是 String 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

表 5-170 请求 Body 参数

参数 是否必选 参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apiVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 是 metadataobject

基本信息,为集合类的元素类型,包含一组由不同名称定义的属性。

spec 是 templatespec object

spec是集合类的元素类型,内容为插件模板具体信息,插件模板的详细描述主体部分都在spec中给出。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 138

Page 149: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-171 templatespec

参数 是否必选 参数类型 描述

type 是 String 模板类型(helm,static)

labels 是 Array ofstrings

模板所属分组

logoURL 是 String Logo图片地址

readmeURL

是 String Logo图片地址

description 是 String 模板描述

versions 是 Array ofversionsobjects

模板具体版本详情

supportVersions

是 Array ofsupportVersionsobjects

支持集群版本号

creationTimestamp

是 String 创建时间

updateTimestamp

是 String 更新时间

表 5-172 supportVersions

参数 是否必选 参数类型 描述

clusterType

是 String 支持的集群类型

clusterVersion

是 Array ofstrings

支持的集群版本(正则表达式)

表 5-173 versions

参数 是否必选 参数类型 描述

version 是 String 插件版本号

input 是 Object 插件安装参数

stable 是 Boolean 是否为稳定版本

translate 是 Object 供界面使用的翻译信息

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 139

Page 150: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

supportVersions

是 Array ofsupportVersionsobjects

支持集群版本号

creationTimestamp

否 String 创建时间

updateTimestamp

是 String 更新时间

表 5-174 supportVersions

参数 是否必选 参数类型 描述

clusterType 是 String 支持的集群类型

clusterVersion

是 Array ofstrings

支持的集群版本(正则表达式)

表 5-175 metadata

参数 是否必选 参数类型 描述

uid 是 String 唯一id标识

name 是 String 插件名称

labels 否 Object 插件标签,key/value对格式

annotations 否 Object 插件注解,由key/value组成

updateTimestamp

是 String 更新时间

creationTimestamp

是 String 创建时间

请求示例:

{ "requesbody": { "kind": "string", "apiVersion": "string", "metadata": { "uid": "string", "name": "string", "labels": "object", "annotations": "object", "updateTimestamp": "string", "creationTimestamp": "string" },

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 140

Page 151: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"spec": { "type": "string", "labels": [ "string", "string" ], "logoURL": "string", "readmeURL": "string", "description": "string", "versions": [ { "version": "string", "input": {}, "stable": "boolean", "translate": "string" } ], "supportVersions": [ { "clusterType": "string", "clusterVersion": [ "string", "string" ] } ], "creationTimestamp": "string", "updateTimestamp": "string" }, "supportVersions": [ { "clusterType": "string", "clusterVersion": [ "string", "string" ] } ], "creationTimestamp": "string", "updateTimestamp": "string" }}

响应消息

响应参数:

NA

响应示例:

● 状态码为 200 时{ "string": "string"}

● 状态码为 500 时{ "code": "SVCSTG.CCE-ADDONMGR.500", "message": "internal error"}

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 141

Page 152: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表 5-176 状态码

状态码 描述

200 OK

500 Internal Server Error

错误码

表 5-177 错误码

错误码 描述 解决方法

400 Bad request -

401 Authenticate failed -

403 Unauthorized -

404 Addon template not exist -

500 Service internal error -

5.3.5 获取 AddonInstance 详情

功能描述

获取插件实例详情。

URIGET /api/v3/addons/{id}?cluster_id={cluster_id}

表 5-178 路径参数

参数 是否必选

参数类型 描述

cluster_id 是 String 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

id 是 String 插件实例ID,获取方式请参见表5-196。

请求消息

请求参数:

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 142

Page 153: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求参数如表5-179所示。

表 5-179 请求 Header 参数

参数 是否必选

参数类型 描述

Content-Type 是 String 消息体的类型(格式),下方类型可任选其一使用

● application/json;charset=utf-8● application/json

X-Auth-Token 是 String 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

响应消息

响应参数:

响应参数如表5-180所示。

表 5-180 响应 Body 参数

参数 是否必选 参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apiVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 否 metadata object

基本信息,为集合类的元素类型,包含一组由不同名称定义的属性。

spec 是 instanceSpecobject

spec是集合类的元素类型,内容为插件实例具体信息,实例的详细描述主体部分都在spec中给出。

status 是 statusobject

插件实例状态。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 143

Page 154: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-181 status

参数 是否必选 参数类型 描述

status 是 String 插件实例状态

reason 是 String 插件安装失败原因

message 是 String 安装错误详情

targetVersions

是 Array ofstrings

此插件版本,支持升级的集群版本

currentVersion

是 versionsobject

当前插件实例使用的具体插件版本信息

表 5-182 versions

参数 是否必选 参数类型 描述

version 是 String 插件版本号

input 是 Object 插件安装参数

stable 是 Boolean 是否为稳定版本

translate 是 Object 供界面使用的翻译信息

supportVersions

是 Array ofsupportVersionsobjects

支持集群版本号

creationTimestamp

否 String 创建时间

updateTimestamp

是 String 更新时间

表 5-183 supportVersions

参数 是否必选 参数类型 描述

clusterType

是 String 支持的集群类型

clusterVersion

是 Array ofstring

支持的集群版本(正则表达式)

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 144

Page 155: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-184 instanceSpec

参数 是否必选 参数类型

描述

clusterID 是 String 集群id

version 是 String 插件模板版本号,如1.0.0

addonTemplateName

是 String 插件模板名称,如coredns

addonTemplateType

是 String 插件模板类型

addonTemplateLabels

否 Array ofstrings

插件模板所属类型

description 是 String 插件模板描述

values 是 Object 插件模板安装参数(各插件不同)

表 5-185 metadata

参数 是否必选 参数类型 描述

uid 是 String 唯一id标识

name 是 String 插件名称

labels 否 Object 插件标签,key/value对格式

annotations 否 Object 插件注解,由key/value组成

updateTimestamp

是 String 更新时间

creationTimestamp

是 String 创建时间

响应示例:

● 状态码为 200 时{ "metadata": { "uid": "24b23108-55c0-11e9-926f-0255ac101a31", "name": "gpu-beta", "creationTimestamp": "2019-04-03T03:25:34Z", "updateTimestamp": "2019-04-03T03:25:34Z" }, "apiVersion": "v3", "kind": "Addon", "spec": { "addonTemplateName": "gpu-beta", "addonTemplateLogo": "", "addonTemplateType": "helm", "values": { "basic": {

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 145

Page 156: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"rbac_enabled": true, "swr_user": "hwofficial", "swr_addr": "10.125.6.246:20202" } }, "description": "A device plugin for nvidia.com/gpu resource on nvidia driver", "addonTemplateLabels": [ "Accelerator" ], "clusterID": "0c0e4a63-5539-11e9-95f7-0255ac10177e", "version": "1.0.0" }, "status": { "message": "", "Reason": "", "currentVersion": { "input": { "basic": { "swr_user": "hwofficial", "swr_addr": "10.125.6.246:20202" }, "parameters": {} }, "stable": true, "creationTimestamp": "2018-10-23T13:14:55Z", "version": "1.0.0", "translate": { "en_US": { "addon": { "changeLog": "A device plugin for nvidia.com/gpu resource on nvidia driver", "description": "A device plugin for nvidia.com/gpu resource on nvidia driver" } } }, "updateTimestamp": "2018-12-07T09:40:24Z" }, "status": "installing" }}

● 状态码为 500 时{ "code": "SVCSTG.CCE-ADDONMGR.500", "message": "internal error"}

状态码

表 5-186 状态码

状态码 描述

200 OK

500 Internal Server Error

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 146

Page 157: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

错误码

表 5-187 错误码

错误码 描述 解决方法

400 Bad request -

401 Authenticate failed -

403 Unauthorized -

404 Addon template not exist -

500 Service internal error -

5.3.6 获取 AddonInstance 列表

功能描述

获取集群所有已安装插件实例。

URI

GET /api/v3/addons?cluster_id={cluster_id}

表 5-188 路径参数

参数 是否必选

参数类型 描述

cluster_id 是 String 集群ID,获取方式请参见9.7 如何获取接口URI中参数。

请求参数

请求参数:

请求参数如表5-189所示。

表 5-189 请求 Header 参数

参数 是否必选 参数类型 描述

Content-Type 是 String 消息体的类型(格式),下方类型可任选其一使用

● application/json;charset=utf-8● application/json

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 147

Page 158: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

X-Auth-Token 是 String 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。

请求示例:

响应消息

响应参数:

响应参数如表5-190所示。

表 5-190 响应 Body 参数

参数 是否必选 参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apiVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 否 String 基本信息,为集合类的元素类型,包含一组由不同名称定义的属性

items 是 Array ofaddoninstanceobjects

插件实例列表

表 5-191 addoninstance

参数 是否必选

参数类型 描述

kind 是 String API类型,固定值“Addon”,该值不可修改。

apiVersion 是 String API版本,固定值“v3”,该值不可修改。

metadata 否 metadataobject

基本信息,为集合类的元素类型,包含一组由不同名称定义的属性。

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 148

Page 159: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

spec 是 instanceSpec object

spec是集合类的元素类型,内容为插件实例具体信息,实例的详细描述主体部分都在spec中给出。

status 是 statusobject

插件实例状态。

表 5-192 status

参数 是否必选 参数类型 描述

status 是 String 插件实例状态

reason 是 String 插件安装失败原因

message 是 String 安装错误详情

targetVersions 是 Array ofstrings

此插件版本,支持升级的集群版本

currentVersion 是 versionsobject

当前插件实例使用的具体插件版本信息

表 5-193 versions

参数 是否必选

参数类型 描述

version 是 String 插件版本号

input 是 Object 插件安装参数

stable 是 Boolean 是否为稳定版本

translate 是 Object 供界面使用的翻译信息

supportVersions

是 Array ofsupportVersionsobjects

支持集群版本号

creationTimestamp

否 String 创建时间

updateTimestamp

是 String 更新时间

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 149

Page 160: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 5-194 supportVersions

参数 是否必选

参数类型 描述

clusterType 是 String 支持的集群类型

clusterVersion 是 Array ofstrings

支持的集群版本(正则表达式)

表 5-195 instanceSpec

参数 是否必选

参数类型 描述

clusterID 是 String 集群id

version 是 String 插件模板版本号,如1.0.0

addonTemplateName

是 String 插件模板名称,如coredns

addonTemplateType

是 String 插件模板类型

addonTemplateLabels

否 Array ofstrings

插件模板所属类型

description 是 String 插件模板描述

values 是 Object 插件模板安装参数(各插件不同)

表 5-196 metadata

参数 是否必选

参数类型 描述

uid 是 String 唯一id标识

name 是 String 插件名称

labels 否 Object 插件标签,key/value对格式

annotations 否 Object 插件注解,由key/value组成

updateTimestamp

是 String 更新时间

creationTimestamp

是 String 创建时间

响应示例:

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 150

Page 161: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● 状态码为 200 时{ "apiVersion": "v3", "kind": "Addon", "items": [ { "metadata": { "uid": "8ca259cc-553b-11e9-926f-0255ac101a31", "name": "storage-driver", "creationTimestamp": "2019-04-02T11:36:26Z", "updateTimestamp": "2019-04-02T11:36:26Z" }, "apiVersion": "v3", "kind": "Addon", "spec": { "addonTemplateName": "storage-driver", "addonTemplateLogo": "https://192.168.48.66/cce-addon-aw1hz2u/storage-driverlogo.svg", "addonTemplateType": "helm", "values": { "flavor": { "replicas": 1 }, "basic": { "obs_url": "", "swr_user": "hwofficial", "euleros_version": "2.2.5", "addon_version": "1.0.10", "platform": "linux-amd64", "swr_addr": "10.125.6.246:20202" }, "parameters": {} }, "description": "A kubernetes FlexVolume Driver used to support cloud storage", "addonTemplateLabels": [ "Storage" ], "clusterID": "0c0e4a63-5539-11e9-95f7-0255ac10177e", "version": "1.0.10" }, "status": { "message": "", "Reason": "Install complete", "currentVersion": { "input": { "basic": { "obs_url": "", "swr_user": "hwofficial", "euleros_version": "2.2.5", "swr_addr": "10.125.6.246:20202" }, "parameters": {} }, "stable": true, "creationTimestamp": "2019-03-29T13:45:37Z", "version": "1.0.10", "translate": { "en_US": { "addon": { "changeLog": "The plug-in is upgraded to enhance the storage plug-in function.", "description": "A kubernetes FlexVolume Driver used to support cloud storage" } }, "zh_CN": { "addon": { "changeLog": "", "description": "" } }

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 151

Page 162: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "updateTimestamp": "2019-03-29T13:45:37Z" }, "status": "running" } } ]}

● 状态码为 500 时{ "code": "SVCSTG.CCE-ADDONMGR.500", "message": "internal error"}

状态码

表 5-197 状态码

状态码 描述

200 OK

500 Internal Server Error

错误码

表 5-198 错误码

错误码 描述 解决方法

400 Bad request -

401 Authenticate failed -

403 Unauthorized -

404 Addon template not exist -

500 Service internal error -

云容器引擎API 参考 5 API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 152

Page 163: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6 Kubernetes API

6.1 Node

6.1.1 获取指定的 Node

功能介绍

该API用于获取指定的Node。

URI

GET /api/v1/nodes/{name}

表6-1描述该API的参数。

表 6-1 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

name Yes IP of the Node.

exact No Should the export be exact.Exact export maintainscluster-specific fields like'Namespace'.

export No Should this value beexported. Export stripsfields that a user cannotspecify.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 153

Page 164: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-81。

响应示例:

{ "kind": "Node", "apiVersion": "v1", "metadata": { "name": "192.168.0.197", "namespace": "default", "selfLink": "/api/v1/namespaces/default/nodes/192.168.0.197", "uid": "868ecebc-dc8e-11e7-9c19-fa163e2d897b", "resourceVersion": "417841", "creationTimestamp": "2017-12-09T03:10:35Z", "labels": { "beta.kubernetes.io/arch": "amd64", "beta.kubernetes.io/os": "linux", "kubernetes.io/hostname": "192.168.0.197", "os.architecture": "amd64", "os.name": "EulerOS_2.0_SP2", "os.version": "3.10.0-327.44.58.35.x86_64", "supportContainer": "true" }, "annotations": { "alpha.kubernetes.io/provided-node-ip": "192.168.0.197", "node.alpha.kubernetes.io/ttl": "0" }, "enable": true }, "spec": { "externalID": "192.168.0.197", "loginSecret": {}, "schedulerHints": {} }, "status": { "capacity": { "cpu": "2", "memory": "3744212Ki", "pods": "110" }, "allocatable": { "cpu": "2", "memory": "3641812Ki", "pods": "110" }, "phase": "Running", "conditions": [ { "type": "OutOfDisk", "status": "False", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z", "reason": "KubeletHasSufficientDisk", "message": "kubelet has sufficient disk space available" }, { "type": "MemoryPressure", "status": "False", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 154

Page 165: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"reason": "KubeletHasSufficientMemory", "message": "kubelet has sufficient memory available" }, { "type": "NetworkCardNotFound", "status": "False", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z", "reason": "NetworkCardFound", "message": "network card has found" }, { "type": "DiskPressure", "status": "False", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z", "reason": "KubeletHasNoDiskPressure", "message": "kubelet has no disk pressure" }, { "type": "Ready", "status": "True", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z", "reason": "KubeletReady", "message": "kubelet is posting ready status" } ], "addresses": [ { "type": "InternalIP", "address": "192.168.0.197" }, { "type": "Hostname", "address": "192.168.0.197" }, { "type": "DataIP", "address": "192.168.0.197" } ], "daemonEndpoints": { "kubeletEndpoint": { "Port": 10250 } }, "nodeInfo": { "machineID": "6f7a744cc4094fea9ed9558f18f59093", "systemUUID": "E73BC002-0E0C-4166-8321-6FE46B5AD12D", "bootID": "747fd7db-1e6c-400b-a703-a1f43371f56f", "kernelVersion": "3.10.0-327.44.58.35.x86_64", "osImage": "EulerOS 2.0 (SP2)", "containerRuntimeVersion": "docker://1.11.2", "kubeletVersion": "v1.7.3-r13", "kubeProxyVersion": "v1.7.3-r13", "operatingSystem": "linux", "architecture": "amd64" }, "images": [ { "names": [ "canal-agent:2.5.T3.B020", "canal-agent:latest" ], "sizeBytes": 461728195 }, { "names": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 155

Page 166: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"cfe-kubedns-amd64:2.11.25" ], "sizeBytes": 334909612 }, { "names": [ "cfe-exechealthz-amd64:2.11.25" ], "sizeBytes": 326663593 }, { "names": [ "cfe-kube-dnsmasq-amd64:2.11.25" ], "sizeBytes": 325558483 }, { "names": [ "euleros:2.2.5" ], "sizeBytes": 288596478 }, { "names": [ "10.125.5.235:20202/test/apache-php:latest" ], "sizeBytes": 244663227 }, { "names": [ "10.125.5.235:20202/test/redis:latest", "10.125.5.235:20202/test/redis:v1" ], "sizeBytes": 109208225 }, { "names": [ "172.16.5.235:20202/test-01/mysql:v1" ], "sizeBytes": 108362139 }, { "names": [ "cfe-pause:2.11.25" ], "sizeBytes": 350164 } ], "nodeState": {}, "hostname": "node-v17.novalocal" }}

状态码

表6-2描述API的状态码。

表 6-2 状态码

状态码 描述

200 This operation succeeds, and a Noderesource object is returned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 156

Page 167: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.1.2 列出指定的 Node

功能介绍

This API is used to obtain a Node list.

URI

GET /api/v1/nodes

表6-3描述该API的参数。

表 6-3 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by theirlabels. Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

fieldSelector No A selector to restrict the list ofreturned objects by theirfields. Defaults to everything.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults tochanges from the beginning ofhistory.

timeoutSeconds No Timeout for the list/watch call.

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 157

Page 168: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "NodeList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/nodes", "resourceVersion": "153893" }, "items": [ { "metadata": { "name": "192.168.0.123", "namespace": "default", "selfLink": "/api/v1/namespaces/default/nodes/192.168.0.123", "uid": "8c7357aa-4ed8-11e8-ac4b-fa163e28d367", "resourceVersion": "153881", "creationTimestamp": "2018-05-03T13:47:41Z", "labels": { "beta.kubernetes.io/arch": "amd64", "beta.kubernetes.io/os": "linux", "failure-domain.beta.kubernetes.io/region": "southchina", "failure-domain.beta.kubernetes.io/zone": "az1.dc1", "kubernetes.io/availablezone": "az1.dc1", "kubernetes.io/hostname": "192.168.0.123", "os.architecture": "amd64", "os.name": "EulerOS_2.0_SP2", "os.version": "3.10.0-327.59.59.46.h38.x86_64", "supportContainer": "true" }, "annotations": { "alpha.kubernetes.io/provided-node-ip": "192.168.0.123", "node.alpha.kubernetes.io/ttl": "0" }, "enable": true }, "spec": { "externalID": "192.168.0.123", "loginSecret": {}, "schedulerHints": {} }, "status": { "capacity": { "alpha.kubernetes.io/nvidia-gpu": "0", "cpu": "2", "memory": "3744164Ki", "pods": "110" }, "allocatable": { "alpha.kubernetes.io/nvidia-gpu": "0", "cpu": "1930m", "memory": "2705828Ki", "pods": "110" }, "phase": "Running", # 1.13 及以上版本集群已经废弃,不会再返回此字段 "conditions": [ { "type": "OutOfDisk", "status": "False", "lastHeartbeatTime": "2018-05-04T07:38:14Z", "lastTransitionTime": "2018-05-03T13:47:41Z", "reason": "KubeletHasSufficientDisk", "message": "kubelet has sufficient disk space available"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 158

Page 169: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, { "type": "MemoryPressure", "status": "False", "lastHeartbeatTime": "2018-05-04T07:38:14Z", "lastTransitionTime": "2018-05-03T13:47:41Z", "reason": "KubeletHasSufficientMemory", "message": "kubelet has sufficient memory available" }, { "type": "NetworkCardNotFound", "status": "False", "lastHeartbeatTime": "2018-05-04T07:38:14Z", "lastTransitionTime": "2018-05-03T13:47:41Z", "reason": "NetworkCardFound", "message": "network card has found" }, { "type": "DiskPressure", "status": "False", "lastHeartbeatTime": "2018-05-04T07:38:14Z", "lastTransitionTime": "2018-05-03T13:47:41Z", "reason": "KubeletHasNoDiskPressure", "message": "kubelet has no disk pressure" }, { "type": "Ready", "status": "True", "lastHeartbeatTime": "2018-05-04T07:38:14Z", "lastTransitionTime": "2018-05-03T13:47:41Z", "reason": "KubeletReady", "message": "kubelet is posting ready status" } ], "addresses": [ { "type": "InternalIP", "address": "192.168.0.123" }, { "type": "Hostname", "address": "192.168.0.123" }, { "type": "DataIP", "address": "192.168.0.123" } ], "daemonEndpoints": { "kubeletEndpoint": { "Port": 10250 } }, "nodeInfo": { "machineID": "ca7caac8-f192-4a29-8ad5-64e287b39ea9", "systemUUID": "7D7F913C-6E32-44C4-BDAE-782D859E7A0B", "bootID": "1b89eab6-92f3-4352-9613-61c2edf6ee4b", "kernelVersion": "3.10.0-327.59.59.46.h38.x86_64", "osImage": "EulerOS 2.0 (SP2)", "containerRuntimeVersion": "docker://1.11.2", "kubeletVersion": "v1.7.3-CCE2.0.7-B003", "kubeProxyVersion": "v1.7.3-CCE2.0.7-B003", "operatingSystem": "linux", "architecture": "amd64" }, "images": [ { "names": [ "canal-agent:2.5.T8.B020",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 159

Page 170: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"canal-agent:latest" ], "sizeBytes": 479214058 }, { "names": [ "cfe-kubedns-amd64:3.7.6" ], "sizeBytes": 335112956 }, { "names": [ "cfe-exechealthz-amd64:3.7.6" ], "sizeBytes": 326813281 }, { "names": [ "cfe-kube-dnsmasq-amd64:3.7.6" ], "sizeBytes": 325716517 }, { "names": [ "euleros:2.2.5" ], "sizeBytes": 288596478 }, { "names": [ "10.125.5.235:20202/test/apache-php:latest" ], "sizeBytes": 244663227 }, { "names": [ "10.125.5.235:20202/test/redis:latest" ], "sizeBytes": 182837415 }, { "names": [ "10.125.5.235:20202/test/redis:v1" ], "sizeBytes": 109208225 }, { "names": [ "cfe-pause:3.7.6" ], "sizeBytes": 350164 } ], "nodeState": {}, "hostname": "wj53-64095.novalocal" } } ], "httpcode": 200, "header": { "Transfer-Encoding": "chunked", "X-Frame-Options": "SAMEORIGIN", "Strict-Transport-Security": "max-age=31536000; includeSubdomains;", "Server": "Web Server", "X-Content-Type-Options": "nosniff", "Connection": "keep-alive", "X-Download-Options": "noopen", "Set-Cookie": "937fe3f5c57648aa8fb270f46ce19b3d=WyIxODE0MTc3NzEwIl0; Expires=Sat, 05-May-18 07:38:19 GMT; Domain=192.145.50.250; Path=/; Secure; HttpOnly",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 160

Page 171: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"X-XSS-Protection": "1; mode=block;", "Date": "Fri, 04 May 2018 07:38:19 GMT", "Content-Type": "application/json" }}

状态码

表6-4描述API的状态码。

表 6-4 状态码

状态码 描述

200 This operation succeeds, and theJSONs of a group of Node objects arereturned.

异常状态码请参见9.3 状态码。

6.1.3 更新指定的 Node

功能介绍

This API is used to update the specified Node.

The following fields can be updated:

● metadata.selfLink● metadata.resourceVersion● metadata.creationTimestamp● metadata.name● metadata.namespace● metadata.labels

URIPATCH /api/v1/nodes/{name}

表6-5描述该API的参数。

表 6-5 参数解释

参数 是否必选 描述

name Yes name of the Job

namespace Yes object name and auth scope, such as for teamsand projects

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 161

Page 172: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json { "metadata": { "labels": { "node-12130306-key": "node-12130306-value" } }}

响应消息

响应参数:

响应参数的详细描述请参见表6-171。

响应示例:

{ "kind": "Node", "apiVersion": "v1", "metadata": { "name": "192.168.0.197", "namespace": "default", "selfLink": "/api/v1/namespaces/default/nodes/192.168.0.197", "uid": "868ecebc-dc8e-11e7-9c19-fa163e2d897b", "resourceVersion": "417845", "creationTimestamp": "2017-12-09T03:10:35Z", "labels": { "beta.kubernetes.io/arch": "amd64", "beta.kubernetes.io/os": "linux", "kubernetes.io/hostname": "192.168.0.197", "node-12130306-key": "node-12130306-value", "os.architecture": "amd64", "os.name": "EulerOS_2.0_SP2", "os.version": "3.10.0-327.44.58.35.x86_64", "supportContainer": "true" }, "annotations": { "alpha.kubernetes.io/provided-node-ip": "192.168.0.197", "node.alpha.kubernetes.io/ttl": "0" }, "enable": true }, "spec": { "externalID": "192.168.0.197", "loginSecret": {}, "schedulerHints": {} }, "status": { "capacity": { "cpu": "2", "memory": "3744212Ki", "pods": "110" }, "allocatable": { "cpu": "2", "memory": "3641812Ki", "pods": "110" }, "phase": "Running",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 162

Page 173: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"conditions": [ { "type": "OutOfDisk", "status": "False", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z", "reason": "KubeletHasSufficientDisk", "message": "kubelet has sufficient disk space available" }, { "type": "MemoryPressure", "status": "False", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z", "reason": "KubeletHasSufficientMemory", "message": "kubelet has sufficient memory available" }, { "type": "NetworkCardNotFound", "status": "False", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z", "reason": "NetworkCardFound", "message": "network card has found" }, { "type": "DiskPressure", "status": "False", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z", "reason": "KubeletHasNoDiskPressure", "message": "kubelet has no disk pressure" }, { "type": "Ready", "status": "True", "lastHeartbeatTime": "2017-12-13T03:05:57Z", "lastTransitionTime": "2017-12-09T03:10:35Z", "reason": "KubeletReady", "message": "kubelet is posting ready status" } ], "addresses": [ { "type": "InternalIP", "address": "192.168.0.197" }, { "type": "Hostname", "address": "192.168.0.197" }, { "type": "DataIP", "address": "192.168.0.197" } ], "daemonEndpoints": { "kubeletEndpoint": { "Port": 10250 } }, "nodeInfo": { "machineID": "6f7a744cc4094fea9ed9558f18f59093", "systemUUID": "E73BC002-0E0C-4166-8321-6FE46B5AD12D", "bootID": "747fd7db-1e6c-400b-a703-a1f43371f56f", "kernelVersion": "3.10.0-327.44.58.35.x86_64", "osImage": "EulerOS 2.0 (SP2)", "containerRuntimeVersion": "docker://1.11.2", "kubeletVersion": "v1.7.3-r13",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 163

Page 174: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"kubeProxyVersion": "v1.7.3-r13", "operatingSystem": "linux", "architecture": "amd64" }, "images": [ { "names": [ "canal-agent:2.5.T3.B020", "canal-agent:latest" ], "sizeBytes": 461728195 }, { "names": [ "cfe-kubedns-amd64:2.11.25" ], "sizeBytes": 334909612 }, { "names": [ "cfe-exechealthz-amd64:2.11.25" ], "sizeBytes": 326663593 }, { "names": [ "cfe-kube-dnsmasq-amd64:2.11.25" ], "sizeBytes": 325558483 }, { "names": [ "euleros:2.2.5" ], "sizeBytes": 288596478 }, { "names": [ "172.16.5.235:20202/test/apache-php:latest" ], "sizeBytes": 244663227 }, { "names": [ "172.16.5.235:20202/test/redis:latest", "172.16.5.235:20202/test/redis:v1" ], "sizeBytes": 109208225 }, { "names": [ "172.16.5.235:20202/lwx348993/mysql:v1" ], "sizeBytes": 108362139 }, { "names": [ "cfe-pause:2.11.25" ], "sizeBytes": 350164 } ], "nodeState": {}, "hostname": "node-v17.novalocal" }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 164

Page 175: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-6描述API的状态码。

表 6-6 状态码

状态码 描述

200 This operation succeeds, and a Noderesource object is returned.

异常状态码请参见9.3 状态码。

6.2 Namespace

6.2.1 创建 Namespace

功能介绍

该API用于创建一个Namespace。

URIPOST /api/v1/namespaces

表6-7 描述该API的参数。

表 6-7 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

请求消息

请求参数:

请求参数如表6-8所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 165

Page 176: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-8 参数描述

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isNamespace.

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

metadata Yes metadataobject

-

spec No spec object -

status No status object -

表 6-9 spec 字段数据结构说明

参数 是否必选 参数类型 描述

finalizers No Array ofstrings

Finalizers is an opaque list ofvalues that must be empty topermanently remove objectfrom storage.

表 6-10 status 字段数据结构说明

参数 是否必选 参数类型 描述

phase No String Phase is the current lifecyclephase of the namespace.

请求示例:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 166

Page 177: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "apiVersion":"v1", "kind": "Namespace", "metadata": { "name": "development", "labels": { "name": "development" } }, "spec": { "finalizers": ["kubernetes"] }, "status": { "phase": "Active" } }

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "development", "selfLink": "/api/v1/namespaces/development", "uid": "c98a9a98-595c-11e6-b444-286ed488fafe", "resourceVersion": "16578", "creationTimestamp": "2016-08-03T09:29:33Z", "labels": { "name": "development" } }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" } }

状态码

表6-11描述API的状态码。

表 6-11 状态码

状态码 描述

201 This operation succeeds, and aNamespace resource object isreturned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 167

Page 178: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.2.2 删除 Namespace

功能介绍

该API用于删除一个Namespace。

URI

DELETE /api/v1/namespaces/{name}

表6-12 描述该API的参数。

表 6-12 参数描述

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

name Yes Name of the Namespace.

gracePeriodSeconds No The duration in seconds beforethe object should be deleted.Value must be non-negativeinteger. The value zero indicatesdelete immediately. If this value isnil, the default grace period forthe specified type will be used.Defaults to a per object value ifnot specified. zero means deleteimmediately.

orphanDependents No Deprecated: please use thePropagationPolicy, this field willbe deprecated in 1.7. Should thedependent objects be orphaned. Iftrue/false, the "orphan" finalizerwill be added to/removed fromthe object's finalizers list. Eitherthis field or PropagationPolicymay be set, but not both.

propagationPolicy No Whether and how garbagecollection will be performed.Either this field orOrphanDependents may be set,but not both. The default policy isdecided by the existing finalizerset in the metadata.finalizers andthe resource-specific defaultpolicy.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 168

Page 179: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数:

请求参数如表6-13所示。

表 6-13 参数描述

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isDeleteOptions.

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

gracePeriodSeconds

No Integer The duration in secondsbefore the object should bedeleted. Value must be non-negative integer. The valuezero indicates deleteimmediately. If this value isnil, the default grace periodfor the specified type will beused. Defaults to a per objectvalue if not specified. zeromeans delete immediately.Value range of thisparameter: > 0.

preconditions No preconditions object

Must be fulfilled before adeletion is carried out. If notpossible, a 409 Conflict statuswill be returned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 169

Page 180: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

orphanDependents

No Boolean Should the dependent objectsbe orphaned. If true/false, the"orphan" finalizer will beadded to/removed from theobject's finalizers list.

propagationPolicy

No String Whether and how garbagecollection will be performed.Either this field orOrphanDependents may beset, but not both. The defaultpolicy is decided by theexisting finalizer set in themetadata.finalizers and theresource-specific defaultpolicy.

表 6-14 preconditions 字段数据结构说明

参数 是否必选 参数类型 描述

uid No String Specifies the target UID.

请求示例:

{ "kind": "DeleteOptions", "apiVersion": "v1", "gracePeriodSeconds": 10 }

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

{ "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "ry", "selfLink": "/api/v1/namespaces/ry", "uid": "3f585ca0-5a58-11e6-b444-286ed488fafe", "resourceVersion": "289585", "creationTimestamp": "2016-08-04T15:29:34Z", "deletionTimestamp": "2016-08-04T15:29:50Z", "labels": { "name": "development" } }, "spec": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 170

Page 181: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"finalizers": [ "kubernetes" ] }, "status": { "phase": "Terminating" } }

状态码

表6-15描述API的状态码。

表 6-15 状态码

状态码 描述

200 Delete a Namespace resource objectresuccessfully.

异常状态码请参见9.3 状态码。

6.2.3 获取指定的 Namespace

功能介绍

该API用于获取指定的Namespace的详细信息。

URI

GET /api/v1/namespaces/{name}

表6-16 描述该API的参数。

表 6-16 参数描述

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

name No Name must be unique within anamespace. Is required whencreating resources, although someresources may allow a client torequest the generation of anappropriate name automatically.Name is primarily intended forcreation idempotence andconfiguration definition. Cannot beupdated.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 171

Page 182: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

exact No Should the export be exact. Exactexport maintains cluster-specificfields like 'Namespace'.

export No Should this value be exported.Export strips fields that a user cannot specify.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "test", "selfLink": "/api/v1/namespaces/test", "uid": "00468bb2-fcef-11e7-9193-fa163ecdc4fd", "resourceVersion": "95092", "creationTimestamp": "2018-01-19T08:01:49Z", "labels": { "name": "test" }, "enable": true }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" }}

状态码

表6-17描述API的状态码。

表 6-17 状态码

状态码 描述

200 This operation succeeds, and aNamespace resource object isreturned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 172

Page 183: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.2.4 替换指定的 Namespace

功能介绍

该API用于替换指定的Namespace的部分信息。

其中以下字段支持更新:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.generateName

● metadata.annotations

URIPUT /api/v1/namespaces/{name}

表6-18 描述该API的参数。

表 6-18 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

name Yes Name of theNamespace.

请求消息

请求参数:

请求参数的详细描述请参见表6-8。

请求示例:

{ "apiVersion": "v1", "kind": "Namespace", "metadata": { "name": "test", "labels": { "name": "test" } }, "spec": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 173

Page 184: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" } }

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "test", "selfLink": "/api/v1/namespaces/test", "uid": "00468bb2-fcef-11e7-9193-fa163ecdc4fd", "resourceVersion": "95099", "creationTimestamp": "2018-01-19T08:01:49Z", "labels": { "name": "test" }, "annotations": { "test": "woil" }, "enable": true }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" }}

状态码

表6-19描述API的状态码。

表 6-19 状态码

状态码 描述

200 This operation succeeds, and aNamespace resource object isreturned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 174

Page 185: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.2.5 替换指定的 Namespace 的状态

功能介绍

该API用于更新指定Namespace的状态信息,即修改namespace对象status各字段的值。

当namespace.deletionTimestamp为空值时,phase只能配置为Active;

当namespace.deletionTimestamp不为空值时,phase只能配置为Terminating。

URIPUT /api/v1/namespaces/{name}/status

表6-20 描述该API的参数。

表 6-20 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

name Yes Name of theNamespace.

请求消息

请求参数:

请求参数的详细描述请参见表6-8。

请求示例:

{ "apiVersion": "v1", "kind": "Namespace", "metadata": { "name": "test", "labels": { "name": "test" } }, "spec": { "finalizers": [ "openshift.com/origin", "kubernetes" ] }, "status": { "phase": "Active" } }

响应消息

响应参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 175

Page 186: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "test", "selfLink": "/api/v1/namespaces/test/status", "uid": "00468bb2-fcef-11e7-9193-fa163ecdc4fd", "resourceVersion": "95099", "creationTimestamp": "2018-01-19T08:01:49Z", "labels": { "name": "test" }, "annotations": { "test": "woil" }, "enable": true }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Terminating" }}

状态码

表6-21描述API的状态码。

表 6-21 状态码

状态码 描述

200 This operation succeeds, and aNamespace resource object isreturned.

异常状态码请参见9.3 状态码。

6.2.6 替换指定的 Namespace 的 Finalize 值

功能介绍

该API用于替换指定Namespce的finalize的值。

URI

PUT /api/v1/namespaces/{name}/finalize

表6-22 描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 176

Page 187: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-22 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

name Yes Name of theNamespace.

请求消息

请求参数:

请求参数的详细描述请参见表6-8。

请求示例:

{ "apiVersion": "v1", "kind": "Namespace", "metadata": { "name": "test", "labels": { "name": "test" } }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" } }

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "test", "selfLink": "/api/v1/namespaces/test/finalize", "uid": "00468bb2-fcef-11e7-9193-fa163ecdc4fd", "resourceVersion": "95099", "creationTimestamp": "2018-01-19T08:01:49Z", "labels": { "name": "test" }, "annotations": { "test": "woil" }, "enable": true }, "spec": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 177

Page 188: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" }}

状态码

表6-23描述API的状态码。

表 6-23 状态码

状态码 描述

200 This operation succeeds, and aNamespace resource object isreturned.

异常状态码请参见9.3 状态码。

6.2.7 列出 Namespace

功能介绍

该API用于获取集群中所有Namespace的详细信息。

URI

GET /api/v1/namespaces

表6-24 描述该API的参数。

表 6-24 参数描述

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 178

Page 189: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

watch No Watch for changes to thedescribed resources and returnthem as a stream of add, update,and remove notifications. SpecifyresourceVersion.

resourceVersion No When specified with a watch call,shows changes that occur afterthat particular version of aresource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

请求消息

N/A

响应消息

响应参数:

响应参数如表6-25所示。

表 6-25 参数描述

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

metadata metadata object -

items Object Items is the list of Namespaceobjects in the list.具体请参见请求消息。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 179

Page 190: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-26 metadata 字段数据结构说明

参数 参数类型 描述

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treated asopaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

响应示例:

{ "kind": "NamespaceList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces", "resourceVersion": "594181" }, "items": [ { "metadata": { "name": "default", "selfLink": "/api/v1/namespaces/default", "uid": "90dd5244-5881-11e7-b5d7-fa163e08a2fd", "resourceVersion": "6", "creationTimestamp": "2017-06-24T02:05:16Z" }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" } }, { "metadata": { "name": "kube-system", "selfLink": "/api/v1/namespaces/kube-system", "uid": "9178fce6-5881-11e7-b5d7-fa163e08a2fd", "resourceVersion": "25", "creationTimestamp": "2017-06-24T02:05:17Z" }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" } }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 180

Page 191: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

]}

状态码

表6-27描述API的状态码。

表 6-27 状态码

状态码 描述

200 This operation succeeds, and a groupof Namespace resource objects isreturned.

异常状态码请参见9.3 状态码。

6.2.8 更新指定的 Namespace

功能介绍

该API用于更新指定Namespace部分信息。

其中以下字段支持更新:

● metadata.selfLink● metadata.resourceVersion● metadata.generation● metadata.creationTimestamp● metadata.deletionTimestamp● metadata.labels● metadata.generateName● metadata.annotations

URIPATCH /api/v1/namespaces/{name}

表6-28 描述该API的参数。

表 6-28 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

name Yes Name of theNamespace.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 181

Page 192: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/json-patch+json[ { "op": "add", "path": "/spec/finalizers/0", "value": "kubernetes" } ]

响应消息

响应参数:

响应参数的详细描述请参见请求消息

响应示例:

{ "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "helloworld", "selfLink": "/api/v1/namespaces/helloworld", "uid": "1298d13a-5d34-11e6-aeb9-286ed488fafe", "resourceVersion": "3043", "creationTimestamp": "2016-08-08T06:48:11Z" }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" } }

状态码

表6-29描述API的状态码。

表 6-29 状态码

状态码 描述

200 This operation succeeds, and aNamespace resource object isreturned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 182

Page 193: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.3 Resourcequotas

6.3.1 获取 Resourcequotas

功能介绍

list or watch objects of kind ResourceQuota.

URI

GET /api/v1/resourcequotas

表 6-30 Query 参数

参数 是否必须

参数类型 说明

continue 否 String The continue option should be setwhen retrieving more results from theserver. Since this value is server defined,clients may only use the continue valuefrom a previous query result withidentical query parameters (except forthe value of continue) and the servermay reject a continue value it does notrecognize. If the specified continuevalue is no longer valid whether due toexpiration (generally five to fifteenminutes) or a configuration change onthe server, the server will respond witha 410 ResourceExpired error togetherwith a continue token. If the clientneeds a consistent list, it must restarttheir list without the continue field.Otherwise, the client may send anotherlist request with the token receivedwith the 410 error, the server willrespond with a list starting from thenext key, but from the latest snapshot,which is inconsistent from the previouslist results - objects that are created,modified, or deleted after the first listrequest will be included in theresponse, as long as their keys are afterthe "next key". This field is notsupported when watch is true. Clientsmay start a watch from the lastresourceVersion value returned by theserver and not miss any modifications.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 183

Page 194: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必须

参数类型 说明

fieldSelector 否 String A selector to restrict the list of returnedobjects by their fields. Defaults toeverything.

includeUninitialized

否 Boolean If true, partially initialized resources areincluded in the response.

labelSelector 否 String A selector to restrict the list of returnedobjects by their labels. Defaults toeverything.

limit 否 Integer limit is a maximum number ofresponses to return for a list call. Ifmore items exist, the server will set the`continue` field on the list metadata toa value that can be used with the sameinitial query to retrieve the next set ofresults. Setting a limit may return fewerthan the requested amount of items(up to zero items) in the event allrequested objects are filtered out andclients should only use the presence ofthe continue field to determinewhether more results are available.Servers may choose not to support thelimit argument and will return all ofthe available results. If limit is specifiedand the continue field is empty, clientsmay assume that no more results areavailable. This field is not supported ifwatch is true. The server guaranteesthat the objects returned when usingcontinue will be identical to issuing asingle list call without a limit - that is,no objects created, modified, or deletedafter the first request is issued will beincluded in any subsequent continuedrequests. This is sometimes referred toas a consistent snapshot, and ensuresthat a client that is using limit toreceive smaller chunks of a very largeresult can ensure they see all possibleobjects. If objects are updated during achunked list the version of the objectthat was present at the time the firstlist result was calculated is returned.

pretty 否 Boolean If 'true', then the output is prettyprinted.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 184

Page 195: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必须

参数类型 说明

resourceVersion

否 String When specified with a watch call,shows changes that occur after thatparticular version of a resource.Defaults to changes from the beginningof history. When specified for list: - ifunset, then the result is returned fromremote storage based on quorum-readflag; - if it's 0, then we simply returnwhat we currently have in cache, noguarantee; - if set to non zero, then theresult is at least as fresh as given rv.

timeoutSeconds

否 Integer Timeout for the list/watch call. Thislimits the duration of the call,regardless of any activity or inactivity.

watch 否 Boolean Watch for changes to the describedresources and return them as a streamof add, update, and removenotifications. Specify resourceVersion.

请求参数

响应参数

状态码为 200 时:

表 6-31 响应 Body 参数

参数 参数类型 描述

apiVersion String APIVersion defines the versioned schema ofthis representation of an object. Servers shouldconvert recognized schemas to the latestinternal value, and may reject unrecognizedvalues. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

items io.k8s.api.core.v1.ResourceQuota object

Items is a list of ResourceQuota objects. Moreinfo: https://kubernetes.io/docs/concepts/policy/resource-quotas/

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 185

Page 196: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

kind String Kind is a string value representing the RESTresource this object represents. Servers mayinfer this from the endpoint the client submitsrequests to. Cannot be updated. In CamelCase.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

metadata io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta object

Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

表 6-32 io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta

参数 参数类型 描述

continue String continue may be set if the user set a limit onthe number of items returned, and indicatesthat the server has more data available. Thevalue is opaque and may be used to issueanother request to the endpoint that servedthis list to retrieve the next set of availableobjects. Continuing a list may not be possible ifthe server configuration has changed or morethan a few minutes have passed. TheresourceVersion field returned when using thiscontinue value will be identical to the value inthe first response.

resourceVersion

String String that identifies the server's internalversion of this object that can be used byclients to determine when objects havechanged. Value must be treated as opaque byclients and passed unmodified back to theserver. Populated by the system. Read-only.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency

selfLink String selfLink is a URL representing this object.Populated by the system. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 186

Page 197: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-33 io.k8s.api.core.v1.ResourceQuota

参数 参数类型 描述

apiVersion String APIVersion defines the versioned schema ofthis representation of an object. Servers shouldconvert recognized schemas to the latestinternal value, and may reject unrecognizedvalues. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

kind String Kind is a string value representing the RESTresource this object represents. Servers mayinfer this from the endpoint the client submitsrequests to. Cannot be updated. In CamelCase.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

metadata io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMetaobject

Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata

spec io.k8s.api.core.v1.ResourceQuotaSpecobject

Spec defines the desired quota. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status

status io.k8s.api.core.v1.ResourceQuotaStatusobject

Status defines the actual enforced quota andits current usage. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status

表 6-34 io.k8s.api.core.v1.ResourceQuotaStatus

参数 参数类型 描述

hard Object Hard is the set of enforced hard limits for eachnamed resource. More info: https://kubernetes.io/docs/concepts/policy/resource-quotas/

used Object Used is the current observed total usage of theresource in the namespace.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 187

Page 198: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-35 io.k8s.api.core.v1.ResourceQuotaSpec

参数 参数类型 描述

hard Object hard is the set of desired hard limits for eachnamed resource. More info: https://kubernetes.io/docs/concepts/policy/resource-quotas/

scopeSelector io.k8s.api.core.v1.ScopeSelector object

scopeSelector is also a collection of filters likescopes that must match each object tracked bya quota but expressed usingScopeSelectorOperator in combination withpossible values. For a resource to match, bothscopes AND scopeSelector (if specified in spec),must be matched.

scopes Array ofstrings

A collection of filters that must match eachobject tracked by a quota. If not specified, thequota matches all objects.

表 6-36 io.k8s.api.core.v1.ScopeSelector

参数 参数类型 描述

matchExpressions

io.k8s.api.core.v1.ScopedResourceSelectorRequirement object

A list of scope selector requirements by scopeof the resources.

表 6-37 io.k8s.api.core.v1.ScopedResourceSelectorRequirement

参数 参数类型 描述

operator String Represents a scope's relationship to a set ofvalues. Valid operators are In, NotIn, Exists,DoesNotExist.

scopeName String The name of the scope that the selectorapplies to.

values Array ofstrings

An array of string values. If the operator is Inor NotIn, the values array must be non-empty.If the operator is Exists or DoesNotExist, thevalues array must be empty. This array isreplaced during a strategic merge patch.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 188

Page 199: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-38 io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta

参数 参数类型 描述

annotations Object Annotations is an unstructured key value mapstored with a resource that may be set byexternal tools to store and retrieve arbitrarymetadata. They are not queryable and shouldbe preserved when modifying objects. Moreinfo: http://kubernetes.io/docs/user-guide/annotations

clusterName String The name of the cluster which the objectbelongs to. This is used to distinguish resourceswith same name and namespace in differentclusters. This field is not set anywhere rightnow and apiserver is going to ignore it if set increate or update request.

creationTimestamp

io.k8s.apimachinery.pkg.apis.meta.v1.Time object

Time is a wrapper around time.Time whichsupports correct marshaling to YAML andJSON. Wrappers are provided for many of thefactory methods that the time package offers.

deletionGracePeriodSeconds

Interger Number of seconds allowed for this object togracefully terminate before it will be removedfrom the system. Only set whendeletionTimestamp is also set. May only beshortened. Read-only.

deletionTimestamp

io.k8s.apimachinery.pkg.apis.meta.v1.Time object

Time is a wrapper around time.Time whichsupports correct marshaling to YAML andJSON. Wrappers are provided for many of thefactory methods that the time package offers.

enable Boolean Enable identify whether the resource isavailable

finalizers Array ofstrings

Must be empty before the object is deletedfrom the registry. Each entry is an identifier forthe responsible component that will removethe entry from the list. If thedeletionTimestamp of the object is non-nil,entries in this list can only be removed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 189

Page 200: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

generateName

String GenerateName is an optional prefix, used bythe server, to generate a unique name ONLY IFthe Name field has not been provided. If thisfield is used, the name returned to the clientwill be different than the name passed. Thisvalue will also be combined with a uniquesuffix. The provided value has the samevalidation rules as the Name field, and may betruncated by the length of the suffix requiredto make the value unique on the server.

If this field is specified and the generatedname exists, the server will NOT return a 409 -instead, it will either return 201 Created or 500with Reason ServerTimeout indicating a uniquename could not be found in the time allotted,and the client should retry (optionally after thetime indicated in the Retry-After header).

Applied only if Name is not specified. Moreinfo: https://git.k8s.io/community/contributors/devel/api-conventions.md#idempotency

generation Interger A sequence number representing a specificgeneration of the desired state. Populated bythe system. Read-only.

initializers io.k8s.apimachinery.pkg.apis.meta.v1.Initializersobject

An initializer is a controller which enforcessome system invariant at object creation time.This field is a list of initializers that have notyet acted on this object. If nil or empty, thisobject has been completely initialized.Otherwise, the object is considereduninitialized and is hidden (in list/watch andget calls) from clients that haven't explicitlyasked to observe uninitialized objects.

When an object is created, the system willpopulate this list with the current set ofinitializers. Only privileged users may set ormodify this list. Once it is empty, it may not bemodified further by any user.

labels Object Map of string keys and values that can be usedto organize and categorize (scope and select)objects. May match selectors of replicationcontrollers and services. More info: http://kubernetes.io/docs/user-guide/labels

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 190

Page 201: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

name String Name must be unique within a namespace. Isrequired when creating resources, althoughsome resources may allow a client to requestthe generation of an appropriate nameautomatically. Name is primarily intended forcreation idempotence and configurationdefinition. Cannot be updated. More info:http://kubernetes.io/docs/user-guide/identifiers#names

namespace String Namespace defines the space within eachname must be unique. An empty namespace isequivalent to the "default" namespace, but"default" is the canonical representation. Notall objects are required to be scoped to anamespace - the value of this field for thoseobjects will be empty.

Must be a DNS_LABEL. Cannot be updated.More info: http://kubernetes.io/docs/user-guide/namespaces

ownerReferences

io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReferenceobject

List of objects depended by this object. If ALLobjects in the list have been deleted, thisobject will be garbage collected. If this object ismanaged by a controller, then an entry in thislist will point to this controller, with thecontroller field set to true. There cannot bemore than one managing controller.

resourceVersion

String An opaque value that represents the internalversion of this object that can be used byclients to determine when objects havechanged. May be used for optimisticconcurrency, change detection, and the watchoperation on a resource or set of resources.Clients must treat these values as opaque andpassed unmodified back to the server. Theymay only be valid for a particular resource orset of resources.

Populated by the system. Read-only. Valuemust be treated as opaque by clients and .More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency

selfLink String SelfLink is a URL representing this object.Populated by the system. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 191

Page 202: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

uid String UID is the unique in time and space value forthis object. It is typically generated by theserver on successful creation of a resource andis not allowed to change on PUT operations.

Populated by the system. Read-only. More info:http://kubernetes.io/docs/user-guide/identifiers#uids

表 6-39 io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference

参数 参数类型 描述

apiVersion String API version of the referent.

blockOwnerDeletion

Boolean If true, AND if the owner has the"foregroundDeletion" finalizer, then the ownercannot be deleted from the key-value storeuntil this reference is removed. Defaults tofalse. To set this field, a user needs "delete"permission of the owner, otherwise 422(Unprocessable Entity) will be returned.

controller Boolean If true, this reference points to the managingcontroller.

kind String Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

name String Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names

uid String UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids

表 6-40 io.k8s.apimachinery.pkg.apis.meta.v1.Initializers

参数 参数类型 描述

pending io.k8s.apimachinery.pkg.apis.meta.v1.Initializer object

Pending is a list of initializers that mustexecute in order before this object is visible.When the last pending initializer is removed,and no failing result is set, the initializers structwill be set to nil and the object is considered asinitialized and visible to all clients.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 192

Page 203: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

result io.k8s.apimachinery.pkg.apis.meta.v1.Status object

If result is set with the Failure field, the objectwill be persisted to storage and then deleted,ensuring that other clients can observe thedeletion.

表 6-41 io.k8s.apimachinery.pkg.apis.meta.v1.Status

参数 参数类型 描述

apiVersion String APIVersion defines the versioned schema ofthis representation of an object. Servers shouldconvert recognized schemas to the latestinternal value, and may reject unrecognizedvalues. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

code Integer Suggested HTTP return code for this status, 0 ifnot set.

details io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetailsobject

Extended data associated with the reason.Each reason may define its own extendeddetails. This field is optional and the datareturned is not guaranteed to conform to anyschema except that defined by the reason type.

kind String Kind is a string value representing the RESTresource this object represents. Servers mayinfer this from the endpoint the client submitsrequests to. Cannot be updated. In CamelCase.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

message String A human-readable description of the status ofthis operation.

metadata io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta object

Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

reason String A machine-readable description of why thisoperation is in the "Failure" status. If this valueis empty there is no information available. AReason clarifies an HTTP status code but doesnot override it.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 193

Page 204: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

status String Status of the operation. One of: "Success" or"Failure". More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status

表 6-42 io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta

参数 参数类型 描述

continue String continue may be set if the user set a limit onthe number of items returned, and indicatesthat the server has more data available. Thevalue is opaque and may be used to issueanother request to the endpoint that servedthis list to retrieve the next set of availableobjects. Continuing a list may not be possible ifthe server configuration has changed or morethan a few minutes have passed. TheresourceVersion field returned when using thiscontinue value will be identical to the value inthe first response.

resourceVersion

String String that identifies the server's internalversion of this object that can be used byclients to determine when objects havechanged. Value must be treated as opaque byclients and passed unmodified back to theserver. Populated by the system. Read-only.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency

selfLink String selfLink is a URL representing this object.Populated by the system. Read-only.

表 6-43 io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails

参数 参数类型 描述

causes io.k8s.apimachinery.pkg.apis.meta.v1.StatusCauseobject

The Causes array includes more detailsassociated with the StatusReason failure. Notall StatusReasons may provide detailed causes.

group String The group attribute of the resource associatedwith the status StatusReason.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 194

Page 205: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

kind String The kind attribute of the resource associatedwith the status StatusReason. On someoperations may differ from the requestedresource Kind. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

name String The name attribute of the resource associatedwith the status StatusReason (when there is asingle name which can be described).

retryAfterSeconds

Integer If specified, the time in seconds before theoperation should be retried. Some errors mayindicate the client must take an alternateaction - for those errors this field may indicatehow long to wait before taking the alternateaction.

uid String UID of the resource. (when there is a singleresource which can be described). More info:http://kubernetes.io/docs/user-guide/identifiers#uids

表 6-44 io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause

参数 参数类型 描述

field String The field of the resource that has caused thiserror, as named by its JSON serialization. Mayinclude dot and postfix notation for nestedattributes. Arrays are zero-indexed. Fields mayappear more than once in an array of causesdue to fields having multiple errors. Optional.Examples:"name" - the field "name" on the currentresource"items[0].name" - the field "name" on the firstarray entry in "items"

message String A human-readable description of the cause ofthe error. This field may be presented as-is to areader.

reason String A machine-readable description of the cause ofthe error. If this value is empty there is noinformation available.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 195

Page 206: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-45 io.k8s.apimachinery.pkg.apis.meta.v1.Initializer

参数 参数类型 描述

name String name of the process that is responsible forinitializing this object.

请求示例

响应示例

状态码为 200 时:

{ "apiVersion": "v1", "items": [ { "apiVersion": "v1", "kind": "ResourceQuota", "metadata": { "creationTimestamp": "2019-07-03T07:59:50Z", "labels": { "app": "resourcequota" }, "name": "rq-test", "namespace": "default", "resourceVersion": "3718271", "selfLink": "/api/v1/namespaces/default/resourcequotas/rq-test", "uid": "886ac259-9d68-11e9-8d38-fa163eb8e88a" }, "spec": { "hard": { "configmaps": "20", "limits.cpu": "5", "limits.memory": "16Gi", "persistentvolumeclaims": "20", "pods": "50", "replicationcontrollers": "20", "requests.cpu": "500m", "requests.memory": "512Mi", "secrets": "20", "services": "50" } }, "status": { "hard": { "configmaps": "20", "limits.cpu": "5", "limits.memory": "16Gi", "persistentvolumeclaims": "20", "pods": "50", "replicationcontrollers": "20", "requests.cpu": "500m", "requests.memory": "512Mi", "secrets": "20", "services": "50" }, "used": { "configmaps": "1", "limits.cpu": "950m", "limits.memory": "2Gi", "persistentvolumeclaims": "5",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 196

Page 207: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"pods": "8", "replicationcontrollers": "0", "requests.cpu": "850m", "requests.memory": "1792Mi", "secrets": "5", "services": "2" } } } ], "kind": "List", "metadata": { "resourceVersion": "", "selfLink": "" }}

返回值

返回值 说明

200 OK

401 Unauthorized

错误码

6.4 Pod

6.4.1 创建 Pod

功能介绍

该API用于在指定Namespace下创建一个Pod对象。

URIPOST /api/v1/namespaces/{namespace}/pods

表6-46 描述该API的参数。

表 6-46 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 197

Page 208: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数:

请求参数的详细描述请参见表7-3。

请求示例:

{ "apiVersion": "v1", "kind": "Pod", "metadata": { "labels": { "name": "pod-test" }, "name": "pod-test" }, "spec": { "containers": [ { "image": "172.16.5.235:20202/test/nginx", "imagePullPolicy": "Always", "name": "test", "resources": { "requests": { "cpu": "100m" } } } ], "imagePullSecrets": [ { "name": "default-secret" } ], "restartPolicy": "Always" }}

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Pod", "apiVersion": "v1", "metadata": { "name": "pod-test", "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/pod-test", "uid": "8917ec2a-fc20-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "486125", "creationTimestamp": "2018-01-18T07:23:52Z", "labels": { "name": "pod-test" }, "enable": true }, "spec": { "volumes": [ { "name": "default-token-512lg", "secret": { "secretName": "default-token-512lg",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 198

Page 209: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"defaultMode": 384 } } ], "containers": [ { "name": "test", "image": "72.16.5.235:20202/test/nginx", "resources": { "requests": { "cpu": "100m" } }, "volumeMounts": [ { "name": "default-token-512lg", "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" } ], "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "serviceAccountName": "default", "serviceAccount": "default", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" }, "status": { "phase": "Pending", "qosClass": "Burstable" }}

状态码

表6-47描述API的状态码。

表 6-47 状态码

状态码 描述

201 This operation succeeds, and a Podresource object is returned.

异常状态码请参见9.3 状态码。

6.4.2 删除 Pod

功能介绍

该API用于删除指定Namespace下的某个Pod对象。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 199

Page 210: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URI

DELETE /api/v1/namespaces/{namespace}/pods/{name}

表6-48 描述该API的参数。

表 6-48 参数描述

名称 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

namespace Yes Object name and auth scope, suchas for teams and projects.

name Yes Name of the Pod.

gracePeriodSeconds No The duration in seconds before theobject should be deleted. Valuemust be non-negative integer. Thevalue zero indicates deleteimmediately. If this value is nil, thedefault grace period for thespecified type will be used.Defaults to a per object value ifnot specified. zero means deleteimmediately.

orphanDependents No Deprecated: please use thePropagationPolicy, this field will bedeprecated in 1.7. Should thedependent objects be orphaned. Iftrue/false, the "orphan" finalizerwill be added to/removed fromthe object's finalizers list. Eitherthis field or PropagationPolicy maybe set, but not both.

propagationPolicy No Whether and how garbagecollection will be performed. Eitherthis field or OrphanDependentsmay be set, but not both. Thedefault policy is decided by theexisting finalizer set in themetadata.finalizers and theresource-specific default policy.

请求消息

请求参数:

请求参数如表6-49所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 200

Page 211: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-49 参数描述

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isDeleteOptions.

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

gracePeriodSeconds

No Integer The duration in secondsbefore the object should bedeleted. Value must be non-negative integer. The valuezero indicates deleteimmediately. If this value isnil, the default grace periodfor the specified type will beused. Defaults to a per objectvalue if not specified. zeromeans delete immediately.Value range of thisparameter: > 0.

preconditions No preconditions object

Must be fulfilled before adeletion is carried out. If notpossible, a 409 Conflict statuswill be returned.

orphanDependents

No Boolean Should the dependent objectsbe orphaned. If true/false, the"orphan" finalizer will beadded to/removed from theobject's finalizers list.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 201

Page 212: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

propagationPolicy

No String Whether and how garbagecollection will be performed.Either this field orOrphanDependents may beset, but not both. The defaultpolicy is decided by theexisting finalizer set in themetadata.finalizers and theresource-specific defaultpolicy.

表 6-50 preconditions 字段数据结构说明

参数 是否必选 参数类型 描述

uid No String Specifies the target UID.

请求示例:

{ "kind": "DeleteOptions", "apiVersion": "v1", "gracePeriodSeconds": 10 }

响应消息

响应参数:

请求参数的详细描述请参见表6-443。

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "code": 200 }

状态码

表6-51描述API的状态码。

表 6-51 状态码

状态码 描述

200 Delete a Pod resource objectresuccessfully.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 202

Page 213: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.4.3 删除所有的 Pod

功能介绍

This API is used to delete collection of Pod.

URI

DELETE /api/v1/namespaces/{namespace}/pods

表6-52描述该API的参数。

表 6-52 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

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

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

Request

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 203

Page 214: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "PodList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/delns-12130306/pods", "resourceVersion": "419153" }, "items": [ { "metadata": { "name": "pod-del-12130306", "namespace": "delns-12130306", "selfLink": "/api/v1/namespaces/delns-12130306/pods/pod-del-12130306", "uid": "026331da-dfb4-11e7-9c19-fa163e2d897b", "resourceVersion": "419153", "creationTimestamp": "2017-12-13T03:16:28Z", "labels": { "cce/appgroup": "container" }, "annotations": { "kubernetes.io/availablezone": "" }, "enable": true }, "spec": { "volumes": [ { "name": "default-token-zx6gk", "secret": { "secretName": "default-token-zx6gk", "defaultMode": 384 } } ], "containers": [ { "name": "podcon-12130306", "image": "172.16.5.235:20202/test/redis:v1", "ports": [ { "name": "tcp", "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "volumeMounts": [ { "name": "default-token-zx6gk", "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" } ], "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 204

Page 215: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"serviceAccountName": "default", "serviceAccount": "default", "nodeName": "192.168.0.197", "securityContext": {}, "schedulerName": "default-scheduler" }, "status": { "phase": "Pending", "conditions": [ { "type": "Initialized", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2017-12-13T03:16:28Z" }, { "type": "Ready", "status": "False", "lastProbeTime": null, "lastTransitionTime": "2017-12-13T03:16:28Z", "reason": "ContainersNotReady", "message": "containers with unready status: [podcon-12130306]" }, { "type": "PodScheduled", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2017-12-13T03:16:28Z" } ], "hostIP": "192.168.0.197", "managementIP": "192.168.0.197", "startTime": "2017-12-13T03:16:28Z", "containerStatuses": [ { "name": "podcon-12130306", "state": { "waiting": { "reason": "ContainerCreating" } }, "lastState": {}, "ready": false, "restartCount": 0, "image": "172.16.5.235:20202/test/redis:v1", "imageID": "" } ], "qosClass": "BestEffort" } } ]}

状态码

表6-53描述API的状态码。

表 6-53 状态码

状态码 描述

200 Delete a DaemonSet resource objectsuccessfully.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 205

Page 216: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.4.4 获取指定的 Pod

功能介绍

该API用于获取指定Namespace下指定Pod的详细信息。

URIGET /api/v1/namespaces/{namespace}/pods/{name}

表6-54 描述该API的参数。

表 6-54 参数描述

名称 是否必选 描述

pretty No If 'true', then the output ispretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Pod.

exact No Should the export be exact.Exact export maintainscluster-specific fields like'Namespace'.

export No Should this value beexported. Export stripsfields that a user can notspecify.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-81。

响应示例:

{ "kind": "Pod", "apiVersion": "v1", "metadata": { "name": "hello-world", "namespace": "default",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 206

Page 217: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"selfLink": "/api/v1/namespaces/default/pods/hello-world", "uid": "1087023f-59ef-11e6-b444-286ed488fafe", "resourceVersion": "152187", "creationTimestamp": "2016-08-04T02:56:39Z", "labels": { "name": "brace" } }, "spec": { "volumes": [ { "name": "test", "emptyDir": {} }, { "name": "default-token-brnb9", "secret": { "secretName": "default-token-brnb9" } } ], "containers": [ { "name": "hello-world", "image": "test:v1", "env": [ { "name": "cy", "value": "cy" } ], "resources": {}, "volumeMounts": [ { "name": "test", "mountPath": "/tmp/foo" }, { "name": "default-token-brnb9", "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" } ], "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "serviceAccountName": "default", "serviceAccount": "default", "nodeName": "127.0.0.1", "securityContext": {} }, "status": { "phase": "Running", "conditions": [ { "type": "Ready", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2016-08-04T02:56:40Z" } ], "hostIP": "127.0.0.1", "podIP": "172.16.0.4", "startTime": "2016-08-04T02:56:39Z", "containerStatuses": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 207

Page 218: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "name": "hello-world", "state": { "running": { "startedAt": "2016-08-04T02:56:39Z" } }, "lastState": {}, "ready": true, "restartCount": 0, "image": "test:v1", "imageID": "docker://sha256:b38119b54befb956986a4f5fb6f6eb79c9a1a4d94bbb8ad5fee82f5c1175e5b9", "containerID": "docker://c1d60a8653c4df7362d330d6d9d7d630179a01ae64cc9b7aeae70369040e6d30" } ] } }

状态码

表6-55描述API的状态码。

表 6-55 状态码

状态码 描述

200 This operation succeeds, and a Podresource object is returned.

异常状态码请参见9.3 状态码。

6.4.5 替换指定的 Pod

功能介绍

该API用于替换指定Namespace下的一个Pod对象。

其中以下字段支持更新:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.clusterName

● metadata.generateName

● metadata.labels

● metadata.annotations

● spec.initContainers[*].image

● spec.containers[*].image

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 208

Page 219: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● spec.activeDeadlineSeconds

● spec.tolerations

其余部分不支持更新。

URIPUT /api/v1/namespaces/{namespace}/pods/{name}

表6-56 描述该API的参数。

表 6-56 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Pod.

请求消息

请求参数:

请求参数的详细描述请参见表7-81。

请求示例:

{ "kind": "Pod", "apiVersion": "v1", "metadata": { "name": "hello-world", "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/hello-world", "uid": "84973056-5d3b-11e6-aeb9-286ed488fafe", "resourceVersion": "3416", "creationTimestamp": "2016-08-08T07:41:29Z", "labels": { "name": "brace" } }, "spec": { "volumes": [ { "name": "test", "emptyDir": {} }, { "name": "default-token-test2", "secret": { "secretName": "default-token-test2" } } ], "containers": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 209

Page 220: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "name": "hello-world", "image": "beego:v1", "env": [ { "name": "cy", "value": "cy" } ], "resources": {}, "volumeMounts": [ { "name": "test", "mountPath": "/tmp/foo" }, { "name": "default-token-test2", "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" } ], "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "serviceAccountName": "default", "serviceAccount": "default", "nodeName": "127.0.0.1", "securityContext": {} }, "status": { "phase": "Running", "conditions": [ { "type": "Ready", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2016-08-08T07:41:29Z" } ], "hostIP": "127.0.0.1", "podIP": "172.16.0.4", "startTime": "2016-08-08T07:41:29Z", "containerStatuses": [ { "name": "hello-world", "state": { "running": { "startedAt": "2016-08-08T07:41:29Z" } }, "lastState": {}, "ready": true, "restartCount": 0, "image": "test:v1", "imageID": "docker://sha256:b38119b54befb956986a4f5fb6f6eb79c9a1a4d94bbb8ad5fee82f5c1175e5b9", "containerID": "docker://ca6e4e70a4617701e3ef95f44426503d171ed23305a9de61e0198baa58822902" } ] } }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 210

Page 221: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Pod", "apiVersion": "v1", "metadata": { "name": "hello-world", "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/hello-world", "uid": "84973056-5d3b-11e6-aeb9-286ed488fafe", "resourceVersion": "3472", "creationTimestamp": "2016-08-08T07:41:29Z", "labels": { "name": "brace" } }, "spec": { "volumes": [ { "name": "test", "emptyDir": {} }, { "name": "default-token-test2", "secret": { "secretName": "default-token-test2" } } ], "containers": [ { "name": "hello-world", "image": "beego:v1", "env": [ { "name": "cy", "value": "cy" } ], "resources": {}, "volumeMounts": [ { "name": "test", "mountPath": "/tmp/foo" }, { "name": "default-token-test2", "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" } ], "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "serviceAccountName": "default", "serviceAccount": "default", "nodeName": "127.0.0.1", "securityContext": {} },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 211

Page 222: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"status": { "phase": "Running", "conditions": [ { "type": "Ready", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2016-08-08T07:41:29Z" } ], "hostIP": "127.0.0.1", "podIP": "172.16.0.4", "startTime": "2016-08-08T07:41:29Z", "containerStatuses": [ { "name": "hello-world", "state": { "running": { "startedAt": "2016-08-08T07:41:29Z" } }, "lastState": {}, "ready": true, "restartCount": 0, "image": "test:v1", "imageID": "docker://sha256:b38119b54befb956986a4f5fb6f6eb79c9a1a4d94bbb8ad5fee82f5c1175e5b9", "containerID": "docker://ca6e4e70a4617701e3ef95f44426503d171ed23305a9de61e0198baa58822902" } ] } }

状态码

表6-57描述API的状态码。

表 6-57 状态码

状态码 描述

200 This operation succeeds, and the JSONof a Pod object is returned.

异常状态码请参见9.3 状态码。

6.4.6 替换指定的 Pod 的状态

功能介绍

该API用于替换指定Namespace下的一个Pod对象的status,即修改Pod对象status各字段的值。

URIPUT /api/v1/namespaces/{namespace}/pods/{name}/status

表6-58 描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 212

Page 223: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-58 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Pod.

请求消息

请求参数:

请求参数的详细描述请参见表7-81。

请求示例:

{ "kind": "Pod", "apiVersion": "v1", "metadata": { "name": "hello-world", "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/hello-world", "uid": "84973056-5d3b-11e6-aeb9-286ed488fafe", "resourceVersion": "3636", "creationTimestamp": "2016-08-08T07:41:29Z", "labels": { "name": "brace" } }, "status": { "phase": "Running", "conditions": [ { "type": "Ready", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2016-08-08T07:41:29Z" } ], "hostIP": "127.0.0.1", "podIP": "172.16.0.4", "startTime": "2016-08-08T07:41:29Z" } }

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Pod", "apiVersion": "v1",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 213

Page 224: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"metadata": { "name": "hello-world", "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/hello-world/status", "uid": "84973056-5d3b-11e6-aeb9-286ed488fafe", "resourceVersion": "3641", "creationTimestamp": "2016-08-08T07:41:29Z", "labels": { "name": "brace" } }, "spec": { "volumes": [ { "name": "test", "emptyDir": {} }, { "name": "default-token-test2", "secret": { "secretName": "default-token-test2" } } ], "containers": [ { "name": "hello-world", "image": "beego:v1", "env": [ { "name": "cy", "value": "cy" } ], "resources": {}, "volumeMounts": [ { "name": "test", "mountPath": "/tmp/foo" }, { "name": "default-token-test2", "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" } ], "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "serviceAccountName": "default", "serviceAccount": "default", "nodeName": "127.0.0.1", "securityContext": {} }, "status": { "phase": "Running", "conditions": [ { "type": "Ready", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2016-08-08T07:41:29Z" } ], "hostIP": "127.0.0.1",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 214

Page 225: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"podIP": "172.16.0.4", "startTime": "2016-08-08T07:41:29Z" } }

状态码

表6-59描述API的状态码。

表 6-59 状态码

状态码 描述

200 This operation succeeds, and the JSONof a Pod object is returned.

异常状态码请参见9.3 状态码。

6.4.7 列出指定 Namespaces 下的所有 Pod

功能介绍

该API用于列出指定Namespaces下面的所有Pod资源对象。

URIGET /api/v1/namespaces/{namespace}/pods

表6-60 描述该API的参数。

表 6-60 参数描述

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 215

Page 226: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "PodList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/pods", "resourceVersion": "1550921" }, "items": [ { "metadata": { "name": "fdsfsd-ddnft", "generateName": "fdsfsd-", "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/fdsfsd-ddnft", "uid": "753a45bc-57c4-11e7-afb7-fa163e218692", "resourceVersion": "1449034", "creationTimestamp": "2017-06-23T03:31:35Z", "labels": { "cce/appgroup": "gfsad", "name": "fdsfsd" }, "annotations": { "kubernetes.io/created-by": "{\"kind\":\"SerializedReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"ReplicationController\",\"namespace\":\"default\",\"name\":\"fdsfsd\",\"uid\":\"7539c329-57c4-11e7-afb7-fa163e218692\",\"apiVersion\":\"v1\",\"resourceVersion\":\"956153\"}}\n", "kubernetes.io/limit-ranger": "LimitRanger plugin set: cpu request for container container01" }, "ownerReferences": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 216

Page 227: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "apiVersion": "v1", "kind": "ReplicationController", "name": "fdsfsd", "uid": "7539c329-57c4-11e7-afb7-fa163e218692", "controller": true } ] }, "spec": { "volumes": [ { "name": "default-token-863rh", "secret": { "secretName": "default-token-863rh", "defaultMode": 420 } } ], "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/apache-php:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": { "requests": { "cpu": "100m" } }, "volumeMounts": [ { "name": "default-token-863rh", "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" } ], "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "serviceAccountName": "default", "serviceAccount": "default", "nodeName": "192.168.12.187", "securityContext": {}, "imagePullSecrets": [ { "name": "myregistry" } ] }, "status": { "phase": "Running", "conditions": [ { "type": "Initialized", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2017-06-23T03:31:36Z" }, { "type": "Ready",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 217

Page 228: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"status": "True", "lastProbeTime": null, "lastTransitionTime": "2017-06-28T06:34:51Z" }, { "type": "PodScheduled", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2017-06-23T03:31:35Z" } ], "hostIP": "192.168.12.187", "podIP": "172.16.56.4", "startTime": "2017-06-23T03:31:36Z", "containerStatuses": [ { "name": "container01", "state": { "running": { "startedAt": "2017-06-28T06:34:46Z" } }, "lastState": {}, "ready": true, "restartCount": 0, "image": "10.154.52.159:443/test/apache-php:latest", "imageID": "docker://sha256:2e233ad9329bd7f65572dd6acb1a03e8839c36abfdb1d1f9012d84d13cecf9fc", "containerID": "docker://f3daa802f753d123fe66b2cba2e917725702f8d446c17541822a68f9d2414c6d" } ] } } ]}

状态码

表6-61描述API的状态码。

表 6-61 状态码

状态码 描述

200 This operation succeeds, and a groupof Pod resource objects is returned.

异常状态码请参见9.3 状态码。

6.4.8 列出 Pod

功能介绍

该API用于获取一个Pod列表。

URI

GET /api/v1/pods

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 218

Page 229: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表6-62 描述该API的参数。

表 6-62 参数描述

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by theirlabels. Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

fieldSelector No A selector to restrict the list ofreturned objects by theirfields. Defaults to everything.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults tochanges from the beginning ofhistory.

timeoutSeconds No Timeout for the list/watch call.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "PodList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/pods", "resourceVersion": "1550321" },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 219

Page 230: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"items": [ { "metadata": { "name": "fdsfsd-ddnft", "generateName": "fdsfsd-", "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/fdsfsd-ddnft", "uid": "753a45bc-57c4-11e7-afb7-fa163e218692", "resourceVersion": "1449034", "creationTimestamp": "2017-06-23T03:31:35Z", "labels": { "cce/appgroup": "gfsad", "name": "fdsfsd" }, "annotations": { "kubernetes.io/created-by": "{\"kind\":\"SerializedReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"ReplicationController\",\"namespace\":\"default\",\"name\":\"fdsfsd\",\"uid\":\"7539c329-57c4-11e7-afb7-fa163e218692\",\"apiVersion\":\"v1\",\"resourceVersion\":\"956153\"}}\n", "kubernetes.io/limit-ranger": "LimitRanger plugin set: cpu request for container container01" }, "ownerReferences": [ { "apiVersion": "v1", "kind": "ReplicationController", "name": "fdsfsd", "uid": "7539c329-57c4-11e7-afb7-fa163e218692", "controller": true } ] }, "spec": { "volumes": [ { "name": "default-token-863rh", "secret": { "secretName": "default-token-863rh", "defaultMode": 420 } } ], "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/apache-php:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": { "requests": { "cpu": "100m" } }, "volumeMounts": [ { "name": "default-token-863rh", "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" } ], "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 220

Page 231: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"serviceAccountName": "default", "serviceAccount": "default", "nodeName": "192.168.12.187", "securityContext": {}, "imagePullSecrets": [ { "name": "myregistry" } ] }, "status": { "phase": "Running", "conditions": [ { "type": "Initialized", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2017-06-23T03:31:36Z" }, { "type": "Ready", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2017-06-28T06:34:51Z" }, { "type": "PodScheduled", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2017-06-23T03:31:35Z" } ], "hostIP": "192.168.12.187", "podIP": "172.16.56.4", "startTime": "2017-06-23T03:31:36Z", "containerStatuses": [ { "name": "container01", "state": { "running": { "startedAt": "2017-06-28T06:34:46Z" } }, "lastState": {}, "ready": true, "restartCount": 0, "image": "10.154.52.159:443/test/apache-php:latest", "imageID": "docker://sha256:2e233ad9329bd7f65572dd6acb1a03e8839c36abfdb1d1f9012d84d13cecf9fc", "containerID": "docker://f3daa802f753d123fe66b2cba2e917725702f8d446c17541822a68f9d2414c6d" } ] } } ]}

状态码

表6-63描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 221

Page 232: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-63 状态码

状态码 描述

200 This operation succeeds, and theJSONs of a group of Pod objects arereturned.

异常状态码请参见9.3 状态码。

6.4.9 更新指定的 Pod

功能介绍

该API用于更新指定Namespace下一个Pod对象。

其中以下字段支持更新:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.clusterName

● metadata.generateName

● metadata.labels

● metadata.annotations

● spec.initContainers[*].image

● spec.containers[*].image

● spec.activeDeadlineSeconds

● spec.tolerations

其余部分不支持更新。

URI

PATCH /api/v1/namespaces/{namespace}/pods/{name}

表6-64 描述该API的参数。

表 6-64 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 222

Page 233: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Pod.

请求消息

请求参数:

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/json-patch+json[ { "op": "add", "path": "/spec/containers/0/image", "value": "busybox:latest" } ]

响应消息

响应参数:

响应参数的详细描述请参见表7-81。

响应示例:

{ "kind": "Pod", "apiVersion": "v1", "metadata": { "name": "hello-world", "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/hello-world", "uid": "b4b50f8d-5d0e-11e6-aeb9-286ed488fafe", "resourceVersion": "1638", "creationTimestamp": "2016-08-08T02:20:42Z", "labels": { "name": "brace" } }, "spec": { "volumes": [ { "name": "test", "emptyDir": {} }, { "name": "default-token-test2", "secret": { "secretName": "default-token-test2" } } ], "containers": [ { "name": "hello-world",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 223

Page 234: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"image": "busybox:latest", "env": [ { "name": "cy", "value": "cy" } ], "resources": {}, "volumeMounts": [ { "name": "test", "mountPath": "/tmp/foo" }, { "name": "default-token-test2", "readOnly": true, "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" } ], "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "serviceAccountName": "default", "serviceAccount": "default", "nodeName": "127.0.0.1", "securityContext": {} }, "status": { "phase": "Running", "conditions": [ { "type": "Ready", "status": "False", "lastProbeTime": null, "lastTransitionTime": "2016-08-08T02:20:44Z", "reason": "ContainersNotReady", "message": "containers with unready status: [hello-world]" } ], "hostIP": "127.0.0.1", "podIP": "172.16.0.4", "startTime": "2016-08-08T02:20:42Z", "containerStatuses": [ { "name": "hello-world", "state": { "waiting": { "reason": "CrashLoopBackOff", "message": "Back-off 5m0s restarting failed container=hello-world pod=hello-world_default(b4b50f8d-5d0e-11e6-aeb9-286ed488fafe)" } }, "lastState": { "terminated": { "exitCode": 0, "reason": "Completed", "startedAt": "2016-08-08T03:38:17Z", "finishedAt": "2016-08-08T03:38:17Z", "containerID": "docker://601ce41bd6cafd403ed30d0beb3d27573c74d0207818b973f42268b37051627c" } }, "ready": false, "restartCount": 24, "image": "busybox:latest",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 224

Page 235: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"imageID": "docker://sha256:2b8fd9751c4c0f5dd266fcae00707e67a2545ef34f9a29354585f93dac906749", "containerID": "docker://601ce41bd6cafd403ed30d0beb3d27573c74d0207818b973f42268b37051627c" } ] } }

状态码

表6-65描述API的状态码。

表 6-65 状态码

状态码 描述

200 This operation succeeds, and the JSONof a Pod object is returned.

异常状态码请参见9.3 状态码。

6.5 Deployment

6.5.1 创建 Deployment

功能介绍

该API用于创建一个Deployment资源对象。

如果要将创建的Deployment对象在CCE工作负载界面上正常显示,则必须给创建的Deployment资源对象添加labels标签。

设置请求消息体中的“metadata.labels”参数键值示例如下:

labels: app: deploymentname

其中:

● 同命名空间下,deploymentname名称不要重复

● deploymentname为显示在CCE工作负载界面上的工作负载名称,需要和metadata.name的值保持一致。且“metadata.labels.app”、“spec.selector.matchLabels.app”、“spec.template.metadata.labels.app”的值要和deploymentname的值同步。可参考请求示例。

URI

POST /apis/apps/v1/namespaces/{namespace}/deployments (Supports only1.9)

POST /apis/apps/v1beta1/namespaces/{namespace}/deployments (Supportsonly1.7)

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 225

Page 236: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

POST /apis/extensions/v1beta1/namespaces/{namespace}/deployments(Compatible)

表6-66描述该API的参数。

表 6-66 参数描述

参数 是否必选 描述

namespace Yes object name and auth scope, such as forteams and projects

pretty No If 'true', then the output is prettyprinted.

请求消息

请求参数:

请求参数如表6-67所示。

表 6-67 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines the versionedschema of this representation of anobject. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind Yes String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the client submitsrequests to. Cannot be updated. InCamelCase.

metadata Yes metadataobject

Standard object metadata.

spec Yes spec object Specification of the desired behaviorof the Deployment.

status No status object Most recently observed status of theDeployment.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 226

Page 237: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-68 spec 字段数据结构说明

参数 是否必选 参数类型 描述

minReadySeconds

No Integer Minimum number of seconds forwhich a newly created pod should beready without any of its containercrashing, for it to be consideredavailable. Defaults to 0 (pod will beconsidered available as soon as it isready)

paused No Boolean Indicates that the deployment ispaused.

progressDeadlineSeconds

No Integer The maximum time in seconds for adeployment to make progress beforeit is considered to be failed. Thedeployment controller will continueto process failed deployments and acondition with aProgressDeadlineExceeded reasonwill be surfaced in the deploymentstatus. Once autoRollback isimplemented, the deploymentcontroller will automatically rollbackfailed deployments. Note thatprogress will not be estimated duringthe time a deployment is paused.Defaults to 600s.

replicas No Integer Number of desired pods. This is apointer to distinguish betweenexplicit zero and not specified.Defaults to 1.

revisionHistoryLimit

No Integer The number of old ReplicaSets toretain to allow rollback. This is apointer to distinguish betweenexplicit zero and not specified.Defaults to 2.

selector No selectorobject

Label selector for pods. ExistingReplicaSets whose pods are selectedby this will be the ones affected bythis deployment.

strategy No strategyobject

The deployment strategy to use toreplace existing pods with new ones.

template Yes templateobject

Template describes the pods that willbe created.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 227

Page 238: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-69 status 字段数据结构说明

参数 是否必选 参数类型 描述

availableReplicas

No Integer Total number of available pods(ready for at leastminReadySeconds) targeted by thisdeployment.

collisionCount

No Integer Count of hash collisions for theDeployment. The Deploymentcontroller uses this field as a collisionavoidance mechanism when it needsto create the name for the newestReplicaSet.

conditions No conditionsobject

Represents the latest availableobservations of a deployment'scurrent state.

observedGeneration

No Integer The generation observed by thedeployment controller

readyReplicas

No Integer Total number of ready pods targetedby this deployment

replicas No Integer Total number of non-terminatedpods targeted by this deployment(their labels match the selector).

unavailableReplicas

No Integer Total number of unavailable podstargeted by this deployment.

updatedReplicas

No Integer Total number of non-terminatedpods targeted by this deploymentthat have the desired template spec.

表 6-70 rollbackTo 字段数据结构说明

参数 是否必选 参数类型 描述

revision No Integer The revision to rollback to. If set to 0,rollback to the last revision.

表 6-71 selector 字段数据结构说明

参数 是否必选 参数类型 描述

matchExpressions

No matchExpressions object

matchExpressions is a list of labelselector requirements. Therequirements are ANDed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 228

Page 239: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

matchLabels

No Object matchLabels is a map of {key,value}pairs. A single {key,value} in thematchLabels map is equivalent to anelement of matchExpressions, whosekey field is "key", the operator is "In",and the values array contains only"value". The requirements areANDed.

表 6-72 strategy 字段数据结构说明

参数 是否必选 参数类型 描述

rollingUpdate

Yes RollingUpateDeployment object

Rolling update config params.Present only ifDeploymentStrategyType =RollingUpdate.

type No String Type of deployment. Can be"Recreate" or "RollingUpdate".Default is RollingUpdate.

表 6-73 conditions 字段数据结构说明

参数 是否必选 参数类型 描述

lastTransitionTime

No String Last time the condition transitionedfrom one status to another.

lastUpdateTime

No String The last time this condition wasupdated.

message No String A human readable messageindicating details about thetransition.

reason No String The reason for the condition's lasttransition.

status No String Status of the condition, one of True,False, Unknown.

type No String Type of deployment condition.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 229

Page 240: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-74 matchExpressions 字段数据结构说明

参数 是否必选 参数类型 描述

key No String key is the label key that the selectorapplies to.

operator No String operator represents a key'srelationship to a set of values. Validoperators ard In, NotIn, Exists andDoesNotExist.

values No Array ofstrings

values is an array of string values. Ifthe operator is In or NotIn, thevalues array must be non-empty. Ifthe operator is Exists orDoesNotExist, the values array mustbe empty. This array is replacedduring a strategic merge patch.

表 6-75 RollingUpateDeployment 字段数据结构说明

参数 是否必选 参数类型 描述

maxSurge No Integer The maximum number of pods thatcan be scheduled above the desirednumber of pods. Value can be anabsolute number (ex: 5) or apercentage of desired pods (ex:10%). This can not be 0 ifMaxUnavailable is 0. Absolutenumber is calculated frompercentage by rounding up. Defaultsto 25%. Example: when this is set to30%, the new RC can be scaled upimmediately when the rolling updatestarts, such that the total number ofold and new pods do not exceed130% of desired pods. Once old podshave been killed, new RC can bescaled up further, ensuring that totalnumber of pods running at any timeduring the update is atmost 130% ofdesired pods.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 230

Page 241: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

maxUnavailable

No Integer The maximum number of pods thatcan be unavailable during theupdate. Value can be an absolutenumber (ex: 5) or a percentage ofdesired pods (ex: 10%). Absolutenumber is calculated frompercentage by rounding down. Thiscan not be 0 if MaxSurge is 0.Defaults to 25%. Example: when thisis set to 30%, the old RC can bescaled down to 70% of desired podsimmediately when the rolling updatestarts. Once new pods are ready, oldRC can be scaled down further,followed by scaling up the new RC,ensuring that the total number ofpods available at all times duringthe update is at least 70% of desiredpods.

请求示例:

{ "apiVersion": "apps/v1beta1", "kind": "Deployment", "metadata": { "labels": { "app": "deployment-test" }, "name": "deployment-test" }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "deployment-test" } }, "template": { "metadata": { "labels": { "app": "deployment-test" } }, "spec": { "containers": [ { "image": "172.16.5.235:20202/test/nginx", "imagePullPolicy": "IfNotPresent", "name": "deployment-test" } ], "imagePullSecrets": [{ "name": "default-secret" }] } }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 231

Page 242: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}}

响应消息

响应参数:

响应参数如表6-67所示。

响应示例:

{ "kind": "Deployment", "apiVersion": "apps/v1beta1", "metadata": { "name": "deployment-test", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/deployments/deployment-test", "uid": "d079d1a0-fc1f-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "485774", "generation": 1, "creationTimestamp": "2018-01-18T07:18:42Z", "labels": { "name": "deployment-test" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "name": "deployment-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "deployment-test" }, "enable": true }, "spec": { "containers": [ { "name": "deployment-test", "image": "172.16.5.235:20202/test/nginx", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 232

Page 243: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"maxSurge": "25%" } }, "revisionHistoryLimit": 2, "progressDeadlineSeconds": 600 }, "status": {}}

状态码

表11 状态码描述API的状态码。

表 6-76 状态码

状态码 描述

200 This operation succeeds, and aEndpoint resource object is returned.

异常状态码请参见9.3 状态码。

6.5.2 创建 Deployment 的回滚操作

功能介绍

This API is used to create rollback of a Deployment Rollback.

URI

POST /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/rollback (Compatible)

POST /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}/rollback(Supports only1.7)

表6-77描述该API的参数。

表 6-77 参数解释

参数 是否必选 描述

name Yes name of the DeploymentRollback

namespace

Yes object name and auth scope, such as for teams andprojects

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

请求消息

请求参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 233

Page 244: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求参数如表6-78所示。

表 6-78 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind Yes String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated. InCamelCase.

name Yes String Required: This must match theName of a deployment.

rollbackTo No rollbackToobject

The config of this deploymentrollback.

updatedAnnotations

No Object The annotations to be updatedto a deployment

表 6-79 rollbackTo 字段数据结构说明

参数 是否必选 参数类型 描述

revision No Integer The revision to rollback to. If setto 0, rollbck to the last revision.

请求示例:

{ "kind": "DeploymentRollback", "apiVersion": "extensions/v1beta1", "name": "deploy-ex-12130306", "rollbackTo": { "revision": 0 }}

响应消息

响应参数:

响应参数的详细描述请参见表6-78

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 234

Page 245: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "message": "rollback request for deployment \"deploy-ex-12130306\" succeeded", "code": 201}

状态码

表6-80描述API的状态码。

表 6-80 状态码

状态码 描述

201 The request has been fulfilled,resulting in the creation of a newresource.

异常状态码请参见9.3 状态码。

6.5.3 删除 Deployment

功能介绍

This API is used to delete a Deployment resource object.

URI

DELETE /apis/apps/v1/namespaces/{namespace}/deployments/{name} (Supportsonly1.9)

DELETE /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}(Supports only1.7)

DELETE /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}(Compatible)

表6-81描述该API的参数。

表 6-81 参数解释

参数 是否必选 描述

name Yes name of the Deployment

namespace Yes object name and auth scope, such as for teams andprojects

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 235

Page 246: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

gracePeriodSeconds

No The duration in seconds before the object should bedeleted. Value must be non-negative integer. Thevalue zero indicates delete immediately. If this valueis nil, the default grace period for the specified typewill be used. Defaults to a per object value if notspecified. zero means delete immediately.

orphanDependents

No Deprecated: please use the PropagationPolicy, thisfield will be deprecated in 1.7. Should thedependent objects be orphaned. If true/false, the"orphan" finalizer will be added to/removed fromthe object's finalizers list. Either this field orPropagationPolicy may be set, but not both.

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field or OrphanDependentsmay be set, but not both. The default policy isdecided by the existing finalizer set in themetadata.finalizers and the resource-specific defaultpolicy. Acceptable values are: 'Orphan' - orphan thedependents; 'Background' - allow the garbagecollector to delete the dependents in thebackground; 'Foreground' - a cascading policy thatdeletes all dependents in the foreground.

请求消息

请求参数:

请求参数的详细描述请参见表6-147。

请求示例:

● 只删除Deployment(对应ReplicSet和Pod不删除){ "Kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->ReplicaSet->Deployment的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

● 后台级联删除(按照Deployment->ReplicaSet->Pod的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Background"}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 236

Page 247: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "details": { "name": "deploy-12130306", "group": "extensions", "kind": "deployments", "uid": "27072a31-dfb3-11e7-9c19-fa163e2d897b" }, "code": 200}

状态码

表6-82描述API的状态码。

表 6-82 状态码

状态码 描述

200 Delete a Deployments resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.5.4 删除所有的 Deployment

功能介绍

This API is used to delete collection of Deployment.

URI

DELETE /apis/apps/v1/namespaces/{namespace}/deployments (Supports only1.9)

DELETE /apis/apps/v1beta1/namespaces/{namespace}/deployments (Supportsonly1.7)

DELETE /apis/extensions/v1beta1/namespaces/{namespace}/deployments(Compatible)

表6-83描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 237

Page 248: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-83 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

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

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

请求参数:

请求参数的详细描述请参见表6-147。

请求示例:

● 只删除Deployment(对应ReplicSet和Pod不删除){ "Kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->ReplicaSet->Deployment的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

● 后台级联删除(按照Deployment->ReplicaSet->Pod的顺序进行删除){ "kind": "DeleteOptions",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 238

Page 249: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "v1", "propagationPolicy": "Background"}

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

{ "kind": "DeploymentList", "apiVersion": "apps/v1beta1", "metadata": { "selfLink": "/apis/apps/v1beta1/namespaces/ns-12130306-s/deployments", "resourceVersion": "418745" }, "items": null}

状态码

表6-84描述API的状态码。

表 6-84 状态码

状态码 描述

200 Delete a Deployment resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.5.5 获取指定的 Deployment

功能介绍

该API用于获取某个Namespace下指定的Deployment对象。

URI

GET /apis/apps/v1/namespaces/{namespace}/deployments/{name} (Supportsonly1.9)

GET /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name} (Supportsonly1.7)

GET /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}(Compatible)

表6-85描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 239

Page 250: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-85 参数描述

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

name Yes name of the Deployment

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

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

export No Should this value be exported. Export stripsfields that a user can not specify.

请求消息

N/A

响应消息

响应消息请参见表6-67

响应示例:

{ "kind": "Deployment", "apiVersion": "apps/v1beta1", "metadata": { "name": "deployment-example", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/deployments/deployment-example", "uid": "1b33145a-9c63-11e6-9c54-42010a800148", "resourceVersion": "2064726", "generation": 4, "creationTimestamp": "2016-10-27T16:33:35Z", "labels": { "app": "nginx" }, "annotations": { "deployment.kubernetes.io/revision": "1" } }, "spec": { "replicas": 3, "selector": { "matchLabels": { "app": "nginx" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "nginx" } }, "spec": { "containers": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 240

Page 251: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "name": "nginx", "image": "nginx:1.10", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": 1, "maxSurge": 1 } } }, "status": { "observedGeneration": 4, "replicas": 3, "updatedReplicas": 3, "availableReplicas": 3 }}

状态码

表6-86描述API的状态码。

表 6-86 状态码

状态码 描述

200 This operation succeeds, and adeployment resource object isreturned.

异常状态码请参见9.3 状态码。

6.5.6 获取指定的 Deployment 的状态

功能介绍

This API is used to read the status of a specified Deployment object under aspecified Namespace.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 241

Page 252: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URIGET /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status(Supports only1.9)

GET /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}/status(Supports only1.7)

GET /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/status (Compatible)

表6-87描述该API的参数。

表 6-87 参数解释

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

{ "kind": "Deployment", "apiVersion": "apps/v1beta1", "metadata": { "name": "deploy-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/apps/v1beta1/namespaces/ns-12130306-s/deployments/deploy-12130306/status", "uid": "27072a31-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418598", "generation": 2, "creationTimestamp": "2017-12-13T03:10:20Z", "labels": { "cce/appgroup": "deploy_test" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "cce/appgroup": "deploy_test"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 242

Page 253: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} }, "template": { "metadata": { "creationTimestamp": null, "labels": { "cce/appgroup": "deploy_test" }, "enable": true }, "spec": { "containers": [ { "name": "deploycon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } }, "revisionHistoryLimit": 2, "progressDeadlineSeconds": 600 }, "status": { "observedGeneration": 2, "replicas": 1, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [ { "type": "Progressing", "status": "True", "lastUpdateTime": "2017-12-13T03:10:20Z", "lastTransitionTime": "2017-12-13T03:10:20Z", "reason": "NewReplicaSetAvailable", "message": "ReplicaSet \"deploy-12130306-3417241766\" has successfully progressed." }, { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-13T03:10:23Z", "lastTransitionTime": "2017-12-13T03:10:23Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] }}

状态码

表6-88描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 243

Page 254: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-88 状态码

状态码 描述

200 This operation succeeds, and aDeployment resource object isreturned.

异常状态码请参见9.3 状态码。

6.5.7 获取指定的 Deployment 的伸缩操作

功能介绍

This API is used to read scale of the specified Scale.

URIGET /apis/apps/v1/namespaces/{namespace}/deployments/{name}/scale (Supportsonly1.9)

GET /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/scale (Compatible)

GET /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}/scale(Supports only1.7)

表6-89描述该API的参数。

表 6-89 参数解释

参数 是否必选 描述

name Yes name of the Scale

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

{ "kind": "Scale",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 244

Page 255: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "extensions/v1beta1", "metadata": { "name": "deploy-ex-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/deployments/deploy-ex-12130306/scale", "uid": "934db57d-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418871", "creationTimestamp": "2017-12-13T03:13:22Z" }, "spec": { "replicas": 2 }, "status": { "replicas": 2, "selector": { "cce/appgroup": "deploy-ex-test" }, "targetSelector": "cce/appgroup=deploy-ex-test" }}

状态码

表6-90描述API的状态码。

表 6-90 状态码

状态码 描述

200 This operation succeeds, and aDeployment resource object isreturned.

异常状态码请参见9.3 状态码。

6.5.8 替换指定的 Deployment

功能介绍

该API用于替换指定的Deployment对象。

其中以下字段支持更新:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.clusterName

● metadata.generateName

● metadata.annotations

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 245

Page 256: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● spec.replicas● template.contaions● spec.restartPolicy● spec.activeDeadlineSeconds

URIPUT /apis/apps/v1/namespaces/{namespace}/deployments/{name} (Supportsonly1.9)

PUT /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name} (Supportsonly1.7)

PUT /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}(Compatible)

表6-91描述该API的参数

表 6-91 参数

参数 是否必选 描述

name Yes name of the Deployment

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

请求参数:

请求参数的详细描述请参见表6-67。

请求示例:

{ "kind": "Deployment", "apiVersion": "apps/v1beta1", "metadata": { "name": "deploy-example", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/deployments/deploy-example", "uid": "27072a31-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418453", "generation": 1, "creationTimestamp": "2017-12-13T03:10:20Z", "labels": { "app": "test" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1,

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 246

Page 257: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"selector": { "matchLabels": { "app": "test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "test" }, "enable": true }, "spec": { "containers": [ { "name": "deploycon-12130306", "image": "nginx", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } }, "revisionHistoryLimit": 2, "progressDeadlineSeconds": 600 }, "status": { "observedGeneration": 1, "conditions": [ { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-13T03:10:20Z", "lastTransitionTime": "2017-12-13T03:10:20Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." }, { "type": "Progressing", "status": "True", "lastUpdateTime": "2017-12-13T03:10:20Z", "lastTransitionTime": "2017-12-13T03:10:20Z", "reason": "NewReplicaSetAvailable", "message": "ReplicaSet \"deploy-12130306-3417241766\" has successfully progressed." } ] }}

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 247

Page 258: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "apiVersion": "apps/v1beta1", "kind": "Deployment", "metadata": { "annotations": { "deployment.kubernetes.io/revision": "1" }, "creationTimestamp": "2017-11-09T01:35:00Z", "enable": true, "generation": 1, "labels": { "app": "test" }, "name": "deployment-example", "namespace": "default", "resourceVersion": "12857132", "selfLink": "/apis/apps/v1beta1/namespaces/default/deployments/deployment-example", "uid": "33a5e8fd-c4ee-11e7-aad0-286ed488d4c6" }, "spec": { "replicas": 3, "selector": { "matchLabels": { "app": "test" } }, "strategy": { "rollingUpdate": { "maxSurge": 1, "maxUnavailable": 1 }, "type": "RollingUpdate" }, "template": { "metadata": { "creationTimestamp": null, "enable": true, "labels": { "app": "test" } }, "spec": { "containers": [ { "image": "nginx:1.13.6", "imagePullPolicy": "Always", "name": "nginx", "resources": {}, "terminationMessagePath": "/dev/termination-log" } ], "dnsPolicy": "ClusterFirst", "restartPolicy": "Always", "securityContext": {}, "terminationGracePeriodSeconds": 30 } } }, "status": { "conditions": [ { "lastTransitionTime": "2017-11-10T17:02:50Z", "lastUpdateTime": "2017-11-10T01:35:01Z", "message": "Deployment does not have minimum availability.", "reason": "MinimumReplicasUnavailable", "status": "False", "type": "Available" }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 248

Page 259: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

], "observedGeneration": 1, "replicas": 3, "unavailableReplicas": 3, "updatedReplicas": 3 }}

状态码

表6-92描述API的状态码。

表 6-92 状态码

状态码 描述

200 This operation succeeds, and aDevelopment resource object is returned.

异常状态码请参见9.3 状态码。

6.5.9 替换指定的 Deployment 的状态

功能介绍

This API is used to replace the status of a specified Deployment object under aspecified Namespace, that is, to modify the value of the status field of theDeployment object.

URI

PUT /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status(Supports only1.9)

PUT /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}/status(Supports only1.7)

PUT /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/status (Compatible)

表6-93描述该API的参数。

表 6-93 参数解释

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teams andprojects

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 249

Page 260: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数:

请求参数的详细描述请参见表6-67。

请求示例:

{ "kind": "Deployment", "apiVersion": "apps/v1beta1", "metadata": { "name": "deploy-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/apps/v1beta1/namespaces/ns-12130306-s/deployments/deploy-12130306/status", "uid": "27072a31-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418598", "generation": 2, "creationTimestamp": "2017-12-13T03:10:20Z", "labels": { "cce/appgroup": "deploy_test" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "cce/appgroup": "deploy_test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "cce/appgroup": "deploy_test" }, "enable": true }, "spec": { "containers": [ { "name": "deploycon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } }, "revisionHistoryLimit": 2, "progressDeadlineSeconds": 600

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 250

Page 261: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "status": { "observedGeneration": 2, "replicas": 1, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [ { "type": "Progressing", "status": "True", "lastUpdateTime": "2017-12-13T03:10:20Z", "lastTransitionTime": "2017-12-13T03:10:20Z", "reason": "NewReplicaSetAvailable", "message": "ReplicaSet \"deploy-12130306-3417241766\" has successfully progressed." }, { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-13T03:10:23Z", "lastTransitionTime": "2017-12-13T03:10:23Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] }}

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

{ "kind": "Deployment", "apiVersion": "apps/v1beta1", "metadata": { "name": "deploy-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/apps/v1beta1/namespaces/ns-12130306-s/deployments/deploy-12130306/status", "uid": "27072a31-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418632", "generation": 2, "creationTimestamp": "2017-12-13T03:10:20Z", "labels": { "cce/appgroup": "deploy_test" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "cce/appgroup": "deploy_test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "cce/appgroup": "deploy_test" }, "enable": true

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 251

Page 262: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "spec": { "containers": [ { "name": "deploycon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } }, "revisionHistoryLimit": 2, "progressDeadlineSeconds": 600 }, "status": { "observedGeneration": 2, "replicas": 1, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [ { "type": "Progressing", "status": "True", "lastUpdateTime": "2017-12-13T03:10:20Z", "lastTransitionTime": "2017-12-13T03:10:20Z", "reason": "NewReplicaSetAvailable", "message": "ReplicaSet \"deploy-12130306-3417241766\" has successfully progressed." }, { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-13T03:10:23Z", "lastTransitionTime": "2017-12-13T03:10:23Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] }}

状态码

表6-94描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 252

Page 263: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-94 状态码

状态码 描述

200 This operation succeeds, and aDeployment resource object isreturned.

异常状态码请参见9.3 状态码。

6.5.10 替换指定的 Deployment 的伸缩操作

功能介绍

This API is used to replace scale of the specified Scale.

The following fields can be updated:

● metadata.resourceVersion

● metadata.creationTimestamp

● spec.replicas

URI

PUT /apis/apps/v1/namespaces/{namespace}/deployments/{name}/scale(Supports only1.9)

PUT /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/scale (Compatible)

PUT /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}/scale(Supports only1.7)

表6-95描述该API的参数。

表 6-95 参数解释

参数 是否必选 描述

name Yes name of the Scale

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

请求参数:

请求参数的详细描述请参见表6-67。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 253

Page 264: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求示例:

须知

如果使用第一个URI:/apis/apps/v1/namespaces/{namespace}/deployments/{name}/scale(Supports only1.9),请将apiVersion的值修改为autoscaling/v1。

{ "kind": "Scale", "apiVersion": "extensions/v1beta1", "metadata": { "name": "deploy-ex-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/deployments/deploy-ex-12130306/scale", "uid": "934db57d-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418871", "creationTimestamp": "2017-12-13T03:13:22Z" }, "spec": { "replicas": 1 }, "status": { "replicas": 1, "selector": { "cce/appgroup": "deploy-ex-test" }, "targetSelector": "cce/appgroup=deploy-ex-test" }}

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

{ "kind": "Scale", "apiVersion": "extensions/v1beta1", "metadata": { "name": "deploy-ex-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/deployments/deploy-ex-12130306/scale", "uid": "934db57d-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418903", "creationTimestamp": "2017-12-13T03:13:22Z" }, "spec": { "replicas": 1 }, "status": { "replicas": 2, "selector": { "cce/appgroup": "deploy-ex-test" }, "targetSelector": "cce/appgroup=deploy-ex-test" }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 254

Page 265: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-96描述API的状态码。

表 6-96 状态码

状态码 描述

200 This operation succeeds, and aDeployment resource object isreturned.

异常状态码请参见9.3 状态码。

6.5.11 列出指定 Namespace 下的 Deployment

功能介绍

This API is used to list all Deployment resource objects under a specifiedNamespace.

URI

GET /apis/apps/v1/namespaces/{namespace}/deployments (Supports only1.9)

GET /apis/apps/v1beta1/namespaces/{namespace}/deployments (Supportsonly1.7)

GET /apis/extensions/v1beta1/namespaces/{namespace}/deployments(Compatible)

表6-97描述该API的参数。

表 6-97 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources are includedin the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 255

Page 266: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently have incache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

{ "kind": "DeploymentList", "apiVersion": "apps/v1beta1", "metadata": { "selfLink": "/apis/apps/v1beta1/namespaces/ns-12130306-s/deployments", "resourceVersion": "418745" }, "items": []}

状态码

表6-98描述API的状态码。

表 6-98 状态码

状态码 描述

200 This operation succeeds, and aDeployment resource object isreturned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 256

Page 267: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.5.12 列出指定的 Deployment

功能介绍

This API is used to list all Deployment resource objects.

URI

GET /apis/apps/v1/deployments (Supports only1.9)

GET /apis/apps/v1beta1/deployments (Supports only1.7)

GET /apis/extensions/v1beta1/deployments (Compatible)

表6-99描述该API的参数。

表 6-99 参数解释

参数 是否必选 描述

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

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

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 257

Page 268: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

{ "kind": "DeploymentList", "apiVersion": "extensions/v1beta1", "metadata": { "selfLink": "/apis/extensions/v1beta1/deployments", "resourceVersion": "418820" }, "items": [ { "metadata": { "name": "nginx", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/deployments/nginx", "uid": "3f7846b5-dc93-11e7-9c19-fa163e2d897b", "resourceVersion": "28579", "generation": 2, "creationTimestamp": "2017-12-09T03:44:24Z", "labels": { "app": "nginx" }, "annotations": { "deployment.kubernetes.io/revision": "1", "service.protal.kubernetes.io/access-ip": "10.247.51.55:123", "service.protal.kubernetes.io/type": "ClusterIP" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "nginx" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "nginx" }, "enable": true }, "spec": { "containers": [ { "name": "nginx", "image": "172.16.5.235:20202/test-01/mysql:v1", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 258

Page 269: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": 1, "maxSurge": 1 } } }, "status": { "observedGeneration": 2, "replicas": 1, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [ { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-09T03:44:24Z", "lastTransitionTime": "2017-12-09T03:44:24Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] } }, { "metadata": { "name": "nginx1", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/deployments/nginx1", "uid": "179598d2-dc94-11e7-9c19-fa163e2d897b", "resourceVersion": "2789", "generation": 1, "creationTimestamp": "2017-12-09T03:50:26Z", "labels": { "app": "nginx" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "nginx" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "nginx" }, "enable": true }, "spec": { "containers": [ { "name": "nginx", "image": "172.16.5.235:20202/test-01/mysql:v1", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Always",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 259

Page 270: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": 1, "maxSurge": 1 } } }, "status": { "observedGeneration": 1, "replicas": 1, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [ { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-09T03:50:26Z", "lastTransitionTime": "2017-12-09T03:50:26Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] } }, { "metadata": { "name": "kube-dns", "namespace": "kube-system", "selfLink": "/apis/extensions/v1beta1/namespaces/kube-system/deployments/kube-dns", "uid": "87211a1c-dc8e-11e7-9c19-fa163e2d897b", "resourceVersion": "137", "generation": 1, "creationTimestamp": "2017-12-09T03:10:36Z", "labels": { "addonmanager.kubernetes.io/mode": "Reconcile", "kubernetes-app": "kube-dns", "kubernetes.io/cluster-service": "true" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "kubernetes-app": "kube-dns", "podaffinity": "kube-dns-pod" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "kubernetes-app": "kube-dns", "podaffinity": "kube-dns-pod" }, "annotations": { "pod.alpha.kubernetes.io/init-containers": "[{\"name\":\"bootstrap-kubedns-init\",\"image\":\"euleros:2.2.5\",\"command\":[\"/bin/sh\",\"-c\",\"touch /var/log/skydns.log; touch /var/log/dnsmasq.log;

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 260

Page 271: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

touch /var/log/exechealthz.log; chown paas:paas /var/log/skydns.log /var/log/dnsmasq.log /var/log/exechealthz.log; chmod 640 /var/log/skydns.log /var/log/dnsmasq.log /var/log/exechealthz.log\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"logfile\",\"mountPath\":\"/var/log\",\"policy\":{\"logs\":{\"rotate\":\"Hourly\"}}}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Never\"}]", "pod.beta.kubernetes.io/init-containers": "[{\"name\":\"bootstrap-kubedns-init\",\"image\":\"euleros:2.2.5\",\"command\":[\"/bin/sh\",\"-c\",\"touch /var/log/skydns.log; touch /var/log/dnsmasq.log; touch /var/log/exechealthz.log; chown paas:paas /var/log/skydns.log /var/log/dnsmasq.log /var/log/exechealthz.log; chmod 640 /var/log/skydns.log /var/log/dnsmasq.log /var/log/exechealthz.log\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"logfile\",\"mountPath\":\"/var/log\",\"policy\":{\"logs\":{\"rotate\":\"Hourly\"}}}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Never\"}]" }, "enable": true }, "spec": { "volumes": [ { "name": "crypto", "emptyDir": { "sizeLimit": "0" } }, { "name": "material", "hostPath": { "path": "/var/paas/srv/kubernetes" } }, { "name": "logfile", "hostPath": { "path": "/var/paas/sys/log/kubernetes" } }, { "name": "kube-dns-config", "configMap": { "name": "kube-dns", "defaultMode": 420, "optional": true } } ], "initContainers": [ { "name": "bootstrap-kubedns-init", "image": "euleros:2.2.5", "command": [ "/bin/sh", "-c", "touch /var/log/skydns.log; touch /var/log/dnsmasq.log; touch /var/log/exechealthz.log; chown paas:paas /var/log/skydns.log /var/log/dnsmasq.log /var/log/exechealthz.log; chmod 640 /var/log/skydns.log /var/log/dnsmasq.log /var/log/exechealthz.log" ], "resources": {}, "volumeMounts": [ { "name": "logfile", "mountPath": "/var/log", "policy": { "logs": { "rotate": "Hourly" } } } ], "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 261

Page 272: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"imagePullPolicy": "Never" } ], "containers": [ { "name": "kubedns", "image": "cfe-kubedns-amd64:2.11.25", "command": [ "/bin/sh", "-c", "/kube-dns 1>>/var/log/skydns.log 2>&1 --domain=cluster.local. --dns-port=10053 --config-dir=/kube-dns-config --v=2" ], "ports": [ { "name": "dns-local", "containerPort": 10053, "protocol": "UDP" }, { "name": "dns-tcp-local", "containerPort": 10053, "protocol": "TCP" }, { "name": "metrics", "containerPort": 10055, "protocol": "TCP" } ], "env": [ { "name": "PROMETHEUS_PORT", "value": "10055" }, { "name": "PAAS_CRYPTO_PATH", "value": "/var/paas/kubernetes/material" } ], "resources": { "limits": { "cpu": "100m", "memory": "512Mi" }, "requests": { "cpu": "100m", "memory": "100Mi" } }, "volumeMounts": [ { "name": "crypto", "mountPath": "/var/paas" }, { "name": "material", "readOnly": true, "mountPath": "/var/paas/kubernetes/material" }, { "name": "logfile", "mountPath": "/var/log", "policy": { "logs": { "rotate": "Hourly" } } },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 262

Page 273: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "name": "kube-dns-config", "mountPath": "/kube-dns-config" } ], "livenessProbe": { "httpGet": { "path": "/healthcheck/kubedns", "port": 10054, "scheme": "HTTP" }, "initialDelaySeconds": 60, "timeoutSeconds": 5, "periodSeconds": 10, "successThreshold": 1, "failureThreshold": 5 }, "readinessProbe": { "httpGet": { "path": "/readiness", "port": 8081, "scheme": "HTTP" }, "initialDelaySeconds": 3, "timeoutSeconds": 5, "periodSeconds": 10, "successThreshold": 1, "failureThreshold": 3 }, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" }, { "name": "dnsmasq", "image": "cfe-kube-dnsmasq-amd64:2.11.25", "command": [ "/bin/sh", "-c", "/dnsmasq-nanny 1>>/var/log/dnsmasq.log 2>&1 -v=2 -logtostderr -configDir=/etc/kubernetes/dns/dnsmasq-nanny -restartDnsmasq=true -- -k --port=5353 --cache-size=1000 --log-facility=- --server=/cluster.local/127.0.0.1#10053 --server=/in-addr.arpa/127.0.0.1#10053 --server=/ip6.arpa/127.0.0.1#10053" ], "ports": [ { "name": "dns", "containerPort": 5353, "protocol": "UDP" }, { "name": "dns-tcp", "containerPort": 5353, "protocol": "TCP" } ], "resources": { "requests": { "cpu": "150m", "memory": "200Mi" } }, "volumeMounts": [ { "name": "logfile", "mountPath": "/var/log", "policy": { "logs": { "rotate": "Hourly"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 263

Page 274: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} } }, { "name": "kube-dns-config", "mountPath": "/etc/kubernetes/dns/dnsmasq-nanny" } ], "livenessProbe": { "httpGet": { "path": "/healthcheck/dnsmasq", "port": 10054, "scheme": "HTTP" }, "initialDelaySeconds": 60, "timeoutSeconds": 5, "periodSeconds": 10, "successThreshold": 1, "failureThreshold": 5 }, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" }, { "name": "sidecar", "image": "cfe-exechealthz-amd64:2.11.25", "command": [ "/bin/sh", "-c", "/sidecar 1>>/var/log/exechealthz.log 2>&1 --v=2 --logtostderr --probe=kubedns,127.0.0.1:10053,kubernetes.default.svc.cluster.local,5,A --probe=dnsmasq,127.0.0.1:5353,kubernetes.default.svc.cluster.local,5,A" ], "ports": [ { "name": "metrics", "containerPort": 10054, "protocol": "TCP" } ], "resources": { "limits": { "cpu": "50m", "memory": "50Mi" }, "requests": { "cpu": "50m", "memory": "50Mi" } }, "volumeMounts": [ { "name": "logfile", "mountPath": "/var/log", "policy": { "logs": { "rotate": "Hourly" } } } ], "livenessProbe": { "httpGet": { "path": "/metrics", "port": 10054, "scheme": "HTTP" }, "initialDelaySeconds": 60,

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 264

Page 275: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"timeoutSeconds": 5, "periodSeconds": 10, "successThreshold": 1, "failureThreshold": 5 }, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "Default", "securityContext": {}, "affinity": { "podAntiAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": [ { "labelSelector": { "matchExpressions": [ { "key": "podaffinity", "operator": "In", "values": [ "kube-dns-pod" ] } ] }, "topologyKey": "kubernetes.io/hostname", "numOfMatchingPods": "1" } ] } }, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": 0, "maxSurge": "10%" } } }, "status": { "observedGeneration": 1, "replicas": 1, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [ { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-09T03:10:59Z", "lastTransitionTime": "2017-12-09T03:10:59Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] } }, { "metadata": { "name": "deploy-12130304", "namespace": "ns-12130304-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130304-s/deployments/

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 265

Page 276: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

deploy-12130304", "uid": "9c31c8f3-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418807", "generation": 2, "creationTimestamp": "2017-12-13T03:13:37Z", "labels": { "cce/appgroup": "deploy_test" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "cce/appgroup": "deploy_test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "cce/appgroup": "deploy_test" }, "enable": true }, "spec": { "containers": [ { "name": "deploycon-12130304", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } }, "revisionHistoryLimit": 2, "progressDeadlineSeconds": 600 }, "status": { "observedGeneration": 2, "replicas": 1, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [ { "type": "Progressing", "status": "True", "lastUpdateTime": "2017-12-13T03:13:37Z", "lastTransitionTime": "2017-12-13T03:13:37Z", "reason": "NewReplicaSetAvailable",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 266

Page 277: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"message": "ReplicaSet \"deploy-12130304-1294264020\" has successfully progressed." }, { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-13T03:13:39Z", "lastTransitionTime": "2017-12-13T03:13:39Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] } }, { "metadata": { "name": "deploy-ex-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/deployments/deploy-ex-12130306", "uid": "934db57d-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418771", "generation": 2, "creationTimestamp": "2017-12-13T03:13:22Z", "labels": { "cce/appgroup": "deploy-ex-test" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "cce/appgroup": "deploy-ex-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "cce/appgroup": "deploy-ex-test" }, "enable": true }, "spec": { "containers": [ { "name": "deploycon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": 1, "maxSurge": 1

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 267

Page 278: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} } }, "status": { "observedGeneration": 2, "replicas": 1, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [ { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-13T03:13:22Z", "lastTransitionTime": "2017-12-13T03:13:22Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] } } ]}

状态码

表6-100描述API的状态码。

表 6-100 状态码

状态码 描述

200 This operation succeeds, and aDeployment resource object isreturned.

异常状态码请参见9.3 状态码。

6.5.13 更新指定的 Deployment

功能介绍

This API is used to update a Deployment object under a specific Namespace.

The following fields can be updated:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.clusterName

● metadata.generateName

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 268

Page 279: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● metadata.annotations

● spec.replicas

● template.contaions

● spec.restartPolicy

● spec.activeDeadlineSeconds

URIPATCH /apis/apps/v1/namespaces/{namespace}/deployments/{name} (Supportsonly1.9)

PATCH /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}(Supports only1.7)

PATCH /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}(Compatible)

表6-101描述该API的参数。

表 6-101 参数解释

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例1,使用json-patch类型:

Content-Type: application/json-patch+json[ { "op": "add", "path": "/spec/template/spec/containers/0/image", "value": "172.16.5.235:20202/test/redis:latest" }]

请求示例2,使用merge-patch类型:

Content-Type: application/merge-patch+json{ "spec": { "template": { "spec": { "containers": [ { "name": "deploycon-12130306",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 269

Page 280: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"image": "172.16.5.235:20202/test/redis:latest" } ] } } }}

请求示例3,使用strategic-merge-patch类型:

Content-Type: application/strategic-merge-patch+json{ "spec": { "template": { "spec": { "containers": [ { "name": "deploycon-12130306", } ] } } }}

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

{ "kind": "Deployment", "apiVersion": "apps/v1beta1", "metadata": { "name": "deploy-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/apps/v1beta1/namespaces/ns-12130306-s/deployments/deploy-12130306", "uid": "27072a31-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418470", "generation": 2, "creationTimestamp": "2017-12-13T03:10:20Z", "labels": { "cce/appgroup": "deploy_test" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "cce/appgroup": "deploy_test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "cce/appgroup": "deploy_test" }, "enable": true }, "spec": { "containers": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 270

Page 281: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "name": "deploycon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } }, "revisionHistoryLimit": 2, "progressDeadlineSeconds": 600 }, "status": { "observedGeneration": 2, "replicas": 1, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [ { "type": "Progressing", "status": "True", "lastUpdateTime": "2017-12-13T03:10:20Z", "lastTransitionTime": "2017-12-13T03:10:20Z", "reason": "NewReplicaSetAvailable", "message": "ReplicaSet \"deploy-12130306-3417241766\" has successfully progressed." }, { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-13T03:10:23Z", "lastTransitionTime": "2017-12-13T03:10:23Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] }}

状态码

表6-102描述API的状态码。

表 6-102 状态码

状态码 描述

200 This operation succeeds, and aDeployment resource object isreturned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 271

Page 282: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.5.14 更新指定的 Deployment 的状态

功能介绍

This API is used to update the status of a specified Deployment object under aspecified Namespace.

URIPATCH /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status(Supports only1.9)

PATCH /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}/status(Supports only1.7)

PATCH /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/status (Compatible)

表6-103描述该API的参数。

表 6-103 参数解释

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teamsand projects

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json [ { "op": "add", "path": "/status/replicas", "value": 3 }]

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 272

Page 283: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "kind": "Deployment", "apiVersion": "apps/v1beta1", "metadata": { "name": "deploy-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/apps/v1beta1/namespaces/ns-12130306-s/deployments/deploy-12130306/status", "uid": "27072a31-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418597", "generation": 2, "creationTimestamp": "2017-12-13T03:10:20Z", "labels": { "cce/appgroup": "deploy_test" }, "annotations": { "deployment.kubernetes.io/revision": "1" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "cce/appgroup": "deploy_test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "cce/appgroup": "deploy_test" }, "enable": true }, "spec": { "containers": [ { "name": "deploycon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } }, "revisionHistoryLimit": 2, "progressDeadlineSeconds": 600 }, "status": { "observedGeneration": 2, "replicas": 3, "updatedReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "conditions": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 273

Page 284: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "type": "Progressing", "status": "True", "lastUpdateTime": "2017-12-13T03:10:20Z", "lastTransitionTime": "2017-12-13T03:10:20Z", "reason": "NewReplicaSetAvailable", "message": "ReplicaSet \"deploy-12130306-3417241766\" has successfully progressed." }, { "type": "Available", "status": "True", "lastUpdateTime": "2017-12-13T03:10:23Z", "lastTransitionTime": "2017-12-13T03:10:23Z", "reason": "MinimumReplicasAvailable", "message": "Deployment has minimum availability." } ] }}

状态码

表6-104描述API的状态码。

表 6-104 状态码

状态码 描述

200 This operation succeeds, and aDeployment resource object isreturned.

异常状态码请参见9.3 状态码。

6.5.15 更新指定的 Deployment 的伸缩操作

功能介绍

This API is used to partially update scale of the specified Scale.

The following fields can be updated:

● metadata.resourceVersion● metadata.creationTimestamp● spec.replicas

URIPATCH /apis/apps/v1/namespaces/{namespace}/deployments/{name}/scale(Supports only1.9)

PATCH /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/scale (Compatible)

PATCH /apis/apps/v1beta1/namespaces/{namespace}/deployments/{name}/scale(Supports only1.7)

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 274

Page 285: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表6-105描述该API的参数。

表 6-105 参数解释

参数 是否必选 描述

name Yes name of the Scale

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/json-patch+json[ { "op": "add", "path": "/spec/replicas", "value": 2 }]

响应消息

响应参数:

响应参数的详细描述请参见表6-67。

响应示例:

{ "kind": "Scale", "apiVersion": "extensions/v1beta1", "metadata": { "name": "deploy-ex-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/deployments/deploy-ex-12130306/scale", "uid": "934db57d-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418857", "creationTimestamp": "2017-12-13T03:13:22Z" }, "spec": { "replicas": 2 }, "status": { "replicas": 1, "selector": { "cce/appgroup": "deploy-ex-test" }, "targetSelector": "cce/appgroup=deploy-ex-test" }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 275

Page 286: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-106描述API的状态码。

表 6-106 状态码

状态码 描述

200 This operation succeeds, and aDeployment resource object isreturned.

异常状态码请参见9.3 状态码。

6.6 StatefulSet

6.6.1 创建 StatefulSet

功能介绍

This API is used to create a StatefulSet resource object.

URI

POST /apis/apps/v1/namespaces/{namespace}/statefulsets (Supports only1.9)

POST /apis/apps/v1beta1/namespaces/{namespace}/statefulsets (Compatible)

表6-107描述该API的参数。

表 6-107 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

请求参数如表6-108所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 276

Page 287: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-108 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind Yes String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated.

metadata Yes metadataobject

Standard list metadata.

spec Yes spec object Spec defines the desiredidentities of pods in this set.

status No status object Status is the current status ofPods in this StatefulSet. Thisdata may be out of date bysome window of time.

表 6-109 status 字段数据结构说明

参数 是否必选 参数类型 描述

observedGeneration

No Integer Most recent generation observedby this autoscaler.

replicas No Integer Replicas is the number of actualreplicas.

currentReplicas No Integer currentReplicas is the number ofPods created by the StatefulSetcontroller from the StatefulSetversion indicated bycurrentRevision.

currentRevision No String currentRevision, if not empty,indicates the version of theStatefulSet used to generatePods in the sequence[0,currentReplicas).

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 277

Page 288: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

readyReplicas No Integer readyReplicas is the number ofPods created by the StatefulSetcontroller that have a ReadyCondition.

updateRevision No String updateRevision, if not empty,indicates the version of theStatefulSet used to generatePods in the sequence [replicas-updatedReplicas,replicas)

updatedReplicas No Integer updatedReplicas is the number ofPods created by the StatefulSetcontroller from the StatefulSetversion indicated byupdateRevision.

表 6-110 spec 字段数据结构说明

参数 是否必选 参数类型 描述

replicas No Integer Replicas is the desired numberof replicas of the givenTemplate. These are replicas inthe sense that they areinstantiations of the sameTemplate, but individual replicasalso have a consistent identity.If unspecified, defaults to 1.

podManagementPolicy

No String podManagementPolicy controlshow pods are created duringinitial scale up, when replacingpods on nodes, or when scalingdown. The default policy isOrderedReady, where pods arecreated in increasing order(pod-0, then pod-1, etc) and thecontroller will wait until eachpod is ready before continuing.When scaling down, the podsare removed in the oppositeorder. The alternative policy isParallel which will create podsin parallel to match the desiredscale without waiting, and onscale down will delete all podsat once.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 278

Page 289: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

revisionHistoryLimit

No Integer revisionHistoryLimit is themaximum number of revisionsthat will be maintained in theStatefulSet's revision history.The revision history consists ofall revisions not represented bya currently appliedStatefulSetSpec version. Thedefault value is 10.

updateStrategy No updateStrategy object

updateStrategy indicates theStatefulSetUpdateStrategy thatwill be employed to updatePods in the StatefulSet when arevision is made to Template.

serviceName Yes String ServiceName is the name of theservice that governs thisStatefulSet. This service mustexist before the StatefulSet, andis responsible for the networkidentity of the set. Pods getDNS/hostnames that follow thepattern: pod-specific-string.serviceName.default.svc.cluster.local where "pod-specific-string" is managed by theStatefulSet controller.

volumeClaimTemplates

No Object VolumeClaimTemplates is a listof claims that pods are allowedto reference. The StatefulSetcontroller is responsible formapping network identities toclaims in a way that maintainsthe identity of a pod. Everyclaim in this list must have atleast one matching (by name)volumeMount in one containerin the template. A claim in thislist takes precedence over anyvolumes in the template, withthe same name.具体请参见表6-400。

selector Yes selector object Selector is a label query overpods that should match thereplica count. If empty,defaulted to labels on the podtemplate.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 279

Page 290: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

template Yes PodTemplateSpec object

Template is the object thatdescribes the pod that will becreated if insufficient replicasare detected. Each pod stampedout by the StatefulSet will fulfillthis Template, but have aunique identity from the rest ofthe StatefulSet.

表 6-111 selector 字段数据结构说明

参数 是否必选 参数类型 描述

matchExpressions

No matchExpressions object

matchExpressions is a list oflabel selector requirements. Therequirements are ANDed.

matchLabels No Object MatchLabels is a map of{key,value} pairs. A single{key,value} in the matchLabelsmap is equivalent to an elementof matchExpressions, whose keyfield is "key", the operator is"In", and the values arraycontains only "value". Therequirements are ANDed.

表 6-112 matchExpressions 字段数据结构说明

参数 是否必选 参数类型 描述

key No String key is the label key that theselector applies to.

operator No String operator represents a key'srelationship to a set of values.Valid operators are In, NotIn,Exists and DoesNotExist.

values No String values is an array of stringvalues. If the operator is In orNotIn, the values array must benon-empty. If the operator isExists or DoesNotExist, thevalues array must be empty.This array is replaced during astrategic merge patch.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 280

Page 291: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-113 PodTemplateSpec 字段数据结构说明

参数 是否必选 参数类型 描述

metadata Yes metadataobject

Standard object's metadata.

spec Yes spec object Specification of the desiredbehavior of the pod.

表 6-114 updateStrategy 字段数据结构说明

参数 是否必选 参数类型 描述

rollingUpdate No rollingUpdateobject

RollingUpdate is used tocommunicate parameterswhen Type isRollingUpdateStatefulSetStrategyType.

type No String Type indicates the type of theStatefulSetUpdateStrategy.

表 6-115 rollingUpdate 字段数据结构说明

参数 是否必选 参数类型 描述

partition No Integer Partition indicates the ordinalat which the StatefulSetshould be partitioned.

请求示例:

{ "apiVersion": "apps/v1beta1", "kind": "StatefulSet", "metadata": { "labels": { "name": "statefulset-test" }, "name": "statefulset-test" }, "spec": { "replicas": 1, "selector": { "matchLabels": { "name": "statefulset-test" } }, "serviceName": "service-test", "template": { "metadata": { "labels": { "name": "statefulset-test" }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 281

Page 292: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "spec": { "containers": [ { "image": "172.16.5.235:20202/test/nginx", "name": "statefulset-test" } ], "imagePullSecrets": [{ "name": "default-secret" }] } } }}

响应消息

响应参数:

响应参数的详细描述请参见表6-108

响应示例:

{ "kind": "StatefulSet", "apiVersion": "apps/v1beta1", "metadata": { "name": "statefulset-test", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/statefulset-test", "uid": "d9e1118c-fc20-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "486277", "generation": 1, "creationTimestamp": "2018-01-18T07:26:08Z", "labels": { "name": "statefulset-test" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "name": "statefulset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "statefulset-test" }, "enable": true }, "spec": { "containers": [ { "name": "statefulset-test", "image": "172.16.5.235:20202/test/nginx", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 282

Page 293: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } }, "serviceName": "service-test", "podManagementPolicy": "OrderedReady", "updateStrategy": { "type": "OnDelete" }, "revisionHistoryLimit": 10 }, "status": { "replicas": 0 }}

状态码

表6-116描述API的状态码。

表 6-116 状态码

状态码 描述

201 The request has been fulfilled,resulting in the creation of a newresource.

异常状态码请参见9.3 状态码。

6.6.2 删除 StatefulSet

功能介绍

This API is used to delete a StatefulSet resource object.

URI

DELETE /apis/apps/v1/namespaces/{namespace}/statefulsets/{name} (Supportsonly1.9)

DELETE /apis/apps/v1beta1/namespaces/{namespace}/statefulsets/{name}(Compatible)

表6-117描述该API的参数。

表 6-117 参数解释

参数 是否必选 描述

name Yes Name of the StatefulSet.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 283

Page 294: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

gracePeriodSeconds

No The duration in seconds before the object shouldbe deleted. Value must be a non-negativeinteger. The value zero indicates deleteimmediately. If this value is nil, the default graceperiod for the specified type will be used.Defaults to a per object value if not specified.zero means delete immediately.

orphanDependents

No Deprecated: Use the PropagationPolicy. This fieldwill be deprecated in 1.7. Should the dependentobjects be orphaned. If true/false, the "orphan"finalizer will be added to/removed from theobject's finalizers list. Either this field orPropagationPolicy may be set, but not both.

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field or OrphanDependentsmay be set, but not both. The default policy isdecided by the existing finalizer set in themetadata.finalizers and the resource-specificdefault policy. Acceptable values are: 'Orphan' -orphan the dependents; 'Background' - allow thegarbage collector to delete the dependents in thebackground; 'Foreground' - a cascading policythat deletes all dependents in the foreground.

请求消息

请求参数:

请求参数的详细描述请参见表6-147。

请求示例:

● 只删除StatefulSet(对应Pod不删除){ "Kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->StatefulSet的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

● 后台级联删除(按照StatefulSet->Pod的顺序进行删除){ "kind": "DeleteOptions",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 284

Page 295: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "v1", "propagationPolicy": "Background"}

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "code": 200}

状态码

表6-118描述API的状态码。

表 6-118 状态码

状态码 描述

200 Delete a StatefulSet resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.6.3 删除所有的 StatefulSet

功能介绍

This API is used to delete collection of StatefulSet.

URIDELETE /apis/apps/v1/namespaces/{namespace}/statefulsets (Supports only1.9)

DELETE /apis/apps/v1beta1/namespaces/{namespace}/statefulsets (Compatible)

表6-119描述该API的参数。

表 6-119 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 285

Page 296: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

continue No The continue option should be set whenretrieving more results from the server. Since thisvalue is server defined, clients may only use thecontinue value from a previous query result withidentical query parameters (except for the valueof continue) and the server may reject a continuevalue it does not recognize. If the specifiedcontinue value is no longer valid whether due toexpiration (generally five to fifteen minutes) or aconfiguration change on the server the serverwill respond with a 410 ResourceExpired errorindicating the client must restart their listwithout the continue field. This field is notsupported when watch is true. Clients may starta watch from the last resourceVersion valuereturned by the server and not miss anymodifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources are includedin the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 286

Page 297: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer than therequested amount of items (up to zero items) inthe event all requested objects are filtered outand clients should only use the presence of thecontinue field to determine whether more resultsare available. Servers may choose not to supportthe limit argument and will return all of theavailable results. If limit is specified and thecontinue field is empty, clients may assume thatno more results are available. This field is notsupported if watch is true. The server guaranteesthat the objects returned when using continuewill be identical to issuing a single list callwithout a limit - that is, no objects created,modified, or deleted after the first request isissued will be included in any subsequentcontinued requests. This is sometimes referred toas a consistent snapshot, and ensures that aclient that is using limit to receive smaller chunksof a very large result can ensure they see allpossible objects. If objects are updated during achunked list the version of the object that waspresent at the time the first list result wascalculated is returned.

resourceVersion No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history. When specified for list: - if unset, thenthe result is returned from remote storage basedon quorum-read flag; - if it's 0, then we simplyreturn what we currently have in cache, noguarantee; - if set to non zero, then the result isat least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update, andremove notifications. Specify resourceVersion.

请求消息

请求参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 287

Page 298: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求参数的详细描述请参见表6-147。

请求示例:

● 只删除StatefulSet(对应Pod不删除){ "Kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->StatefulSet的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

● 后台级联删除(按照StatefulSet->Pod的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Background"}

响应消息

响应参数:

响应参数的详细描述请参见表6-108。

响应示例:

{ "kind": "StatefulSet", "apiVersion": "apps/v1beta1", "metadata": { "name": "state--12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/apps/v1beta1/namespaces/ns-12130306-s/statefulsets/state--12130306", "uid": "dc139fbd-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418993", "generation": 2, "creationTimestamp": "2017-12-13T03:15:24Z", "deletionTimestamp": "2017-12-13T03:15:24Z", "deletionGracePeriodSeconds": 0, "labels": { "app": "mysql-0" }, "finalizers": [ "orphan" ], "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "cce" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "cce" }, "enable": true

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 288

Page 299: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "spec": { "containers": [ { "name": "rccon-12130306", "image": "172.16.5.235:20202/test/redis:v1", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "serviceName": "sc-12130306-s-0", "podManagementPolicy": "OrderedReady", "updateStrategy": { "type": "OnDelete" }, "revisionHistoryLimit": 10 }, "status": { "observedGeneration": 1, "replicas": 1, "currentReplicas": 1, "currentRevision": "state--12130306-1800136863", "updateRevision": "state--12130306-1800136863" }}

状态码

表6-120描述API的状态码。

表 6-120 状态码

状态码 描述

200 Delete a StatefulSet resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.6.4 获取指定的 StatefulSet

功能介绍

This API is used to read a StatefulSet object under a specified Namespace.

URI

GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name} (Supportsonly1.9)

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 289

Page 300: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

GET /apis/apps/v1beta1/namespaces/{namespace}/statefulsets/{name}(Compatible)

表6-121描述该API的参数。

表 6-121 参数解释

参数 是否必选 描述

name Yes Name of the StatefulSet.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

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

export No Should this value be exported. Export strips fieldsthat a user cannot specify.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-108。

响应示例:

{ "kind": "StatefulSet", "apiVersion": "apps/v1beta1", "metadata": { "name": "mysql", "generateName": "sz", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/mysql", "uid": "f5cf50f5-23fc-11e7-9c83-fa163ec08232", "resourceVersion": "1808945", "generation": 1, "creationTimestamp": "2017-04-18T06:05:02Z", "labels": { "app": "mysql" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "mysql" } }, "template": { "metadata": { "name": "-sz", "creationTimestamp": null,

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 290

Page 301: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"labels": { "app": "mysql" } }, "spec": { "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/nginx:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } }, "volumeClaimTemplates": [ { "metadata": { "name": "db", "creationTimestamp": null }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "1Gi" } } }, "status": { "phase": "Pending" } } ], "serviceName": "mysql-service" }, "status": { "replicas": 1 }}

状态码

表6-122描述API的状态码。

表 6-122 状态码

Status Code 描述

200 This operation succeeds, and aStatefulSet resource object is returned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 291

Page 302: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.6.5 获取指定的 StatefulSet 的状态

功能介绍

This API is used to read the status of a specified StatefulSet object under aspecified Namespace.

URIGET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status (Supportsonly1.9)

GET /apis/apps/v1beta1/namespaces/{namespace}/statefulsets/{name}/status(Compatible)

表6-123描述该API的参数。

表 6-123 参数解释

参数 是否必选 描述

name Yes Name of the StatefulSet.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-108。

响应示例:

{ "kind": "StatefulSet", "apiVersion": "apps/v1beta1", "metadata": { "name": "mysql", "generateName": "sz", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/mysql/status", "uid": "f5cf50f5-23fc-11e7-9c83-fa163ec08232", "resourceVersion": "1808945", "generation": 1, "creationTimestamp": "2017-04-18T06:05:02Z", "labels": { "app": "mysql" }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 292

Page 303: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "mysql" } }, "template": { "metadata": { "name": "-sz", "creationTimestamp": null, "labels": { "app": "mysql" } }, "spec": { "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/nginx:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } }, "volumeClaimTemplates": [ { "metadata": { "name": "db", "creationTimestamp": null }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "1Gi" } } }, "status": { "phase": "Pending" } } ], "serviceName": "mysql-service" }, "status": { "replicas": 1 }}

状态码

表6-124描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 293

Page 304: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-124 状态码

状态码 描述

200 This operation succeeds, and aStatefulSet resource object is returned.

异常状态码请参见9.3 状态码。

6.6.6 替换指定的 StatefulSet

功能介绍

This API is used to replace a StatefulSet object under a specified Namespace.

The following fields can be updated:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.clusterName

● metadata.generateName

● metadata.annotations

● spec.replicas

● template.contaions

● spec.restartPolicy

● spec.activeDeadlineSeconds

The other fields cannot be updated.

URI

PUT /apis/apps/v1/namespaces/{namespace}/statefulsets/{name} (Supportsonly1.9)

PUT /apis/apps/v1beta1/namespaces/{namespace}/statefulsets/{name}(Compatible)

表6-125描述该API的参数。

表 6-125 参数解释

参数 是否必选 描述

name Yes Name of the StatefulSet.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 294

Page 305: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

请求参数的详细描述请参见表6-108。

请求示例:

{ "apiVersion": "apps/v1beta1", "kind": "StatefulSet", "metadata": { "generateName": "sz", "labels": { "app": "mysql-0" }, "name": "mysql", "namespace": "default", "resourceVersion": "1923999" }, "spec": { "replicas": 1, "serviceName": "mysql-service", "template": { "metadata": { "labels": { "app": "mysql" } }, "spec": { "containers": [ { "image": "10.154.52.159:443/test/nginx:latest", "imagePullPolicy": "IfNotPresent", "name": "container01", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationGracePeriodSeconds": 100, "terminationMessagePath": "/dev/termination-log" } ] } }, "volumeClaimTemplates": [ { "metadata": { "name": "db" }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 295

Page 306: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"requests": { "storage": "1Gi" } } } } ] }}

响应消息

响应参数:

响应参数的详细描述请参见表6-108。

响应示例:

{ "kind": "StatefulSet", "apiVersion": "apps/v1beta1", "metadata": { "name": "mysql", "generateName": "sz", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/mysql", "uid": "1688bdcb-24da-11e7-9c83-fa163ec08232", "resourceVersion": "1923999", "generation": 1, "creationTimestamp": "2017-04-19T08:27:55Z", "labels": { "app": "mysql-0" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "mysql" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "mysql" } }, "spec": { "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/nginx:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 296

Page 307: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "volumeClaimTemplates": [ { "metadata": { "name": "db", "creationTimestamp": null }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "1Gi" } } }, "status": { "phase": "Pending" } } ], "serviceName": "mysql-service" }, "status": { "replicas": 1 }}

状态码

表6-126描述API的状态码。

表 6-126 状态码

状态码 描述

200 This operation succeeds, and aStatefulSet resource object is returned.

异常状态码请参见9.3 状态码。

6.6.7 替换指定的 StatefulSet 的状态

功能介绍

This API is used to replace the status of a specified StatefulSet object under aspecified Namespace, that is, to modify the value of the status field of theStatefulSet object.

URIPUT /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status (Supportsonly1.9)

PUT /apis/apps/v1beta1/namespaces/{namespace}/statefulsets/{name}/status(Compatible)

表6-127描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 297

Page 308: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-127 参数解释

参数 是否必选 描述

name Yes Name of the StatefulSet.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

请求参数的详细描述请参见表6-108。

请求示例:

{ "apiVersion": "apps/v1beta1", "kind": "StatefulSet", "metadata": { "generateName": "sz", "name": "numberlimit", "namespace": "default" }, "spec": { "replicas": 1, "serviceName": "service-number", "template": { "metadata": { "labels": { "app": "mysql" } }, "spec": { "containers": [ { "image": "10.154.52.159:443/test/mongo:latest", "imagePullPolicy": "IfNotPresent", "name": "container01", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": { "limits": { "cpu": "99M" }, "requests": { "cpu": "0.3G" } }, "terminationMessagePath": "/dev/termination-log" } ] } } }, "status": { "replicas": 3

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 298

Page 309: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}}

响应消息

响应参数:

响应参数的详细描述请参见表6-108。

响应示例:

{ "kind": "StatefulSet", "apiVersion": "apps/v1beta1", "metadata": { "name": "numberlimit", "generateName": "sz", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/numberlimit/status", "uid": "841f6be1-2a25-11e7-a2a3-fa163e3a4289", "resourceVersion": "1399495", "generation": 3, "creationTimestamp": "2017-04-26T02:10:27Z", "labels": { "app": "mysql" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "mysql" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "mysql" } }, "spec": { "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/mongo:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": { "limits": { "cpu": "99M" }, "requests": { "cpu": "300M" } }, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 299

Page 310: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "serviceName": "service-number" }, "status": { "replicas": 3 }}

状态码

表6-128描述API的状态码。

表 6-128 状态码

状态码 描述

200 This operation succeeds, and aStatefulSet resource object is returned.

异常状态码请参见9.3 状态码。

6.6.8 列出指定 Namespace 下的 StatefulSet

功能介绍

This API is used to list all StatefulSet resource objects under a specifiedNamespace.

URI

GET /apis/apps/v1/namespaces/{namespace}/statefulsets (Supports only1.9)

GET /apis/apps/v1beta1/namespaces/{namespace}/statefulsets (Compatible)

表6-129描述该API的参数。

表 6-129 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

includeUninitialized

No If true, partially initialized resources are includedin the response.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 300

Page 311: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

resourceVersion

No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history.

timeoutSeconds

No Timeout for the list/watch call.

watch No Watch for changes to the described resources andreturn them as a stream of add, update, andremove notifications. Specify resourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-108。

响应示例:

{ "kind": "StatefulSetList", "apiVersion": "apps/v1beta1", "metadata": { "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets", "resourceVersion": "1809849" }, "items": [ { "metadata": { "name": "mysql", "generateName": "sz", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/mysql", "uid": "f5cf50f5-23fc-11e7-9c83-fa163ec08232", "resourceVersion": "1809843", "generation": 1, "creationTimestamp": "2017-04-18T06:05:02Z", "labels": { "app": "mysql" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "mysql" } }, "template": { "metadata": { "name": "-sz", "creationTimestamp": null, "labels": { "app": "mysql"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 301

Page 312: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} }, "spec": { "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/nginx:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } }, "volumeClaimTemplates": [ { "metadata": { "name": "db", "creationTimestamp": null }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "1Gi" } } }, "status": { "phase": "Pending" } } ], "serviceName": "mysql-service" }, "status": { "replicas": 1 } } ]}

状态码

表6-130描述API的状态码。

表 6-130 状态码

状态码 描述

200 This operation succeeds, and aStatefulSet resource object is returned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 302

Page 313: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.6.9 列出指定的 StatefulSet

功能介绍

This API is used to list all StatefulSet resource objects.

URI

GET /apis/apps/v1/statefulsets (Supports only1.9)

GET /apis/apps/v1beta1/statefulsets (Compatible)

表6-131描述该API的参数。

表 6-131 参数解释

参数 是否必选 描述

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

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

includeUninitialized

No If true, partially initialized resources are includedin the response.

resourceVersion

No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history.

timeoutSeconds

No Timeout for the list/watch call.

watch No Watch for changes to the described resources andreturn them as a stream of add, update, andremove notifications. Specify resourceVersion.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

请求消息

N/A

响应消息

响应参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 303

Page 314: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-132 响应参数

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

items Object List of StatefulSets.具体请参见表6-108。

metadata metadata object Standard list metadata.

表 6-133 metadata 字段数据结构说明

参数 参数类型 描述

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treatedas opaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

响应示例:

{ "kind": "StatefulSetList", "apiVersion": "apps/v1beta1", "metadata": { "selfLink": "/apis/apps/v1beta1/statefulsets", "resourceVersion": "1809953" }, "items": [ { "metadata": { "name": "mysql", "generateName": "sz",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 304

Page 315: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/mysql", "uid": "f5cf50f5-23fc-11e7-9c83-fa163ec08232", "resourceVersion": "1809843", "generation": 1, "creationTimestamp": "2017-04-18T06:05:02Z", "labels": { "app": "mysql" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "mysql" } }, "template": { "metadata": { "name": "-sz", "creationTimestamp": null, "labels": { "app": "mysql" } }, "spec": { "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/nginx:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } }, "volumeClaimTemplates": [ { "metadata": { "name": "db", "creationTimestamp": null }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "1Gi" } } }, "status": { "phase": "Pending" } } ], "serviceName": "mysql-service"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 305

Page 316: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "status": { "replicas": 1 } } ]}

状态码

表6-134描述API的状态码。

表 6-134 状态码

状态码 描述

200 This operation succeeds, and a groupof StatefulSet resource objects isreturned.

异常状态码请参见9.3 状态码。

6.6.10 更新指定的 StatefulSet

功能介绍

This API is used to update a StatefulSet object under a specific Namespace.

The following fields can be updated:

● metadata.labels

● metadata.clusterName

● metadata.generateName

● metadata.annotations

● spec.replicas

● template.contaions

The other fields cannot be updated.

URI

PATCH /apis/apps/v1/namespaces/{namespace}/statefulsets/{name} (Supportsonly1.9)

PATCH /apis/apps/v1beta1/namespaces/{namespace}/statefulsets/{name}(Compatible)

表6-135描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 306

Page 317: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-135 参数解释

参数 是否必选 描述

name Yes Name of the StatefulSet.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json{ "metadata": { "labels": { "app": "mysql-0" } }}

响应消息

响应参数:

响应参数的详细描述请参见表6-108。

响应示例:

{ "kind": "StatefulSet", "apiVersion": "apps/v1beta1", "metadata": { "name": "mysql", "generateName": "sz", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/mysql", "uid": "1688bdcb-24da-11e7-9c83-fa163ec08232", "resourceVersion": "1924739", "generation": 1, "creationTimestamp": "2017-04-19T08:27:55Z", "labels": { "app": "mysql-0" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "mysql" } }, "template": { "metadata": { "creationTimestamp": null, "labels": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 307

Page 318: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"app": "mysql" } }, "spec": { "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/nginx:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } }, "volumeClaimTemplates": [ { "metadata": { "name": "db", "creationTimestamp": null }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "1Gi" } } }, "status": { "phase": "Pending" } } ], "serviceName": "mysql-service" }, "status": { "replicas": 1 }}

状态码

表6-136描述API的状态码。

表 6-136 状态码

状态码 描述

200 This operation succeeds, and aStatefulSet resource object is returned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 308

Page 319: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.6.11 更新指定的 StatefulSet 的状态

功能介绍

This API is used to update the status of a specified StatefulSet object under aspecified Namespace.

URIPATCH /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status(Supports only1.9)

PATCH /apis/apps/v1beta1/namespaces/{namespace}/statefulsets/{name}/status(Compatible)

表6-137描述该API的参数。

表 6-137 参数解释

参数 是否必选 描述

name Yes Name of the StatefulSet.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/json-patch+json[ { "op": "replace", "path": "/status/replicas", "value": 3 }]

响应消息

响应参数:

响应参数的详细描述请参见表6-108。

响应示例:

{ "kind": "StatefulSet",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 309

Page 320: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "apps/v1beta1", "metadata": { "name": "numberlimit", "generateName": "sz", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/numberlimit/status", "uid": "841f6be1-2a25-11e7-a2a3-fa163e3a4289", "resourceVersion": "1399731", "generation": 3, "creationTimestamp": "2017-04-26T02:10:27Z", "labels": { "app": "mysql" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "mysql" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "mysql" } }, "spec": { "containers": [ { "name": "container01", "image": "10.154.52.159:443/test/mongo:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": { "limits": { "cpu": "99M" }, "requests": { "cpu": "300M" } }, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } }, "serviceName": "service-number" }, "status": { "replicas": 3 }}

状态码

表6-138描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 310

Page 321: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-138 状态码

状态码 描述

200 This operation succeeds, and aStatefulSet resource object is returned.

异常状态码请参见9.3 状态码。

6.7 DaemonSet

6.7.1 创建 DaemonSet

功能介绍

This API is used to create a DaemonSet resource object.

URIPOST /apis/apps/v1/namespaces/{namespace}/daemonsets (Supports only1.9)

POST /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets(Compatible)

表6-139描述该API的参数。

表 6-139 参数描述

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

请求参数如表6-140所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 311

Page 322: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-140 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind Yes String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated. InCamelCase.

metadata Yes metadataobject

Standard object's metadata.

spec Yes spec object The desired behavior of thisdaemon set.

status No statusobject

The current status of thisdaemon set. This data may beout of date by some window oftime. Populated by the system.Read-only.

表 6-141 spec 字段数据结构说明

参数 是否必选 参数类型 描述

minReadySeconds

No Integer The minimum number ofseconds for which a newlycreated DaemonSet pod shouldbe ready without any of itscontainer crashing, for it to beconsidered available. Defaults to0 (pod will be consideredavailable as soon as it is ready).

revisionHistoryLimit

No Integer The number of old history toretain to allow rollback. This is apointer to distinguish betweenexplicit zero and not specified.Defaults to 10.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 312

Page 323: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

selector No selectorobject

A label query over pods that aremanaged by the daemon set.Must match in order to becontrolled. If empty, defaultedto labels on Pod template.

template Yes templateobject

An object that describes the podthat will be created. TheDaemonSet will create exactlyone copy of this pod on everynode that matches thetemplate's node selector (or onevery node if no node selector isspecified).

templateGeneration

No Integer DEPRECATED. A sequencenumber representing a specificgeneration of the template.Populated by the system. It canbe set only during the creation.

updateStrategy No updateStrategy object

An update strategy to replaceexisting DaemonSet pods withnew pods.

表 6-142 status 字段数据结构说明

参数 是否必选 参数类型 描述

collisionCount No Integer Count of hash collisions for theDaemonSet. The DaemonSetcontroller uses this field as acollision avoidance mechanismwhen it needs to create thename for the newestControllerRevision.

currentNumberScheduled

No Integer The number of nodes that arerunning at least 1 daemon podand are supposed to run thedaemon pod.

desiredNumberScheduled

No Integer The total number of nodes thatshould be running the daemonpod (including nodes correctlyrunning the daemon pod).

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 313

Page 324: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

numberAvailable

No Integer The number of nodes thatshould be running the daemonpod and have one or more ofthe daemon pod running andavailable (ready for at leastspec.minReadySeconds)

numberMisscheduled

No Integer The number of nodes that arerunning the daemon pod, butare not supposed to run thedaemon pod.

numberReady No Integer The number of nodes thatshould be running the daemonpod and have one or more ofthe daemon pod running andready.

numberUnavailable

No Integer The number of nodes thatshould be running the daemonpod and have none of thedaemon pod running andavailable (ready for at leastspec.minReadySeconds)

observedGeneration

No Integer The most recent generationobserved by the daemon setcontroller.

updatedNumberScheduled

No Integer The total number of nodes thatare running updated daemonpod

表 6-143 template 字段数据结构说明

参数 是否必选 参数类型 描述

metadata Yes metadataobject

Standard object's metadata.

spec Yes Object Specification of the desiredbehavior of the pod.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 314

Page 325: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-144 updateStrategy 字段数据结构说明

参数 是否必选 参数类型 描述

rollingUpdate Yes Object Rolling update config params.Present only if type ="RollingUpdate".

type No String Type of daemon set update. Canbe "RollingUpdate" or"OnDelete". Default isOnDelete.

请求示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "daemonset-test", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "daemonset-test", "image": "172.16.5.235:20202/test/nginx", "imagePullPolicy": "IfNotPresent" } ], "imagePullSecrets": [{ "name": "default-secret" }] } } }}

响应消息

响应参数:

响应参数的详细描述请参见表6-140

响应示例:

{ "kind": "DaemonSet",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 315

Page 326: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "extensions/v1beta1", "metadata": { "name": "daemonset-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/daemonsets/daemonset-test", "uid": "f9808766-fc23-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "487764", "generation": 1, "creationTimestamp": "2018-01-18T07:48:29Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "daemonset-test", "image": "172.16.5.235:20202/test/nginx", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 0, "numberMisscheduled": 0, "desiredNumberScheduled": 0, "numberReady": 0 }}

状态码

表6-145描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 316

Page 327: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-145 状态码

状态码 描述

201 The request has been fulfilled,resulting in the creation of a newresource.

异常状态码请参见9.3 状态码。

6.7.2 删除 DaemonSet

功能介绍

This API is used to delete a DaemonSet resource object.

URI

DELETE /apis/apps/v1/namespaces/{namespace}/daemonsets/{name} (Supportsonly1.9)

DELETE /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets/{name}(Compatible)

表6-146描述该API的参数。

表 6-146 参数解释

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teamsand projects

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

gracePeriodSeconds

No The duration in seconds before the objectshould be deleted. Value must be non-negativeinteger. The value zero indicates deleteimmediately. If this value is nil, the defaultgrace period for the specified type will be used.Defaults to a per object value if not specified.zero means delete immediately.

orphanDependents

No Deprecated: please use the PropagationPolicy,this field will be deprecated in 1.7. Should thedependent objects be orphaned. If true/false,the "orphan" finalizer will be added to/removed from the object's finalizers list. Eitherthis field or PropagationPolicy may be set, butnot both.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 317

Page 328: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field orOrphanDependents may be set, but not both.The default policy is decided by the existingfinalizer set in the metadata.finalizers and theresource-specific default policy. Acceptablevalues are: 'Orphan' - orphan the dependents;'Background' - allow the garbage collector todelete the dependents in the background;'Foreground' - a cascading policy that deletesall dependents in the foreground.

请求消息

请求参数:

请求参数如表6-147所示。

表 6-147 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines the versionedschema of this representation of anobject. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

gracePeriodSeconds

No Integer The duration in seconds before theobject should be deleted. Valuemust be non-negative integer. Thevalue zero indicates deleteimmediately. If this value is nil, thedefault grace period for thespecified type will be used. Defaultsto a per object value if notspecified. zero means deleteimmediately.

kind Ye String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 318

Page 329: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

orphanDependents

No Boolean Deprecated: please use thePropagationPolicy, this field will bedeprecated in 1.7. Should thedependent objects be orphaned. Iftrue/false, the "orphan" finalizerwill be added to/removed from theobject's finalizers list. Either thisfield or PropagationPolicy may beset, but not both.

preconditions

No preconditionsobject

Must be fulfilled before a deletionis carried out. If not possible, a 409Conflict status will be returned.

propagationPolicy

No String Whether and how garbagecollection will be performed. Eitherthis field or OrphanDependentsmay be set, but not both. Thedefault policy is decided by theexisting finalizer set in themetadata.finalizers and theresource-specific default policy.Acceptable values are: 'Orphan' -orphan the dependents;'Background' - allow the garbagecollector to delete the dependentsin the background; 'Foreground' - acascading policy that deletes alldependents in the foreground.

表 6-148 preconditions 字段数据结构说明

参数 是否必选 参数类型 描述

uid No String Specifies the target UID.

请求示例:

● 只删除DaemonSet(对应Pod不删除){ "Kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->DaemonSet的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 319

Page 330: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● 后台级联删除(按照DaemonSet->Pod的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Background"}

响应消息

响应参数:

响应参数的详细描述请参见Table 5-9。

响应示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419055", "generation": 2, "creationTimestamp": "2017-12-13T03:15:24Z", "deletionTimestamp": "2017-12-13T03:15:55Z", "deletionGracePeriodSeconds": 0, "labels": { "name": "daemonset-test" }, "finalizers": [ "orphan" ], "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 320

Page 331: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 1 }}

状态码

表6-149描述API的状态码。

表 6-149 状态码

状态码 描述

200 Delete a DeamonSet resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.7.3 删除所有的 Daemonset

功能介绍

This API is used to delete collection of DaemonSet.

URIDELETE /apis/apps/v1/namespaces/{namespace}/daemonsets (Supports only1.9)

DELETE /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets(Compatible)

表6-150描述该API的参数。

表 6-150 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

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

fieldSelector No A selector to restrict the list of returnedobjects by their fields. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 321

Page 332: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returnedobjects by their labels. Defaults to everything.

resourceVersion

No When specified with a watch call, showschanges that occur after that particularversion of a resource. Defaults to changesfrom the beginning of history. When specifiedfor list: - if unset, then the result is returnedfrom remote storage based on quorum-readflag; - if it's 0, then we simply return what wecurrently have in cache, no guarantee; - if setto non zero, then the result is at least as freshas given rv.

timeoutSeconds

No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

请求参数:

请求参数的详细描述请参见表6-147。

请求示例:

● 只删除DaemonSet(对应Pod不删除){ "Kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->DaemonSet的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

● 后台级联删除(按照DaemonSet->Pod的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Background"}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 322

Page 333: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表6-140。

响应示例:

{ "kind": "DaemonSetList", "apiVersion": "extensions/v1beta1", "metadata": { "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets", "resourceVersion": "419060" }, "items": []}

状态码

表6-151描述API的状态码。

表 6-151 状态码

状态码 描述

200 Delete a DaemonSet resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.7.4 获取指定的 DaemonSet

功能介绍

This API is used to read a DaemonSet object under a specified Namespace.

URIGET /apis/apps/v1/namespaces/{namespace}/daemonsets/{name} (Supportsonly1.9)

GET /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets/{name}(Compatible)

表6-152描述该API的参数。

表 6-152 参数描述

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teamsand projects

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 323

Page 334: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

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

exact No Should the export be exact. Exact export maintainscluster-specific fields like 'Namespace'.

export No Should this value be exported. Export strips fieldsthat a user can not specify.

请求消息

N/A

响应消息

响应参数:

响应参数的详细说明请参见表6-140。

响应示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419052", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ],

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 324

Page 335: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 1 }}

状态码

表6-153描述API的状态码。

表 6-153 状态码

状态码 描述

200 This operation succeeds, and aDaemonSet resource object isreturned.

异常状态码请参见9.3 状态码。

6.7.5 获取指定的 DaemonSet 的状态

功能介绍

This API is used to read the status of a specified DaemonSet object under aspecified Namespace.

URI

GET /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}/status(Supports only1.9)

GET /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets/{name}/status (Compatible)

表6-154描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 325

Page 336: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-154 参数解释

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-140。

响应示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306/status", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419052", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 326

Page 337: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 1 }}

状态码

表6-155描述API的状态码。

表 6-155 状态码

状态码 描述

200 This operation succeeds, and aDaemonSet resource object isreturned.

异常状态码请参见9.3 状态码。

6.7.6 更新指定的 DaemonSet

功能介绍

This API is used to update a DaemonSet object under a specific Namespace.

The following fields can be updated:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.labels

● spec.selector

● spec.template.spec.containers

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 327

Page 338: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● spec.templateGeneration● spec.revisionHistoryLimit

The other fields cannot be updated.

URIPATCH /apis/apps/v1/namespaces/{namespace}/daemonsets/{name} (Supportsonly1.9)

PATCH /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets/{name}(Compatible)

表6-156描述该API的参数。

表 6-156 参数解释

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/json-patch+json[ { "op": "add", "path": "/spec/template/spec/containers/0/image", "value": "172.16.5.235:20202/test/redis:latest" }]

响应消息

响应参数:

响应参数的详细描述请参见表6-140。

响应示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 328

Page 339: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"resourceVersion": "419012", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 1 }}

状态码

表6-157描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 329

Page 340: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-157 状态码

状态码 描述

200 This operation succeeds, and aDaemonSet resource object isreturned.

异常状态码请参见9.3 状态码。

6.7.7 更新指定的 DaemonSet 的状态

功能介绍

This API is used to update the status of a specified DaemonSet object under aspecified Namespace.

URIPATCH /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}/status(Supports only1.9)

PATCH /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets/{name}/status (Compatible)

表6-158描述该API的参数。

表 6-158 参数解释

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teamsand projects

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json[ { "op": "add", "path": "/status/numberAvailable", "value": 2 }]

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 330

Page 341: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表6-140。

响应示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306/status", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419051", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1,

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 331

Page 342: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"numberAvailable": 2 }}

状态码

表6-159描述API的状态码。

表 6-159 状态码

状态码 描述

200 This operation succeeds, and aDaemonSet resource object isreturned.

异常状态码请参见9.3 状态码。

6.7.8 列出指定的 DaemonSet

功能介绍

This API is used to list all DemonSet resource objects.

URIGET /apis/apps/v1/daemonsets (Supports only1.9)

GET /apis/extensions/v1beta1/daemonsets (Compatible)

表6-160描述该API的参数。

表 6-160 参数解释

参数 是否必选 描述

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources are includedin the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 332

Page 343: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently have incache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

响应消息

响应参数:

表 6-161 响应参数

参数 参数类型 描述

apiVersion String APIVersion defines the versioned schema of thisrepresentation of an object. Servers shouldconvert recognized schemas to the latestinternal value, and may reject unrecognizedvalues.

items Array ofstrings

A list of daemon sets.

kind String Kind is a string value representing the RESTresource this object represents. Servers mayinfer this from the endpoint the client submitsrequests to. Cannot be updated. In CamelCase.

metadata metadataobject

Standard list metadata.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 333

Page 344: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-162 metadata 字段数据结构说明

参数 参数类型 描述

resourceVersion

String String that identifies the server's internalversion of this object that can be used by clientsto determine when objects have changed. Valuemust be treated as opaque by clients andpassed unmodified back to the server.Populated by the system. Read-only.

selfLink String SelfLink is a URL representing this object.Populated by the system. Read-only.

响应示例:

{ "kind": "DaemonSetList", "apiVersion": "extensions/v1beta1", "metadata": { "selfLink": "/apis/extensions/v1beta1/daemonsets", "resourceVersion": "419049" }, "items": [ { "metadata": { "name": "icagent", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/daemonsets/icagent", "uid": "ac2cd485-dc8e-11e7-9c19-fa163e2d897b", "resourceVersion": "23583", "generation": 1, "creationTimestamp": "2017-12-09T03:11:39Z", "labels": { "name": "icagent" }, "enable": true }, "spec": { "selector": { "matchLabels": { "app": "icagent" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "icagent" }, "annotations": { "scheduler.alpha.kubernetes.io/tolerations": "[{\"key\":\"beta.k8s.io/accepted-app\",\"operator\":\"Exists\", \"effect\":\"NoSchedule\"}]" }, "enable": true }, "spec": { "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default_secrets"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 334

Page 345: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} ], "schedulerName": "default-scheduler", "processes": [ { "name": "icagent", "package": "https://172.16.5.235:20202/swr/v2/domains/op_svc_apm/namespaces/op_svc_apm/repositories/default/packages/icagent-repo/versions/5.6.67/file_paths/ICProbeAgent-5.6.67.zip", "env": [ { "name": "cluster_id", "value": "8bfd2e95-dc8d-11e7-8766-0255ac101a0c" }, { "name": "cluster_name", "value": "test-1209" } ], "resources": {}, "livenessProbe": { "exec": { "command": [ "/bin/bash", "-c", "curl --connect-timeout 5 -m 5 http://127.0.0.1:28002/health 2>/dev/null | /usr/bin/grep -w 200 | /usr/bin/grep -v /usr/bin/grep 1>/dev/null" ] }, "initialDelaySeconds": 15, "timeoutSeconds": 5, "periodSeconds": 10, "successThreshold": 1, "failureThreshold": 3 }, "lifecycle": { "install": { "exec": { "command": [ "/bin/bash", "bin/manual/setup.sh", "-ip", "172.16.5.235:9999", "-localip", "127.0.0.1", "-user", "root" ] } }, "uninstall": { "exec": { "command": [ "/bin/bash", "-c", "/bin/bash bin/manual/uninstall.sh" ] } }, "start": { "exec": { "command": [ "/bin/bash", "-c", "cd /opt/oss/servicemgr/ICAgent/bin/manual/;/bin/bash mstart.sh" ] } }, "restart": { "exec": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 335

Page 346: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"command": [ "/bin/bash", "-c", "cd /opt/oss/servicemgr/ICAgent/bin/manual/;/bin/bash mstop.sh;/bin/bash mstart.sh" ] } }, "stop": { "exec": { "command": [ "/bin/bash", "-c", "cd /opt/oss/servicemgr/ICAgent/bin/manual/;/bin/bash mstop.sh" ] } }, "update": { "exec": { "command": [ "" ] } } } } ] } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 1 } }, { "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419012", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 336

Page 347: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 1 } } ]}

状态码

表6-163描述API的状态码。

表 6-163 状态码

状态码 描述

200 This operation succeeds, and aDaemonSet resource object isreturned.

异常状态码请参见9.3 状态码。

6.7.9 列出指定 Namespace 下的 DaemonSet

功能介绍

This API is used to list all DaemonSet resource objects under a specifiedNamespace.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 337

Page 348: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URI

GET /apis/apps/v1/namespaces/{namespace}/daemonsets (Supports only1.9)

GET /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets(Compatible)

表6-164描述该API的参数。

表 6-164 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

fieldSelector No A selector to restrict the list of returned objects bytheir fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources are included inthe response.

labelSelector No A selector to restrict the list of returned objects bytheir labels. Defaults to everything.

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

resourceVersion

No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history. When specified for list: - if unset, thenthe result is returned from remote storage basedon quorum-read flag; - if it's 0, then we simplyreturn what we currently have in cache, noguarantee; - if set to non zero, then the result is atleast as fresh as given rv.

timeoutSeconds

No Timeout for the list/watch call.

watch No Watch for changes to the described resources andreturn them as a stream of add, update, andremove notifications. Specify resourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-140。

响应示例:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 338

Page 349: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "kind": "DaemonSetList", "apiVersion": "extensions/v1beta1", "metadata": { "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets", "resourceVersion": "419006" }, "items": [ { "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419004", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 0, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberUnavailable": 1 }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 339

Page 350: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} ]}

状态码

表6-165描述API的状态码。

表 6-165 状态码

状态码 描述

200 This operation succeeds, and aDaemonSet resource object isreturned.

异常状态码请参见9.3 状态码。

6.7.10 替换指定的 DaemonSet

功能介绍

This API is used to replace a DaemonSet object under a specified Namespace.

The following fields can be updated:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.labels

● spec.selector

● spec.template.spec.containers

● spec.templateGeneration

● spec.revisionHistoryLimit

The other fields cannot be updated.

URI

PUT /apis/apps/v1/namespaces/{namespace}/daemonsets/{name} (Supportsonly1.9)

PUT /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets/{name}(Compatible)

表6-166描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 340

Page 351: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-166 参数描述

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

请求参数:

请求参数的详细描述请参见表6-140。

请求示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419052", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 341

Page 352: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 1 }}

响应消息

响应参数:

响应参数的详细描述请参见表6-140。

响应示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419052", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 342

Page 353: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 1 }}

状态码

表6-167描述API的状态码。

表 6-167 状态码

状态码 描述

200 This operation succeeds, and aDaemonSet resource object isreturned.

异常状态码请参见9.3 状态码。

6.7.11 替换指定的 DaemonSet 的状态

功能介绍

This API is used to replace the status of a specified DaemonSet object under aspecified Namespace, that is, to modify the value of the status field of theDaemonSet object.

URI

PUT /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}/status(Supports only1.9)

PUT /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets/{name}/status (Compatible)

表6-168描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 343

Page 354: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-168 参数解释

参数 是否必选 描述

name Yes name of the DaemonSet

namespace Yes object name and auth scope, such as for teams andprojects

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

请求消息

请求参数:

请求参数的详细说明请参见表6-140。

请求示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306/status", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419052", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 344

Page 355: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 2 }}

响应消息

响应参数:

响应参数的详细说明请参见表6-140。

响应示例:

{ "kind": "DaemonSet", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ds-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/extensions/v1beta1/namespaces/ns-12130306-s/daemonsets/ds-12130306/status", "uid": "dc72a82b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419053", "generation": 1, "creationTimestamp": "2017-12-13T03:15:24Z", "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "selector": { "matchLabels": { "name": "daemonset-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "daemonset-test" }, "enable": true }, "spec": { "containers": [ { "name": "dscon-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 345

Page 356: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } }, "updateStrategy": { "type": "OnDelete" }, "templateGeneration": 1, "revisionHistoryLimit": 10 }, "status": { "currentNumberScheduled": 1, "numberMisscheduled": 0, "desiredNumberScheduled": 1, "numberReady": 1, "observedGeneration": 1, "updatedNumberScheduled": 1, "numberAvailable": 2 }}

状态码

表6-169描述API的状态码。

表 6-169 状态码

状态码 描述

200 This operation succeeds, and aDaemonSet resource object isreturned.

异常状态码请参见9.3 状态码。

6.8 Job

6.8.1 创建 Job

功能介绍

This API is used to create a Job resource object.

URIPOST /apis/batch/v1/namespaces/{namespace}/jobs

表6-170描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 346

Page 357: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-170 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

请求参数如表6-171所示。

表 6-171 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind Yes String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated.

metadata Yes metadataobject

Standard list metadata.

spec Yes spec object Spec defines the desiredidentities of pods in this set.

status No status object Status is the current status ofPods in this StatefulSet. Thisdata may be out of date bysome window of time.

表 6-172 status 字段数据结构说明

参数 是否必选 参数类型 描述

active No Integer The number of actively runningpods.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 347

Page 358: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

completionTime No String Replicas is the number of actualreplicas.

conditions No JobConditionobject

The latest available observationsof an object's current state. Moreinfo:

failed No Integer The number of pods whichreached phase Failed.

startTime No String Represents time when the jobwas acknowledged by the jobcontroller. It is not guaranteed tobe set in happens-before orderacross separate operations. It isrepresented in RFC3339 form andis in UTC.

succeeded No Integer The number of pods whichreached phase Succeeded.

表 6-173 spec 字段数据结构说明

参数 是否必选 参数类型 描述

activeDeadlineSeconds

No Integer Specifies the duration inseconds relative to thestartTime that the job may beactive before the system tries toterminate it; value must bepositive integer

backoffLimit No Integer Specifies the number of retriesbefore marking this job failed.Defaults to 6.

completions No Integer Specifies the desired number ofsuccessfully finished pods thejob should be run with. Settingto nil means that the success ofany pod signals the success ofall pods, and allows parallelismto have any positive value.Setting to 1 means thatparallelism is limited to 1 andthe success of that pod signalsthe success of the job.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 348

Page 359: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

manualSelector No Boolean manualSelector controlsgeneration of pod labels andpod selectors. LeavemanualSelector unset unlessyou are certain what you aredoing. When false or unset, thesystem pick labels unique to thisjob and appends those labels tothe pod template. When true,the user is responsible forpicking unique labels andspecifying the selector. Failureto pick a unique label maycause this and other jobs to notfunction correctly. However, Youmay see manualSelector=true injobs that were created with theold extensions/v1beta1 API.

parallelism No Integer Specifies the maximum desirednumber of pods the job shouldrun at any given time. Theactual number of pods runningin steady state will be less thanthis number when((.spec.completions- .status.successful)< .spec.parallelism), i.e. whenthe work left to do is less thanmax parallelism.

selector Yes selector object Selector is a label query overpods that should match thereplica count. If empty,defaulted to labels on the podtemplate.

template Yes templateobject

Template is the object thatdescribes the pod that will becreated if insufficient replicasare detected. Each pod stampedout by the StatefulSet will fulfillthis Template, but have aunique identity from the rest ofthe StatefulSet.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 349

Page 360: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-174 selector 字段数据结构说明

参数 是否必选 参数类型 描述

matchExpressions

No matchExpressions object

matchExpressions is a list oflabel selector requirements. Therequirements are ANDed.

matchLabels No Object MatchLabels is a map of{key,value} pairs. A single{key,value} in the matchLabelsmap is equivalent to an elementof matchExpressions, whose keyfield is "key", the operator is"In", and the values arraycontains only "value". Therequirements are ANDed.

表 6-175 matchExpressions 字段数据结构说明

参数 是否必选 参数类型 描述

key No String key is the label key that theselector applies to.

operator No String operator represents a key'srelationship to a set of values.Valid operators are In, NotIn,Exists and DoesNotExist.

values No String values is an array of stringvalues. If the operator is In orNotIn, the values array must benon-empty. If the operator isExists or DoesNotExist, thevalues array must be empty.This array is replaced during astrategic merge patch.

表 6-176 PodTemplateSpec 字段数据结构说明

参数 是否必选 参数类型 描述

metadata Yes metadataobject

Standard object's metadata.

spec Yes spec object Specification of the desiredbehavior of the pod.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 350

Page 361: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-177 JobCondition 字段数据结构说明

参数 是否必选 参数类型 描述

lastProbeTime No String Last time the condition waschecked.

lastTransitionTime

No String Last time the condition transitfrom one status to another.

message No String Human readable messageindicating details about lasttransition

reason No String (brief) reason for thecondition's last transition.

status No String Status of the condition, one ofTrue, False, Unknown.

type No String Type of job condition,Complete or Failed.

请求示例:

{ "apiVersion": "batch/v1", "kind": "Job", "metadata": { "labels": { "name": "job-test" }, "name": "job-test" }, "spec": { "template": { "metadata": { "labels": { "name": "job-test" }, "name": "job-test" }, "spec": { "containers": [ { "image": "172.16.5.235:20202/test/nginx", "name": "job-test" } ], "imagePullSecrets": [{ "name": "default-secret" }], "restartPolicy": "Never" } } }}

响应消息

响应参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 351

Page 362: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应参数的详细描述请参见表6-171。

响应示例:

{ "kind": "Job", "apiVersion": "batch/v1", "metadata": { "name": "job-test", "namespace": "default", "selfLink": "/apis/batch/v1/namespaces/default/jobs/job-test", "uid": "45444e9b-fc20-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "486000", "creationTimestamp": "2018-01-18T07:21:58Z", "labels": { "name": "job-test" }, "enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "45444e9b-fc20-11e7-9c3c-fa163eb8ad1a" } }, "template": { "metadata": { "name": "job-test", "creationTimestamp": null, "labels": { "controller-uid": "45444e9b-fc20-11e7-9c3c-fa163eb8ad1a", "job-name": "job-test", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "job-test", "image": "172.16.5.235:20202/test/nginx", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } }, "status": {}}

状态码

表6-178描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 352

Page 363: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-178 状态码

状态码 描述

201 The request has been fulfilled,resulting in the creation of a newresource.

异常状态码请参见9.3 状态码。

6.8.2 删除 Job

功能介绍

This API is used to delete a Job.

URIDELETE /apis/batch/v1/namespaces/{namespace}/jobs/{name}

表6-179描述该API的参数。

表 6-179 参数解释

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

name Yes name of the Job

namespace Yes object name and auth scope, suchas for teams and projects

gracePeriodSeconds No The duration in seconds beforethe object should be deleted.Value must be a non-negativeinteger. The value zero indicatesdelete immediately. If this value isnil, the default grace period forthe specified type will be used.Defaults to a per object value ifnot specified. zero means deleteimmediately.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 353

Page 364: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

orphanDependents No Deprecated: please use thePropagationPolicy, this field willbe deprecated in 1.7. Should thedependent objects be orphaned. Iftrue/false, the "orphan" finalizerwill be added to/removed fromthe object's finalizers list. Eitherthis field or PropagationPolicymay be set, but not both.

propagationPolicy No Whether and how garbagecollection will be performed.Either this field orOrphanDependents may be set,but not both. The default policy isdecided by the existing finalizerset in the metadata.finalizers andthe resource-specific defaultpolicy. Acceptable values are:'Orphan' - orphan thedependents; 'Background' - allowthe garbage collector to deletethe dependents in thebackground; 'Foreground' - acascading policy that deletes alldependents in the foreground.

请求消息

请求参数:

请求参数如表6-180所示。

表 6-180 参数解释

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this object represents.Servers may infer this fromthe endpoint the clientsubmits requests to. Cannotbe updated. In CamelCase.The value of this parameter isDeleteOptions.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 354

Page 365: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

gracePeriodSeconds

No Integer The duration in secondsbefore the object should bedeleted. Value must be a non-negative integer. The valuezero indicates deleteimmediately. If this value isnil, the default grace periodfor the specified type will beused. Defaults to a per objectvalue if not specified. zeromeans delete immediately.Value range of this parameter:> 0.

preconditions No preconditions object

Must be fulfilled before adeletion is carried out. If notpossible, a 409 Conflict statuswill be returned.

orphanDependents

No Boolean Deprecated: please use thePropagationPolicy, this fieldwill be deprecated in 1.7.Should the dependent objectsbe orphaned. If true/false, the"orphan" finalizer will beadded to/removed from theobject's finalizers list. Eitherthis field or PropagationPolicymay be set, but not both.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 355

Page 366: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

propagationPolicy

No String Whether and how garbagecollection will be performed.Either this field orOrphanDependents may beset, but not both. The defaultpolicy is decided by theexisting finalizer set in themetadata.finalizers and theresource-specific defaultpolicy. Acceptable values are:'Orphan' - orphan thedependents; 'Background' -allow the garbage collector todelete the dependents in thebackground; 'Foreground' - acascading policy that deletesall dependents in theforeground.

表 6-181 preconditions 字段数据结构说明

参数 是否必选 参数类型 描述

uid No String Specifies the target UID.

请求示例:

● 只删除Job(对应Pod不删除):{ "kind": "DeleteOptions", "apiVersion": "v1", "gracePeriodSeconds": 0, "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->Job的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

● 后台级联删除(按照Job->Pod的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Background"}

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 356

Page 367: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "kind": "Job", "apiVersion": "batch/v1", "metadata": { "name": "jobs-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs/jobs-12130306", "uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419072", "creationTimestamp": "2017-12-13T03:15:55Z", "deletionTimestamp": "2017-12-13T03:15:56Z", "deletionGracePeriodSeconds": 0, "labels": { "app": "new-jobs", "name": "job-test" }, "finalizers": [ "orphan" ], "enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b" } }, "template": { "metadata": { "name": "jobs-12130306", "creationTimestamp": null, "labels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "job-name": "jobs-12130306", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "jobs-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "startTime": "2017-12-13T03:15:55Z", "active": 1 }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 357

Page 368: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-182描述API的状态码。

表 6-182 状态码

状态码 描述

200 Delete a Job resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.8.3 删除所有的 Job

功能介绍

This API is used to delete collection of Job.

URI

DELETE /apis/batch/v1/namespaces/{namespace}/jobs

表6-183描述该API的参数。

表 6-183 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

continue No The continue option should be set whenretrieving more results from the server. Since thisvalue is server defined, clients may only use thecontinue value from a previous query result withidentical query parameters (except for the valueof continue) and the server may reject a continuevalue it does not recognize. If the specifiedcontinue value is no longer valid whether due toexpiration (generally five to fifteen minutes) or aconfiguration change on the server the serverwill respond with a 410 ResourceExpired errorindicating the client must restart their listwithout the continue field. This field is notsupported when watch is true. Clients may starta watch from the last resourceVersion valuereturned by the server and not miss anymodifications.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 358

Page 369: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources are includedin the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer than therequested amount of items (up to zero items) inthe event all requested objects are filtered outand clients should only use the presence of thecontinue field to determine whether more resultsare available. Servers may choose not to supportthe limit argument and will return all of theavailable results. If limit is specified and thecontinue field is empty, clients may assume thatno more results are available. This field is notsupported if watch is true. The server guaranteesthat the objects returned when using continuewill be identical to issuing a single list callwithout a limit - that is, no objects created,modified, or deleted after the first request isissued will be included in any subsequentcontinued requests. This is sometimes referred toas a consistent snapshot, and ensures that aclient that is using limit to receive smaller chunksof a very large result can ensure they see allpossible objects. If objects are updated during achunked list the version of the object that waspresent at the time the first list result wascalculated is returned.

resourceVersion No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history. When specified for list: - if unset, thenthe result is returned from remote storage basedon quorum-read flag; - if it's 0, then we simplyreturn what we currently have in cache, noguarantee; - if set to non zero, then the result isat least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 359

Page 370: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

watch No Watch for changes to the described resourcesand return them as a stream of add, update, andremove notifications. Specify resourceVersion.

请求消息

请求参数:

请求参数的详细描述请参见表6-180。

请求示例:

● 只删除Job(对应Pod不删除):{ "kind": "DeleteOptions", "apiVersion": "v1", "gracePeriodSeconds": 0, "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->Job的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

● 后台级联删除(按照Job->Pod的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Background"}

响应消息

响应参数:

响应参数的详细描述请参见表6-171。

响应示例:

{ "kind": "JobList", "apiVersion": "batch/v1", "metadata": { "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs", "resourceVersion": "419076" }, "items": []}

状态码

表6-184描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 360

Page 371: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-184 状态码

状态码 描述

200 Delete a Job resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.8.4 获取指定的 Job

功能介绍

This API is used to read the specified Job.

URIGET /apis/batch/v1/namespaces/{namespace}/jobs/{name}

表6-185描述该API的参数。

表 6-185 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Job.

exact No Should the export be exact.Exact export maintainscluster-specific fields like'Namespace'.

export No Should this value beexported. Export stripsfields that a user cannotspecify.

请求消息

N/A

响应消息

响应参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 361

Page 372: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应参数的详细描述请参见表6-171。

响应示例:

{ "kind": "Job", "apiVersion": "batch/v1", "metadata": { "name": "example-job", "namespace": "default", "selfLink": "/apis/batch/v1/namespaces/default/jobs/example-job", "uid": "d93a3569-a2be-11e6-a008-fa043d458cc7", "resourceVersion": "7482", "creationTimestamp": "2016-11-04T18:45:25Z" }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "d93a3569-a2be-11e6-a008-fa043d458cc7" } }, "template": { "metadata": { "name": "example-job", "creationTimestamp": null, "labels": { "controller-uid": "d93a3569-a2be-11e6-a008-fa043d458cc7", "job-name": "example-job" } }, "spec": { "containers": [ { "name": "pi", "image": "perl", "command": [ "perl", "-Mbignum=bpi", "-wle", "print bpi(2000)" ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } } }, "status": { "startTime": "2016-11-04T18:45:25Z", "active": 1 }}

状态码

表6-186描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 362

Page 373: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-186 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

6.8.5 获取指定的 Job 的状态

功能介绍

This API is used to read the status of the specified Job.

URIGET /apis/batch/v1/namespaces/{namespace}/jobs/{name}/status

表6-187描述该API的参数。

表 6-187 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Job.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见Table 3-82。

响应示例:

{ "kind": "Job", "apiVersion": "batch/v1", "metadata": { "name": "jobs-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs/jobs-12130306/status",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 363

Page 374: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419068", "creationTimestamp": "2017-12-13T03:15:55Z", "labels": { "app": "new-jobs", "name": "job-test" }, "enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b" } }, "template": { "metadata": { "name": "jobs-12130306", "creationTimestamp": null, "labels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "job-name": "jobs-12130306", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "jobs-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "startTime": "2017-12-13T03:15:55Z", "active": 1 }}

状态码

表6-188描述API的状态码。

表 6-188 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 364

Page 375: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.8.6 替换指定的 Job

功能介绍

This API is used to replace the specified Job.

The following fields can be updated:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.clusterName

● metadata.generateName

● metadata.annotations

● spec.replicas

● template.contaions

● spec.restartPolicy

● spec.activeDeadlineSeconds

URI

PUT /apis/batch/v1/namespaces/{namespace}/jobs/{name}

表6-189描述该API的参数。

表 6-189 参数解释

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

name Yes name of the Job

namespace Yes object name and authscope, such as for teamsand projects

请求消息

请求参数:

请求参数的详细描述请参见表6-171。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 365

Page 376: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求示例:

{ "metadata": { "name": "jobs-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs/jobs-12130306", "uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419068", "creationTimestamp": "2017-12-13T03:15:55Z", "labels": { "app": "new-jobs", "name": "job-test" }, "enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b" } }, "template": { "metadata": { "name": "jobs-12130306", "creationTimestamp": null, "labels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "job-name": "jobs-12130306", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "jobs-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "startTime": "2017-12-13T03:15:55Z", "active": 1 }}

响应消息

响应参数:

响应参数的详细描述请参见表6-171。

响应示例:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 366

Page 377: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "kind": "Job", "apiVersion": "batch/v1", "metadata": { "name": "jobs-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs/jobs-12130306", "uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419068", "creationTimestamp": "2017-12-13T03:15:55Z", "labels": { "app": "new-jobs", "name": "job-test" }, "enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b" } }, "template": { "metadata": { "name": "jobs-12130306", "creationTimestamp": null, "labels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "job-name": "jobs-12130306", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "jobs-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "startTime": "2017-12-13T03:15:55Z", "active": 1 }}

状态码

表6-190描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 367

Page 378: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-190 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

6.8.7 替换指定的 Job 的状态

功能介绍

This API is used to replace status of the specified Job.

URIPUT /apis/batch/v1/namespaces/{namespace}/jobs/{name}/status

表6-191描述该API的参数。

表 6-191 参数解释

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

name Yes name of the Job

namespace Yes object name and authscope, such as for teamsand projects

请求消息

请求参数:

请求参数的详细描述请参见表6-171。

请求示例:

{ "kind": "Job", "apiVersion": "batch/v1", "metadata": { "name": "jobs-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs/jobs-12130306", "uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419068", "creationTimestamp": "2017-12-13T03:15:55Z", "labels": { "app": "new-jobs", "name": "job-test"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 368

Page 379: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b" } }, "template": { "metadata": { "name": "jobs-12130306", "creationTimestamp": null, "labels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "job-name": "jobs-12130306", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "jobs-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "startTime": "2017-12-13T03:15:55Z", "active": 1 }}

响应消息

响应参数:

响应参数的详细描述请参见表6-171。

响应示例:

{ "kind": "Job", "apiVersion": "batch/v1", "metadata": { "name": "jobs-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs/jobs-12130306", "uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419068", "creationTimestamp": "2017-12-13T03:15:55Z", "labels": { "app": "new-jobs", "name": "job-test" },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 369

Page 380: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b" } }, "template": { "metadata": { "name": "jobs-12130306", "creationTimestamp": null, "labels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "job-name": "jobs-12130306", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "jobs-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "startTime": "2017-12-13T03:15:55Z", "active": 1 }}

状态码

表6-192描述API的状态码。

表 6-192 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 370

Page 381: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.8.8 列出指定 Namespace 下的 Job

功能介绍

This API is used to list all Jod resource objects under a specified Namespace.

URI

GET /apis/batch/v1/namespaces/{namespace}/jobs

表6-193描述该API的参数。

表 6-193 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

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

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 371

Page 382: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "JobList", "apiVersion": "batch/v1", "metadata": { "selfLink": "/apis/batch/v1/namespaces/default/jobs", "resourceVersion": "7589" }, "items": [ { "metadata": { "name": "", "namespace": "default", "selfLink": "/apis/batch/v1/namespaces/default/jobs/", "uid": "d93a3569-a2be-11e6-a008-fa043d458cc7", "resourceVersion": "7482", "creationTimestamp": "2016-11-04T18:45:25Z" }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "d93a3569-a2be-11e6-a008-fa043d458cc7" } }, "template": { "metadata": { "name": "", "creationTimestamp": null, "labels": { "controller-uid": "d93a3569-a2be-11e6-a008-fa043d458cc7", "job-name": "" } }, "spec": { "containers": [ { "name": "pi", "image": "perl", "command": [ "perl", "-Mbignum=bpi", "-wle", "print bpi(2000)" ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } } }, "status": { "startTime": "2016-11-04T18:45:25Z", "active": 1 }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 372

Page 383: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} ]}

状态码

表6-194描述API的状态码。

表 6-194 状态码

状态码 描述

200 This operation succeeds, and a groupof Job resource objects is returned.

异常状态码请参见9.3 状态码。

6.8.9 列出所有 Job

功能介绍

This API is used to obtain a Job list.

URIGET /apis/batch/v1/jobs

表6-195描述该API的参数。

表 6-195 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by theirlabels. Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

fieldSelector No A selector to restrict the list ofreturned objects by theirfields. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 373

Page 384: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults tochanges from the beginning ofhistory.

timeoutSeconds No Timeout for the list/watch call.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "JobList", "apiVersion": "batch/v1", "metadata": { "selfLink": "/apis/batch/v1/jobs", "resourceVersion": "419065" }, "items": [ { "metadata": { "name": "jobs-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs/jobs-12130306", "uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419064", "creationTimestamp": "2017-12-13T03:15:55Z", "labels": { "name": "job-test" }, "enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b" } }, "template": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 374

Page 385: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"metadata": { "name": "jobs-12130306", "creationTimestamp": null, "labels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "job-name": "jobs-12130306", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "jobs-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "startTime": "2017-12-13T03:15:55Z", "active": 1 } } ]}

状态码

表6-196描述API的状态码。

表 6-196 状态码

状态码 描述

200 This operation succeeds, and the Jobof a group of Pod objects are returned.

异常状态码请参见9.3 状态码。

6.8.10 更新指定的 Job 的状态

功能介绍

This API is used to update the status of a specified Job under a specifiedNamespace.

URIPATCH /apis/batch/v1/namespaces/{namespace}/jobs/{name}/status

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 375

Page 386: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表6-197描述该API的参数。

表 6-197 参数解释

参数 是否必选 描述

name Yes Name of the Job.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/json-patch+json [ { "op": "add", "path": "/status/active", "value": 2 }]

响应消息

响应参数:

响应参数的详细描述请参见表6-171。

响应示例:

{ "kind": "Job", "apiVersion": "batch/v1", "metadata": { "name": "jobs-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs/jobs-12130306/status", "uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419067", "creationTimestamp": "2017-12-13T03:15:55Z", "labels": { "app": "new-jobs", "name": "job-test" }, "enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b" } },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 376

Page 387: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"template": { "metadata": { "name": "jobs-12130306", "creationTimestamp": null, "labels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "job-name": "jobs-12130306", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "jobs-12130306", "image": "172.16.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "startTime": "2017-12-13T03:15:55Z", "active": 2 }}

状态码

表6-198描述API的状态码。

表 6-198 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

6.8.11 更新指定的 Job

功能介绍

This API is used to update the specified Job.

The following fields can be updated:

● metadata.selfLink

● metadata.resourceVersion

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 377

Page 388: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● metadata.creationTimestamp● metadata.name● metadata.namespace● metadata.labels● spec.parallelism● spec.completions● spec.selector

URIPATCH /apis/batch/v1/namespaces/{namespace}/jobs/{name}

表6-199描述该API的参数。

表 6-199 参数解释

参数 是否必选 描述

name Yes name of the Job

namespace Yes object name and auth scope, such as for teamsand projects

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json{ "op": "replace", "path": "/status", "value": "Available"}

响应消息

响应参数:

响应参数的详细描述请参见表6-171。

响应示例:

{ "kind": "Job", "apiVersion": "batch/v1", "metadata": { "name": "jobs-12130306", "namespace": "ns-12130306-s", "selfLink": "/apis/batch/v1/namespaces/ns-12130306-s/jobs/jobs-12130306", "uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 378

Page 389: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"resourceVersion": "419066", "creationTimestamp": "2017-12-13T03:15:55Z", "labels": { "app": "new-jobs", "name": "job-test" }, "enable": true }, "spec": { "parallelism": 1, "completions": 1, "selector": { "matchLabels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b" } }, "template": { "metadata": { "name": "jobs-12130306", "creationTimestamp": null, "labels": { "controller-uid": "eed6b02b-dfb3-11e7-9c19-fa163e2d897b", "job-name": "jobs-12130306", "name": "job-test" }, "enable": true }, "spec": { "containers": [ { "name": "jobs-12130306", "image": "10.125.5.235:20202/test/redis:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "startTime": "2017-12-13T03:15:55Z", "active": 1 }}

状态码

表6-200描述API的状态码。

表 6-200 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 379

Page 390: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.9 CronJob

6.9.1 创建 CronJob

功能介绍

This API is used to create a CronJob resource object.

URI

POST /apis/batch/v1beta1/namespaces/{namespace}/cronjobs

表6-201描述该API的参数。

表 6-201 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

请求参数如表6-202所示。

表 6-202 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind Yes String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated. InCamelCase.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 380

Page 391: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

metadata Yes metadataobject

Standard list metadata.

spec Yes spec object Specification of the desiredbehavior of a cron job, includingthe schedule.

status No status object Current status of a cron job.

表 6-203 spec 字段数据结构说明

参数 是否必选 参数类型 描述

concurrencyPolicy

No String Specifies how to treatconcurrent executions of a Job.Valid values are: - "Allow"(default): allows CronJobs torun concurrently; - "Forbid":forbids concurrent runs,skipping next run if previous runhasn’t finished yet; -"Replace": cancels currentlyrunning job and replaces it witha new one.

failedJobsHistoryLimit

No Integer The number of failed finishedjobs to retain. This is a pointerto distinguish between explicitzero and not specified. Defaultsto 1.

jobTemplate Yes jobTemplateobject

Specifies the job that will becreated when executing aCronJob.

schedule Yes String The schedule in Cron format.

startingDeadlineSeconds

No Integer Optional deadline in seconds forstarting the job if it missesscheduled time for any reason.Missed jobs executions will becounted as failed ones.

successfulJobsHistoryLimit

No Intege The number of successfulfinished jobs to retain. This is apointer to distinguish betweenexplicit zero and not specified.Defaults to 3.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 381

Page 392: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

suspend No Boolean This flag tells the controller tosuspend subsequent executions,it does not apply to alreadystarted executions. Defaults tofalse.

表 6-204 status 字段数据结构说明

参数 是否必选 参数类型 描述

active No claimRefobject

A list of pointers to currentlyrunning jobs.

lastScheduleTime

No String Information when was the lasttime the job was successfullyscheduled.

表 6-205 jobTemplate 字段数据结构说明

参数 是否必选 参数类型 描述

metadata No metadataobject

Standard object’s metadata ofthe jobs created from thistemplate.

spec No spec object Specification of the desiredbehavior of the job.

请求示例:

{ "apiVersion": "batch/v1beta1", "kind": "CronJob", "metadata": { "name": "cronjob-test", "namespace": "default" }, "spec": { "concurrencyPolicy": "Allow", "jobTemplate": { "spec": { "template": { "metadata": { "enable": true, "labels": { "sjname": "cronjob-test" } }, "spec": { "containers": [ { "image": "nginx:stable-perl",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 382

Page 393: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"imagePullPolicy": "IfNotPresent", "lifecycle": {}, "name": "container-0" } ], "dnsPolicy": "ClusterFirst", "imagePullSecrets": [ { "name": "default-secret" } ], "restartPolicy": "OnFailure" } } } }, "schedule": "*/59 * * * *" }}

响应消息

响应参数:

响应参数的详细描述请参见表6-202。

响应示例:

{ "apiVersion": "batch/v1beta1", "kind": "CronJob", "metadata": { "annotations": { "container.io/container-0": "https://console.huaweicloud.com/swr/dockerimage/nginx.png", "description": "" }, "creationTimestamp": "2018-03-07T12:08:52Z", "enable": true, "name": "cronjob-test", "namespace": "default", "resourceVersion": "441019", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "4d78b666-2200-11e8-96aa-fa163ecd089c" }, "spec": { "concurrencyPolicy": "Allow", "failedJobsHistoryLimit": 1, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "enable": true, "labels": { "sjname": "cronjob-test" } }, "spec": { "containers": [ { "image": "nginx:stable-perl", "imagePullPolicy": "IfNotPresent", "lifecycle": {}, "name": "container-0", "resources": {},

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 383

Page 394: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File" } ], "dnsPolicy": "ClusterFirst", "imagePullSecrets": [ { "name": "default-secret" } ], "restartPolicy": "OnFailure", "schedulerName": "default-scheduler", "securityContext": {}, "terminationGracePeriodSeconds": 30 } } } }, "schedule": "*/59 * * * *", "successfulJobsHistoryLimit": 3, "suspend": false }, "status": {}}

状态码

表6-206描述API的状态码。

表 6-206 状态码

状态码 描述

201 The request has been fulfilled,resulting in the creation of a newresource.

异常状态码请参见9.3 状态码。

6.9.2 删除 CronJob

功能介绍

This API is used to delete a CronJob.

URIDELETE /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name}

表6-207描述该API的参数。

表 6-207 参数解释

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 384

Page 395: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

name Yes name of the CronJob

namespace Yes object name and auth scope, suchas for teams and projects

gracePeriodSeconds No The duration in seconds beforethe object should be deleted.Value must be a non-negativeinteger. The value zero indicatesdelete immediately. If this value isnil, the default grace period forthe specified type will be used.Defaults to a per object value ifnot specified. zero means deleteimmediately.

orphanDependents No Deprecated: Use thePropagationPolicy. This field willbe deprecated in 1.7. Should thedependent objects be orphaned. Iftrue/false, the "orphan" finalizerwill be added to/removed fromthe object's finalizers list. Eitherthis field or PropagationPolicymay be set, but not both.

propagationPolicy No Whether and how garbagecollection will be performed.Either this field orOrphanDependents may be set,but not both. The default policy isdecided by the existing finalizerset in the metadata.finalizers andthe resource-specific defaultpolicy. Acceptable values are:'Orphan' - orphan thedependents; 'Background' - allowthe garbage collector to deletethe dependents in thebackground; 'Foreground' - acascading policy that deletes alldependents in the foreground.

请求消息

请求参数:

请求参数的详细描述请参见表6-180。

请求示例:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 385

Page 396: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● 只删除CronJob(对应Job和Pod不删除){ "kind": "DeleteOptions", "apiVersion": "v1", "gracePeriodSeconds": 0, "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->Job->CronJob的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

● 后台级联删除(按照CronJob->Job->Pod的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Background"}

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

{ "kind": "CronJob", "apiVersion": "batch/v1beta1", "metadata": { "name": "cronjob-test", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "4d78b666-2200-11e8-96aa-fa163ecd089c", "resourceVersion": "441442", "creationTimestamp": "2018-03-07T12:08:52Z", "deletionTimestamp": "2018-03-07T12:15:11Z", "deletionGracePeriodSeconds": 0, "annotations": { "container.io/container-0": "https://console.huaweicloud.com/swr/dockerimage/nginx.png", "description": "" }, "finalizers": [ "orphan" ], "enable": true }, "spec": { "schedule": "*/59 * * * *", "concurrencyPolicy": "Allow", "suspend": false, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test" }, "enable": true },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 386

Page 397: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {

}, "lifecycle": {

}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {

}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {

}}

状态码

表6-208描述API的状态码。

表 6-208 状态码

状态码 描述

200 Delete a Job resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.9.3 删除所有的 CronJob

功能介绍

This API is used to delete collection of CronJob.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 387

Page 398: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URIDELETE /apis/batch/v1beta1/namespaces/{namespace}/cronjobs

表6-209描述该API的参数。

表 6-209 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

continue No The continue option should be set whenretrieving more results from the server. Since thisvalue is server defined, clients may only use thecontinue value from a previous query result withidentical query parameters (except for the valueof continue) and the server may reject a continuevalue it does not recognize. If the specifiedcontinue value is no longer valid whether due toexpiration (generally five to fifteen minutes) or aconfiguration change on the server the server willrespond with a 410 ResourceExpired errorindicating the client must restart their list withoutthe continue field. This field is not supportedwhen watch is true. Clients may start a watchfrom the last resourceVersion value returned bythe server and not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources are includedin the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 388

Page 399: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer than therequested amount of items (up to zero items) inthe event all requested objects are filtered outand clients should only use the presence of thecontinue field to determine whether more resultsare available. Servers may choose not to supportthe limit argument and will return all of theavailable results. If limit is specified and thecontinue field is empty, clients may assume thatno more results are available. This field is notsupported if watch is true. The server guaranteesthat the objects returned when using continuewill be identical to issuing a single list callwithout a limit - that is, no objects created,modified, or deleted after the first request isissued will be included in any subsequentcontinued requests. This is sometimes referred toas a consistent snapshot, and ensures that aclient that is using limit to receive smaller chunksof a very large result can ensure they see allpossible objects. If objects are updated during achunked list the version of the object that waspresent at the time the first list result wascalculated is returned.

resourceVersion No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history. When specified for list: - if unset, thenthe result is returned from remote storage basedon quorum-read flag; - if it's 0, then we simplyreturn what we currently have in cache, noguarantee; - if set to non zero, then the result isat least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resources andreturn them as a stream of add, update, andremove notifications. Specify resourceVersion.

请求消息

请求参数:

请求参数的详细描述请参见表6-180。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 389

Page 400: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求示例:

● 只删除CronJob(对应Job和Pod不删除){ "kind": "DeleteOptions", "apiVersion": "v1", "gracePeriodSeconds": 0, "propagationPolicy": "Orphan"}

● 前台级联删除(按照Pod->Job->CronJob的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Foreground"}

● 后台级联删除(按照CronJob->Job->Pod的顺序进行删除){ "kind": "DeleteOptions", "apiVersion": "v1", "propagationPolicy": "Background"}

响应消息

响应参数:

响应参数的详细描述请参见表7-100。

响应示例:

{ "kind": "CronJobList", "apiVersion": "batch/v1beta1", "metadata": { "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs", "resourceVersion": "441539" }, "items": [ { "metadata": { "name": "cronjob-test", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "53ea08bb-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441513", "creationTimestamp": "2018-03-07T12:16:13Z", "enable": true }, "spec": { "schedule": "*/59 * * * *", "concurrencyPolicy": "Allow", "suspend": false, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test" }, "enable": true },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 390

Page 401: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {

}, "lifecycle": {

}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {

}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {

} } ]}

状态码

表6-210描述API的状态码。

表 6-210 状态码

状态码 描述

200 Delete a Job resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.9.4 获取指定的 CronJob

功能介绍

This API is used to read the specified CronJob.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 391

Page 402: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URIGET /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name}

表6-211描述该API的参数。

表 6-211 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Pod.

exact No Should the export be exact.Exact export maintainscluster-specific fields like'Namespace'.

export No Should this value beexported. Export stripsfields that a user cannotspecify.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-171。

响应示例:

{ "kind": "CronJob", "apiVersion": "batch/v1beta1", "metadata": { "name": "cronjob-test", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441600", "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true }, "spec": { "schedule": "*/59 * * * *", "concurrencyPolicy": "Allow", "suspend": false, "jobTemplate": { "metadata": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 392

Page 403: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test" }, "enable": true }, "spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {

}, "lifecycle": {

}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {

}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {

}}

状态码

表6-212描述API的状态码。

表 6-212 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 393

Page 404: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.9.5 获取指定的 CronJob 的状态

功能介绍

This API is used to read the status of the specified CronJob.

URIGET /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name}/status

表6-213描述该API的参数。

表 6-213 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Pod.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-202。

响应示例:

{ "kind": "CronJob", "apiVersion": "batch/v1beta1", "metadata": { "name": "cronjob-test", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test/status", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441600", "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true }, "spec": { "schedule": "*/59 * * * *", "concurrencyPolicy": "Allow", "suspend": false, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 394

Page 405: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test" }, "enable": true }, "spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {

}, "lifecycle": {

}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {

}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {

}}

状态码

表6-214描述API的状态码。

表 6-214 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 395

Page 406: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.9.6 替换指定的 CronJob

功能介绍

This API is used to replace the specified CronJob.

The following fields can be updated:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.clusterName

● metadata.generateName

● metadata.annotations

● spec.replicas

● template.contaions

● spec.restartPolicy

● spec.activeDeadlineSeconds

URI

PUT /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name}

表6-215描述该API的参数。

表 6-215 参数解释

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

name Yes name of the Job

namespace Yes object name and authscope, such as for teamsand projects

请求消息

请求参数:

请求参数的详细描述请参见表6-202。

请求示例:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 396

Page 407: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "kind": "CronJob", "apiVersion": "batch/v1beta1", "metadata": { "name": "cronjob-test", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test/status", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441600", "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true }, "spec": { "schedule": "*/59 * * * *", "concurrencyPolicy": "Forbid", "suspend": false, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test" }, "enable": true }, "spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {

}, "lifecycle": {

}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {

}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 397

Page 408: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表6-202。

响应示例:

{ "kind": "CronJob", "apiVersion": "batch/v1beta1", "metadata": { "name": "cronjob-test", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441884", "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true }, "spec": { "schedule": "*/59 * * * *", "concurrencyPolicy": "Forbid", "suspend": false, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test" }, "enable": true }, "spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {}, "lifecycle": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {}}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 398

Page 409: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-216描述API的状态码。

表 6-216 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

6.9.7 替换指定的 CronJob 的状态

功能介绍

This API is used to replace status of the specified CronJob.

URIPUT /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name}/status

表6-217描述该API的参数。

表 6-217 参数解释

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

name Yes name of the Job

namespace Yes object name and authscope, such as for teamsand projects

请求消息

请求参数:

请求参数的详细描述请参见表6-202。

请求示例:

{ "apiVersion": "batch/v1beta1", "kind": "CronJob", "metadata": { "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true, "name": "cronjob-test",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 399

Page 410: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"namespace": "default", "resourceVersion": "442543", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c" }, "spec": { "concurrencyPolicy": "Forbid", "failedJobsHistoryLimit": 1, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "enable": true, "labels": { "sjname": "cronjob-test" } }, "spec": { "containers": [ { "image": "nginx:stable-perl", "imagePullPolicy": "IfNotPresent", "lifecycle": {}, "name": "container-0", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File" } ], "dnsPolicy": "ClusterFirst", "imagePullSecrets": [ { "name": "default-secret" } ], "restartPolicy": "OnFailure", "schedulerName": "default-scheduler", "securityContext": {}, "terminationGracePeriodSeconds": 30 } } } }, "schedule": "*/2 * * * *", "successfulJobsHistoryLimit": 3, "suspend": false }, "status": { "active": [ { "apiVersion": "batch", "kind": "Job", "name": "cronjob-test-1520425800", "namespace": "default", "resourceVersion": "442542", "uid": "75aede3f-2203-11e8-96aa-fa163ecd089c" } ], "lastScheduleTime": "2018-03-07T12:30:00Z" }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 400

Page 411: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表6-202。

响应示例:

{ "apiVersion": "batch/v1beta1", "kind": "CronJob", "metadata": { "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true, "name": "cronjob-test", "namespace": "default", "resourceVersion": "442543", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c" }, "spec": { "concurrencyPolicy": "Forbid", "failedJobsHistoryLimit": 1, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "enable": true, "labels": { "sjname": "cronjob-test" } }, "spec": { "containers": [ { "image": "nginx:stable-perl", "imagePullPolicy": "IfNotPresent", "lifecycle": {}, "name": "container-0", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File" } ], "dnsPolicy": "ClusterFirst", "imagePullSecrets": [ { "name": "default-secret" } ], "restartPolicy": "OnFailure", "schedulerName": "default-scheduler", "securityContext": {}, "terminationGracePeriodSeconds": 30 } } } }, "schedule": "*/2 * * * *", "successfulJobsHistoryLimit": 3, "suspend": false }, "status": { "active": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 401

Page 412: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "apiVersion": "batch", "kind": "Job", "name": "cronjob-test-1520425800", "namespace": "default", "resourceVersion": "442542", "uid": "75aede3f-2203-11e8-96aa-fa163ecd089c" } ], "lastScheduleTime": "2018-03-07T12:30:00Z" }}

状态码

表6-218描述API的状态码。

表 6-218 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

6.9.8 列出指定 Namespace 下的 CronJob

功能介绍

This API is used to list all CronJod resource objects under a specified Namespace.

URIGET /apis/batch/v1beta1/namespaces/{namespace}/cronjobs

表6-219描述该API的参数。

表 6-219 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope,such as for teams and projects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 402

Page 413: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

continue No The continue option should beset when retrieving moreresults from the server. Sincethis value is server defined,clients may only use thecontinue value from a previousquery result with identicalquery parameters (except forthe value of continue) and theserver may reject a continuevalue it does not recognize. Ifthe specified continue value isno longer valid whether due toexpiration (generally five tofifteen minutes) or aconfiguration change on theserver the server will respondwith a 410 ResourceExpirederror indicating the client mustrestart their list without thecontinue field. This field is notsupported when watch is true.Clients may start a watch fromthe last resourceVersion valuereturned by the server and notmiss any modifications.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 403

Page 414: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number ofresponses to return for a listcall. If more items exist, theserver will set the continuefieldon the list metadata to a valuethat can be used with the sameinitial query to retrieve the nextset of results. Setting a limitmay return fewer than therequested amount of items (upto zero items) in the event allrequested objects are filteredout and clients should only usethe presence of the continuefield to determine whethermore results are available.Servers may choose not tosupport the limit argument andwill return all of the availableresults. If limit is specified andthe continue field is empty,clients may assume that nomore results are available. Thisfield is not supported if watchis true.The server guarantees that theobjects returned when usingcontinue will be identical toissuing a single list call withouta limit - that is, no objectscreated, modified, or deletedafter the first request is issuedwill be included in anysubsequent continued requests.This is sometimes referred to asa consistent snapshot, andensures that a client that isusing limit to receive smallerchunks of a very large resultcan ensure they see all possibleobjects. If objects are updatedduring a chunked list theversion of the object that waspresent at the time the first listresult was calculated isreturned.

pretty No If true, then the output ispretty printed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 404

Page 415: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults to changesfrom the beginning of history.When specified for list: - ifunset, then the result isreturned from remote storagebased on quorum-read flag; - ifit’s 0, then we simply returnwhat we currently have incache, no guarantee; - if set tonon zero, then the result is atleast as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "CronJobList", "apiVersion": "batch/v1beta1", "metadata": { "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs", "resourceVersion": "442038" }, "items": [ { "metadata": { "name": "cronjob-test", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441884", "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true }, "spec": { "schedule": "*/59 * * * *",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 405

Page 416: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"concurrencyPolicy": "Forbid", "suspend": false, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test" }, "enable": true }, "spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {

}, "lifecycle": {

}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {

}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {

} }, { "metadata": { "name": "cronjob-test11", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test11", "uid": "7b8312a5-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441597", "creationTimestamp": "2018-03-07T12:17:19Z", "enable": true }, "spec": { "schedule": "*/59 * * * *", "concurrencyPolicy": "Allow", "suspend": false,

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 406

Page 417: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test11" }, "enable": true }, "spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {

}, "lifecycle": {

}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {

}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {

} } ]}

状态码

表6-220描述API的状态码。

表 6-220 状态码

状态码 描述

200 This operation succeeds, and a groupof Job resource objects is returned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 407

Page 418: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.9.9 列出所有的 CronJob

功能介绍

This API is used to obtain a CronJob list.

URI

GET /apis/batch/v1beta1/cronjobs

表6-221描述该API的参数。

表 6-221 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope,such as for teams and projects.

continue No The continue option should beset when retrieving moreresults from the server. Sincethis value is server defined,clients may only use thecontinue value from a previousquery result with identicalquery parameters (except forthe value of continue) and theserver may reject a continuevalue it does not recognize. Ifthe specified continue value isno longer valid whether due toexpiration (generally five tofifteen minutes) or aconfiguration change on theserver the server will respondwith a 410 ResourceExpirederror indicating the client mustrestart their list without thecontinue field. This field is notsupported when watch is true.Clients may start a watch fromthe last resourceVersion valuereturned by the server and notmiss any modifications.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 408

Page 419: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

includeUninitialized No If true, partially initializedresources are included in theresponse.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 409

Page 420: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number ofresponses to return for a listcall. If more items exist, theserver will set the continuefieldon the list metadata to a valuethat can be used with the sameinitial query to retrieve the nextset of results. Setting a limitmay return fewer than therequested amount of items (upto zero items) in the event allrequested objects are filteredout and clients should only usethe presence of the continuefield to determine whethermore results are available.Servers may choose not tosupport the limit argument andwill return all of the availableresults. If limit is specified andthe continue field is empty,clients may assume that nomore results are available. Thisfield is not supported if watchis true.The server guarantees that theobjects returned when usingcontinue will be identical toissuing a single list call withouta limit - that is, no objectscreated, modified, or deletedafter the first request is issuedwill be included in anysubsequent continued requests.This is sometimes referred to asa consistent snapshot, andensures that a client that isusing limit to receive smallerchunks of a very large resultcan ensure they see all possibleobjects. If objects are updatedduring a chunked list theversion of the object that waspresent at the time the first listresult was calculated isreturned.

pretty No If true, then the output ispretty printed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 410

Page 421: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults to changesfrom the beginning of history.When specified for list: - ifunset, then the result isreturned from remote storagebased on quorum-read flag; - ifit’s 0, then we simply returnwhat we currently have incache, no guarantee; - if set tonon zero, then the result is atleast as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "CronJobList", "apiVersion": "batch/v1beta1", "metadata": { "selfLink": "/apis/batch/v1beta1/cronjobs", "resourceVersion": "442065" }, "items": [ { "metadata": { "name": "cronjob-test", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441884", "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true }, "spec": { "schedule": "*/59 * * * *",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 411

Page 422: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"concurrencyPolicy": "Forbid", "suspend": false, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test" }, "enable": true }, "spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {

}, "lifecycle": {

}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {

}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {

} }, { "metadata": { "name": "cronjob-test11", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test11", "uid": "7b8312a5-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441597", "creationTimestamp": "2018-03-07T12:17:19Z", "enable": true }, "spec": { "schedule": "*/59 * * * *", "concurrencyPolicy": "Allow", "suspend": false,

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 412

Page 423: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test11" }, "enable": true }, "spec": { "containers": [ { "name": "container-0", "image": "nginx:stable-perl", "resources": {

}, "lifecycle": {

}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {

}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {

} } ]}

状态码

表6-222描述API的状态码。

表 6-222 状态码

状态码 描述

200 This operation succeeds, and the Jobof a group of Pod objects are returned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 413

Page 424: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.9.10 更新指定的 CronJob 的状态

功能介绍

This API is used to update the status of a specified CronJob under a specifiedNamespace.

URIPATCH /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name}/status

表6-223描述该API的参数。

表 6-223 参数解释

参数 是否必选 描述

name Yes Name of the Job.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/json-patch+json "status": { "active": [ { "apiVersion": "batch", "kind": "Job", "name": "cronjob-test-1520425800", "namespace": "default", "resourceVersion": "442542", "uid": "75aede3f-2203-11e8-96aa-fa163ecd089c" } ], "lastScheduleTime": "2018-03-07T12:30:00Z"}

响应消息

响应参数:

响应参数的详细描述请参见表6-202。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 414

Page 425: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "apiVersion": "batch/v1beta1", "kind": "CronJob", "metadata": { "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true, "name": "cronjob-test", "namespace": "default", "resourceVersion": "442543", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c" }, "spec": { "concurrencyPolicy": "Forbid", "failedJobsHistoryLimit": 1, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "enable": true, "labels": { "sjname": "cronjob-test" } }, "spec": { "containers": [ { "image": "nginx:stable-perl", "imagePullPolicy": "IfNotPresent", "lifecycle": {}, "name": "container-0", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File" } ], "dnsPolicy": "ClusterFirst", "imagePullSecrets": [ { "name": "default-secret" } ], "restartPolicy": "OnFailure", "schedulerName": "default-scheduler", "securityContext": {}, "terminationGracePeriodSeconds": 30 } } } }, "schedule": "*/2 * * * *", "successfulJobsHistoryLimit": 3, "suspend": false }, "status": { "active": [ { "apiVersion": "batch", "kind": "Job", "name": "cronjob-test-1520425800", "namespace": "default", "resourceVersion": "442542", "uid": "75aede3f-2203-11e8-96aa-fa163ecd089c"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 415

Page 426: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} ], "lastScheduleTime": "2018-03-07T12:30:00Z" }}

状态码

表6-224描述API的状态码。

表 6-224 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

6.9.11 更新指定的 CronJob

功能介绍

This API is used to update the specified CronJob.

The following fields can be updated:

● metadata.selfLink

● metadata.resourceVersion

● metadata.creationTimestamp

● metadata.name

● metadata.namespace

● metadata.labels

● spec.parallelism

● spec.completions

● spec.selector

URI

PATCH /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name}

表6-225描述该API的参数。

表 6-225 参数解释

参数 是否必选 描述

name Yes name of the CronJob.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 416

Page 427: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json{ "spec": { "concurrencyPolicy": "Forbid" }}

响应消息

响应参数:

响应参数的详细描述请参见表6-202。

响应示例:

{ "kind": "CronJob", "apiVersion": "batch/v1beta1", "metadata": { "name": "cronjob-test", "namespace": "default", "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test", "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c", "resourceVersion": "441884", "creationTimestamp": "2018-03-07T12:17:22Z", "enable": true }, "spec": { "schedule": "*/59 * * * *", "concurrencyPolicy": "Forbid", "suspend": false, "jobTemplate": { "metadata": { "creationTimestamp": null, "enable": true }, "spec": { "template": { "metadata": { "creationTimestamp": null, "labels": { "sjname": "cronjob-test" }, "enable": true }, "spec": { "containers": [ {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 417

Page 428: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"name": "container-0", "image": "nginx:stable-perl", "resources": {}, "lifecycle": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "OnFailure", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } } }, "successfulJobsHistoryLimit": 3, "failedJobsHistoryLimit": 1 }, "status": {}}

状态码

表6-226描述API的状态码。

表 6-226 状态码

状态码 描述

200 This operation succeeds, and a Jobresource object is returned.

异常状态码请参见9.3 状态码。

6.10 ReplicSet

6.10.1 列出指定的 ReplicaSet

功能介绍

This API is used to list all ReplicaSet resource objects under a specifiedNamespace.

URIGET /apis/apps/v1/namespaces/{namespace}/replicasets (Supports only1.9)

GET /apis/extensions/v1beta1/namespaces/{namespace}/replicasets (Compatible)

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 418

Page 429: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表6-227描述该API的参数。

表 6-227 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

includeUninitialized

No If true, partially initialized resources are includedin the response.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

resourceVersion

No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history.

timeoutSeconds

No Timeout for the list/watch call.

watch No Watch for changes to the described resources andreturn them as a stream of add, update, andremove notifications. Specify resourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-108。

响应示例:

{ "kind": "ReplicaSetList", "apiVersion": "extensions/v1beta1", "metadata": { "selfLink": "/apis/extensions/v1beta1/namespaces/default/replicasets", "resourceVersion": "793174" }, "items": [ { "metadata": { "name": "deployment-test-800400086", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/replicasets/deployment-test-800400086",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 419

Page 430: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"uid": "67775454-df2f-11e7-961f-fa163ed139d5", "resourceVersion": "784294", "generation": 1, "creationTimestamp": "2017-12-12T11:27:15Z", "labels": { "name": "deployment-test", "pod-template-hash": "800400086" }, "annotations": { "deployment.kubernetes.io/desired-replicas": "1", "deployment.kubernetes.io/max-replicas": "2", "deployment.kubernetes.io/revision": "1" }, "ownerReferences": [ { "apiVersion": "extensions/v1beta1", "kind": "Deployment", "name": "deployment-test", "uid": "6776d16b-df2f-11e7-961f-fa163ed139d5", "controller": true, "blockOwnerDeletion": true } ], "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "name": "deployment-test", "pod-template-hash": "800400086" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "deployment-test", "pod-template-hash": "800400086" }, "enable": true }, "spec": { "containers": [ { "name": "deployment-test", "image": "172.16.5.235:20202/test/testnginx:v3", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "replicas": 1, "fullyLabeledReplicas": 1, "observedGeneration": 1 } }, { "metadata": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 420

Page 431: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"name": "test-pv-446136006", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/replicasets/test-pv-446136006", "uid": "3b3dee35-dfd7-11e7-961f-fa163ed139d5", "resourceVersion": "784441", "generation": 1, "creationTimestamp": "2017-12-13T07:28:36Z", "labels": { "app": "test-pv", "pod-template-hash": "446136006" }, "annotations": { "deployment.kubernetes.io/desired-replicas": "2", "deployment.kubernetes.io/max-replicas": "2", "deployment.kubernetes.io/revision": "1" }, "ownerReferences": [ { "apiVersion": "extensions/v1beta1", "kind": "Deployment", "name": "test-pv", "uid": "3b3d3a22-dfd7-11e7-961f-fa163ed139d5", "controller": true, "blockOwnerDeletion": true } ], "enable": true }, "spec": { "replicas": 2, "selector": { "matchLabels": { "app": "test-pv", "pod-template-hash": "446136006" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "test-pv", "pod-template-hash": "446136006" }, "annotations": { "metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]" }, "enable": true }, "spec": { "volumes": [ { "name": "wwww", "persistentVolumeClaim": { "claimName": "pvc1513149915389" } } ], "containers": [ { "name": "container-0", "image": "172.16.5.235:20202/test/nginx:latest", "resources": {}, "volumeMounts": [ { "name": "wwww", "readOnly": true, "mountPath": "/tmp0" } ],

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 421

Page 432: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"lifecycle": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "affinity": {}, "schedulerName": "default-scheduler" } } }, "status": { "replicas": 2, "fullyLabeledReplicas": 2, "readyReplicas": 2, "availableReplicas": 2, "observedGeneration": 1 } } ]}

状态码

表6-228描述API的状态码。

表 6-228 状态码

状态码 描述

200 This operation succeeds, and aReplicaSet resource object is returned.

异常状态码请参见9.3 状态码。

6.10.2 获取指定的 ReplicaSet

功能介绍

list or watch objects of kind Namespace.

URI

GET /apis/apps/v1/namespaces/{namespace}/replicasets/{name}

GET /apis/extensions/v1beta1/namespaces/{namespace}/replicasets/{name}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 422

Page 433: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-229 Query 参数

参数 是否必选

参数类型 说明

pretty 否 String If 'true', then the output is prettyprinted.

continue 否 String The continue option should be setwhen retrieving more results from theserver. Since this value is server defined,clients may only use the continue valuefrom a previous query result withidentical query parameters (except forthe value of continue) and the servermay reject a continue value it does notrecognize. If the specified continuevalue is no longer valid whether due toexpiration (generally five to fifteenminutes) or a configuration change onthe server the server will respond witha 410 ResourceExpired error indicatingthe client must restart their list withoutthe continue field. This field is notsupported when watch is true. Clientsmay start a watch from the lastresourceVersion value returned by theserver and not miss any modifications.

fieldSelector 否 String A selector to restrict the list of returnedobjects by their fields. Defaults toeverything.

includeUninitialized

否 Boolean If true, partially initialized resources areincluded in the response.

labelSelector 否 String A selector to restrict the list of returnedobjects by their labels. Defaults toeverything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 423

Page 434: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 说明

limit 否 Integer limit is a maximum number ofresponses to return for a list call. Ifmore items exist, the server will set the`continue` field on the list metadata toa value that can be used with the sameinitial query to retrieve the next set ofresults. Setting a limit may return fewerthan the requested amount of items(up to zero items) in the event allrequested objects are filtered out andclients should only use the presence ofthe continue field to determinewhether more results are available.Servers may choose not to support thelimit argument and will return all ofthe available results. If limit is specifiedand the continue field is empty, clientsmay assume that no more results areavailable. This field is not supported ifwatch is true.

The server guarantees that the objectsreturned when using continue will beidentical to issuing a single list callwithout a limit - that is, no objectscreated, modified, or deleted after thefirst request is issued will be included inany subsequent continued requests.This is sometimes referred to as aconsistent snapshot, and ensures that aclient that is using limit to receivesmaller chunks of a very large resultcan ensure they see all possible objects.If objects are updated during a chunkedlist the version of the object that waspresent at the time the first list resultwas calculated is returned.

resourceVersion

否 String When specified with a watch call,shows changes that occur after thatparticular version of a resource.Defaults to changes from the beginningof history. When specified for list: - ifunset, then the result is returned fromremote storage based on quorum-readflag; - if it's 0, then we simply returnwhat we currently have in cache, noguarantee; - if set to non zero, then theresult is at least as fresh as given rv.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 424

Page 435: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 说明

timeoutSeconds

否 Integer Timeout for the list/watch call. Thislimits the duration of the call,regardless of any activity or inactivity.

watch 否 Boolean Watch for changes to the describedresources and return them as a streamof add, update, and removenotifications. Specify resourceVersion.

请求参数

响应参数

状态码为 200 时:

表 6-230 响应 Body 参数

参数 参数类型 说明

apiVersion String APIVersion defines the versioned schema ofthis representation of an object. Servers shouldconvert recognized schemas to the latestinternal value, and may reject unrecognizedvalues.

items Array ofio.k8s.api.core.v1.Namespace objects

Items is the list of Namespace objects in thelist. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

kind String Kind is a string value representing the RESTresource this object represents. Servers mayinfer this from the endpoint the client submitsrequests to. Cannot be updated. In CamelCase.

metadata Array ofio.k8s.apimachinery.pkg.apis.meta.v1.ListMeta objects

Standard list metadata.

请求示例

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 425

Page 436: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例

状态码为 200 时:

{ "apiVersion": "extensions/v1beta1", "kind": "ReplicaSet", "metadata": { "annotations": { "deployment.kubernetes.io/desired-replicas": "1", "deployment.kubernetes.io/max-replicas": "2", "deployment.kubernetes.io/revision": "1" }, "creationTimestamp": "2019-07-03T03:29:52Z", "generation": 1, "labels": { "app": "web-terminal", "pod-template-hash": "68cb66c8bf", "release": "cceaddon-web-terminal" }, "name": "web-terminal-68cb66c8bf", "namespace": "default", "ownerReferences": [ { "apiVersion": "apps/v1", "blockOwnerDeletion": true, "controller": true, "kind": "Deployment", "name": "web-terminal", "uid": "d1d6c18e-9d42-11e9-8d38-fa163eb8e88a" } ], "resourceVersion": "3675383", "selfLink": "/apis/extensions/v1beta1/namespaces/default/replicasets/web-terminal-68cb66c8bf", "uid": "d1d810bf-9d42-11e9-8d38-fa163eb8e88a" }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "web-terminal", "pod-template-hash": "68cb66c8bf" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "web-terminal", "pod-template-hash": "68cb66c8bf", "release": "cceaddon-web-terminal" } }, "spec": { "containers": [ { "env": [ { "name": "PASSWORD", "value": "" } ], "image": "10.79.1.215:20202/hwofficial/web-terminal:1.0.2", "imagePullPolicy": "IfNotPresent", "name": "web-terminal", "resources": { "limits": { "cpu": "200m", "memory": "512Mi"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 426

Page 437: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "requests": { "cpu": "100m", "memory": "256Mi" } }, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File" } ], "dnsPolicy": "ClusterFirst", "restartPolicy": "Always", "schedulerName": "default-scheduler", "securityContext": {}, "serviceAccount": "web-terminal", "serviceAccountName": "web-terminal", "terminationGracePeriodSeconds": 30 } } }, "status": { "availableReplicas": 1, "fullyLabeledReplicas": 1, "observedGeneration": 1, "readyReplicas": 1, "replicas": 1 }}

返回值

返回值 说明

200 OK

401 Unauthorized

错误码

6.10.3 获取 Replicasets

功能介绍

list or watch objects of kind ReplicaSet

URIGET /apis/apps/v1/replicasets

GET /apis/extensions/v1beta1/replicasets

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 427

Page 438: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-231 Query 参数

参数 是否必选

参数类型 描述

continue 否 String The continue option should be setwhen retrieving more results from theserver. Since this value is server defined,clients may only use the continue valuefrom a previous query result withidentical query parameters (except forthe value of continue) and the servermay reject a continue value it does notrecognize. If the specified continuevalue is no longer valid whether due toexpiration (generally five to fifteenminutes) or a configuration change onthe server the server will respond witha 410 ResourceExpired error indicatingthe client must restart their list withoutthe continue field. This field is notsupported when watch is true. Clientsmay start a watch from the lastresourceVersion value returned by theserver and not miss any modifications.

fieldSelector 否 String A selector to restrict the list of returnedobjects by their fields. Defaults toeverything.

includeUninitialized

否 Boolean If true, partially initialized resources areincluded in the response.

labelSelector 否 String A selector to restrict the list of returnedobjects by their labels. Defaults toeverything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 428

Page 439: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

limit 否 Integer limit is a maximum number ofresponses to return for a list call. Ifmore items exist, the server will set the`continue` field on the list metadata toa value that can be used with the sameinitial query to retrieve the next set ofresults. Setting a limit may return fewerthan the requested amount of items(up to zero items) in the event allrequested objects are filtered out andclients should only use the presence ofthe continue field to determinewhether more results are available.Servers may choose not to support thelimit argument and will return all ofthe available results. If limit is specifiedand the continue field is empty, clientsmay assume that no more results areavailable. This field is not supported ifwatch is true.

The server guarantees that the objectsreturned when using continue will beidentical to issuing a single list callwithout a limit - that is, no objectscreated, modified, or deleted after thefirst request is issued will be included inany subsequent continued requests.This is sometimes referred to as aconsistent snapshot, and ensures that aclient that is using limit to receivesmaller chunks of a very large resultcan ensure they see all possible objects.If objects are updated during a chunkedlist the version of the object that waspresent at the time the first list resultwas calculated is returned.

pretty 否 String If 'true', then the output is prettyprinted.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 429

Page 440: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选

参数类型 描述

resourceVersion

否 String When specified with a watch call,shows changes that occur after thatparticular version of a resource.Defaults to changes from the beginningof history. When specified for list: - ifunset, then the result is returned fromremote storage based on quorum-readflag; - if it's 0, then we simply returnwhat we currently have in cache, noguarantee; - if set to non zero, then theresult is at least as fresh as given rv.

timeoutSeconds

否 Integer Timeout for the list/watch call. Thislimits the duration of the call,regardless of any activity or inactivity.

watch 否 Boolean Watch for changes to the describedresources and return them as a streamof add, update, and removenotifications. Specify resourceVersion.

请求参数

响应参数

状态码为 200 时:

表 6-232 响应 Body 参数

参数 参数类型 描述

apiVersion String APIVersion defines the versioned schema ofthis representation of an object. Serversshould convert recognized schemas to thelatest internal value, and may rejectunrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

items Array ofio.k8s.api.apps.v1.ReplicaSetobjects

List of ReplicaSets. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 430

Page 441: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

kind String Kind is a string value representing the RESTresource this object represents. Servers mayinfer this from the endpoint the clientsubmits requests to. Cannot be updated. InCamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

metadata Array ofio.k8s.apimachinery.pkg.apis.meta.v1.ListMetaobjects

Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

请求示例

响应示例

状态码为 200 时:

{ "apiVersion": "v1", "items": [ { "apiVersion": "extensions/v1beta1", "kind": "ReplicaSet", "metadata": { "annotations": { "deployment.kubernetes.io/desired-replicas": "2", "deployment.kubernetes.io/max-replicas": "3", "deployment.kubernetes.io/revision": "1" }, "creationTimestamp": "2019-07-03T07:35:30Z", "generation": 1, "labels": { "app": "coredns", "k8s-app": "coredns", "kubernetes.io/evictcritical": "", "pod-template-hash": "85cb64445b", "release": "cceaddon-coredns" }, "name": "coredns-85cb64445b", "namespace": "kube-system", "ownerReferences": [ { "apiVersion": "apps/v1", "blockOwnerDeletion": true, "controller": true, "kind": "Deployment", "name": "coredns", "uid": "22573447-9d65-11e9-8d38-fa163eb8e88a" } ], "resourceVersion": "3714356", "selfLink": "/apis/extensions/v1beta1/namespaces/kube-system/replicasets/coredns-85cb64445b", "uid": "22586f58-9d65-11e9-8d38-fa163eb8e88a" },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 431

Page 442: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"spec": { "replicas": 2, "selector": { "matchLabels": { "app": "coredns", "k8s-app": "coredns", "pod-template-hash": "85cb64445b" } }, "template": { "metadata": { "annotations": { "checksum/config": "3095a9b4028195e7e0b8b22c550bf183d0b7a8a7eba20808b36081d0b39f8b81", "scheduler.alpha.kubernetes.io/critical-pod": "", "scheduler.alpha.kubernetes.io/tolerations": "[{\"key\":\"CriticalAddonsOnly\", \"operator\":\"Exists\"}]" }, "creationTimestamp": null, "labels": { "app": "coredns", "k8s-app": "coredns", "kubernetes.io/evictcritical": "", "pod-template-hash": "85cb64445b", "release": "cceaddon-coredns" } }, "spec": { "affinity": { "podAntiAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": [ { "labelSelector": { "matchExpressions": [ { "key": "app", "operator": "In", "values": [ "coredns" ] } ] }, "topologyKey": "kubernetes.io/hostname" } ] } }, "containers": [ { "args": [ "-conf", "/etc/coredns/Corefile", "-rmem", "udp#8388608", "-wmem", "udp#1048576" ], "image": "100.79.1.215:20202/hwofficial/cce-coredns-linux-amd64:1.2.6.1", "imagePullPolicy": "IfNotPresent", "livenessProbe": { "failureThreshold": 5, "httpGet": { "path": "/health", "port": 8080, "scheme": "HTTP" }, "initialDelaySeconds": 60, "periodSeconds": 10,

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 432

Page 443: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"successThreshold": 1, "timeoutSeconds": 5 }, "name": "coredns", "ports": [ { "containerPort": 5353, "protocol": "UDP" } ], "readinessProbe": { "failureThreshold": 3, "httpGet": { "path": "/health", "port": 8080, "scheme": "HTTP" }, "initialDelaySeconds": 3, "periodSeconds": 5, "successThreshold": 1, "timeoutSeconds": 3 }, "resources": { "limits": { "cpu": "500m", "memory": "512Mi" }, "requests": { "cpu": "500m", "memory": "512Mi" } }, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "volumeMounts": [ { "mountPath": "/etc/coredns", "name": "config-volume" } ] } ], "dnsPolicy": "Default", "restartPolicy": "Always", "schedulerName": "default-scheduler", "securityContext": {}, "serviceAccount": "coredns", "serviceAccountName": "coredns", "terminationGracePeriodSeconds": 30, "tolerations": [ { "effect": "NoExecute", "key": "node.kubernetes.io/not-ready", "operator": "Exists", "tolerationSeconds": 60 }, { "effect": "NoExecute", "key": "node.kubernetes.io/unreachable", "operator": "Exists", "tolerationSeconds": 60 } ], "volumes": [ { "configMap": { "defaultMode": 420, "items": [ {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 433

Page 444: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"key": "Corefile", "path": "Corefile" } ], "name": "coredns" }, "name": "config-volume" } ] } } }, "status": { "fullyLabeledReplicas": 2, "observedGeneration": 1, "replicas": 2 } } ], "kind": "List", "metadata": { "resourceVersion": "", "selfLink": "" }}

返回值

返回值 说明

200 OK

401 Unauthorized

错误码

6.11 ReplicationController

6.11.1 创建 ReplicationController

功能介绍

该API用于创建ReplicationController资源类型。

URI

POST /api/v1/namespaces/{namespace}/replicationcontrollers

表6-233 描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 434

Page 445: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-233 参数说明

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

请求消息

请求参数:

请求参数的详细描述请参见表7-1。

请求示例:

{ "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "frontend-controller", "labels": { "cce/group": "frontend-controller", "name": "frontend" } }, "spec": { "replicas": 2, "selector": { "cce/group": "frontend-controller", "name": "frontend" }, "template": { "metadata": { "labels": { "cce/group": "frontend-controller", "name": "frontend" } }, "spec": { "volumes": null, "containers": [ { "name": "php-redis", "image": "redis", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "dnsPolicy": "ClusterFirst" } } }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 435

Page 446: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "apiVersion": "v1", "kind": "ReplicationController", "metadata": { "creationTimestamp": "2017-06-23T08:40:52Z", "generation": 1, "labels": { "cce/group": "frontend-controller", "name": "frontend" }, "name": "frontend-controller", "namespace": "default", "resourceVersion": "850929", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/frontend-controller", "uid": "aa123f3f-57ef-11e7-97f8-fa163e61f3f9" }, "spec": { "replicas": 2, "selector": { "cce/group": "frontend-controller", "name": "frontend" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "cce/group": "frontend-controller", "name": "frontend" } }, "spec": { "containers": [ { "image": "redis", "imagePullPolicy": "IfNotPresent", "name": "php-redis", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log" } ], "dnsPolicy": "ClusterFirst", "restartPolicy": "Always", "securityContext": {}, "terminationGracePeriodSeconds": 30 } } }, "status": { "availableReplicas": 2, "fullyLabeledReplicas": 2, "observedGeneration": 1, "readyReplicas": 2, "replicas": 2 }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 436

Page 447: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-234描述API的状态码。

表 6-234 状态码

状态码 描述

201 操作成v功,返回ReplicationController资源对象。

异常状态码请参见9.3 状态码。

6.11.2 删除 ReplicationController

功能介绍

该API用于删除一个ReplicationController对象。

URIDELETE /api/v1/namespaces/{namespace}/replicationcontrollers/{name}

表6-235 描述该API的参数。

表 6-235 参数描述

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

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

name Yes Name of theReplicationController.

gracePeriodSeconds No The duration in seconds beforethe object should be deleted.Value must be non-negativeinteger. The value zero indicatesdelete immediately. If this valueis nil, the default grace period forthe specified type will be used.Defaults to a per object value ifnot specified. zero means deleteimmediately.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 437

Page 448: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

orphanDependents No Deprecated: please use thePropagationPolicy, this field willbe deprecated in 1.7. Should thedependent objects be orphaned.If true/false, the "orphan"finalizer will be added to/removed from the object'sfinalizers list. Either this field orPropagationPolicy may be set,but not both.

propagationPolicy No Whether and how garbagecollection will be performed.Either this field orOrphanDependents may be set,but not both. The default policyis decided by the existingfinalizer set in themetadata.finalizers and theresource-specific default policy.

请求消息

请求参数:

请求参数表6-236所示。

表 6-236 参数描述

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isDeleteOptions.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 438

Page 449: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

gracePeriodSeconds

No Integer The duration in secondsbefore the object should bedeleted. Value must be non-negative integer. The valuezero indicates deleteimmediately. If this value isnil, the default grace periodfor the specified type will beused. Defaults to a per objectvalue if not specified. zeromeans delete immediately.Value range of thisparameter: > 0.

preconditions No preconditions field object

Must be fulfilled before adeletion is carried out. If notpossible, a 409 Conflict statuswill be returned.

orphanDependents

No Boolean Should the dependent objectsbe orphaned. If true/false, the"orphan" finalizer will beadded to/removed from theobject’s finalizers list.

propagationPolicy

No String Whether and how garbagecollection will be performed.Either this field orOrphanDependents may beset, but not both. The defaultpolicy is decided by theexisting finalizer set in themetadata.finalizers and theresource-specific defaultpolicy.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 439

Page 450: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-237 preconditions field

参数 是否必选 参数类型 描述

uid No String Specifies the target UID.

请求示例:

{ "kind": "DeleteOptions", "apiVersion": "v1", "gracePeriodSeconds": 10 }

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "code": 200 }

状态码

表6-238描述API的状态码。

表 6-238 状态码

状态码 描述

200 Delete a ReplicationController resourceobjectre successfully.

异常状态码请参见9.3 状态码。

6.11.3 删除所有的 ReplicationController

功能介绍

该API用于批量删除ReplicationController。

URIDELETE /api/v1/namespaces/{namespace}/replicationcontrollers

表6-239描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 440

Page 451: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-239 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

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

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

RequestN/A

响应消息

响应参数:

响应参数的详细描述请参见表7-80。

响应示例:

{ "kind": "ReplicationControllerList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/delns-12130306/replicationcontrollers", "resourceVersion": "419242" }, "items": [ { "metadata": { "name": "rc-del-12130306",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 441

Page 452: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"namespace": "delns-12130306", "selfLink": "/api/v1/namespaces/delns-12130306/replicationcontrollers/rc-del-12130306", "uid": "1465eea3-dfb4-11e7-9c19-fa163e2d897b", "resourceVersion": "419242", "generation": 1, "creationTimestamp": "2017-12-13T03:16:58Z", "labels": { "cce/appgroup": "test" }, "enable": true }, "spec": { "replicas": 0, "selector": { "cce/appgroup": "test" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "cce/appgroup": "test" }, "enable": true }, "spec": { "containers": [ { "name": "rccon-12130306", "image": "172.16.5.235:20202/test/redis:v1", "ports": [ { "containerPort": 6379, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" } } }, "status": { "replicas": 0, "observedGeneration": 1 } } ]}

状态码

表6-240描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 442

Page 453: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-240 状态码

状态码 描述

200 Delete a DaemonSet resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.11.4 获取指定 Namespace 下的 ReplicationController

功能介绍

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

URIGET /api/v1/namespaces/{namespace}/replicationcontrollers/{name}

表6-241 描述该API的参数。

表 6-241 参数描述

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

namespace Yes Object name and auth scope, suchas for teams and projects.

name Yes Name of the ReplicationController.

exact No Should the export be exact. Exactexport maintains cluster-specificfields like 'Namespace'.

export No Should this value be exported.Export strips fields that a user cannot specify.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-79。

响应示例:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 443

Page 454: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "frontend-controller", "namespace": "default", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/frontend-controller", "uid": "9c664f9f-5954-11e6-b444-286ed488fafe", "resourceVersion": "13050", "generation": 1, "creationTimestamp": "2016-08-03T08:31:01Z", "labels": { "state": "serving" } }, "spec": { "replicas": 2, "selector": { "app": "frontend" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "frontend" } }, "spec": { "containers": [ { "name": "php-redis", "image": "redis", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } } }, "status": { "replicas": 2, "fullyLabeledReplicas": 2, "observedGeneration": 1 } }

状态码

表6-242描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 444

Page 455: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-242 状态码

状态码 描述

200 This operation succeeds, and aReplicationController resource object isreturned.

异常状态码请参见9.3 状态码。

6.11.5 替换指定 Namespace 下的 ReplicationController

功能介绍

该API用于替换指定Namespace下的ReplicationController对象。

其中以下字段支持更新:

● metadata.selfLink● metadata.resourceVersion● metadata.generation● metadata.creationTimestamp● metadata.deletionTimestamp● metadata.labels● metadata.clusterName● metadata.generateName● metadata.annotations● spec.replicas● template.contaions● spec.restartPolicy● spec.activeDeadlineSeconds

URIPUT /api/v1/namespaces/{namespace}/replicationcontrollers/{name}

表6-243 描述该API的参数。

表 6-243 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 445

Page 456: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

name Yes Name of theReplicationController.

请求消息

请求参数:

请求参数的详细描述请参见表7-1。

请求示例:

{ "apiVersion": "v1", "kind": "ReplicationController", "metadata": { "name": "frontend-controller" }, "spec": { "replicas": 2, "selector": { "app": "nginx" }, "template": { "metadata": { "labels": { "app": "nginx", "label1": "testexample" } }, "spec": { "containers": [ { "name": "redis", "image": "redis:latest", "ports": [ { "containerPort": 80 } ] } ] } } }}

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "frontend-controller", "namespace": "default", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/frontend-controller",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 446

Page 457: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"uid": "cd4594b6-5d0b-11e6-aeb9-286ed488fafe", "resourceVersion": "3544", "generation": 4, "creationTimestamp": "2016-08-08T01:59:55Z", "labels": { "app": "nginx", "label1": "testexample" } }, "spec": { "replicas": 2, "selector": { "app": "nginx" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "nginx", "label1": "testexample" } }, "spec": { "containers": [ { "name": "redis", "image": "redis:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } } }, "status": { "replicas": 2, "fullyLabe;edRelicas": 2, "observedGeneration": 1 }}

状态码

表6-244描述API的状态码。

表 6-244 状态码

状态码 描述

200 This operation succeeds, and aReplicationController resource object isreturned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 447

Page 458: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.11.6 替换指定 Namespace 下的 ReplicationController 状态

功能介绍

该API用于替换指定Namespace下的某个ReplicationController对象的状态,即修改ReplicationController对象status各字段的值。

URIPUT /api/v1/namespaces/{namespace}/replicationcontrollers/{name}/status

表6-245 描述该API的参数。

表 6-245 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of theReplicationController.

请求消息

请求参数:

请求参数的详细描述请参见表7-1。

请求示例:

{ "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "frontend-controller", "namespace": "default", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/frontend-controller", "uid": "cd4594b6-5d0b-11e6-aeb9-286ed488fafe", "resourceVersion": "3586", "generation": 4, "creationTimestamp": "2016-08-08T01:59:55Z", "labels": { "app": "nginx", "label1": "testexample" } }, "status": { "replicas": 1, "observedGeneration": 3 }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 448

Page 459: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "frontend-controller", "namespace": "default", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/frontend-controller/status", "uid": "cd4594b6-5d0b-11e6-aeb9-286ed488fafe", "resourceVersion": "3593", "generation": 4, "creationTimestamp": "2016-08-08T01:59:55Z", "labels": { "app": "nginx", "label1": "testexample" } }, "spec": { "replicas": 2, "selector": { "app": "nginx" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "nginx", "label1": "testexample" } }, "spec": { "containers": [ { "name": "redis", "image": "redis:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } } }, "status": { "replicas": 1, "observedGeneration": 3 }}

状态码

表6-246描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 449

Page 460: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-246 状态码

状态码 描述

200 This operation succeeds, and aReplicationController resource object isreturned.

异常状态码请参见9.3 状态码。

6.11.7 列出指定 Namespace 下的 ReplicationController

功能介绍

该API用于列出指定Namespace下的所有ReplicationController。

URI

GET /api/v1/namespaces/{namespace}/replicationcontrollers

表6-247 描述该API的参数。

表 6-247 参数描述

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add, update,and remove notifications. SpecifyresourceVersion.

resourceVersion No When specified with a watch call,shows changes that occur afterthat particular version of aresource. Defaults to changes fromthe beginning of history.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 450

Page 461: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

timeoutSeconds No Timeout for the list/watch call.

namespace Yes Object name and auth scope, suchas for teams and projects.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-80。

响应示例:

{ "kind": "ReplicationControllerList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/replicationcontrollers", "resourceVersion": "591585" }, "items": [ { "metadata": { "name": "rc-test", "namespace": "default", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/rc-test", "uid": "4aabff80-fc1d-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "506966", "generation": 1, "creationTimestamp": "2018-01-18T07:00:39Z", "labels": { "name": "rc-test" }, "enable": true }, "spec": { "replicas": 1, "selector": { "name": "rc-test" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "rc-test" }, "enable": true }, "spec": { "containers": [ { "name": "pod-test", "image": "172.16.5.235:20202/test/nginx", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 451

Page 462: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } }, "status": { "replicas": 1, "fullyLabeledReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "observedGeneration": 1 } } ]}

状态码

表6-248描述API的状态码。

表 6-248 状态码

状态码 描述

200 This operation succeeds, and a groupof ReplicationController resourceobjects is returned.

异常状态码请参见9.3 状态码。

6.11.8 列出 ReplicationController

功能介绍

该API用于获取ReplicationController列表。

URIGET /api/v1/replicationcontrollers

表6-249 描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 452

Page 463: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-249 参数描述

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-80。

响应示例:

{ "kind": "ReplicationControllerList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/replicationcontrollers", "resourceVersion": "591671" }, "items": [ { "metadata": { "name": "rc-test", "namespace": "default",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 453

Page 464: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"selfLink": "/api/v1/namespaces/default/replicationcontrollers/rc-test", "uid": "4aabff80-fc1d-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "506966", "generation": 1, "creationTimestamp": "2018-01-18T07:00:39Z", "labels": { "name": "rc-test" }, "enable": true }, "spec": { "replicas": 1, "selector": { "name": "rc-test" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "rc-test" }, "enable": true }, "spec": { "containers": [ { "name": "pod-test", "image": "172.16.5.235:20202/test/nginx", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } } }, "status": { "replicas": 1, "fullyLabeledReplicas": 1, "readyReplicas": 1, "availableReplicas": 1, "observedGeneration": 1 } } ]}

状态码

表6-250描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 454

Page 465: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-250 状态码

状态码 描述

200 This operation succeeds, and a groupof ReplicationController resourceobjects is returned.

异常状态码请参见9.3 状态码。

6.11.9 更新指定的 ReplicationController

功能介绍

该API用于更新指定Namespace下的ReplicationController对象。

其中以下字段支持更新:

● metadata.selfLink● metadata.resourceVersion● metadata.generation● metadata.creationTimestamp● metadata.deletionTimestamp● metadata.labels● metadata.clusterName● metadata.generateName● metadata.annotations● spec.replicas● template.contaions● spec.restartPolicy● spec.activeDeadlineSeconds

URIPATCH /api/v1/namespaces/{namespace}/replicationcontrollers/{name}

表6-251 描述该API的参数。

表 6-251 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 455

Page 466: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

name Yes Name of theReplicationController.

请求消息

响应参数:

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求参数的详细描述请参见表7-1。

请求示例:

Content-Type: application/strategic-merge-patch+json { "spec": { "template": { "spec": { "containers": [ { "name": "hello-world", "image": "busybox:latest" }, { "name": "hello", "image": "busybox:latest" } ] } } } }

响应消息

响应参数:

响应参数的详细描述请参见表7-79。

响应示例:

{ "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "frontend-controller", "namespace": "default", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/frontend-controller", "uid": "cd4594b6-5d0b-11e6-aeb9-286ed488fafe", "resourceVersion": "1658", "generation": 2, "creationTimestamp": "2016-08-08T01:59:55Z", "labels": { "app": "nginx" } }, "spec": { "replicas": 2, "selector": { "app": "nginx" },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 456

Page 467: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"template": { "metadata": { "creationTimestamp": null, "labels": { "app": "nginx" } }, "spec": { "containers": [ { "name": "hello-world", "image": "busybox:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" }, { "name": "hello", "image": "busybox:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } } }, "status": { "replicas": 2, "fullyLabeledReplicas": 2, "observedGeneration": 1 } }

状态码

表6-252描述API的状态码。

表 6-252 状态码

状态码 描述

200 This operation succeeds, and aReplicationController resource object isreturned.

异常状态码请参见9.3 状态码。

6.12 Endpoints

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 457

Page 468: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.12.1 创建 Endpoints

功能介绍

该API用于创建一个Endpoints资源对象。

URIPOST /api/v1/namespaces/{namespace}/endpoints

表6-253 描述该API的参数。

表 6-253 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

请求消息

请求参数:

请求参数如表6-254所示。

表 6-254 参数描述

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isEndpoints.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 458

Page 469: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

metadata Yes metadataobject

-

subsets Yes subsetsobject

The set of all endpoints is theunion of all subsets.Addresses are placed intosubsets according to the IPsthey share. A single addresswith multiple ports, some ofwhich are ready and some ofwhich are not (because theycome from differentcontainers) will result in theaddress being displayed indifferent subsets for thedifferent ports. No addresswill appear in both Addressesand NotReadyAddresses inthe same subset. Sets ofaddresses and ports thatcomprise a service.

表 6-255 subsets 字段数据结构说明

参数 是否必选 参数类型 描述

addresses Yes addressesobject

IP addresses which offer therelated ports that are markedas ready. These endpointsshould be considered safe forload balancers and clients toutilize.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 459

Page 470: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

notReadyAddresses

No addressesobject

IP addresses which offer therelated ports but are notcurrently marked as readybecause they have not yetfinished starting, haverecently failed a readinesscheck, or have recently faileda liveness check.

ports Yes ports object Port numbers available on therelated IP addresses.

表 6-256 addresses 字段数据结构说明

参数 是否必选 参数类型 描述

ip Yes String The IP of this endpoint.

targetRef No targetRefobject

-

hostname No String Hostname of thisendpoint.eant to be used byDNS servers etc.

nodeName No String Optional: Node hosting thisendpoint. This can be used todetermine endpoints local toa node.

表 6-257 ports 字段数据结构说明

参数 是否必选 参数类型 描述

name No String The name of this port(corresponds toServicePort.Name). Must be aDNS_LABEL. Optional only ifone port is defined.Value length: 0 character <String length ≤ 63 characters.The string must comply withregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

port Yes Integer The port number of theendpoint.Value range: (0, 65535].

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 460

Page 471: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

protocol No String The IP protocol for this port.This parameter can be set to:● TCP● UDP

Default: TCP.

表 6-258 targetRef 字段数据结构说明

参数 是否必选 参数类型 描述

kind No String Phase is the current lifecyclephase of the namespace.

namespace No String Namespace of the referent.

name No String Name of the referent.

uid No String UID of the referent.

apiVersion No String API version of the referent.

resourceVersion No String Specific resourceVersion towhich this reference is made,if any.说明

This parameter is automaticallygenerated. Do not assign valuesto this parameter. Otherwise, theAPI fails to be called.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 461

Page 472: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

fieldPath No String If referring to a piece of anobject instead of an entireobject, this string shouldcontain a valid JSON/Go fieldaccess statement, such asdesiredState.manifest.containers[2]. For example, if theobject reference is to acontainer within a pod, thiswould take on a value like:"spec.containers{name}"(where "name" refers to thename of the container thattriggered the event) or if nocontainer name is specified"spec.containers[2]"(container with index 2 in thispod). This syntax is chosenonly to have some well-defined way of referencing apart of an object.

请求示例:

{ "kind": "Endpoints", "apiVersion": "v1", "metadata": { "name": "cluster-test" }, "subsets": [ { "addresses": [ { "ip": "172.16.106.152" } ], "ports": [ { "port": 1 } ] }, { "addresses": [ { "ip": "172.16.79.157" } ], "ports": [ { "port": 1 } ] } ] }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 462

Page 473: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Endpoints", "apiVersion": "v1", "metadata": { "name": "cluster-test", "namespace": "default", "selfLink": "/api/v1/namespaces/default/endpoints/cluster-test", "uid": "81b1503d-5960-11e6-b444-286ed488fafe", "resourceVersion": "18186", "creationTimestamp": "2016-08-03T09:56:10Z" }, "subsets": [ { "addresses": [ { "ip": "172.16.106.152" }, { "ip": "172.16.79.157" } ], "ports": [ { "port": 1, "protocol": "TCP" } ] } ] }

状态码

表6-259描述API的状态码。

表 6-259 状态码

状态码 描述

201 This operation succeeds, and anEndpoint resource object is returned.

异常状态码请参见9.3 状态码。

6.12.2 删除 Endpoints

功能介绍

该API用于删除一个Endpoints资源对象。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 463

Page 474: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URI

DELETE /api/v1/namespaces/{namespace}/endpoints/{name}

表6-260 描述该API的参数。

表 6-260 参数描述

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

namespace Yes Object name and auth scope, suchas for teams and projects.

name Yes Name of the Endpoints.

gracePeriodSeconds No The duration in seconds before theobject should be deleted. Valuemust be non-negative integer. Thevalue zero indicates deleteimmediately. If this value is nil, thedefault grace period for thespecified type will be used.Defaults to a per object value ifnot specified. zero means deleteimmediately.

orphanDependents No Deprecated: please use thePropagationPolicy, this field will bedeprecated in 1.7. Should thedependent objects be orphaned. Iftrue/false, the "orphan" finalizerwill be added to/removed fromthe object's finalizers list. Eitherthis field or PropagationPolicy maybe set, but not both.

propagationPolicy No Whether and how garbagecollection will be performed. Eitherthis field or OrphanDependentsmay be set, but not both. Thedefault policy is decided by theexisting finalizer set in themetadata.finalizers and theresource-specific default policy.

请求消息

请求参数:

请求参数如表6-261所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 464

Page 475: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-261 参数描述

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isDeleteOptions.

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

gracePeriodSeconds

No Integer The duration in secondsbefore the object should bedeleted. Value must be non-negative integer. The valuezero indicates deleteimmediately. If this value isnil, the default grace periodfor the specified type will beused. Defaults to a per objectvalue if not specified. zeromeans delete immediately.Value range of thisparameter: > 0.

propagationPolicy

No String Whether and how garbagecollection will be performed.Either this field orOrphanDependents may beset, but not both. The defaultpolicy is decided by theexisting finalizer set in themetadata.finalizers and theresource-specific defaultpolicy.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 465

Page 476: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

preconditions No preconditionsobject

Must be fulfilled before adeletion is carried out. If notpossible, a 409 Conflict statuswill be returned.

orphanDependents

No Boolean Should the dependent objectsbe orphaned. If true/false, the"orphan" finalizer will beadded to/removed from theobject's finalizers list.

表 6-262 preconditions 字段数据结构说明

参数 是否必选 参数类型 描述

uid No String Specifies the target UID.

请求示例:

{ "kind": "DeleteOptions", "apiVersion": "string", "gracePeriodSeconds": 0 }

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "code": 200 }

状态码

表6-263描述API的状态码。

表 6-263 状态码

状态码 描述

200 Delete an Endpoint resource objectresuccessfully.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 466

Page 477: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.12.3 删除所有的 Endpoints

功能介绍

This API is used to delete collection of Endpoints.

URI

DELETE /api/v1/namespaces/{namespace}/endpoints

表6-264描述该API的参数。

表 6-264 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

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

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

Request

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 467

Page 478: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表6-254

响应示例:

{ "kind": "EndpointsList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/delns-12130306/endpoints", "resourceVersion": "419246" }, "items": [ { "metadata": { "name": "ep-del-12130306", "namespace": "delns-12130306", "selfLink": "/api/v1/namespaces/delns-12130306/endpoints/ep-del-12130306", "uid": "1480f55c-dfb4-11e7-9c19-fa163e2d897b", "resourceVersion": "419246", "creationTimestamp": "2017-12-13T03:16:58Z", "enable": true }, "subsets": [ { "addresses": [ { "ip": "10.154.75.241" } ], "ports": [ { "port": 31043, "protocol": "TCP" } ] } ] } ]}

状态码

表6-265描述API的状态码。

表 6-265 状态码

状态码 描述

200 Delete a DaemonSet resource objectsuccessfully.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 468

Page 479: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.12.4 获取指定的 Endpoints

功能介绍

该API用于获取某个Namespace下指定的Endpoints对象。

URIGET /api/v1/namespaces/{namespace}/endpoints/{name}

表6-266 描述该API的参数。

表 6-266 参数描述

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

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

name Yes Name of the Endpoint.

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 usercan not specify.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-254。

响应示例:

{ "kind": "Endpoints", "apiVersion": "v1", "metadata": { "name": "cluster-test", "namespace": "default", "selfLink": "/api/v1/namespaces/default/endpoints/cluster-test", "uid": "81b1503d-5960-11e6-b444-286ed488fafe", "resourceVersion": "18186", "creationTimestamp": "2016-08-03T09:56:10Z" }, "subsets": [ {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 469

Page 480: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"addresses": [ { "ip": "172.16.106.152" }, { "ip": "172.16.79.157" } ], "ports": [ { "port": 1, "protocol": "TCP" } ] } ] }

状态码

表6-267描述API的状态码。

表 6-267 状态码

状态码 描述

200 This operation succeeds, and anEndpoint resource object is returned.

异常状态码请参见9.3 状态码。

6.12.5 替换指定的 Endpoints

功能介绍

该API用于替换指定Namespace下指定的Endpoints资源对象。

其中以下字段支持更新:

● metadata.selfLink● metadata.resourceVersion● metadata.generation● metadata.creationTimestamp● metadata.deletionTimestamp● metadata.labels● metadata.clusterName● metadata.generateName● metadata.annotations● subnet.*

URIPUT /api/v1/namespaces/{namespace}/endpoints/{name}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 470

Page 481: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表6-268 描述该API的参数。

表 6-268 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Endpoints.

请求消息

请求参数:

请求参数的详细描述请参见表6-254。

请求示例:

{ "kind": "Endpoints", "apiVersion": "v1", "metadata": { "name": "cluster-test" }, "subsets": [ { "addresses": [ { "ip": "172.16.106.150" } ], "ports": [ { "port": 1 } ] }, { "addresses": [ { "ip": "172.16.79.223" } ], "ports": [ { "port": 1 } ] },{ "addresses": [ { "ip": "172.16.106.154" } ], "ports": [ { "port": 1 }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 471

Page 482: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

] } ] }

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Endpoints", "apiVersion": "v1", "metadata": { "name": "cluster-test", "namespace": "default", "selfLink": "/api/v1/namespaces/default/endpoints/cluster-test", "uid": "88a7230f-5d36-11e6-aeb9-286ed488fafe", "resourceVersion": "3203", "creationTimestamp": "2016-08-08T07:05:48Z" }, "subsets": [ { "addresses": [ { "ip": "172.16.106.150" }, { "ip": "172.16.106.154" }, { "ip": "172.16.79.223" } ], "ports": [ { "port": 1, "protocol": "TCP" } ] } ] }

状态码

表6-269描述API的状态码。

表 6-269 状态码

状态码 描述

200 This operation succeeds, and a groupof Endpoint resource objects isreturned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 472

Page 483: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.12.6 列出 Endpoints

功能介绍

该API用于列出所有的Endpoints资源对象。

URIGET /api/v1/endpoints

表6-270 描述该API的参数。

表 6-270 参数描述

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

请求消息

N/A

响应消息

响应参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 473

Page 484: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应参数如表6-271所示。

表 6-271 参数描述

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

metadata metadata object -

items Object List of endpoints.具体请参见表6-254。

表 6-272 metadata 字段数据结构说明

参数 参数类型 描述

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treated asopaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

响应示例:

{ "kind": "EndpointsList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/endpoints", "resourceVersion": "599259" }, "items": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 474

Page 485: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "metadata": { "name": "kubernetes", "namespace": "default", "selfLink": "/api/v1/namespaces/default/endpoints/kubernetes", "uid": "64593b5d-f83d-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "49", "creationTimestamp": "2018-01-13T08:40:21Z", "enable": true }, "subsets": [ { "addresses": [ { "ip": "192.168.0.64" } ], "ports": [ { "name": "https", "port": 5444, "protocol": "TCP" } ] } ] }, { "metadata": { "name": "kube-controller-manager", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/endpoints/kube-controller-manager", "uid": "654e158d-f83d-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "599259", "creationTimestamp": "2018-01-13T08:40:23Z", "annotations": { "control-plane.alpha.kubernetes.io/leader": "{\"holderIdentity\":\"192-168-0-64\",\"leaseDurationSeconds\":15,\"acquireTime\":\"2018-01-13T08:40:23Z\",\"renewTime\":\"2018-01-19T09:31:56Z\",\"leaderTransitions\":0}" }, "enable": true }, "subsets": null }, { "metadata": { "name": "kube-dns", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/endpoints/kube-dns", "uid": "6cfc9958-f83d-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "506984", "creationTimestamp": "2018-01-13T08:40:36Z", "labels": { "addonmanager.kubernetes.io/mode": "Reconcile", "kubernetes-app": "kube-dns", "kubernetes.io/cluster-service": "true", "kubernetes.io/name": "KubeDNS" }, "enable": true }, "subsets": [ { "addresses": [ { "ip": "172.31.0.10", "nodeName": "192.168.0.228", "targetRef": { "kind": "Pod", "namespace": "kube-system",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 475

Page 486: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"name": "kube-dns-139966378-crrqm", "uid": "c46cfbf9-fc4b-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "506982" } } ], "ports": [ { "name": "dns-tcp", "port": 5353, "protocol": "TCP" }, { "name": "dns", "port": 5353, "protocol": "UDP" } ] } ] }, { "metadata": { "name": "kube-scheduler", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/endpoints/kube-scheduler", "uid": "64d35553-f83d-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "599258", "creationTimestamp": "2018-01-13T08:40:22Z", "annotations": { "control-plane.alpha.kubernetes.io/leader": "{\"holderIdentity\":\"192-168-0-64\",\"leaseDurationSeconds\":15,\"acquireTime\":\"2018-01-13T08:40:22Z\",\"renewTime\":\"2018-01-19T09:31:56Z\",\"leaderTransitions\":0}" }, "enable": true }, "subsets": null } ]}

状态码

表6-273描述API的状态码。

表 6-273 状态码

状态码 描述

200 This operation succeeds, and a groupof Endpoint resource objects isreturned.

异常状态码请参见9.3 状态码。

6.12.7 列出指定 Namespace 下的 Endpoints

功能介绍

该API用于获取指定Namespace下的所有Endpoints对象。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 476

Page 487: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URIGET /api/v1/namespaces/{namespace}/endpoints

表6-274 描述该API的参数。

表 6-274 参数描述

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version of aresource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-271。

响应示例:

{ "kind": "EndpointsList",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 477

Page 488: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/endpoints", "resourceVersion": "598704" }, "items": [ { "metadata": { "name": "kubernetes", "namespace": "default", "selfLink": "/api/v1/namespaces/default/endpoints/kubernetes", "uid": "64593b5d-f83d-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "49", "creationTimestamp": "2018-01-13T08:40:21Z", "enable": true }, "subsets": [ { "addresses": [ { "ip": "192.168.0.64" } ], "ports": [ { "name": "https", "port": 5444, "protocol": "TCP" } ] } ] } ]}

状态码

表6-275描述API的状态码。

表 6-275 状态码

状态码 描述

200 This operation succeeds, and a groupof Endpoint resource objects isreturned.

异常状态码请参见9.3 状态码。

6.12.8 更新指定的 Endpoints

功能介绍

该API用于更新指定Namespace下的Endpoints对象。

其中以下字段支持更新:

● metadata.selfLink

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 478

Page 489: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.clusterName

● metadata.generateName

● metadata.annotations

● subnet.*

URI

PATCH /api/v1/namespaces/{namespace}/endpoints/{name}

表6-276 描述该API的参数。

表 6-276 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Endpoints.

请求消息

请求参数:

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json{ "subsets": [ { "addresses": [ { "ip": "172.16.106.154" } ], "ports": [ { "port": 1 } ] } ]}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 479

Page 490: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表6-254.

响应示例:

{ "kind": "Endpoints", "apiVersion": "v1", "metadata": { "name": "cluster-test", "namespace": "default", "selfLink": "/api/v1/namespaces/default/endpoints/cluster-test", "uid": "88a7230f-5d36-11e6-aeb9-286ed488fafe", "resourceVersion": "3182", "creationTimestamp": "2016-08-08T07:05:48Z" }, "subsets": [ { "addresses": [ { "ip": "172.16.106.150" }, { "ip": "172.16.106.154" }, { "ip": "172.16.79.123" } ], "ports": [ { "port": 1, "protocol": "TCP" } ] } ] }

状态码

表6-277描述API的状态码。

表 6-277 状态码

状态码 描述

200 This operation succeeds, and anEndpoint resource object is returned.

异常状态码请参见9.3 状态码。

6.13 Service

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 480

Page 491: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.13.1 创建 Service

功能介绍

该API用于创建一个Service对象。

● 如果在创建Service资源对象和Deployment资源对象后,要在CCE界面,工作负载详情页面中,“访问方式”页签下显示对应的Service资源,则需要给创建的Service资源对象添加labels标签,并且设置对应的selector。设置请求消息体中的“metadata.labels”参数键值如下:labels: app: appname

设置请求消息体中的“spec.selector”参数键值如下:selector: app: appname

其中:

– lables参数下“app”参数所键入的“appname”为显示在CCE工作负载界面上的工作负载名称,其值与Deployment的“metadata.labels”中所添加的内容一致。

– selector参数下“app”的值与需要关联的Deployment的“spec.selector”保持一致。

URIPOST /api/v1/namespaces/{namespace}/services

表6-278 描述该API的参数。

表 6-278 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Name and auth scope,such as for teams andprojects.

请求消息

请求参数:

请求参数如表6-279所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 481

Page 492: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-279 参数描述

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isService.

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

metadata Yes metadataobject

-

spec Yes spec object -

status No status object -

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 482

Page 493: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-280 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

name Yes String Name must be unique withina namespace. Is requiredwhen creating resources,although some resources mayallow a client to request thegeneration of an appropriatename automatically. Name isprimarily intended forcreation idempotence andconfiguration definition.Cannot be updated.Value length: 0 character <String length ≤ 24 charactersThe string must comply withregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

clusterName No String The name of the clusterwhich the object belongs to.This is used to distinguishresources with same nameand namespace in differentclusters. This field is not setanywhere right now andapiserver is going to ignore itif set in create or updaterequest.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 483

Page 494: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

initializers No initializersobject

An initializer is a controllerwhich enforces some systeminvariant at object creationtime. This field is a list ofinitializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized.Otherwise, the object isconsidered uninitialized and ishidden (in list/watch and getcalls) from clients thathaven't explicitly asked toobserve uninitialized objects.When an object is created,the system will populate thislist with the current set ofinitializers. Only privilegedusers may set or modify thislist. Once it is empty, it maynot be modified further byany user.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 484

Page 495: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

generateName No String GenerateName is an optionalprefix, used by the server, togenerate a unique nameONLY IF the Name field hasnot been provided. If this fieldis used, the name returned tothe client will be differentthan the name passed. Thisvalue will also be combinedwith a unique suffix. Theprovided value has the samevalidation rules as the Namefield, and may be truncatedby the length of the suffixrequired to make the valueunique on the server.If this field is specified andthe generated name exists,the server will NOT return a409 - instead, it will eitherreturn 201 Created or 500with Reason ServerTimeoutindicating a unique namecould not be found in thetime allotted, and the clientshould retry (optionally afterthe time indicated in theRetry-After header).Applied only if Name is notspecified.Value length: 0 character <String length ≤ 24 charactersThe string must comply withregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 485

Page 496: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

namespace No String Namespace defines the spacewithin each name must beunique. An empty namespaceis equivalent to the "default"namespace, but "default" isthe canonical representation.Not all objects are required tobe scoped to a namespace -the value of this field forthose objects will be empty.Must be a DNS_LABEL.Cannot be updated.Value length: 0 character <String length ≤ 63 characters.The string must comply withregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

selfLink No String SelfLink is a URL representingthis object. Populated by thesystem. Read-only.说明

This parameter is automaticallygenerated. Do not assign valuesto this parameter. Otherwise, theAPI fails to be called.

uid No String UID is the unique in time andspace value for this object. Itis typically generated by theserver on successful creationof a resource and is notallowed to change on PUToperations. Populated by thesystem. Read-only.说明

This parameter is automaticallygenerated. Do not assign valuesto this parameter. Otherwise, theAPI fails to be called.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 486

Page 497: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

resourceVersion No String An opaque value thatrepresents the internal versionof this object that can beused by clients to determinewhen objects have changed.May be used for optimisticconcurrency, changedetection, and the watchoperation on a resource or setof resources. Clients musttreat these values as opaqueand passed unmodified backto the server. They may onlybe valid for a particularresource or set of resources.Populated by the system.Read-only. Value must betreated as opaque by clients.说明

This parameter is automaticallygenerated. Do not assign valuesto this parameter. Otherwise, theAPI fails to be called.

generation No Integer A sequence numberrepresenting a specificgeneration of the desiredstate. Currently onlyimplemented by replicationcontrollers. Populated by thesystem. Read-only.

creationTimestamp

No String CreationTimestamp is atimestamp representing theserver time when this objectwas created. It is notguaranteed to be set inhappens-before order acrossseparate operations. Clientsmay not set this value. It isrepresented in RFC3339 formand is in UTC. Populated bythe system. Read-only. Nullfor lists.说明

This parameter is automaticallygenerated. Do not assign valuesto this parameter. Otherwise, theAPI fails to be called.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 487

Page 498: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionTimestamp

No String DeletionTimestamp is RFC3339 date and time at whichthis resource will be deleted.This field is set by the serverwhen a graceful deletion isrequested by the user, and isnot directly settable by aclient. The resource will bedeleted (no longer visiblefrom resource lists, and notreachable by name) after thetime in this field. Once set,this value may not be unsetor be set further into thefuture, although it may beshortened or the resourcemay be deleted prior to thistime. For example, a user mayrequest that a pod is deletedin 30 seconds. The Kubeletwill react by sending agraceful termination signal tothe containers in the pod.Once the resource is deletedin the API, the Kubelet willsend a hard terminationsignal to the container. If notset, graceful deletion of theobject has not beenrequested. Populated by thesystem when a gracefuldeletion is requested. Read-only.

deletionGracePeriodSeconds

No Integer Number of seconds allowedfor this object to gracefullyterminate before it will beremoved from the system.Only set whendeletionTimestamp is also set.May only be shortened. Read-only.

labels No Object Map of string keys and valuesthat can be used to organizeand categorize (scope andselect) objects. May matchselectors of replicationcontrollers and services.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 488

Page 499: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

Annotations No Object Annotations is anunstructured key value mapstored with a resource thatmay be set by external toolsto store and retrieve arbitrarymetadata. They are notqueryable and should bepreserved when modifyingobjects.

ownerReferences

No ownerReferences object

List of objects depended bythis object. If ALL objects inthe list have been deleted,this object will be garbagecollected. If this object ismanaged by a controller, thenan entry in this list will pointto this controller, with thecontroller field set to true.There cannot be more thanone managing controller.

finalizers No Array ofstrings

Must be empty before theobject is deleted from theregistry. Each entry is anidentifier for the responsiblecomponent that will removethe entry from the list. If thedeletionTimestamp of theobject is non-nil, entries inthis list can only be removed.

表 6-281 spec 字段数据结构说明

参数 是否必选 参数类型 描述

ports Yes ports object The list of ports that areexposed by this service.

selector No Object This service will route trafficto pods having labelsmatching this selector. Labelkeys and values that mustmatch in order to receivetraffic for this service. Ifempty, all pods are selected, ifnot specified, endpoints mustbe manually specified.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 489

Page 500: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

clusterIP No String ClusterIP is usually assignedby the master and is the IPaddress of the service. Ifspecified, it will be allocatedto the service if it is unused orelse creation of the servicewill fail. Valid values areNone, empty string (""), or avalid IP address. 'None' can bespecified for a headlessservice when proxying is notrequired. Cannot be updated.The value of this parameter isNONE or a valid IP address.

type No String Type of exposed service. Mustbe ClusterIP, NodePort, orLoadBalancer. Defaults toClusterIP.The “LoadBalancer” valueindicates that Elastic LoadBalance (ELB) is in use. Fordetails about how to use ELBwith a cluster created by theCCE console, see section 9.6集群中使用ELB的操作方法。

externalIPs No Array ofstrings

externalIPs is a list of IPaddresses for which nodes inthe cluster will also accepttraffic for this service. TheseIPs are not managed byKubernetes. The user isresponsible for ensuring thattraffic arrives at a node withthis IP. A common example isexternal load-balancers thatare not part of theKubernetes system. Aprevious form of thisfunctionality exists as thedeprecatedPublicIPs field.When using this field, callersshould also clear thedeprecatedPublicIPs field.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 490

Page 501: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

externalTrafficPolicy

No String externalTrafficPolicy denotesif this Service desires to routeexternal traffic to node-localor cluster-wide endpoints."Local" preserves the clientsource IP and avoids a secondhop for LoadBalancer andNodeport type services, butrisks potentially imbalancedtraffic spreading. "Cluster"obscures the client source IPand may cause a second hopto another node, but shouldhave good overall load-spreading.

healthCheckNodePort

No Integer healthCheckNodePortspecifies the healthchecknodePort for the service. Ifnot specified,HealthCheckNodePort iscreated by the service apibackend with the allocatednodePort. Will use user-specified nodePort value ifspecified by the client. Onlyeffects when Type is set toLoadBalancer andExternalTrafficPolicy is set toLocal.

externalName No String externalName is the externalreference that kubedns orequivalent will return as aCNAME record for this service.No proxying will be involved.Must be a valid DNS nameand requires Type to beExternalName.

sessionAffinity No String Supports "ClientIP" and"None". Used to maintainsession affinity. Enable clientIP based session affinity. Mustbe ClientIP or None. Defaultsto None.This parameter can be set to:● ClientIP● None

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 491

Page 502: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

loadBalancerIP No String Only applies to Service Type:LoadBalancer LoadBalancerwill get created with the IPspecified in this field. Thisfeature depends on whetherthe underlying cloud-providersupports specifying theloadBalancerIP when a loadbalancer is created. This fieldwill be ignored if the cloud-provider does not support thefeature.

loadBalancerSourceRanges

No Array ofstrings

Optional: If specified andsupported by the platform,this will restrict trafficthrough the cloud-provide.load-balancer will berestricted to the specifiedclient IPs. This field will beignored if the cloud-providerdoes not support thefeature.".

publishNotReadyAddresses

No Boolean publishNotReadyAddresses,when set to true, indicatesthat DNS implementationsmust publish thenotReadyAddresses of subsetsfor the Endpoints associatedwith the Service. The defaultvalue is false. The primary usecase for setting this field is touse a StatefulSet's HeadlessService to propagate SRVrecords for its Pods withoutrespect to their readiness forpurpose of peer discovery.This field will replace theservice.alpha.kubernetes.io/tolerate-unready-endpointswhen that annotation isdeprecated and all clientshave been converted to usethis field.

sessionAffinityConfig

No SessionAffinityConfigobject

sessionAffinityConfig containsthe configurations of sessionaffinity.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 492

Page 503: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-282 status 字段数据结构说明

参数 是否必选 参数类型 描述

loadBalancer No loadBalancerobject

-

表 6-283 ownerReferences 字段数据结构说明

参数 是否必选 参数类型 描述

apiVersion No String API version of the referent.

blockOwnerDeletion

No Boolean If true, AND if the owner hasthe "foregroundDeletion"finalizer, then the ownercannot be deleted from thekey-value store until thisreference is removed.Defaults to false. To set thisfield, a user needs "delete"permission of the owner,otherwise 422 (UnprocessableEntity) will be returned.

kind No String Kind of the referent.

name Yes String Name of the referent.

uid No String UID of the referent.

controller No Boolean If true, this reference pointsto the managing controller.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 493

Page 504: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-284 ports 字段数据结构说明

参数 是否必选 参数类型 描述

name No String The name of this port withinthe service. This must be aDNS_LABEL. All ports within aServiceSpec must have uniquenames. This maps to the'Name' field in EndpointPortobjects. Optional if only oneServicePort is defined on thisservice.Value length: 0 character <String length ≤ 63 characters.The string must comply withregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

protocol No String The IP protocol for this port.Supports "TCP" and "UDP".This parameter can be set to:● TCP● UDP

port Yes Integer The port that will be exposedby this service.Value range: (0,65535].

targetPort No String Number or name of the portto access on the podstargeted by the service.Number must be in the range1 to 65535. Name must be anIANA_SVC_NAME. If this is astring, it will be looked up asa named port in the targetPod's container ports. If this isnot specified, the value ofPort is used (an identitymap). Defaults to the serviceport.Value range: (0,65535].

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 494

Page 505: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

nodePort No Integer The port on each node onwhich this service is exposedwhen type=NodePort orLoadBalancer. Usuallyassigned by the system. Ifspecified, it will be allocatedto the service if unused orelse creation of the servicewill fail. Default is to auto-allocate a port if theServiceType of this Servicerequires one.Value range: [30000,32767].

表 6-285 loadBalancer 字段数据结构说明

参数 是否必选 参数类型 描述

ingress No ingress object Ingress is a list containingingress points for the load-balancer. Traffic intended forthe service should be sent tothese ingress points.

表 6-286 ingress 字段数据结构说明

参数 是否必选 参数类型 描述

ip No String IP is set for load-balanceringress points that are IPbased.

hostname No String Hostname is set for load-balancer ingress points thatare DNS based.

表 6-287 SessionAffinityConfig 字段数据结构说明

参数 是否必选 参数类型 描述

clientIP No ClientIPConfig object

clientIP contains theconfigurations of Client IPbased session affinity.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 495

Page 506: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-288 ClientIPConfig 字段数据结构说明

参数 是否必选 参数类型 描述

timeoutSeconds

No Integer timeoutSeconds specifies theseconds of ClientIP typesession sticky time. The valuemust be >0 && <=86400(for 1day) if ServiceAffinity =="ClientIP". Default value is10800(for 3 hours).

请求示例:

{ "kind":"Service", "apiVersion":"v1", "metadata":{ "name":"service-test", "creationTimestamp":null, "labels":{ "app":"cce" } }, "spec":{ "ports":[{ "name":"http", "port":80, "targetPort":0 }], "selector":{ "app":"cce" }, "clusterIP":"None" }, "status":{ "loadBalancer":{} }}

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind":"Service", "apiVersion":"v1", "metadata":{ "name":"service-test", "namespace":"default", "selfLink":"/api/v1/namespaces/default/services/service-test", "uid":"61c9aee7-29aa-11e7-896b-fa163ebe5340", "resourceVersion":"1349201", "creationTimestamp":"2017-04-25T11:29:01Z", "labels":{ "app":"cce" } }, "spec":{

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 496

Page 507: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"ports":[{ "name":"http", "protocol":"TCP", "port":80, "targetPort":80 }], "selector":{"app":"cce"}, "clusterIP":"None", "type":"ClusterIP", "sessionAffinity":"None" }, "status":{ "loadBalancer":{} }}

状态码

表6-289描述API的状态码。

表 6-289 状态码

状态码 描述

201 The request has been fulfilled,resulting in the creation of a newresource.

异常状态码请参见9.3 状态码。

6.13.2 删除 Service

功能介绍

该API用于删除一个Service对象。

URIDELETE /api/v1/namespaces/{namespace}/services/{name}

表6-290 描述该API的参数。

表 6-290 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Service.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 497

Page 508: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "code": 200 }

状态码

表6-291描述API的状态码。

表 6-291 状态码

状态码 描述

200 Delete a Service resource objectresuccessfully.

异常状态码请参见9.3 状态码。

6.13.3 获取指定的 Service

功能介绍

该API用于获取指定的Service对象。

URI

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

表6-292 描述该API的参数。

表 6-292 参数描述

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 498

Page 509: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

name Yes Name of the Service.

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 usercan not specify.

请求消息

N/A

响应消息

响应参数:

响应参数如表6-293所示。

表 6-293 参数描述

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

metadata metadata object -

spec spec object -

status status object -

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 499

Page 510: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-294 metadata 字段数据结构说明

参数 参数类型 描述

name String Name must be unique within anamespace. Is required whencreating resources, although someresources may allow a client torequest the generation of anappropriate name automatically.Name is primarily intended forcreation idempotence andconfiguration definition. Cannotbe updated.

clusterName String The name of the cluster which theobject belongs to. This is used todistinguish resources with samename and namespace in differentclusters. This field is not setanywhere right now and apiserveris going to ignore it if set in createor update request.

initializers initializers object An initializer is a controller whichenforces some system invariant atobject creation time. This field is alist of initializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized. Otherwise,the object is considereduninitialized and is hidden (in list/watch and get calls) from clientsthat haven't explicitly asked toobserve uninitialized objects.When an object is created, thesystem will populate this list withthe current set of initializers. Onlyprivileged users may set or modifythis list. Once it is empty, it maynot be modified further by anyuser.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 500

Page 511: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

generateName String GenerateName is an optionalprefix, used by the server, togenerate a unique name ONLY IFthe Name field has not beenprovided. If this field is used, thename returned to the client will bedifferent than the name passed.This value will also be combinedwith a unique suffix. The providedvalue has the same validationrules as the Name field, and maybe truncated by the length of thesuffix required to make the valueunique on the server.If this field is specified and thegenerated name exists, the serverwill NOT return a 409 - instead, itwill either return 201 Created or500 with Reason ServerTimeoutindicating a unique name couldnot be found in the time allotted,and the client should retry(optionally after the timeindicated in the Retry-Afterheader).Applied only if Name is notspecified.

namespace String Namespace defines the spacewithin each name must be unique.An empty namespace is equivalentto the "default" namespace, but"default" is the canonicalrepresentation. Not all objects arerequired to be scoped to anamespace - the value of this fieldfor those objects will be empty.Must be a DNS_LABEL. Cannot beupdated.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 501

Page 512: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

uid String UID is the unique in time andspace value for this object. It istypically generated by the serveron successful creation of aresource and is not allowed tochange on PUT operations.Populated by the system. Read-only.

resourceVersion String An opaque value that representsthe internal version of this objectthat can be used by clients todetermine when objects havechanged. May be used foroptimistic concurrency, changedetection, and the watchoperation on a resource or set ofresources. Clients must treat thesevalues as opaque and passedunmodified back to the server.They may only be valid for aparticular resource or set ofresources. Populated by thesystem. Read-only. Value must betreated as opaque by clients.

generation Integer A sequence number representing aspecific generation of the desiredstate. Currently only implementedby replication controllers.Populated by the system. Read-only.

creationTimestamp

String CreationTimestamp is atimestamp representing the servertime when this object was created.It is not guaranteed to be set inhappens-before order acrossseparate operations. Clients maynot set this value. It is representedin RFC3339 form and is in UTC.Populated by the system. Read-only. Null for lists.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 502

Page 513: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

deletionTimestamp

String DeletionTimestamp is RFC 3339date and time at which thisresource will be deleted. This fieldis set by the server when agraceful deletion is requested bythe user, and is not directlysettable by a client. The resourcewill be deleted (no longer visiblefrom resource lists, and notreachable by name) after the timein this field. Once set, this valuemay not be unset or be set furtherinto the future, although it may beshortened or the resource may bedeleted prior to this time. Forexample, a user may request thata pod is deleted in 30 seconds.The Kubelet will react by sendinga graceful termination signal tothe containers in the pod. Oncethe resource is deleted in the API,the Kubelet will send a hardtermination signal to thecontainer. If not set, gracefuldeletion of the object has notbeen requested. Populated by thesystem when a graceful deletion isrequested. Read-only.

deletionGracePeriodSeconds

Integer Number of seconds allowed forthis object to gracefully terminatebefore it will be removed from thesystem. Only set whendeletionTimestamp is also set.May only be shortened. Read-only.

labels Object Map of string keys and values thatcan be used to organize andcategorize (scope and select)objects. May match selectors ofreplication controllers andservices.

Annotations Object Annotations is an unstructured keyvalue map stored with a resourcethat may be set by external toolsto store and retrieve arbitrarymetadata. They are not queryableand should be preserved whenmodifying objects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 503

Page 514: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

ownerReferences ownerReferencesobject

List of objects depended by thisobject. If ALL objects in the listhave been deleted, this object willbe garbage collected. If this objectis managed by a controller, thenan entry in this list will point tothis controller, with the controllerfield set to true. There cannot bemore than one managingcontroller.

finalizers Array of strings Must be empty before the objectis deleted from the registry. Eachentry is an identifier for theresponsible component that willremove the entry from the list. Ifthe deletionTimestamp of theobject is non-nil, entries in this listcan only be removed.

表 6-295 spec 字段数据结构说明

参数 参数类型 描述

ports ports object The list of ports that are exposedby this service.

selector No This service will route traffic topods having labels matching thisselector. Label keys and valuesthat must match in order toreceive traffic for this service. Ifempty, all pods are selected, if notspecified, endpoints must bemanually specified.

clusterIP String ClusterIP is usually assigned by themaster and is the IP address of theservice. If specified, it will beallocated to the service if it isunused or else creation of theservice will fail. Valid values areNone, empty string (""), or a validIP address. 'None' can be specifiedfor a headless service whenproxying is not required. Cannotbe updated.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 504

Page 515: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

type String Type of exposed service. Must beClusterIP, NodePort, orLoadBalancer. Defaults toClusterIP.

externalIPs Array of strings externalIPs is a list of IP addressesfor which nodes in the cluster willalso accept traffic for this service.These IPs are not managed byKubernetes. The user isresponsible for ensuring thattraffic arrives at a node with thisIP. A common example is externalload-balancers that are not part ofthe Kubernetes system. A previousform of this functionality exists asthe deprecatedPublicIPs field.When using this field, callersshould also clear thedeprecatedPublicIPs field.

healthCheckNodePort

Integer healthCheckNodePort specifies thehealthcheck nodePort for theservice. If not specified,HealthCheckNodePort is createdby the service api backend withthe allocated nodePort. Will useuser-specified nodePort value ifspecified by the client. Only effectswhen Type is set to LoadBalancerand ExternalTrafficPolicy is set toLocal.

loadBalancerSourceRanges

Array of strings If specified and supported by theplatform, this will restrict trafficthrough the cloud-provider load-balancer will be restricted to thespecified client IPs. This field willbe ignored if the cloud-providerdoes not support the feature.

externalName String externalName is the externalreference that kubedns orequivalent will return as a CNAMErecord for this service. No proxyingwill be involved. Must be a validDNS name and requires Type tobe ExternalName.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 505

Page 516: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

deprecatedPublicIPs

Array of strings deprecatedPublicIPs is deprecatedand replaced by the externalIPsfield with almost the exact samesemantics. This field is retained inthe v1 API for compatibility untilat least 8/20/2016. It will beremoved from any new APIrevisions. If bothdeprecatedPublicIPs andexternalIPs are set,deprecatedPublicIPs is used.

sessionAffinity String Supports "ClientIP" and "None".Used to maintain session affinity.Enable client IP based sessionaffinity. Must be ClientIP or None.Defaults to None.

loadBalancerIP String Only applies to Service Type:LoadBalancer LoadBalancer willget created with the IP specified inthis field. This feature depends onwhether the underlying cloud-provider supports specifying theloadBalancerIP when a loadbalancer is created. This field willbe ignored if the cloud-providerdoes not support the feature.

表 6-296 status 字段数据结构说明

参数 参数类型 描述

loadBalancer loadBalancer object -

表 6-297 ownerReferences 字段数据结构说明

参数 参数类型 描述

apiVersion String API version of the referent.

kind String Kind of the referent.

name String Name of the referent.

uid String UID of the referent.

controller Boolean If true, this reference points to themanaging controller.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 506

Page 517: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

blockOwnerDeletion

Boolean If true, AND if the owner has the"foregroundDeletion" finalizer,then the owner cannot be deletedfrom the key-value store until thisreference is removed. Defaults tofalse. To set this field, a user needs"delete" permission of the owner,otherwise 422 (UnprocessableEntity) will be returned.

表 6-298 ports 字段数据结构说明

参数 参数类型 描述

name String The name of this port within theservice. This must be aDNS_LABEL. All ports within aServiceSpec must have uniquenames. This maps to the 'Name'field in EndpointPort objects.Optional if only one ServicePort isdefined on this service.

protocol String The IP protocol for this port.Supports "TCP" and "UDP".Default is TCP.

port Integer The port that will be exposed bythis service.

targetPort String Number or name of the port toaccess on the pods targeted by theservice. Number must be in therange 1 to 65535. Name must bean IANA_SVC_NAME. If this is astring, it will be looked up as anamed port in the target Pod'scontainer ports. If this is notspecified, the value of Port is used(an identity map). Defaults to theservice port.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 507

Page 518: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

nodePort Integer The port on each node on whichthis service is exposed whentype=NodePort or LoadBalancer.Usually assigned by the system. Ifspecified, it will be allocated tothe service if unused or elsecreation of the service will fail.Default is to auto-allocate a portif the ServiceType of this Servicerequires one.

表 6-299 loadBalancer 字段数据结构说明

参数 参数类型 描述

ingress ingress object Ingress is a list containing ingresspoints for the load-balancer.Traffic intended for the serviceshould be sent to these ingresspoints.

表 6-300 ingress 字段数据结构说明

参数 参数类型 描述

ip String IP is set for load-balancer ingresspoints that are IP based

hostname String Hostname is set for load-balanceringress points that are DNS based

响应示例:

{ "kind": "Service", "apiVersion": "v1", "metadata": { "name": "myapp", "namespace": "default", "selfLink": "/api/v1/namespaces/default/services/myapp", "uid": "58b5ca7c-5d12-11e6-aeb9-286ed488fafe", "resourceVersion": "683", "creationTimestamp": "2016-08-08T02:46:46Z" }, "spec": { "ports": [ { "protocol": "TCP", "port": 8765, "targetPort": 9376 }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 508

Page 519: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

], "selector": { "app": "example" }, "clusterIP": "10.0.0.139", "type": "ClusterIP", "sessionAffinity": "None" }, "status": { "loadBalancer": {} } }

状态码

表6-301描述API的状态码。

表 6-301 状态码

状态码 描述

200 This operation succeeds, and a Serviceresource object is returned.

异常状态码请参见9.3 状态码。

6.13.4 替换指定的 Service

功能介绍

该API用于替换指定的Service对象。

其中以下字段支持更新:

● metadata.selfLink● metadata.resourceVersion● metadata.generation● metadata.creationTimestamp● metadata.deletionTimestamp● metadata.labels● metadata.clusterName● metadata.generateName● metadata.annotations● spec.externalTrafficPolicy● spec.sessionAffinity● spec.type

说明

spec.type的值,可更新的优先级为LoadBalancer>NodePort>ClusterIP,即当spec.type的值为ClusterIP时,可更新为LoadBalancer或NodePort;当spec.type的值为NodePort时,只能更新为LoadBalancer;当spec.type的值为LoadBalancer时,spec.type不可更新。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 509

Page 520: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● spec.port● spec.selector● spec.externalIPs● spec.loadBalancerIP● spec.loadBalancerSourceRanges

URIPUT /api/v1/namespaces/{namespace}/services/{name}

表6-302 描述该API的参数。

表 6-302 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Service.

请求消息

响应参数:

请求参数的详细描述请参见表6-279。

请求示例:

{ "kind": "Service", "apiVersion": "v1", "metadata": { "name": "myapp", "resourceVersion": "683" }, "spec": { "ports": [{ "port": 80, "targetPort": 80 }], "selector": { "app": "example" }, "clusterIP": "10.0.0.139" } }

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 510

Page 521: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "kind": "Service", "apiVersion": "v1", "metadata": { "name": "myapp", "namespace": "default", "selfLink": "/api/v1/namespaces/default/services/myapp", "uid": "58b5ca7c-5d12-11e6-aeb9-286ed488fafe", "resourceVersion": "1204", "creationTimestamp": "2016-08-08T02:46:46Z" }, "spec": { "ports": [ { "protocol": "TCP", "port": 80, "targetPort": 80 } ], "selector": { "app": "example" }, "clusterIP": "10.0.0.139", "type": "ClusterIP", "sessionAffinity": "None" }, "status": { "loadBalancer": {} } }

状态码

表6-303描述API的状态码。

表 6-303 状态码

状态码 描述

200 This operation succeeds, and a Serviceresource object is returned.

异常状态码请参见9.3 状态码。

6.13.5 列出指定 Namespace 下的 Service

功能介绍

该API用于列出指定Namespace下的Service对象。

URI

GET /api/v1/namespaces/{namespace}/services

表6-304 描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 511

Page 522: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-304 参数描述

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add, update,and remove notifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version of aresource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

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

includeUninitialized No If true, partially initializedresources are included in theresponse.

请求消息

N/A

响应消息

响应参数:

响应参数如表6-305所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 512

Page 523: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-305 参数描述

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

metadata metadata object -

items Object List of services,具体请参见表6-293。

表 6-306 metadata 字段数据结构说明

参数 参数类型 描述

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treated asopaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

响应示例:

{ "kind": "ServiceList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/services", "resourceVersion": "1230" }, "items": [ { "metadata": { "name": "kubernetes", "namespace": "default",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 513

Page 524: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"selfLink": "/api/v1/namespaces/default/services/kubernetes", "uid": "a50a2352-5d0b-11e6-aeb9-286ed488fafe", "resourceVersion": "8", "creationTimestamp": "2016-08-08T01:58:47Z", "labels": { "component": "apiserver", "provider": "kubernetes" } }, "spec": { "ports": [ { "name": "https", "protocol": "TCP", "port": 443, "targetPort": 443 } ], "clusterIP": "10.0.0.1", "type": "ClusterIP", "sessionAffinity": "None" }, "status": { "loadBalancer": {} } }, { "metadata": { "name": "myapp", "namespace": "default", "selfLink": "/api/v1/namespaces/default/services/myapp", "uid": "58b5ca7c-5d12-11e6-aeb9-286ed488fafe", "resourceVersion": "1204", "creationTimestamp": "2016-08-08T02:46:46Z" }, "spec": { "ports": [ { "protocol": "TCP", "port": 80, "targetPort": 80 } ], "selector": { "app": "example" }, "clusterIP": "10.0.0.139", "type": "ClusterIP", "sessionAffinity": "None" }, "status": { "loadBalancer": {} } } ] }

状态码

表6-307描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 514

Page 525: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-307 状态码

状态码 描述

200 This operation succeeds, and a groupof Service resource objects is returned.

异常状态码请参见9.3 状态码。

6.13.6 列出 Service

功能介绍

该API用于获取集群中的Service列表。

URI

GET /api/v1/services

表6-308 描述该API的参数。

表 6-308 参数描述

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by theirlabels. Defaults to everything.

fieldSelector No A selector to restrict the list ofreturned objects by theirfields. Defaults to everything.

watch No Watch for changes to thedescribed resources andreturn them as a stream ofadd, update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults tochanges from the beginningof history.

timeoutSeconds No Timeout for the list/watchcall.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 515

Page 526: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

includeUninitialized No If true, partially initializedresources are included in theresponse.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-305。

响应示例:

{ "kind": "ServiceList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/services", "resourceVersion": "1244" }, "items": [ { "metadata": { "name": "kubernetes", "namespace": "default", "selfLink": "/api/v1/namespaces/default/services/kubernetes", "uid": "a50a2352-5d0b-11e6-aeb9-286ed488fafe", "resourceVersion": "8", "creationTimestamp": "2016-08-08T01:58:47Z", "labels": { "component": "apiserver", "provider": "kubernetes" } }, "spec": { "ports": [ { "name": "https", "protocol": "TCP", "port": 443, "targetPort": 443 } ], "clusterIP": "10.0.0.1", "type": "ClusterIP", "sessionAffinity": "None" }, "status": { "loadBalancer": {} } }, { "metadata": { "name": "myapp", "namespace": "default", "selfLink": "/api/v1/namespaces/default/services/myapp", "uid": "58b5ca7c-5d12-11e6-aeb9-286ed488fafe", "resourceVersion": "1204",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 516

Page 527: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"creationTimestamp": "2016-08-08T02:46:46Z" }, "spec": { "ports": [ { "protocol": "TCP", "port": 80, "targetPort": 80 } ], "selector": { "app": "example" }, "clusterIP": "10.0.0.139", "type": "ClusterIP", "sessionAffinity": "None" }, "status": { "loadBalancer": {} } } ] }

状态码

表6-309描述API的状态码。

表 6-309 状态码

状态码 描述

200 This operation succeeds, and a groupof Service resource objects is returned.

异常状态码请参见9.3 状态码。

6.13.7 更新指定的 Service

功能介绍

该API用于替换指定的Service对象。

其中以下字段支持更新:

● metadata.selfLink● metadata.resourceVersion● metadata.generation● metadata.creationTimestamp● metadata.deletionTimestamp● metadata.labels● metadata.clusterName● metadata.generateName● metadata.annotations

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 517

Page 528: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● spec.externalTrafficPolicy● spec.sessionAffinity● spec.type

说明

spec.type的值,可更新的优先级为LoadBalancer>NodePort>ClusterIP,即当spec.type的值为ClusterIP时,可更新为LoadBalancer或NodePort;当spec.type的值为NodePort时,只能更新为LoadBalancer;当spec.type的值为LoadBalancer时,spec.type不可更新。

● spec.port● spec.selector● spec.externalIPs● spec.loadBalancerIP● spec.loadBalancerSourceRanges

URIPATCH /api/v1/namespaces/{namespace}/services/{name}

表6-310 描述该API的参数。

表 6-310 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Service.

请求消息

响应参数:

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求参数的详细描述请参见表6-279。

请求示例:

Content-Type: application/strategic-merge-patch+json { "spec": { "ports": [ { "name": "ttt1", "protocol": "TCP", "port": 8765, "targetPort": 9376 }, {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 518

Page 529: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"name": "ttt2", "protocol": "TCP", "port": 8765, "targetPort": 9076 } ], "selector": { "app": "example" } } }

响应消息

响应参数:

响应参数的详细描述请参见表6-293。

响应示例:

{ "kind": "Service", "apiVersion": "v1", "metadata": { "name": "raoy", "namespace": "default", "selfLink": "/api/v1/namespaces/default/services/raoy", "uid": "e0d681b7-5d17-11e6-aeb9-286ed488fafe", "resourceVersion": "1602", "creationTimestamp": "2016-08-08T03:26:21Z" }, "spec": { "ports": [ { "name": "ttt1", "protocol": "TCP", "port": 8765, "targetPort": 9376 }, { "name": "ttt2", "protocol": "TCP", "port": 8765, "targetPort": 9076 } ], "selector": { "app": "example" }, "clusterIP": "10.0.0.193", "type": "ClusterIP", "sessionAffinity": "None" }, "status": { "loadBalancer": {} } }

状态码

表6-311描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 519

Page 530: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-311 状态码

状态码 描述

200 This operation succeeds, and a Serviceresource object is returned.

异常状态码请参见9.3 状态码。

6.14 Ingress

6.14.1 创建 Ingress

功能介绍

This API is used to create an Ingress.

URIPOST /apis/extensions/v1beta1/namespaces/{namespace}/ingresses

表6-312描述该API的参数。

表 6-312 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes 请参见表6-313。

请求消息

请求参数:

请求参数如表6-313所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 520

Page 531: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-313 请求参数

参数 是否必选 参数类型 描述

apiVersion No String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind No String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated.

metadata No metadataobject

Standard object’s metadata.

spec No spec object Spec is the desired state of theIngress.

status No status object Status is the current state of theIngress.

表 6-314 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

annotations No Object Annotations is anunstructured key value mapstored with a resource thatmay be set by external toolsto store and retrieve arbitrarymetadata. They are notqueryable and should bepreserved when modifyingobjects.

clusterName No String The name of the clusterwhich the object belongs to.This is used to distinguishresources with same nameand namespace in differentclusters. This field is not setanywhere right now andapiserver is going to ignore itif set in create or updaterequest.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 521

Page 532: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

creationTimestamp

No String CreationTimestamp is atimestamp representing theserver time when this objectwas created. It is notguaranteed to be set inhappens-before order acrossseparate operations. Clientsmay not set this value. It isrepresented in RFC3339 formand is in UTC.Populated by the system.Read-only. Null for lists.

deletionGracePeriodSeconds

No Integer Number of seconds allowedfor this object to gracefullyterminate before it will beremoved from the system.Only set whendeletionTimestamp is alsoset. May only be shortened.Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 522

Page 533: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionTimestamp

No String DeletionTimestamp is RFC3339 date and time at whichthis resource will be deleted.This field is set by the serverwhen a graceful deletion isrequested by the user, and isnot directly settable by aclient. The resource isexpected to be deleted (nolonger visible from resourcelists, and not reachable byname) after the time in thisfield, once the finalizers list isempty. As long as thefinalizers list contains items,deletion is blocked. Once thedeletionTimestamp is set, thisvalue may not be unset or beset further into the future,although it may be shortenedor the resource may bedeleted prior to this time. Forexample, a user may requestthat a pod is deleted in 30seconds. The Kubelet willreact by sending a gracefultermination signal to thecontainers in the pod. Afterthat 30 seconds, the Kubeletwill send a hard terminationsignal (SIGKILL) to thecontainer and after cleanup,remove the pod from the API.In the presence of networkpartitions, this object maystill exist after thistimestamp, until anadministrator or automatedprocess can determine theresource is fully terminated. Ifnot set, graceful deletion ofthe object has not beenrequested.Populated by the systemwhen a graceful deletion isrequested. Read-only.

enable No Boolean Enable identify whether theresource is available.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 523

Page 534: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

finalizers No Array ofstrings

Must be empty before theobject is deleted from theregistry. Each entry is anidentifier for the responsiblecomponent that will removethe entry from the list. If thedeletionTimestamp of theobject is non-nil, entries inthis list can only be removed.

generateName No String If this field is specified andthe generated name exists,the server will NOT return a409 - instead, it will eitherreturn 201 Created or 500with Reason ServerTimeoutindicating a unique namecould not be found in thetime allotted, and the clientshould retry (optionally afterthe time indicated in theRetry-After header).Applied only if Name is notspecified.

generation No Integer A sequence numberrepresenting a specificgeneration of the desiredstate. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 524

Page 535: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

initializers No initializersobject

An initializer is a controllerwhich enforces some systeminvariant at object creationtime. This field is a list ofinitializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized.Otherwise, the object isconsidered uninitialized and ishidden (in list/watch and getcalls) from clients thathaven’t explicitly asked toobserve uninitialized objects.When an object is created,the system will populate thislist with the current set ofinitializers. Only privilegedusers may set or modify thislist. Once it is empty, it maynot be modified further byany user.

labels No Object Map of string keys and valuesthat can be used to organizeand categorize (scope andselect) objects. May matchselectors of replicationcontrollers and services.

name No String Name must be unique withina namespace. Is requiredwhen creating resources,although some resources mayallow a client to request thegeneration of an appropriatename automatically. Name isprimarily intended forcreation idempotence andconfiguration definition.Cannot be updated.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 525

Page 536: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

namespace No String Namespace defines the spacewithin each name must beunique. An empty namespaceis equivalent to the "default"namespace, but "default" isthe canonical representation.Not all objects are required tobe scoped to a namespace -the value of this field forthose objects will be empty.Must be a DNS_LABEL.Cannot be updated.

ownerReferences

No Array ofstrings

List of objects depended bythis object. If ALL objects inthe list have been deleted,this object will be garbagecollected. If this object ismanaged by a controller, thenan entry in this list will pointto this controller, with thecontroller field set to true.There cannot be more thanone managing controller.

resourceVersion No String An opaque value thatrepresents the internalversion of this object that canbe used by clients todetermine when objects havechanged. May be used foroptimistic concurrency,change detection, and thewatch operation on aresource or set of resources.Clients must treat thesevalues as opaque and passedunmodified back to theserver. They may only be validfor a particular resource orset of resources.Populated by the system.Read-only. Value must betreated as opaque by clientsand .

selfLink No String SelfLink is a URL representingthis object. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 526

Page 537: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

uid No String UID is the unique in time andspace value for this object. Itis typically generated by theserver on successful creationof a resource and is notallowed to change on PUToperations.Populated by the system.Read-only.

表 6-315 spec 字段数据结构说明

参数 是否必选 参数类型 描述

backend No backendobject

A default backend capable ofservicing requests that don’tmatch any rule. At least oneof backend or rules must bespecified. This field is optionalto allow the loadbalancercontroller or defaulting logicto specify a global default.

rules No Array ofstrings

A list of host rules used toconfigure the Ingress. Ifunspecified, or no rulematches, all traffic is sent tothe default backend.

tls No Array ofstrings

TLS configuration. Currentlythe Ingress only supports asingle TLS port, 443. Ifmultiple members of this listspecify different hosts, theywill be multiplexed on thesame port according to thehostname specified throughthe SNI TLS extension, if theingress controller fulfilling theingress supports SNI.

表 6-316 status 字段数据结构说明

参数 是否必选 参数类型 描述

loadBalancer No loadBalancerobject

LoadBalancer contains thecurrent status of the load-balancer.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 527

Page 538: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-317 backend 字段数据结构说明

参数 是否必选 参数类型 描述

serviceName No String Specifies the name of thereferenced service.

servicePort No Integer Specifies the port of thereferenced service.

表 6-318 loadBalancer 字段数据结构说明

参数 是否必选 参数类型 描述

ingress No Array ofstrings

Ingress is a list containing ingresspoints for the load-balancer.Traffic intended for the serviceshould be sent to these ingresspoints.

请求示例:

{ "apiVersion": "extensions/v1beta1", "kind": "Ingress", "metadata": { "annotations": { "ingress.kubernetes.io/secure-backends": "false", "ingress.beta.kubernetes.io/role": "data", "kubernetes.io/elb.ip": "192.168.0.39", "kubernetes.io/elb.port": "80", "kubernetes.io/elb.subnet-id": "bf04639b-9e67-4f02-ac63-379e9ce48ea2" }, "labels": { "zone": "data", "isExternal": "true", "deploy-ingress": "ingress-test" }, "name": "ingress-test" }, "spec": { "tls": { "secretName: ": "ingress-test" }, "rules": [ { "http": { "paths": [ { "backend": { "serviceName": "ingress-test", "servicePort": 8080 }, "path": "/healthz", "property": { "ingress.beta.kubernetes.io/url-match-mode": "EQUAL_TO" }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 528

Page 539: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} ] } } ] }}

响应消息

响应参数:

响应参数的详细描述请参见表6-313。

响应示例:

{ "kind": "Ingress", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test", "uid": "3acdf7b4-7ac5-11e8-a5f8-fa163e458c2a", "resourceVersion": "1473939", "generation": 1, "creationTimestamp": "2018-06-28T11:20:14Z", "labels": { "isExternal": "true", "zone": "data" }, "annotations": { "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubernetes.io/elb.subnet-id": "bf04639b-9e67-4f02-ac63-379e9ce48ea2", "kubernetes.io/elb.ip": "192.168.0.39", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP" } }, "spec": { "rules": [ { "host": "test", "http": { "paths": [ { "path": "/healthz", "backend": { "serviceName": "ingress-test", "servicePort": 8080 }, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": {} }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 529

Page 540: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-319描述API的状态码。

表 6-319 状态码

状态码 描述

201 success

异常状态码请参见9.3 状态码。

6.14.2 更新指定的 Ingress

功能介绍

This API is used to partially update the specified Ingress.

其中以下字段支持更新:

● metadata.name

● metadata.namespace

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.uid

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.annotations

● spec.rules

● spec.loadBalancerIP

URI

PATCH /apis/extensions/v1beta1/namespaces/{namespace}/ingresses/{name}

表6-320描述该API的参数。

表 6-320 参数解释

参数 是否必选 描述

name Yes Name of the Ingress.

namespace Yes Object name and auth scope, such as for teamsand projects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 530

Page 541: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见表6-313。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "spec": { "rules": [ { "http": { "paths": [ { "backend": { "serviceName": "test", "servicePort": 8080 }, "path": "/sssss", "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] }, "host": "agag" } ] }}

响应消息

响应参数:

响应参数的详细描述请参见表6-313。

响应示例:

{ "kind": "Ingress", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test", "uid": "138af621-7ad3-11e8-a5f8-fa163e458c2a", "resourceVersion": "1490196", "generation": 10, "creationTimestamp": "2018-06-28T12:59:21Z", "labels": { "isExternal": "true", "zone": "data" },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 531

Page 542: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"annotations": { "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"extensions/v1beta1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{\"ingress.beta.kubernetes.io/role\":\"data\",\"ingress.kubernetes.io/secure-backends\":\"false\",\"kubernetes.io/elb.id\":\"203e27c4-ceaa-4bca-b652-6947f77d1ce0\",\"kubernetes.io/elb.ip\":\"10.154.199.81\",\"kubernetes.io/elb.port\":\"80\",\"kubernetes.io/ingress.class\":\"public-elb\",\"protocol\":\"HTTP\"},\"labels\":{\"isExternal\":\"true\",\"zone\":\"data\"},\"name\":\"ingress-test\",\"namespace\":\"default\"},\"spec\":{\"rules\":[{\"host\":\"agag\",\"http\":{\"paths\":[{\"backend\":{\"serviceName\":\"ingress-test\",\"servicePort\":8086},\"path\":\"/sssss\",\"property\":{\"ingress.beta.kubernetes.io/url-match-mode\":\"STARTS_WITH\"}}]}}]}}\n", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0", "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP" } }, "spec": { "rules": [ { "host": "agaaaa", "http": { "paths": [ { "path": "/sssss", "backend": { "serviceName": "test", "servicePort": 8080 }, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": { "ingress": [ { "ip": "10.154.199.81", "hostname": "sssss" } ] } }}

状态码

表6-321描述API的状态码。

表 6-321 状态码

状态码 描述

200 success

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 532

Page 543: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.14.3 替换指定的 Ingress

功能介绍

This API is used to replace the specified Ingress.

其中以下字段支持更新:

● metadata.name

● metadata.namespace

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.uid

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.annotations

● spec.rules

● spec.loadBalancerIP

URIPUT /apis/extensions/v1beta1/namespaces/{namespace}/ingresses/{name}

表6-322描述该API的参数。

表 6-322 参数解释

参数 是否必选 描述

name Yes name of the Ingress

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

响应参数:

请求参数的详细描述请参见表6-313。

请求示例:

{ "apiVersion": "extensions/v1beta1",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 533

Page 544: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"kind": "Ingress", "metadata": { "annotations": { "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0", "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP" }, "labels": { "isExternal": "true", "zone": "data" }, "name": "ingress-test", "namespace": "default", "resourceVersion": "1486389" }, "spec": { "rules": [ { "host": "test", "http": { "paths": [ { "backend": { "serviceName": "ingress-test", "servicePort": 8086 }, "path": "/sssss", "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }}

响应消息

响应参数:

响应参数的详细描述请参见请求消息。

响应示例:

{ "kind": "Ingress", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test", "uid": "3acdf7b4-7ac5-11e8-a5f8-fa163e458c2a", "resourceVersion": "1490779", "generation": 2, "creationTimestamp": "2018-06-28T11:20:14Z", "labels": { "isExternal": "true", "zone": "data" }, "annotations": { "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 534

Page 545: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP" } }, "spec": { "rules": [ { "host": "test", "http": { "paths": [ { "path": "/sssss", "backend": { "serviceName": "ingress-test", "servicePort": 8086 }, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": { "ingress": [ { "ip": "10.154.199.81", "hostname": "test" } ] } }}

状态码

表6-323描述API的状态码。

表 6-323 状态码

状态码 描述

200 success

201 Created

6.14.4 删除 Ingress

功能介绍

This API is used to delete an Ingress.

URIDELETE /apis/extensions/v1beta1/namespaces/{namespace}/ingresses/{name}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 535

Page 546: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表6-324描述该API的参数。

表 6-324 参数解释

参数 是否必选 描述

name Yes Name of the Ingress.

namespace Yes Object name and auth scope, such as for teamsand projects.

gracePeriodSeconds

No The duration in seconds before the objectshould be deleted. Value must be non-negativeinteger. The value zero indicates deleteimmediately. If this value is nil, the defaultgrace period for the specified type will be used.Defaults to a per object value if not specified.zero means delete immediately.

orphanDependents

No Deprecated: please use the PropagationPolicy,this field will be deprecated in 1.7. Should thedependent 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 beset, but not both.

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

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field orOrphanDependents may be set, but not both.The default policy is decided by the existingfinalizer set in the metadata.finalizers and theresource-specific default policy. Acceptablevalues are: Orphan - orphan the dependents;Background - allow the garbage collector todelete the dependents in the background;Foreground - a cascading policy that deletes alldependents in the foreground.

body Yes -

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 536

Page 547: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "details": { "name": "ingress-test", "group": "extensions", "kind": "ingresses", "uid": "138af621-7ad3-11e8-a5f8-fa163e458c2a" }, "code": 200}

状态码

表6-325描述API的状态码。

表 6-325 状态码

状态码 描述

200 success

异常状态码请参见9.3 状态码。

6.14.5 删除所有的 Ingress

功能介绍

This API is used to delete collection of Ingress.

URIDELETE /apis/extensions/v1beta1/namespaces/{namespace}/ingresses

表6-326描述该API的参数。

表 6-326 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 537

Page 548: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 538

Page 549: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continuefield on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true.The server guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large result canensure they see all possible objects. If objectsare updated during a chunked list the version ofthe object that was present at the time the firstlist result was calculated is returned.

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

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it’s 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 539

Page 550: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

{ "kind": "IngressList", "apiVersion": "extensions/v1beta1", "metadata": { "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses", "resourceVersion": "1494570" }, "items": [ { "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test", "uid": "0bb1b895-7adb-11e8-a5f8-fa163e458c2a", "resourceVersion": "1494559", "generation": 1, "creationTimestamp": "2018-06-28T13:56:24Z", "labels": { "isExternal": "true", "zone": "data" }, "annotations": { "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0", "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP" } }, "spec": { "rules": [ { "host": "test", "http": { "paths": [ { "path": "/sssss", "backend": { "serviceName": "ingress-test", "servicePort": 8086 }, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": { "ingress": [ {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 540

Page 551: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"ip": "10.154.199.81", "hostname": "test" } ] } } } ]}

状态码

表6-327描述API的状态码。

表 6-327 状态码

状态码 描述

200 success

异常状态码请参见9.3 状态码。

6.14.6 获取指定的 Ingress

功能介绍

This API is used to read the specified Ingress.

URI

GET /apis/extensions/v1beta1/namespaces/{namespace}/ingresses/{name}

表6-328描述该API的参数。

表 6-328 参数解释

参数 是否必选 描述

name Yes Name of the Ingress.

namespace Yes Object name and auth scope, such as for teamsand projects.

exact No Should the export be exact. Exact exportmaintains cluster-specific fields likeNamespace.

export No Should this value be exported. Export stripsfields that a user can not specify.

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 541

Page 552: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-313。

响应示例:

{ "kind": "Ingress", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test", "uid": "29817662-7adb-11e8-a5f8-fa163e458c2a", "resourceVersion": "1494672", "generation": 1, "creationTimestamp": "2018-06-28T13:57:14Z", "labels": { "isExternal": "true", "zone": "data" }, "annotations": { "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0", "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP" } }, "spec": { "rules": [ { "host": "test", "http": { "paths": [ { "path": "/sssss", "backend": { "serviceName": "ingress-test", "servicePort": 8086 }, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": { "ingress": [ { "ip": "10.154.199.81", "hostname": "test" } ] }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 542

Page 553: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}}

状态码

表6-329描述API的状态码。

表 6-329 状态码

状态码 描述

200 success

异常状态码请参见9.3 状态码。

6.14.7 列出指定 Namespace 下的 Ingress

功能介绍

This API is used to list or watch objects of kind Ingress.

URI

GET /apis/extensions/v1beta1/namespaces/{namespace}/ingresses

表6-330描述该API的参数。

表 6-330 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 543

Page 554: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continuefield on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true.The server guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

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

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it’s 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 544

Page 555: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-313。

响应示例:

{ "kind": "IngressList", "apiVersion": "extensions/v1beta1", "metadata": { "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses", "resourceVersion": "1494741" }, "items": [ { "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test", "uid": "29817662-7adb-11e8-a5f8-fa163e458c2a", "resourceVersion": "1494672", "generation": 1, "creationTimestamp": "2018-06-28T13:57:14Z", "labels": { "isExternal": "true", "zone": "data" }, "annotations": { "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0", "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP" } }, "spec": { "rules": [ { "host": "test", "http": { "paths": [ { "path": "/sssss", "backend": { "serviceName": "ingress-test", "servicePort": 8086

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 545

Page 556: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": { "ingress": [ { "ip": "10.154.199.81", "hostname": "test" } ] } } } ]}

状态码

表6-331描述API的状态码。

表 6-331 状态码

状态码 描述

200 success

异常状态码请参见9.3 状态码。

6.14.8 获取 Ingress 列表

功能介绍

This API is used to list or watch objects of kind Ingress.

URIGET /apis/extensions/v1beta1/ingresses

表6-332描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 546

Page 557: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-332 参数解释

参数 是否必选 描述

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 547

Page 558: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continuefield on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true.The server guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large result canensure they see all possible objects. If objectsare updated during a chunked list the version ofthe object that was present at the time the firstlist result was calculated is returned.

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

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it’s 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 548

Page 559: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-313。

响应示例:

{ "kind": "IngressList", "apiVersion": "extensions/v1beta1", "metadata": { "selfLink": "/apis/extensions/v1beta1/ingresses", "resourceVersion": "1495401" }, "items": [ { "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test", "uid": "29817662-7adb-11e8-a5f8-fa163e458c2a", "resourceVersion": "1494672", "generation": 1, "creationTimestamp": "2018-06-28T13:57:14Z", "labels": { "isExternal": "true", "zone": "data" }, "annotations": { "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0", "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP" } }, "spec": { "rules": [ { "host": "test", "http": { "paths": [ { "path": "/sssss", "backend": { "serviceName": "ingress-test", "servicePort": 8086 }, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": { "ingress": [ {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 549

Page 560: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"ip": "10.154.199.81", "hostname": "test" } ] } } } ]}

状态码

表6-333描述API的状态码。

表 6-333 状态码

状态码 描述

200 success

异常状态码请参见9.3 状态码。

6.14.9 获取指定 Namespace 下的某个 Ingress 对象的状态

功能介绍

This API is used to read status of the specified Ingress.

URIGET /apis/extensions/v1beta1/namespaces/{namespace}/ingresses/{name}/status

表6-334描述该API的参数。

表 6-334 参数解释

参数 是否必选 描述

name Yes name of the Ingress.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

N/A

响应消息

响应参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 550

Page 561: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应参数的详细描述请参见表6-313。

响应示例:

{ "kind": "Ingress", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test/status", "uid": "29817662-7adb-11e8-a5f8-fa163e458c2a", "resourceVersion": "1494672", "generation": 1, "creationTimestamp": "2018-06-28T13:57:14Z", "labels": { "isExternal": "true", "zone": "data" }, "annotations": { "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP", "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0" } }, "spec": { "rules": [ { "host": "test", "http": { "paths": [ { "path": "/sssss", "backend": { "serviceName": "ingress-test", "servicePort": 8086 }, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": { "ingress": [ { "ip": "10.154.199.81", "hostname": "test" } ] } }}

状态码

表6-335描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 551

Page 562: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-335 状态码

状态码 描述

200 success

异常状态码请参见9.3 状态码。

6.14.10 替换指定 Namespace 下的某个 Ingress 对象的状态

功能介绍

This API is used to replace status of the specified Ingress.

其中以下字段支持更新:

status.loadBalancer

URIPUT /apis/extensions/v1beta1/namespaces/{namespace}/ingresses/{name}/status

表6-336描述该API的参数。

表 6-336 参数解释

参数 是否必选 描述

name Yes name of the Ingress.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见表6-313。

请求示例:

{ "apiVersion": "extensions/v1beta1", "kind": "Ingress", "metadata": { "labels": { "zone": "data", "isExternal": "true" }, "name": "ingress-test", "annotations": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 552

Page 563: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"kubernetes.io/ingress.class": "public-elb", "ingress.kubernetes.io/secure-backends": "false", "ingress.beta.kubernetes.io/role": "data", "protocol": "HTTP", "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0" } }, "spec": { "rules": [ { "http": { "paths": [ { "backend": { "serviceName": "ingress-test", "servicePort": 8087 }, "path": "/sssss", "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] }, "host": "test" } ] }}

响应消息

响应参数:

响应参数的详细描述请参见表6-313。

响应示例:

{ "kind": "Ingress", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test/status", "uid": "29817662-7adb-11e8-a5f8-fa163e458c2a", "resourceVersion": "1499417", "generation": 3, "creationTimestamp": "2018-06-28T13:57:14Z", "labels": { "isExternal": "true", "zone": "data" }, "annotations": { "ingress.beta.kubernetes.io/role": "data", "ingress.kubernetes.io/secure-backends": "false", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0", "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80", "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP" } }, "spec": { "rules": [ { "host": "agaaaa",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 553

Page 564: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"http": { "paths": [ { "path": "/sssss", "backend": { "serviceName": "test", "servicePort": 8080 }, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": {} }}

状态码

表6-337描述API的状态码。

表 6-337 状态码

状态码 描述

200 success

201 created

异常状态码请参见9.3 状态码。

6.14.11 更新指定 Namespace 下的某个 Ingress 对象的状态

功能介绍

This API is used to partially update status of the specified Ingress.

其中以下字段支持更新:

status.loadBalancer

URIPATCH /apis/extensions/v1beta1/namespaces/{namespace}/ingresses/{name}/status

表6-338描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 554

Page 565: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-338 参数解释

参数 是否必选 描述

name Yes name of the Ingress

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见表6-313。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "status": { "loadBalancer": { "ingress": [ { "ip": "10.154.199.81", "hostname": "testaa" } ] } }}

响应消息

响应参数:

响应参数的详细描述请参见表6-313。

响应示例:

{ "kind": "Ingress", "apiVersion": "extensions/v1beta1", "metadata": { "name": "ingress-test", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/ingress-test/status", "uid": "29817662-7adb-11e8-a5f8-fa163e458c2a", "resourceVersion": "1498365", "generation": 3, "creationTimestamp": "2018-06-28T13:57:14Z", "labels": { "isExternal": "true", "zone": "data" }, "annotations": { "kubernetes.io/ingress.class": "public-elb", "protocol": "HTTP", "ingress.beta.kubernetes.io/role": "data",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 555

Page 566: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"ingress.kubernetes.io/secure-backends": "false", "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"extensions/v1beta1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{\"ingress.beta.kubernetes.io/role\":\"data\",\"ingress.kubernetes.io/secure-backends\":\"false\",\"kubernetes.io/elb.id\":\"203e27c4-ceaa-4bca-b652-6947f77d1ce0\",\"kubernetes.io/elb.ip\":\"10.154.199.81\",\"kubernetes.io/elb.port\":\"80\",\"kubernetes.io/ingress.class\":\"public-elb\",\"protocol\":\"HTTP\"},\"labels\":{\"isExternal\":\"true\",\"zone\":\"data\"},\"name\":\"ingress-test\",\"namespace\":\"default\"},\"spec\":{\"rules\":[{\"host\":\"test1\",\"http\":{\"paths\":[{\"backend\":{\"serviceName\":\"ingress-test\",\"servicePort\":8086},\"path\":\"/sssss\",\"property\":{\"ingress.beta.kubernetes.io/url-match-mode\":\"STARTS_WITH\"}}]}}]}}\n", "kubernetes.io/elb.id": "203e27c4-ceaa-4bca-b652-6947f77d1ce0", "kubernetes.io/elb.ip": "10.154.199.81", "kubernetes.io/elb.port": "80" } }, "spec": { "rules": [ { "host": "agaaaa", "http": { "paths": [ { "path": "/sssss", "backend": { "serviceName": "test", "servicePort": 8080 }, "property": { "ingress.beta.kubernetes.io/url-match-mode": "STARTS_WITH" } } ] } } ] }, "status": { "loadBalancer": { "ingress": [ { "ip": "10.154.199.81", "hostname": "testaa" } ] } }}

状态码

表6-339描述API的状态码。

表 6-339 状态码

状态码 描述

200 success

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 556

Page 567: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.15 NetworkPolicy

所支持的集群版本:

1.7集群:v1.7.3-r12及以上版本

1.9集群:v1.9.2-r3及以上版本

1.11集群的所有版本

6.15.1 创建 networkpolicy

功能介绍

This API is used to create a NetworkPolicy.

URL

POST /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies

参数解释描述该API的参数。

表 6-340 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes 请参见表6-341。

请求消息

请求参数:

请求参数如表6-341所示。

表 6-341 请求参数

参数 是否必选 参数类型 描述

apiVersion No String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 557

Page 568: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

kind No String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated. InCamelCase.

metadata No metadataobject

Standard object’s metadata.

spec No spec object Specification of the desiredbehavior for this NetworkPolicy.

表 6-342 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

annotations No Object Annotations is anunstructured key value mapstored with a resource thatmay be set by external toolsto store and retrieve arbitrarymetadata. They are notqueryable and should bepreserved when modifyingobjects.

clusterName No String The name of the clusterwhich the object belongs to.This is used to distinguishresources with same nameand namespace in differentclusters. This field is not setanywhere right now andapiserver is going to ignore itif set in create or updaterequest.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 558

Page 569: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

creationTimestamp

No String CreationTimestamp is atimestamp representing theserver time when this objectwas created. It is notguaranteed to be set inhappens-before order acrossseparate operations. Clientsmay not set this value. It isrepresented in RFC3339 formand is in UTC. Populated bythe system. Read-only. Nullfor lists.

deletionGracePeriodSeconds

No Integer Number of seconds allowedfor this object to gracefullyterminate before it will beremoved from the system.Only set whendeletionTimestamp is alsoset. May only be shortened.Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 559

Page 570: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionTimestamp

No String DeletionTimestamp is RFC3339 date and time at whichthis resource will be deleted.This field is set by the serverwhen a graceful deletion isrequested by the user, and isnot directly settable by aclient. The resource isexpected to be deleted (nolonger visible from resourcelists, and not reachable byname) after the time in thisfield, once the finalizers list isempty. As long as thefinalizers list contains items,deletion is blocked. Once thedeletionTimestamp is set, thisvalue may not be unset or beset further into the future,although it may be shortenedor the resource may bedeleted prior to this time. Forexample, a user may requestthat a pod is deleted in 30seconds. The Kubelet willreact by sending a gracefultermination signal to thecontainers in the pod. Afterthat 30 seconds, the Kubeletwill send a hard terminationsignal (SIGKILL) to thecontainer and after cleanup,remove the pod from the API.In the presence of networkpartitions, this object maystill exist after thistimestamp, until anadministrator or automatedprocess can determine theresource is fully terminated. Ifnot set, graceful deletion ofthe object has not beenrequested. Populated by thesystem when a gracefuldeletion is requested. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 560

Page 571: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

finalizers No Array ofstrings

Must be empty before theobject is deleted from theregistry. Each entry is anidentifier for the responsiblecomponent that will removethe entry from the list. If thedeletionTimestamp of theobject is non-nil, entries inthis list can only be removed.

generateName No String GenerateName is an optionalprefix, used by the server, togenerate a unique nameONLY IF the Name field hasnot been provided. If this fieldis used, the name returned tothe client will be differentthan the name passed. Thisvalue will also be combinedwith a unique suffix. Theprovided value has the samevalidation rules as the Namefield, and may be truncatedby the length of the suffixrequired to make the valueunique on the server. If thisfield is specified and thegenerated name exists, theserver will NOT return a 409 -instead, it will either return201 Created or 500 withReason ServerTimeoutindicating a unique namecould not be found in thetime allotted, and the clientshould retry (optionally afterthe time indicated in theRetry-After header). Appliedonly if Name is not specified.

generation No Integer A sequence numberrepresenting a specificgeneration of the desiredstate. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 561

Page 572: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

initializers No initializersobject

An initializer is a controllerwhich enforces some systeminvariant at object creationtime. This field is a list ofinitializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized.Otherwise, the object isconsidered uninitialized and ishidden (in list/watch and getcalls) from clients thathaven't explicitly asked toobserve uninitialized objects.When an object is created,the system will populate thislist with the current set ofinitializers. Only privilegedusers may set or modify thislist. Once it is empty, it maynot be modified further byany user.

labels No Object Map of string keys and valuesthat can be used to organizeand categorize (scope andselect) objects. May matchselectors of replicationcontrollers and services.

name No String Name must be unique withina namespace. Is requiredwhen creating resources,although some resources mayallow a client to request thegeneration of an appropriatename automatically. Name isprimarily intended forcreation idempotence andconfiguration definition.Cannot be updated.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 562

Page 573: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

namespace No String Namespace defines the spacewithin each name must beunique. An empty namespaceis equivalent to the "default"namespace, but "default" isthe canonical representation.Not all objects are required tobe scoped to a namespace -the value of this field forthose objects will be empty.Must be a DNS_LABEL.Cannot be updated.

ownerReferences

No Array ofstrings

List of objects depended bythis object. If ALL objects inthe list have been deleted,this object will be garbagecollected. If this object ismanaged by a controller, thenan entry in this list will pointto this controller, with thecontroller field set to true.There cannot be more thanone managing controller.

resourceVersion No String An opaque value thatrepresents the internalversion of this object that canbe used by clients todetermine when objects havechanged. May be used foroptimistic concurrency,change detection, and thewatch operation on aresource or set of resources.Clients must treat thesevalues as opaque and passedunmodified back to theserver. They may only be validfor a particular resource orset of resources. Populated bythe system. Read-only. Valuemust be treated as opaque byclients and .

selfLink No String SelfLink is a URL representingthis object. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 563

Page 574: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

uid No String UID is the unique in time andspace value for this object. Itis typically generated by theserver on successful creationof a resource and is notallowed to change on PUToperations. Populated by thesystem. Read-only.

表 6-343 spec 字段数据结构说明

参数 是否必选 参数类型 描述

ingress No NetworkPolicyIngressRule object

List of ingress rules to beapplied to the selected pods.Traffic is allowed to a pod ifthere are no NetworkPoliciesselecting the pod (and clusterpolicy otherwise allows thetraffic), OR if the trafficsource is the pod's local node,OR if the traffic matches atleast one ingress rule acrossall of the NetworkPolicyobjects whose podSelectormatches the pod. If this fieldis empty then thisNetworkPolicy does not allowany traffic (and serves solelyto ensure that the pods itselects are isolated bydefault)

podSelector No LabelSelector object

Selects the pods to which thisNetworkPolicy object applies.The array of ingress rules isapplied to any pods selectedby this field. Multiple networkpolicies can select the sameset of pods. In this case, theingress rules for each arecombined additively. This fieldis NOT optional and followsstandard label selectorsemantics. An emptypodSelector matches all podsin this namespace.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 564

Page 575: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

policyTypes No Array ofstrings

List of rule types that theNetworkPolicy relates to.Valid options are Ingress,Egress, or Ingress,Egress. Ifthis field is not specified, itwill default based on theexistence of Ingress or Egressrules; policies that contain anEgress section are assumed toaffect Egress, and all policies(whether or not they containan Ingress section) areassumed to affect Ingress. Ifyou want to write an egress-only policy, you mustexplicitly specify policyTypes[ "Egress" ]. Likewise, if youwant to write a policy thatspecifies that no egress isallowed, you must specify apolicyTypes value that include"Egress" (since such a policywould not include an Egresssection and would otherwisedefault to just [ "Ingress" ]).This field is beta-level in 1.8

表 6-344 NetworkPolicyIngressRule 字段数据结构说明

参数 是否必选 参数类型 描述

from No Networkpolicypeerobject

List of sources which shouldbe able to access the podsselected for this rule. Items inthis list are combined using alogical OR operation. If thisfield is empty or missing, thisrule matches all sources(traffic not restricted bysource). If this field is presentand contains at least on item,this rule allows traffic only ifthe traffic matches at leastone item in the from list.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 565

Page 576: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

ports No NetworkPolicyPort object

List of ports which should bemade accessible on the podsselected for this rule. Eachitem in this list is combinedusing a logical OR. If this fieldis empty or missing, this rulematches all ports (traffic notrestricted by port). If this fieldis present and contains atleast one item, then this ruleallows traffic only if the trafficmatches at least one port inthe list.

表 6-345 LabelSelector 字段数据结构说明

参数 是否必选 参数类型 描述

matchExpressions No Array ofstrings

matchExpressions is a list oflabel selector requirements.The requirements are ANDed.

matchLabels No Object matchLabels is a map of{key,value} pairs. A single{key,value} in the matchLabelsmap is equivalent to anelement of matchExpressions,whose key field is "key", theoperator is "In", and thevalues array contains only"value". The requirements areANDed.

表 6-346 NetworkPolicyPeer 字段数据结构说明

参数 是否必选 参数类型 描述

namespaceSelector

No LabelSelector object

Selects Namespaces usingcluster scoped-labels. Thismatches all pods in allnamespaces selected by thislabel selector. This fieldfollows standard label selectorsemantics. If present butempty, this selector selects allnamespaces.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 566

Page 577: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

podSelector No LabelSelector object

This is a label selector whichselects Pods in thisnamespace. This field followsstandard label selectorsemantics. If present butempty, this selector selects allpods in this namespace.

表 6-347 NetworkPolicyPort 字段数据结构说明

参数 是否必选 参数类型 描述

port No String matchExpressions is a list oflabel selector requirements.The requirements are ANDed.

protocol No String The protocol (TCP or UDP)which traffic must match. Ifnot specified, this fielddefaults to TCP.

请求示例:

{ "apiVersion": "networking.k8s.io/v1", "kind": "NetworkPolicy", "metadata": { "name": "test-network-policy", "namespace": "default", "labels": { "app": "nginx" } }, "spec": { "podSelector": { "matchLabels": { "app": "nginx" } }, "ingress": [{ "from": [{ "podSelector": { "matchLabels": { "app": "naginx1" } } }], "ports": [{ "protocol": "TCP", "port": 6379 }] }] }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 567

Page 578: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "NetworkPolicy", "apiVersion": "networking.k8s.io/v1", "metadata": { "name": "test-network-policy", "namespace": "default", "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/networkpolicies/test-network-policy", "uid": "be347ddd-e8af-11e8-b187-fa163e3cca63", "resourceVersion": "213982", "generation": 1, "creationTimestamp": "2018-11-15T08:23:34Z", "labels": { "app": "nginx" } }, "spec": { "podSelector": { "matchLabels": { "app": "nginx" } }, "ingress": [{ "from": [{ "podSelector": { "matchLabels": { "app": "nginx1" } } }], "ports": [{ "protocol": "TCP", "port": 6379 }] }], "policyTypes":[ "Ingress" ] }}

状态码

表6-348描述API的状态码。

表 6-348 状态码

状态码 描述

201 Created

200 OK

202 Accepted

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 568

Page 579: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.15.2 更新指定的 networkpolicy

功能介绍

This API is used to partially update the specified NetworkPolicy

其中以下字段支持更新:

● metadata.name● metadata.namespace● metadata.selfLink● metadata.resourceVersion● metadata.generation● metadata.uid● metadata.creationTimestamp● metadata.deletionTimestamp● metadata.labels● metadata.annotations● spec.ingress

URLPATCH /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

参数解释描述该API的参数。

表 6-349 参数解释

参数 是否必选 描述

name Yes Name of the NetworkPolicy.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json{

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 569

Page 580: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"spec": { "ingress": [{ "from": [{ "podSelector": { "matchLabels": { "app": "nginx2" } } }] }] }}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "NetworkPolicy", "apiVersion": "networking.k8s.io/v1", "metadata": { "name": "test-network-policy", "namespace": "default", "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/networkpolicies/test-network-policy", "uid": "be347ddd-e8af-11e8-b187-fa163e3cca63", "resourceVersion": "213982", "generation": 1, "creationTimestamp": "2018-11-15T08:23:34Z", "labels": { "app": "nginx" } }, "spec": { "podSelector": { "matchLabels": { "app": "nginx" } }, "ingress": [{ "from": [{ "podSelector": { "matchLabels": { "app": "nginx2" } } }], "ports": [{ "protocol": "TCP", "port": 6379 }] }], "policyTypes":[ "Ingress" ] }}

状态码

状态码描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 570

Page 581: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-350 状态码

状态码 描述

200 OK

6.15.3 替换指定的 networkpolicy

功能介绍

This API is used to replace the specified NetworkPolicy.

URLPUT /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

其中以下字段支持更新:

● metadata.name● metadata.namespace● metadata.selfLink● metadata.resourceVersion● metadata.generation● metadata.uid● metadata.creationTimestamp● metadata.deletionTimestamp● metadata.labels● metadata.annotations● spec.ingress

参数解释描述该API的参数。

表 6-351 参数解释

参数 是否必选 描述

name Yes Name of the NetworkPolicy.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

请求参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 571

Page 582: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "kind": "NetworkPolicy", "apiVersion": "networking.k8s.io/v1", "metadata": { "name": "test-network-policy", "namespace": "default", "resourceVersion": "213982", "generation": 1, "labels": { "app": "nginx" } }, "spec": { "podSelector": { "matchLabels": { "app": "nginx" } }, "ingress": [{ "from": [{ "podSelector": { "matchLabels": { "app": "nginx3" } } }], "ports": [{ "protocol": "TCP", "port": 6379 }] }], "policyTypes":[ "Ingress" ] }}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "NetworkPolicy", "apiVersion": "networking.k8s.io/v1", "metadata": { "name": "test-network-policy", "namespace": "default", "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/networkpolicies/test-network-policy", "uid": "be347ddd-e8af-11e8-b187-fa163e3cca63", "resourceVersion": "213982", "generation": 1, "creationTimestamp": "2018-11-15T08:23:34Z", "labels": { "app": "nginx", } } "spec": { "podSelector": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 572

Page 583: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"matchLabels": { "app": "nginx" } }, "ingress": [{ "from": [{ "podSelector": { "matchLabels": { "app": "nginx3" } } }], "ports": [{ "protocol": "TCP", "port": 6379 }] }], "policyTypes":{ "Ingress" } }}

状态码

状态码描述API的状态码。

表 6-352 状态码

状态码 描述

200 OK

201 Created

6.15.4 删除 networkpolicy

功能介绍

This API is used to delete a NetworkPolicy.

URL

DELETE /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

参数解释描述该API的参数。

表 6-353 参数解释

参数 是否必选 描述

name Yes Name of the NetworkPolicy.

namespace Yes Object name and auth scope, such as for teamsand projects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 573

Page 584: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

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

body Yes -

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "apiVersion": "v1", "code": 200, "details": { "name": "aqws", "group": "networking.k8s.io", "kind": "networkpolicies", "uid" : "0eea113a-ebb6-11e8-889b-fa163ecbd381" }, "kind": "Status", "metadata" : {}, "status": "Success" }

状态码

状态码描述API的状态码。

表 6-354 状态码

状态码 描述

200 OK

6.15.5 批量删除 networkpolicy

功能介绍

This API is used to delete collection of NetworkPolicy

URLDELETE /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 574

Page 585: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-355 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "NetworkPolicyList", "apiVersion": "extensions/v1beta1", "metadata": { "selfLink": "/apis/extensions/v1beta1/namespaces/default/networkpolicies", "resourceVersion": "1105434" }, "items": [ { "metadata": { "name": "test111", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/networkpolicies/test111", "uid": "c4ca7f4e-ed3a-11e8-85b0-fa163e2ce5f0", "resourceVersion": "1105348", "generation": 1, "creationTimestamp": "2018-11-21T03:08:50Z", "labels": { "app": "nginx" } }, "spec": { "podSelector": { "matchLabels": { "app": "nginx" } }, "ingress": [ { "ports": [ { "protocol": "TCP", "port": 80 } ], "from": [ { "namespaceSelector": { "matchLabels": { "project": "default"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 575

Page 586: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} } } ] } ], "policyTypes": [ "Ingress" ] } }, { "metadata": { "name": "test222", "namespace": "default", "selfLink": "/apis/extensions/v1beta1/namespaces/default/networkpolicies/test222", "uid": "9017a491-ed3a-11e8-85b0-fa163e2ce5f0", "resourceVersion": "1105156", "generation": 1, "creationTimestamp": "2018-11-21T03:07:21Z", "labels": { "app": "nginx" } }, "spec": { "podSelector": { "matchLabels": { "app": "nginx" } }, "ingress": [ { "ports": [ { "protocol": "TCP", "port": 80 } ], "from": [ { "podSelector": { "matchLabels": { "app": "nginx" } } } ] } ], "policyTypes": [ "Ingress" ] } } ]}

状态码

状态码描述API的状态码。

表 6-356 状态码

状态码 描述

200 OK

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 576

Page 587: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.15.6 获取指定的 networkpolicy

功能介绍

This API is used to read the specified NetworkPolicy

URLGET /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

表6-357描述该API的参数。

表 6-357 参数解释

参数 是否必选 描述

name Yes name of the NetworkPolicy

namespace Yes object name and auth scope, such as for teamsand projects

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

export No Should this value be exported. Export stripsfields that a user can not specify.

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "NetworkPolicy", "apiVersion": "networking.k8s.io/v1", "metadata": { "name": "test-network-policy", "namespace": "default", "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/networkpolicies/test-network-policy", "uid": "be347ddd-e8af-11e8-b187-fa163e3cca63", "resourceVersion": "213982", "generation": 1, "creationTimestamp": "2018-11-15T08:23:34Z", "labels": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 577

Page 588: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"app": "nginx" } }, "spec": { "podSelector": { "matchLabels": { "app": "nginx" } }, "ingress": [{ "from": [{ "podSelector": { "matchLabels": { "app": "nginx2" } } }], "ports": [{ "protocol": "TCP", "port": 6379 }] }], "policyTypes":[ "Ingress" ] }}

状态码

状态码描述API的状态码。

表 6-358 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.15.7 列出指定 namespace 下的 networkpolicy

功能介绍

This API is used to list or watch objects of kind NetworkPolicy

URLGET /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 578

Page 589: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-359 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 579

Page 590: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No imit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

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

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 580

Page 591: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "NetworkPolicyList", "apiVersion": "networking.k8s.io/v1", "metadata": { "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/networkpolicies", "resourceVersion": "231375" }, "items": [{ "metadata": { "name": "network-test", "namespace": "default", "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/networkpolicies/network-test", "uid": "be347ddd-e8af-11e8-b187-fa163e3cca63", "resourceVersion": "213982", "generation": 1, "creationTimestamp": "2018-11-15T08:23:34Z", "labels": { "app": "nginx" } }, "spec": { "ingress": [{ "from": [{ "podSelector": { "matchLabels": { "app": "nginx2" } } }], "ports": [{ "protocol": "TCP", "port": 6379 }] }], "podSelector": { "matchLabels": { "app": "nginx" } }, "policyTypes": [ "Ingress" ] } }]}

状态码

状态码描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 581

Page 592: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-360 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.15.8 获取 networkpolicy 列表

功能介绍

This API is used to list or watch objects of kind NetworkPolicy

URL

GET /apis/networking.k8s.io/v1/networkpolicies

参数解释描述该API的参数。

表 6-361 参数解释

参数 是否必选 描述

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 582

Page 593: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large result canensure they see all possible objects. If objectsare updated during a chunked list the version ofthe object that was present at the time the firstlist result was calculated is returned.

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

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 583

Page 594: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "NetworkPolicyList", "apiVersion": "networking.k8s.io/v1", "metadata": { "selfLink": "/apis/networking.k8s.io/v1/networkpolicies", "resourceVersion": "231375" }, "items": [{ "metadata": { "name": "network-test", "namespace": "default", "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/networkpolicies/network-test", "uid": "be347ddd-e8af-11e8-b187-fa163e3cca63", "resourceVersion": "213982", "generation": 1, "creationTimestamp": "2018-11-15T08:23:34Z", "labels": { "app": "nginx" } }, "spec": { "ingress": [{ "from": [{ "podSelector": { "matchLabels": { "app": "nginx2" } } }], "ports": [{ "protocol": "TCP", "port": 6379 }] }], "podSelector": { "matchLabels": { "app": "nginx" } }, "policyTypes": [ "Ingress" ] } }]}

状态码

状态码描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 584

Page 595: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-362 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.16 PersistentVolume

6.16.1 创建 PersistentVolume

功能介绍

该API用于创建一个PersistentVolume。

URI

POST /api/v1/persistentvolumes

表6-363 描述该API的参数。

表 6-363 参数描述

参数 是否必选 描述

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

请求消息

请求参数:

请求参数如表6-364所示。

表 6-364 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 585

Page 596: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from theendpoint the client submitsrequests to. Cannot be updated.In CamelCase.

metadata Yes metadataobject

Standard object's metadata.

spec Yes spec object Spec defines a specification of apersistent volume owned by thecluster. Provisioned by anadministrator.

status No status object Status represents the currentinformation/status for thepersistent volume. Populated bythe system. Read-only.

表 6-365 spec 字段数据结构说明

参数 是否必选 参数类型 描述

accessModes Yes Array ofstrings

Access mode.Options:ReadWriteOnce: can be readand written by a single node.ReadOnlyMany: can only beread by multiple nodes.ReadWriteMany: can be readand written by multiple nodes.

capacity Yes Object A description of the persistentvolume's resources and capacity.

claimRef No claimRefobject

ClaimRef is part of a bi-directional binding betweenPersistentVolume andPersistentVolumeClaim.Expected to be non-nil whenbound. claim. VolumeName isthe authoritative bind betweenPV and PVC.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 586

Page 597: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

hostPath No hostPathobject

HostPath represents a directoryon the host. Provisioned by adeveloper or tester. This isuseful for single-nodedevelopment and testing only!On-host storage is notsupported in any way and WILLNOT WORK in a multi-nodecluster.

nfs No nfs object NFS represents an NFS mounton the host. Provisioned by anadmin.

persistentVolumeReclaimPolicy

No String What happens to a persistentvolume when released from itsclaim. Valid options are Retain(default) and Recycle. Recyclingmust be supported by thevolume plugin underlying thispersistent volume.

storageClassName

No String Name of StorageClass to whichthis persistent volume belongs.Empty value means that thisvolume does not belong to anyStorageClass.

表 6-366 status 字段数据结构说明

参数 是否必选 参数类型 描述

message No String A human-readable messageindicating details about why thevolume is in this state.

phase No String Phase indicates if a volume isavailable, bound to a claim, orreleased by a claim.

reason No String Reason is a brief CamelCasestring that describes any failureand is meant for machineparsing and tidy display in theCLI.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 587

Page 598: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-367 claimRef 字段数据结构说明

参数 是否必选 参数类型 描述

apiVersion No String API version of the referent.

fieldPath No String If referring to a piece of anobject instead of an entireobject, this string should containa valid JSON/Go field accessstatement, such asdesiredState.manifest.containers[2]. For example, if the objectreference is to a containerwithin a pod, this would take ona value like:"spec.containers{name}" (where"name" refers to the name ofthe container that triggered theevent) or if no container nameis specified "spec.containers[2]"(container with index 2 in thispod). This syntax is chosen onlyto have some well-defined wayof referencing a part of anobject.

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 towhich this reference is made, ifany.

uid No String UID of the referent.

表 6-368 hostPath 字段数据结构说明

参数 是否必选 参数类型 描述

path No String Path of the directory on thehost.

表 6-369 nfs 字段数据结构说明

参数 是否必选 参数类型 描述

path No String Path that is exported by the NFSserver.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 588

Page 599: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

readOnly No Boolean ReadOnly here will force theNFS export to be mounted withread-only permissions. Defaultsto false.

server No String Server is the hostname or IPaddress of the NFS server.

请求示例:

1.15集群版本示例:

{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "annotations": { "pv.kubernetes.io/namespace": "default", "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-7", "failure-domain.beta.kubernetes.io/zone": "cn-north-7b" }, "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": "SATA", "storage.kubernetes.io/csiProvisionerIdentity": "everest-csi-provisioner" }, "volumeHandle": "9c44d068-42ab-4fcf-bb8f-1609823da5bb" }, "persistentVolumeReclaimPolicy": "Delete", "storageClassName": "csi-disk", "volumeMode": "Filesystem" }}

1.13及之前版本示例:

{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "labels": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 589

Page 600: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "name": "pv-test-02" }, "name": "pv-test-02", "annotations": { "volume.beta.kubernetes.io/storage-class": "sata", "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol" } }, "spec": { "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "10Gi" }, "hostPath": { "path": "/home" }, "persistentVolumeReclaimPolicy": "Delete" } }

响应消息

响应参数:

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

响应示例:

1.15集群版本示例:

{ "kind":"PersistentVolumeClaim", "apiVersion":"v1", "metadata":{ "name":"cce-evs-k6m0pl2w-en9i", "namespace":"default", "selfLink":"/api/v1/namespaces/default/persistentvolumeclaims/pv-test-02", "uid":"67db6e01-d42f-45af-8abd-913f9aaca171", "resourceVersion":"2284565", "creationTimestamp":"2020-02-14T10:17:22Z", "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" }, "finalizers":[ "kubernetes.io/pvc-protection" ] }, "spec":{ "accessModes":[ "ReadWriteOnce" ], "resources":{ "requests":{ "storage":"10Gi" } }, "storageClassName":"csi-disk", "volumeMode":"Filesystem" }, "status":{

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 590

Page 601: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"phase":"Pending" }}

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-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "name": "pv-test-02" }, "annotations": { "volume.beta.kubernetes.io/storage-class": "sata", "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" }}

状态码

表6-370描述API的状态码。

表 6-370 状态码

状态码 描述

201 The request has been fulfilled,resulting in the creation of a newresource.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 591

Page 602: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.16.2 删除指定的 PersistentVolume

功能介绍

该API用于删除指定的PersistentVolume对象。

URI

DELETE /api/v1/persistentvolumes/{name}

表6-371 描述该API的参数。

表 6-371 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolume.

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

gracePeriodSeconds

No The duration in seconds before the objectshould be deleted. Value must be non-negative integer. The value zero indicatesdelete immediately. If this value is nil, thedefault grace period for the specified type willbe used. Defaults to a per object value if notspecified. zero means delete immediately.

orphanDependents

No Deprecated: please use the PropagationPolicy,this field will be deprecated in 1.7. Should thedependent objects be orphaned. If true/false,the "orphan" finalizer will be added to/removed from the object's finalizers list. Eitherthis field or PropagationPolicy may be set, butnot both.

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field orOrphanDependents may be set, but not both.The default policy is decided by the existingfinalizer set in the metadata.finalizers and theresource-specific default policy.

请求消息

请求参数:

请求参数的详细描述请参见表6-261.

请求示例:

{ "kind": "DeleteOptions", "apiVersion": "v1",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 592

Page 603: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"gracePeriodSeconds": 0 }

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

1.15及之后集群版本示例:

{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "annotations": { "pv.kubernetes.io/namespace": "default", "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-7", "failure-domain.beta.kubernetes.io/zone": "cn-north-7b" }, "name": "pvc-efe92ec5-fb39-4e17-bb26-c5d336ce5c14", "resourceVersion": "5025500", "selfLink": "/api/v1/persistentvolumes/pvc-efe92ec5-fb39-4e17-bb26-c5d336ce5c14", "uid": "b14a40bc-8be7-4b26-90e5-975261d470a2" }, "spec": { "accessModes": [ "ReadWriteOnce" ], "capacity": { "storage": "20Gi" }, "claimRef": { "apiVersion": "v1", "kind": "PersistentVolumeClaim", "name": "cce-evs-k54nobs9-ljhc", "namespace": "default", "resourceVersion": "3578282", "uid": "efe92ec5-fb39-4e17-bb26-c5d336ce5c14" }, "csi": { "driver": "disk.csi.everest.io", "fsType": "ext4", "volumeAttributes": { "everest.io/disk-mode": "SCSI", "everest.io/disk-volume-type": "SATA", "storage.kubernetes.io/csiProvisionerIdentity": "everest-csi-provisioner" }, "volumeHandle": "9c44d068-42ab-4fcf-bb8f-1609823da5bb" }, "persistentVolumeReclaimPolicy": "Delete", "storageClassName": "csi-disk", "volumeMode": "Filesystem" }, "status": { "phase": "Released" }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 593

Page 604: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

1.13及之前集群版本示例:

{ "kind": "PersistentVolume", "apiVersion": "v1", "metadata": { "name": "pv-test-02", "generateName": "pv-demo", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumes/pv-test-02", "uid": "98efd6aa-920a-11e8-81cc-fa163e49263c", "resourceVersion": "5674455", "creationTimestamp": "2018-07-28T02:04:44Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "name": "pv-test-03" }, "annotations": { "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": { "capacity": { "storage": "11Gi" }, "hostPath": { "path": "/home", "type": "" }, "accessModes": [ "ReadWriteMany" ], "claimRef": { "kind": "PersistentVolumeClaim", "namespace": "default", "name": "db-mysql", "uid": "638e26ac-9148-11e8-8cd0-fa163e082286", "apiVersion": "v1", "resourceVersion": "5456583" }, "persistentVolumeReclaimPolicy": "Delete" }, "status": { "phase": "Bound" }}

状态码

表6-372描述API的状态码。

表 6-372 状态码

状态码 描述

200 Delete a specified PersistentVolumeresource objectre successfully.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 594

Page 605: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.16.3 删除所有的 PersistentVolume

Function该API用于删除所有的PersistentVolume对象。

URIDELETE /api/v1/persistentvolumes

表6-373描述该API的参数。

表 6-373 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

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

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

RequestN/A

Response响应参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 595

Page 606: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应参数的详细描述请参见表6-364。

响应示例:

{ "kind": "PersistentVolumeList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/persistentvolumes", "resourceVersion": "5679025" }, "items": [ { "metadata": { "name": "pv-test-02", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumes/pv-test-02", "uid": "b1e175a8-920c-11e8-8cd0-fa163e082286", "resourceVersion": "5675029", "creationTimestamp": "2018-07-28T02:19:45Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "name": "pv-test-02" }, "annotations": { "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": { "capacity": { "storage": "10Gi" }, "hostPath": { "path": "/home", "type": "" }, "accessModes": [ "ReadWriteMany" ], "claimRef": { "kind": "PersistentVolumeClaim", "namespace": "default", "name": "db-mysql", "uid": "638e26ac-9148-11e8-8cd0-fa163e082286", "apiVersion": "v1", "resourceVersion": "5674792" }, "persistentVolumeReclaimPolicy": "Delete" }, "status": { "phase": "Bound" } }, { "metadata": { "name": "pv-test-03", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumes/pv-test-03", "uid": "e4e15446-920c-11e8-81cc-fa163e49263c", "resourceVersion": "5675754", "creationTimestamp": "2018-07-28T02:21:11Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "name": "pv-test-03" }, "annotations": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 596

Page 607: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"volume.beta.kubernetes.io/storage-class": "sata", "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol" } }, "spec": { "capacity": { "storage": "3Gi" }, "hostPath": { "path": "/home", "type": "" }, "accessModes": [ "ReadWriteMany" ], "persistentVolumeReclaimPolicy": "Delete" }, "status": { "phase": "Available" } } ]}

状态码

表6-374 describes the status code of this API.

表 6-374 状态码

Status Code 描述

200 Delete a DaemonSet resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.16.4 获取指定的 PersistentVolume

功能介绍

该API用于获取指定的PersistentVolume对象。

URI

GET /api/v1/persistentvolumes/{name}

表6-375 描述该API的参数。

表 6-375 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolume.

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 597

Page 608: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

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

export No Should this value be exported. Export stripsfields that a user cannot specify.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-364。

响应示例:

{ "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": "5672676", "creationTimestamp": "2018-07-28T02:04:44Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "name": "pv-test-02" }, "annotations": { "volume.beta.kubernetes.io/storage-class": "sata", "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol" } }, "spec": { "capacity": { "storage": "10Gi" }, "hostPath": { "path": "/home", "type": "" }, "accessModes": [ "ReadWriteMany" ], "persistentVolumeReclaimPolicy": "Delete" }, "status": { "phase": "Available" }}

状态码

表6-376描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 598

Page 609: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-376 状态码

状态码 描述

200 This operation succeeds, and aPersistentVolume resource object isreturned.

异常状态码请参见9.3 状态码。

6.16.5 替换指定的 PersistentVolume

功能介绍

该API用于替换指定的PersistentVolume对象。

其中以下字段支持更新:

● metadata.labels● metadata.generateName● spec.accessModes● spec.capacity● spec.persistentVolumeReclaimPolicy

URIPUT /api/v1/persistentvolumes/{name}

表6-377 描述该API的参数。

表 6-377 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolume.

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

请求消息

请求参数:

请求参数的详细描述请参见表6-364。

请求示例:

{ "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 599

Page 610: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "name": "pv-test-03" }, "name": "pv-test-02", "annotations": { "volume.beta.kubernetes.io/storage-class": "sata", "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol" }, "generateName": "pv-demo" }, "spec": { "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "11Gi" }, "hostPath": { "path": "/home" }, "persistentVolumeReclaimPolicy": "Delete" } }

响应消息

响应参数:

响应参数的详细描述请参见表6-364.

响应示例:

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 600

Page 611: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}}

状态码

表6-378描述API的状态码。

表 6-378 状态码

状态码 描述

200 This operation succeeds, and aPersistentVolume resource object isreturned.

异常状态码请参见9.3 状态码。

6.16.6 替换指定的 PersistentVolume 的状态

功能介绍

该API用于替换指定的PersistentVolume对象的状态。

其中以下字段支持更新:

● status.phase

URIPUT /api/v1/persistentvolumes/{name}/status

表6-379 描述该API的参数。

表 6-379 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolume.

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

请求消息

请求参数:

请求参数的详细描述请参见表6-364

请求示例:

{ "kind": "PersistentVolume", "apiVersion": "v1", "metadata": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 601

Page 612: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"name": "pv-test", "selfLink": "/api/v1/persistentvolumes/pv-test", "uid": "e0b9c5e3-fcfc-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "189565", "creationTimestamp": "2018-01-19T09:41:09Z", "labels": { "app": "test" } }, "spec": { "capacity": { "storage": "1Gi" }, "hostPath": { "path": "/home" }, "accessModes": [ "ReadWriteMany" ], "persistentVolumeReclaimPolicy": "Delete" }, "status": { "phase": "Bound" }}

响应消息

响应参数:

响应参数的详细描述请参见表6-364.

响应示例:

{ "kind": "PersistentVolume", "apiVersion": "v1", "metadata": { "name": "pv-test", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumes/pv-test", "uid": "e0b9c5e3-fcfc-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "599899", "creationTimestamp": "2018-01-19T09:41:09Z", "labels": { "name": "pv-test" }, "enable": true }, "spec": { "capacity": { "storage": "1Gi" }, "hostPath": { "path": "/home" }, "accessModes": [ "ReadWriteMany" ], "persistentVolumeReclaimPolicy": "Delete" }, "status": { "phase": "Available" }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 602

Page 613: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-380描述API的状态码。

表 6-380 状态码

状态码 描述

200 This operation succeeds, and aPersistentVolume resource object isreturned.

异常状态码请参见9.3 状态码。

6.16.7 列出所有的 PersistentVolume

功能介绍

该API用于列出所有PersistentVolume资源对象。

URIGET /api/v1/persistentvolumes

表6-381描述该API的参数。

表 6-381 参数描述

参数 是否必选 描述

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

fieldSelector No A selector to restrict the list of returnedobjects by their fields. Defaults to everything.

labelSelector No A selector to restrict the list of returnedobjects by their labels. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

resourceVersion No When specified with a watch call, showschanges that occur after that particularversion of a resource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 603

Page 614: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

表 6-382 响应参数

参数 参数类型 描述

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

items Object List of persistent volumes.具体请参见表6-364。

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

metadata ListMeta object Standard list metadata.

表 6-383 ListMeta 字段数据结构说明

参数 参数类型 描述

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treated asopaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

响应示例:

{ "kind": "PersistentVolumeList",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 604

Page 615: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

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

状态码

表6-384描述API的状态码。

表 6-384 状态码

状态码 描述

200 This operation succeeds, and a groupof PersistentVolume resource objects isreturned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 605

Page 616: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.16.8 更新指定的 PersistentVolume

功能介绍

该API用于更新PersistentVolume对象。

其中以下字段支持更新:

● metadata.labels

● metadata.generateName

● spec.accessModes

● spec.capacity

● spec.persistentVolumeReclaimPolicy

URIPATCH /api/v1/persistentvolumes/{name}

表6-385 描述该API的参数。

表 6-385 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolume.

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

请求消息

请求参数:

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/json-patch+json[ { "op": "add", "path": "/spec/persistentVolumeReclaimPolicy", "value": "Retain" }]

响应消息

响应参数:

响应参数的详细描述请参见表6-364.

响应示例:

{ "kind": "PersistentVolume",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 606

Page 617: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "v1", "metadata": { "name": "pv-test-03", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumes/pv-test-03", "uid": "45eb3e76-9212-11e8-8cd0-fa163e082286", "resourceVersion": "5690537", "creationTimestamp": "2018-07-28T02:59:41Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "name": "pv-test-03" }, "annotations": { "volume.beta.kubernetes.io/storage-class": "sata", "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol" } }, "spec": { "capacity": { "storage": "20Gi" }, "hostPath": { "path": "/home", "type": "" }, "accessModes": [ "ReadWriteMany" ], "persistentVolumeReclaimPolicy": "Delete" }, "status": { "phase": "Available" }}

状态码

表6-386描述API的状态码。

表 6-386 状态码

状态码 描述

200 This operation succeeds, and aPersistentVolume resource object isreturned.

异常状态码请参见9.3 状态码。

6.17 PersistentVolumeClaim

6.17.1 创建 PersistentVolumeClaim

功能介绍

该API用于在指定的Namespace下创建PersistentVolumeClaim。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 607

Page 618: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URIPOST /api/v1/namespaces/{namespace}/persistentvolumeclaims

表6-387 描述该API的参数。

表 6-387 参数描述

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

表 6-388 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind Yes String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated.

metadata Yes metadataobject

Standard object's metadata.

spec Yes spec object Spec defines the desiredcharacteristics of a volumerequested by a pod author.

status No status object Status represents the currentinformation/status of apersistent volume claim. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 608

Page 619: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-389 status 字段数据结构说明

参数 是否必选 参数类型 描述

accessModes No Array ofstrings

AccessModes contains theactual access modes the volumebacking the PVC has.

capacity No Object Represents the actual resourcesof the underlying volume.

phase No String Phase represents the currentphase ofPersistentVolumeClaim.

表 6-390 spec 字段数据结构说明

参数 是否必选 参数类型 描述

volumeName No String VolumeName is the bindingreference to thePersistentVolume backing thisclaim.

accessModes Yes Array ofstrings

AccessModes contains thedesired access modes thevolume should have.

resources Yes resourcesobject

Resources represents theminimum resources the volumeshould have.

selector No selectorobject

A label query over volumes toconsider for binding.

storageClassName

No String Name of the StorageClassrequired by the claim.

表 6-391 resources 字段数据结构说明

参数 是否必选 参数类型 描述

limits No Object Limits describes the maximumamount of compute resourcesallowed.说明

Parameter limits is invalid.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 609

Page 620: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

requests No Object Requests describes theminimum amount of computeresources required. If Requestsis omitted for a container, itdefaults to Limits if that isexplicitly specified, otherwise toan implementation-definedvalue.说明

Except parameter storage, theother parameters (such as CPUand memory) are invalid.

表 6-392 selector 字段数据结构说明

参数 是否必选 参数类型 描述

matchExpressions

No matchExpressions object

MatchExpressions is a list oflabel selector requirements. Therequirements are ANDed.

matchLabels No Object MatchLabels is a map of{key,value} pairs. A single{key,value} in the matchLabelsmap is equivalent to anelement of matchExpressions,whose key field is "key", theoperator is "In", and the valuesarray contains only "value". Therequirements are ANDed.

表 6-393 matchExpressions 字段数据结构说明

参数 是否必选 参数类型 描述

key No String Key is the label key that theselector applies to.

operator No String Operator represents a key'srelationship to a set of values.Valid operators are In, NotIn,Exists and DoesNotExist.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 610

Page 621: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

values No Array ofstrings

Values is an array of stringvalues. If the operator is In orNotIn, the values array must benon-empty. If the operator isExists or DoesNotExist, thevalues array must be empty.This array is replaced during astrategic merge patch.

云硬盘存储卷请求示例:

● 1.15及之后集群版本请求示例:{ "kind":"PersistentVolumeClaim", "apiVersion":"v1", "metadata":{ "name":"cce-evs-k6m16atm-3ays", "namespace":"default", "selfLink":"/api/v1/namespaces/default/persistentvolumeclaims/cce-evs-k6m16atm-3ays", "uid":"80f111e7-7d7e-4841-bd73-7ef97df0ee51", "resourceVersion":"2287083", "creationTimestamp":"2020-02-14T10:30:20Z", "labels":{ "failure-domain.beta.kubernetes.io/region":"cn-north-5", "failure-domain.beta.kubernetes.io/zone":"cn-north-5a" }, "annotations":{ "everest.io/crypt-key-id":"527cbece-428d-463b-a92c-936a11077b5d", //创建加密卷必需,若无或不全,则不加密; "everest.io/disk-volume-type":"SATA" }, "finalizers":[ "kubernetes.io/pvc-protection" ] }, "spec":{ "accessModes":[ "ReadWriteOnce" ], "resources":{ "requests":{ "storage":"10Gi" } }, "storageClassName":"csi-disk", "volumeMode":"Filesystem" }, "status":{ "phase":"Pending" }}

● 1.13及之前版本示例:{ "apiVersion": "v1", "kind": "PersistentVolumeClaim", "metadata": { "name": "db-mysql", "namespace": "default", "annotations": { "paas.storage.io/cryptKeyId": "1ed68cb7-b09b-423c-8d66-fdd2e063769d", //此annotation表明是否加密,若无,则不加密;

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 611

Page 622: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"volume.beta.kubernetes.io/storage-class": "sata", "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol" }, "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" } }, "spec": { "accessModes": [ "ReadWriteMany" ], "resources": { "requests": { "storage": "10Gi" } } }}

文件存储卷请求示例:

● 1.15及之后集群版本示例{ "apiVersion": "v1", "kind": "PersistentVolumeClaim", "metadata": { "annotations": { "everest.io/crypt-key-id": "3cfaea47-eb9b-4c68-b108-86fe399aebaf", "everest.io/crypt-domain-id": "fff357e41a3a4a0d88e821f35194d110", "everest.io/crypt-alias": "sfs/default" }, "creationTimestamp": "2020-02-14T08:54:08Z", "finalizers": [ "kubernetes.io/pvc-protection" ], "labels": { "app": "test-sfs" }, "name": "pvc-158167040158916159-test-sfs-0", "namespace": "default", }, "spec": { "accessModes": [ "ReadWriteMany" ], "resources": { "requests": { "storage": "10Gi" } }, "storageClassName": "csi-nas", "volumeMode": "Filesystem", "volumeName": "pvc-1c933c44-1f47-41a4-9353-3800a21cab6b" }}

● 1.13及之前集群版本示例:{ "apiVersion": "v1", "kind": "PersistentVolumeClaim", "metadata": { "name": "sfs-pvc", "namespace": "default", "annotations": { "paas.storage.io/cryptAlias": "sfs/default" , //红色字体部分三个annotation是创建加密卷必需,若无或不全,则不加密; "paas.storage.io/cryptDomainId": "fff357e41a3a4a0d88e821f35194d110", "paas.storage.io/cryptKeyId": "3cfaea47-eb9b-4c68-b108-86fe399aebaf", "volume.beta.kubernetes.io/storage-class": "nfs-rw",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 612

Page 623: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxinfs" }, "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" } }, "spec": { "accessModes": [ "ReadWriteMany" ], "resources": { "requests": { "storage": "10Gi" } } }}

响应消息

响应参数:

响应参数的详细描述请参见14.2 Table2 Request parameters.

云硬盘存储卷响应示例:

● 1.15及之后集群版本yaml示例{ "kind":"PersistentVolumeClaim", "apiVersion":"v1", "metadata":{ "name":"cce-evs-k6m16atm-3ays", "namespace":"default", "selfLink":"/api/v1/namespaces/default/persistentvolumeclaims/cce-evs-k6m16atm-3ays", "uid":"80f111e7-7d7e-4841-bd73-7ef97df0ee51", "resourceVersion":"2287083", "creationTimestamp":"2020-02-14T10:30:20Z", "labels":{ "failure-domain.beta.kubernetes.io/region":"cn-north-5", "failure-domain.beta.kubernetes.io/zone":"cn-north-5a" }, "annotations":{ "everest.io/crypt-key-id":"527cbece-428d-463b-a92c-936a11077b5d",//若为加密卷,则存在 "everest.io/disk-volume-type":"SATA" }, "finalizers":[ "kubernetes.io/pvc-protection" ] }, "spec":{ "accessModes":[ "ReadWriteOnce" ], "resources":{ "requests":{ "storage":"10Gi" } }, "storageClassName":"csi-disk", "volumeName": "pvc-d34f6a93-9eba-4a33-9320-8fa4addd3753", "volumeMode":"Filesystem" }, "status":{ "phase":"Pending" }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 613

Page 624: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● 1.13及之前版本yaml示例:{ "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-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "annotations": { "paas.storage.io/cryptKeyId": "1ed68cb7-b09b-423c-8d66-fdd2e063769d" //若为加密卷,则存在 "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" } }}

状态码

表6-394描述API的状态码。

表 6-394 状态码

状态码 描述

201 The request has been fulfilled,resulting in the creation of a newresource.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 614

Page 625: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.17.2 删除指定的 PersistentVolumeClaim

功能介绍

该API用于删除指定Namespace下的PersistentVolumeClaim对象。

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

表6-395 描述该API的参数。

表 6-395 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolumeClaim

namespace Yes Object name and auth scope, such as for teamsand projects.

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

gracePeriodSeconds

No The duration in seconds before the object shouldbe deleted. Value must be non-negative integer.The value zero indicates delete immediately. Ifthis value is nil, the default grace period for thespecified type will be used. Defaults to a perobject value if not specified. zero means deleteimmediately.

orphanDependents

No Deprecated: please use the PropagationPolicy,this field will be deprecated in 1.7. Should thedependent objects be orphaned. If true/false, the"orphan" finalizer will be added to/removedfrom the object's finalizers list. Either this field orPropagationPolicy may be set, but not both.

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field orOrphanDependents may be set, but not both.The default policy is decided by the existingfinalizer set in the metadata.finalizers and theresource-specific default policy.

请求消息

请求参数:

请求参数的详细描述请参见12.3 Table2 Parameter description.

请求示例:

{ "kind": "DeleteOptions",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 615

Page 626: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "v1", "gracePeriodSeconds": 0 }

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

● 1.15及之后集群版本示例:{ "kind":"PersistentVolumeClaim", "apiVersion":"v1", "metadata":{ "name":"cce-evs-k6m16atm-3ays", "namespace":"default", "selfLink":"/api/v1/namespaces/default/persistentvolumeclaims/cce-evs-k6m16atm-3ays", "uid":"80f111e7-7d7e-4841-bd73-7ef97df0ee51", "resourceVersion":"2289620", "creationTimestamp":"2020-02-14T10:30:20Z", "deletionTimestamp":"2020-02-14T10:43:29Z", "deletionGracePeriodSeconds":0, "labels":{ "failure-domain.beta.kubernetes.io/region":"cn-north-5", "failure-domain.beta.kubernetes.io/zone":"cn-north-5a" }, "annotations":{ "everest.io/crypt-key-id":"527cbece-428d-463b-a92c-936a11077b5d",//若为加密卷,则存在 "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" } }, "storageClassName":"csi-disk", "volumeMode":"Filesystem", "volumeName": "pvc-d34f6a93-9eba-4a33-9320-8fa4addd3753" }, "status":{ "phase":"Pending" }}

● 1.13及之前集群版本示例:{ "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": "db-mysql-0", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "9d070d77-8ce1-11e8-8ee0-fa163e49263c", "resourceVersion": "4202924",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 616

Page 627: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"creationTimestamp": "2018-07-21T12:28:46Z", "labels": { "app": "mysql", "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "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": "5Gi" } }, "volumeName": "pvc-9d070d77-8ce1-11e8-8ee0-fa163e49263c", "volumeNamespace": "default" }, "status": { "phase": "Bound", "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "5Gi" } }}

状态码

表6-396描述API的状态码。

表 6-396 状态码

状态码 描述

200 Delete a PersistentVolumeClaimresource objectre successfully.

异常状态码请参见9.3 状态码。

6.17.3 删除所有的 PersistentVolumeClaim

功能介绍

该API用于删除所有的PersistentVolumeClaim资源对象。

URIDELETE /api/v1/namespaces/{namespace}/persistentvolumeclaims

表6-397描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 617

Page 628: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-397 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

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

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

RequestN/A

响应消息

响应参数:

响应参数的详细描述请参见表6-388。

响应示例:

● 1.15及之后集群版本示例:{ "kind": "PersistentVolumeClaimList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims", "resourceVersion": "4203652" }, "items": [ {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 618

Page 629: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"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-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "annotations": { "everest.io/crypt-key-id":"527cbece-428d-463b-a92c-936a11077b5d",//若为加密卷,则存在 "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" } }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "10Gi" } }, "volumeName": "pvc-ac34af93-8cdd-11e8-8ee0-fa163e49263c", "storageClassName":"csi-disk", "volumeMode":"Filesystem" }, "status": { "phase": "Bound", "accessModes": [ "ReadWriteOnce" ], "capacity": { "storage": "10Gi" } } } ]}

● 1.13及之前版本示例:{ "kind": "PersistentVolumeClaimList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims", "resourceVersion": "4203652" }, "items": [ { "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-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "annotations": { "pv.kubernetes.io/bind-completed": "yes", "pv.kubernetes.io/bound-by-controller": "yes",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 619

Page 630: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"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" } } } ]}

状态码

表6-398描述API的状态码。

表 6-398 状态码

状态码 描述

200 Delete a DaemonSet resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.17.4 获取指定的 PersistentVolumeClaim

功能介绍

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

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

表6-399 描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 620

Page 631: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-399 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolumeClaim.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

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

export No Should this value be exported. Export stripsfields that a user can not specify.

请求消息

N/A

响应消息

响应参数:

表 6-400 响应参数

参数 参数类型 描述

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

metadata metadata object Standard object's metadata.

spec spec object Spec defines the desiredcharacteristics of a volumerequested by a pod author.

status status object Status represents the currentinformation/status of a persistentvolume claim. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 621

Page 632: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-401 status 字段数据结构说明

参数 参数类型 描述

accessModes Array of strings AccessModes contains the actualaccess modes the volume backingthe PVC has.

capacity Object Represents the actual resources ofthe underlying volume.

phase String Phase represents the currentphase of PersistentVolumeClaim.

表 6-402 spec 字段数据结构说明

参数 参数类型 描述

volumeName String VolumeName is the bindingreference to the PersistentVolumebacking this claim.

accessModes Array of strings AccessModes contains the desiredaccess modes the volume shouldhave.

storageClassName

String Name of the StorageClassrequired by the claim.

resources resources object Resources represents theminimum resources the volumeshould have.

selector selector object A label query over volumes toconsider for binding.

表 6-403 resources 字段数据结构说明

参数 参数类型 描述

limits Object Limits describes the maximumamount of compute resourcesallowed.说明

Parameter limits is invalid.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 622

Page 633: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

requests Object Requests describes the minimumamount of compute resourcesrequired. If Requests is omitted fora container, it defaults to Limits ifthat is explicitly specified,otherwise to an implementation-defined value.说明

Except parameter storage, the otherparameters (such as CPU andmemory) are invalid.

表 6-404 selector 字段数据结构说明

参数 参数类型 描述

matchExpressions matchExpressionsobject

MatchExpressions is a list of labelselector requirements. Therequirements are ANDed.

matchLabels Object MatchLabels is a map of{key,value} pairs. A single{key,value} in the matchLabelsmap is equivalent to an elementof matchExpressions, whose keyfield is "key", the operator is "In",and the values array contains only"value". The requirements areANDed.

表 6-405 matchExpressions 字段数据结构说明

参数 参数类型 描述

key String Key is the label key that theselector applies to.

operator String Operator represents a key'srelationship to a set of values.Valid operators are In, NotIn,Exists and DoesNotExist.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 623

Page 634: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

values Array of strings Values is an array of string values.If the operator is In or NotIn, thevalues array must be non-empty.If the operator is Exists orDoesNotExist, the values arraymust be empty. This array isreplaced during a strategic mergepatch.

响应示例:

● 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及之前集群版本示例:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 624

Page 635: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "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-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "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" } }}

状态码

表6-406描述API的状态码。

表 6-406 状态码

状态码 描述

200 This operation succeeds, and aPersistentVolumeClaim resource objectis returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 625

Page 636: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.17.5 替换指定的 PersistentVolumeClaim

功能介绍

该API用于替换指定Namespace下的PersistentVolumeClaim对象。

其中以下字段支持更新:

● metadata.labels

● metadata.generateName

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

表6-407 描述该API的参数。

表 6-407 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolumeClaim.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

响应参数:

请求参数的详细描述请参见表6-388

请求示例:

● 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", "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"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 626

Page 637: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

] }, "spec":{ "accessModes":[ "ReadWriteOnce" ], "resources":{ "requests":{ "storage":"10Gi" } }, "volumeName":"pvc-d34f6a93-9eba-4a33-9320-8fa4addd3753", "storageClassName":"csi-disk", "volumeMode":"Filesystem" }}

● 1.13及之前集群版本yaml示例:{ "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": "db-mysql-0", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "f6585eb2-8cdd-11e8-a538-fa163e082286", "resourceVersion": "4198033", "creationTimestamp": "2018-07-21T12:02:38Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "app":"mysql" }, "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": "5Gi" } }, "volumeName": "pvc-f6585eb2-8cdd-11e8-a538-fa163e082286", "volumeNamespace": "default" }, "status": { "phase": "Bound", "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "5Gi" } }}

响应消息

响应参数:

响应参数的详细描述请参见14.2-Table2 Request parameters.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 627

Page 638: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

● 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-0", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "f6585eb2-8cdd-11e8-a538-fa163e082286", "resourceVersion": "4201550", "creationTimestamp": "2018-07-21T12:02:38Z", "labels": { "app": "mysql", "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "annotations": { "pv.kubernetes.io/bind-completed": "yes", "pv.kubernetes.io/bound-by-controller": "yes",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 628

Page 639: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"volume.beta.kubernetes.io/storage-class": "sata", "volume.beta.kubernetes.io/storage-provisioner": "flexvolume-huawei.com/fuxivol" } }, "spec": { "accessModes": [ "ReadWriteMany" ], "resources": { "requests": { "storage": "5Gi" } }, "volumeName": "pvc-f6585eb2-8cdd-11e8-a538-fa163e082286", "volumeNamespace": "default" }, "status": { "phase": "Bound", "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "5Gi" } }}

状态码

表6-408描述API的状态码。

表 6-408 状态码

状态码 描述

200 This operation succeeds, and aPersistentVolumeClaim resource objectis returned.

异常状态码请参见9.3 状态码。

6.17.6 替换指定的 PersistentVolumeClaim 的状态

功能介绍

该API用于替换指定的Namespace下指定的PersistentVolumeClaim对象的状态。

其中以下字段支持更新:

● status.phase

URI

PUT /api/v1/namespaces/{namespace}/persistentvolumeclaims/{name}/status

表6-409 描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 629

Page 640: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-409 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolumeClaim.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

请求参数的详细描述请参见表6-388。

请求示例:

● 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"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 630

Page 641: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} }}

● 1.13及之前集群版本示例:{ "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": "db-mysql-0", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "9d070d77-8ce1-11e8-8ee0-fa163e49263c", "resourceVersion": "4202107", "creationTimestamp": "2018-07-21T12:28:46Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "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": "5Gi" } }, "volumeName": "pvc-9d070d77-8ce1-11e8-8ee0-fa163e49263c", "volumeNamespace": "default" }, "status": { "phase": "Bound", "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "5Gi" } }}

响应消息

响应参数:

响应参数的详细描述请参见14.2-Table2 Request parameters.

响应示例:

● 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",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 631

Page 642: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"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-0", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "9d070d77-8ce1-11e8-8ee0-fa163e49263c", "resourceVersion": "4202107", "creationTimestamp": "2018-07-21T12:28:46Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "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": "5Gi" } }, "volumeName": "pvc-9d070d77-8ce1-11e8-8ee0-fa163e49263c",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 632

Page 643: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"volumeNamespace": "default" }, "status": { "phase": "Bound", "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "5Gi" } }}

状态码

表6-410描述API的状态码。

表 6-410 状态码

状态码 描述

200 This operation succeeds, and aPersistentVolumeClaim resource objectis returned.

异常状态码请参见9.3 状态码。

6.17.7 列出指定的 Namespace 下的 PersistentVolumeClaim

功能介绍

该API用于列出指定Namespace下的所有PersistentVolumeClaim资源对象。

URI

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

表6-411 描述该API的参数。

表 6-411 参数描述

参数 是否必选 描述

namespace Yes Object name and auth scope, such as forteams and projects.

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

includeUninitialized

No If true, partially initialized resources areincluded in the response.

fieldSelector No A selector to restrict the list of returnedobjects by their fields. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 633

Page 644: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

labelSelector No A selector to restrict the list of returnedobjects by their labels. Defaults to everything.

resourceVersion No When specified with a watch call, showschanges that occur after that particularversion of a resource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

响应消息

响应参数:

表 6-412 响应参数

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

metadata metadata object Standard list metadata.

items Object A list of persistent volume claims.具体请参见14.2-Table2 Requestparameters。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 634

Page 645: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-413 metadata 字段数据结构说明

参数 参数类型 描述

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treated asopaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

响应示例:

● 1.15及之后集群版本示例:{ "kind":"PersistentVolumeClaimList", "apiVersion":"v1", "metadata":{ "selfLink":"/api/v1/persistentvolumeclaims", "resourceVersion":"2306215" }, "items":[ { "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"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 635

Page 646: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "status":{ "phase":"Bound", "accessModes":[ "ReadWriteOnce" ], "capacity":{ "storage":"10Gi" } } } ]}

● 1.13及之前集群版本示例:{ "kind": "PersistentVolumeClaimList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims", "resourceVersion": "4198037" }, "items": [ { "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-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "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" } } }, { "metadata": { "name": "db-mysql-0", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "f6585eb2-8cdd-11e8-a538-fa163e082286",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 636

Page 647: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"resourceVersion": "4198033", "creationTimestamp": "2018-07-21T12:02:38Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "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": "5Gi" } }, "volumeName": "pvc-f6585eb2-8cdd-11e8-a538-fa163e082286", "volumeNamespace": "default" }, "status": { "phase": "Bound", "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "5Gi" } } } ]}

6.17.8 列出所有的 PersistentVolumeClaim

功能介绍

该API用于列出所有PersistentVolumeClaim资源对象。

URI

GET /api/v1/persistentvolumeclaims

表6-414 描述该API的参数。

表 6-414 参数描述

参数 是否必选 描述

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

fieldSelector No A selector to restrict the list of returnedobjects by their fields. Defaults to everything.

labelSelector No A selector to restrict the list of returnedobjects by their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 637

Page 648: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

includeUninitialized

No If true, partially initialized resources areincluded in the response.

resourceVersion No When specified with a watch call, showschanges that occur after that particularversion of a resource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-412.

响应示例:

● 1.15及之后集群版本示例{ "kind":"PersistentVolumeClaimList", "apiVersion":"v1", "metadata":{ "selfLink":"/api/v1/persistentvolumeclaims", "resourceVersion":"2306215" }, "items":[ { "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":{

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 638

Page 649: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"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": "PersistentVolumeClaimList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/persistentvolumeclaims", "resourceVersion": "4199767" }, "items": [ { "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-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "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" ],

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 639

Page 650: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"capacity": { "storage": "10Gi" } } }, { "metadata": { "name": "db-mysql-0", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "f6585eb2-8cdd-11e8-a538-fa163e082286", "resourceVersion": "4198033", "creationTimestamp": "2018-07-21T12:02:38Z", "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "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": "5Gi" } }, "volumeName": "pvc-f6585eb2-8cdd-11e8-a538-fa163e082286", "volumeNamespace": "default" }, "status": { "phase": "Bound", "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "5Gi" } } } ]}

状态码

表6-415描述API的状态码。

表 6-415 状态码

状态码 描述

200 This operation succeeds, and a groupof PersistentVolumeClaim resourceobjects is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 640

Page 651: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.17.9 更新指定的 PersistentVolumeClaim

功能介绍

该API用于更新PersistentVolumeClaim对象。

其中以下字段支持更新:

● metadata.labels● metadata.generateName

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

表6-416 描述该API的参数。

表 6-416 参数描述

参数 是否必选 描述

name Yes Name of the PersistentVolumeClaim.

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json{ "metadata": { "labels": { "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a", "app":"mysql" } }}

响应消息

响应参数:

响应参数的详细描述请参见表6-388.

响应示例:

● 1.15及之后集群版本示例:{ "kind":"PersistentVolumeClaim",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 641

Page 652: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"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-0", "namespace": "default", "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/db-mysql-0", "uid": "9d070d77-8ce1-11e8-8ee0-fa163e49263c", "resourceVersion": "4202924", "creationTimestamp": "2018-07-21T12:28:46Z", "labels": { "app": "mysql", "failure-domain.beta.kubernetes.io/region": "cn-north-1", "failure-domain.beta.kubernetes.io/zone": "cn-north-1a" }, "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": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 642

Page 653: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"accessModes": [ "ReadWriteMany" ], "resources": { "requests": { "storage": "5Gi" } }, "volumeName": "pvc-9d070d77-8ce1-11e8-8ee0-fa163e49263c", "volumeNamespace": "default" }, "status": { "phase": "Bound", "accessModes": [ "ReadWriteMany" ], "capacity": { "storage": "5Gi" } }}

状态码

表6-417描述API的状态码。

表 6-417 状态码

状态码 描述

200 This operation succeeds, and aPersistentVolumeClaim resource objectis returned.

异常状态码请参见9.3 状态码。

6.18 ConfigMap

6.18.1 创建 ConfigMap

功能介绍

This API is used to create a Node Node resource object.

URIPOST /api/v1/namespaces/{namespace}/configmaps

表6-418描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 643

Page 654: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-418 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

请求消息

请求参数:

请求参数如表6-419所示。

表 6-419 请求参数

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind Yes String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated.

metadata Yes metadataobject

Standard list metadata.

data Yes Object Data contains the configurationdata. Each key must consist ofalphanumeric characters, '-', '_'or '.'.

请求示例:

{ "apiVersion": "v1", "data": { "property_1": "test" }, "kind": "ConfigMap", "metadata": { "name": "test-12130306" }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 644

Page 655: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表6-419。

响应示例:

{ "kind": "ConfigMap", "apiVersion": "v1", "metadata": { "name": "test-12130306", "namespace": "ns-12130306-s", "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps/test-12130306", "uid": "efd6d9e0-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419081", "creationTimestamp": "2017-12-13T03:15:57Z", "enable": true }, "data": { "property_1": "test" }}

状态码

表6-420描述API的状态码。

表 6-420 状态码

状态码 描述

201 The request has been fulfilled,resulting in the creation of a newresource.

异常状态码请参见9.3 状态码。

6.18.2 删除 ConfigMap

功能介绍

This API is used to delete a ConfigMap.

URIDELETE /api/v1/namespaces/{namespace}/configmaps/{name}

表6-421描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 645

Page 656: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-421 参数解释

参数 是否必选 描述

pretty No If 'true', then the output is prettyprinted.

name Yes name of the ConfigMap

namespace Yes object name and auth scope, suchas for teams and projects

gracePeriodSeconds No The duration in seconds beforethe object should be deleted.Value must be a non-negativeinteger. The value zero indicatesdelete immediately. If this value isnil, the default grace period forthe specified type will be used.Defaults to a per object value ifnot specified. zero means deleteimmediately.

orphanDependents No Deprecated: Use thePropagationPolicy. This field willbe deprecated in 1.7. Should thedependent objects be orphaned. Iftrue/false, the "orphan" finalizerwill be added to/removed fromthe object's finalizers list. Eitherthis field or PropagationPolicymay be set, but not both.

propagationPolicy No Whether and how garbagecollection will be performed.Either this field orOrphanDependents may be set,but not both. The default policy isdecided by the existing finalizerset in the metadata.finalizers andthe resource-specific defaultpolicy.

请求消息

请求参数:

请求参数如表6-422所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 646

Page 657: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-422 参数解释

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this object represents.Servers may infer this fromthe endpoint the clientsubmits requests to. Cannotbe updated. In CamelCase.The value of this parameter isDeleteOptions.

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

gracePeriodSeconds

No Integer The duration in secondsbefore the object should bedeleted. Value must be a non-negative integer. The valuezero indicates deleteimmediately. If this value isnil, the default grace periodfor the specified type will beused. Defaults to a per objectvalue if not specified. zeromeans delete immediately.Value range of this parameter:> 0.

preconditions No preconditions object

Must be fulfilled before adeletion is carried out. If notpossible, a 409 Conflict statuswill be returned.

orphanDependents

No Boolean Should the dependent objectsbe orphaned. If true/false, the"orphan" finalizer will beadded to/removed from theobject's finalizers list.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 647

Page 658: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

propagationPolicy

No String Whether and how garbagecollection will be performed.Either this field orOrphanDependents may beset, but not both. The defaultpolicy is decided by theexisting finalizer set in themetadata.finalizers and theresource-specific defaultpolicy.

表 6-423 preconditions 字段数据结构说明

参数 是否必选 参数类型 描述

uid No String Specifies the target UID.

请求示例:

{ "kind": "DeleteOptions", "apiVersion": "v1", "gracePeriodSeconds": 0}

响应消息

响应参数:

响应参数的详细描述请参见表6-443。

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "details": { "name": "test-12130306", "kind": "configmaps", "uid": "efd6d9e0-dfb3-11e7-9c19-fa163e2d897b" }, "code": 200}

状态码

表6-424描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 648

Page 659: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-424 状态码

状态码 描述

200 Delete a ConfigMap resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.18.3 删除所有的 ConfigMap

功能介绍

This API is used to delete collection of ConfigMap.

URI

DELETE /api/v1/namespaces/{namespace}/configmaps

表6-425描述该API的参数。

表 6-425 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

continue No The continue option should be set whenretrieving more results from the server. Since thisvalue is server defined, clients may only use thecontinue value from a previous query result withidentical query parameters (except for the valueof continue) and the server may reject a continuevalue it does not recognize. If the specifiedcontinue value is no longer valid whether due toexpiration (generally five to fifteen minutes) or aconfiguration change on the server the serverwill respond with a 410 ResourceExpired errorindicating the client must restart their listwithout the continue field. This field is notsupported when watch is true. Clients may starta watch from the last resourceVersion valuereturned by the server and not miss anymodifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 649

Page 660: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

includeUninitialized

No If true, partially initialized resources are includedin the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer than therequested amount of items (up to zero items) inthe event all requested objects are filtered outand clients should only use the presence of thecontinue field to determine whether more resultsare available. Servers may choose not to supportthe limit argument and will return all of theavailable results. If limit is specified and thecontinue field is empty, clients may assume thatno more results are available. This field is notsupported if watch is true. The server guaranteesthat the objects returned when using continuewill be identical to issuing a single list callwithout a limit - that is, no objects created,modified, or deleted after the first request isissued will be included in any subsequentcontinued requests. This is sometimes referred toas a consistent snapshot, and ensures that aclient that is using limit to receive smaller chunksof a very large result can ensure they see allpossible objects. If objects are updated during achunked list the version of the object that waspresent at the time the first list result wascalculated is returned.

resourceVersion No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history. When specified for list: - if unset, thenthe result is returned from remote storage basedon quorum-read flag; - if it's 0, then we simplyreturn what we currently have in cache, noguarantee; - if set to non zero, then the result isat least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update, andremove notifications. Specify resourceVersion.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 650

Page 661: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表6-419。

响应示例:

{ "kind": "ConfigMapList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps", "resourceVersion": "419144" }, "items": []}

状态码

表6-426描述API的状态码。

表 6-426 状态码

状态码 描述

200 Delete a ConfigMap resource objectsuccessfully.

异常状态码请参见9.3 状态码。

6.18.4 获取指定的 ConfigMap

功能介绍

This API is used to read the specified ConfigMap.

URI

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

表6-427描述该API的参数。

表 6-427 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 651

Page 662: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Pod.

exact No Should the export be exact.Exact export maintainscluster-specific fields like'Namespace'.

export No Should this value beexported. Export stripsfields that a user cannotspecify.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-81。

响应示例:

{ "kind": "ConfigMap", "apiVersion": "v1", "metadata": { "name": "test-12130306", "namespace": "ns-12130306-s", "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps/test-12130306", "uid": "efd6d9e0-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419141", "creationTimestamp": "2017-12-13T03:15:57Z", "enable": true }, "data": { "property_1": "new" }}

状态码

表6-428描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 652

Page 663: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-428 状态码

状态码 描述

200 This operation succeeds, and aConfigMap resource object is returned.

异常状态码请参见9.3 状态码。

6.18.5 替换指定 ConfigMap

功能介绍

This API is used to replace the specified ConfigMap.

The following fields can be updated:

● metadata.selfLink● metadata.resourceVersion● metadata.generation● metadata.creationTimestamp● metadata.deletionTimestamp● metadata.labels● metadata.generateName● metadata.annotations● data.value

URIPUT /api/v1/namespaces/{namespace}/configmaps/{name}

表6-429描述该API的参数。

表 6-429 参数解释

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

name Yes name of the ConfigMap

namespace Yes object name and authscope, such as for teamsand projects

请求消息

请求参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 653

Page 664: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求参数的详细描述请参见表6-419。

请求示例:

{ "kind": "ConfigMap", "apiVersion": "v1", "metadata": { "name": "test-12130306", "namespace": "ns-12130306-s", "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps/test-12130306", "uid": "efd6d9e0-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419141", "creationTimestamp": "2017-12-13T03:15:57Z", "enable": true }, "data": { "property_1": "new1" }}

响应消息

响应参数:

响应参数的详细描述请参见表6-419。

响应示例:

{ "kind": "ConfigMap", "apiVersion": "v1", "metadata": { "name": "test-12130306", "namespace": "ns-12130306-s", "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps/test-12130306", "uid": "efd6d9e0-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419143", "creationTimestamp": "2017-12-13T03:15:57Z", "enable": true }, "data": { "property_1": "new1" }}

状态码

表6-430描述API的状态码。

表 6-430 状态码

状态码 描述

200 This operation succeeds, and aConfigMap resource object is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 654

Page 665: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.18.6 列出指定 Namespace 下的 ConfigMap

功能介绍

This API is used to list all ConfigMap resource objects under a specifiedNamespace.

URI

GET /api/v1/namespaces/{namespace}/configmaps

表6-431描述该API的参数。

表 6-431 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by their labels.Defaults to everything.

fieldSelector No A selector to restrict the list ofreturned objects by their fields.Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults to changesfrom the beginning of history.

timeoutSeconds No Timeout for the list/watch call.

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

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 655

Page 666: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "ConfigMapList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps", "resourceVersion": "419140" }, "items": [ { "metadata": { "name": "test-12130306", "namespace": "ns-12130306-s", "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps/test-12130306", "uid": "efd6d9e0-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419081", "creationTimestamp": "2017-12-13T03:15:57Z", "enable": true }, "data": { "property_1": "test" } } ]}

状态码

表6-432描述API的状态码。

表 6-432 状态码

状态码 描述

200 This operation succeeds, and a groupof ConfigMap resource objects isreturned.

异常状态码请参见9.3 状态码。

6.18.7 列出指定的 ConfigMap

功能介绍

This API is used to obtain a ConfigMap list.

URIGET /api/v1/configmaps

表6-433描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 656

Page 667: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-433 参数解释

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

labelSelector No A selector to restrict the list ofreturned objects by theirlabels. Defaults to everything.

includeUninitialized No If true, partially initializedresources are included in theresponse.

fieldSelector No A selector to restrict the list ofreturned objects by theirfields. Defaults to everything.

watch No Watch for changes to thedescribed resources and returnthem as a stream of add,update, and removenotifications. SpecifyresourceVersion.

resourceVersion No When specified with a watchcall, shows changes that occurafter that particular version ofa resource. Defaults tochanges from the beginning ofhistory.

timeoutSeconds No Timeout for the list/watch call.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见表7-82。

响应示例:

{ "kind": "ConfigMapList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/configmaps", "resourceVersion": "419140" }, "items": [ { "metadata": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 657

Page 668: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"name": "cluster-versions", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/configmaps/cluster-versions", "uid": "89dff34e-dc8e-11e7-9c19-fa163e2d897b", "resourceVersion": "19743", "creationTimestamp": "2017-12-09T03:10:41Z", "enable": true }, "data": { "192.168.0.197": "v1.7.3-r13", "192.168.0.200": "v1.7.3-r13", "master": "v1.7.3-r13" } }, { "metadata": { "name": "extension-apiserver-authentication", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/configmaps/extension-apiserver-authentication", "uid": "842ce75c-dc8e-11e7-9c19-fa163e2d897b", "resourceVersion": "69", "creationTimestamp": "2017-12-09T03:10:31Z", "enable": true }, "data": { "client-ca-file": "" } }, { "metadata": { "name": "kube-dns", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/configmaps/kube-dns", "uid": "86f45cfb-dc8e-11e7-9c19-fa163e2d897b", "resourceVersion": "80", "creationTimestamp": "2017-12-09T03:10:36Z", "labels": { "addonmanager.kubernetes.io/mode": "EnsureExists" }, "enable": true } }, { "metadata": { "name": "cm-12130306", "namespace": "ns-12130306-s", "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps/cm-12130306", "uid": "efd6d9e0-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419081", "creationTimestamp": "2017-12-13T03:15:57Z", "enable": true }, "data": { "property_1": "cm-test" } } ]}

状态码

表6-434描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 658

Page 669: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-434 状态码

状态码 描述

200 This operation succeeds, and theJSONs of a group of ConfigMapobjects are returned.

异常状态码请参见9.3 状态码。

6.18.8 更新指定的 ConfigMap

功能介绍

This API is used to update the specified ConfigMap.

The following fields can be updated:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.clusterName

● metadata.generateName

● metadata.annotations

● spec.replicas

● spec.restartPolicy

● spec.activeDeadlineSeconds

URI

PATCH /api/v1/namespaces/{namespace}/configmaps/{name}

表6-435描述该API的参数。

表 6-435 参数解释

参数 是否必选 描述

name Yes name of the Job

namespace Yes object name and auth scope, such as for teamsand projects

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 659

Page 670: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

请求参数:

“Content-Type”消息头说明请参见9.1 PATCH请求方法操作说明。

请求示例:

Content-Type: application/merge-patch+json{ "data": { "property_1": "new" }}

响应消息

响应参数:

响应参数的详细描述请参见表6-419。

响应示例:

{ "kind": "ConfigMap", "apiVersion": "v1", "metadata": { "name": "test-12130306", "namespace": "ns-12130306-s", "selfLink": "/api/v1/namespaces/ns-12130306-s/configmaps/test-12130306", "uid": "efd6d9e0-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "419141", "creationTimestamp": "2017-12-13T03:15:57Z", "enable": true }, "data": { "property_1": "new" }}

状态码

表6-436描述API的状态码。

表 6-436 状态码

状态码 描述

200 This operation succeeds, and aConfigMap resource object is returned.

异常状态码请参见9.3 状态码。

6.19 Secret

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 660

Page 671: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.19.1 创建 Secret

功能介绍

该API用于创建Secret资源类型,Secret解决了密码、token、密钥等敏感数据的配置问题,而不需要把这些敏感数据暴露到镜像或者Pod Spec中。Secret可以以Volume或者环境变量的方式使用。

Secret有主要有四种类型:

● kubernetes.io/service-account-token :用来访问Kubernetes API,由Kubernetes自动创建,并且会自动挂载到Pod的/run/secrets/kubernetes.io/serviceaccount目录中;

● opaque :base64编码格式的Secret,用来存储密码、密钥等;

● kubernetes.io/dockerconfigjson :用来存储私有docker registry的认证信息。

URI

POST /api/v1/namespaces/{namespace}/secrets

表6-437 描述该API的参数。

表 6-437 参数描述

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teams andprojects.

请求消息

请求参数:

请求参数如表6-438所示。

表 6-438 参数描述

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isSecret.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 661

Page 672: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

metadata Yes metadataobject

-

data No Object Data contains the secret data.Each key must be a validDNS_SUBDOMAIN or leadingdot followed by validDNS_SUBDOMAIN. Theserialized form of the secretdata is a base64 encodedstring, representing thearbitrary (possibly non-string)data value here.

type No String Used to facilitateprogrammatic handling ofsecret data.The primitive k8s supports thefollowing secret types:● kubernetes.io/service-

account-token● kubernetes.io/.dockercfg● kubernetes.io/.dockerconfig

json● kubernetes.io/basic-auth● kubernetes.io/ssh-auth● kubernetes.io/tls

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 662

Page 673: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-439 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

name Yes String Name must be unique withina namespace. Is requiredwhen creating resources,although some resources mayallow a client to request thegeneration of an appropriatename automatically. Name isprimarily intended forcreation idempotence andconfiguration definition.The name must be 0 to 253characters in length.The string must comply withregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 663

Page 674: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

generateName No String GenerateName is an optionalprefix, used by the server, togenerate a unique nameONLY IF the Name field hasnot been provided. If this fieldis used, the name returned tothe client will be differentthan the name passed. Thisvalue will also be combinedwith a unique suffix. Theprovided value has the samevalidation rules as the Namefield, and may be truncatedby the length of the suffixrequired to make the valueunique on the server.If this field is specified andthe generated name exists,the server will NOT return a409 - instead, it will eitherreturn 201 Created or 500with Reason ServerTimeoutindicating a unique namecould not be found in thetime allotted, and the clientshould retry (optionally afterthe time indicated in theRetry-After header).Applied only if Name is notspecified.Value length: 0 character <String length ≤ 253characters.The string must comply withregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 664

Page 675: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

namespace No String Namespace defines the spacewithin each name must beunique. An empty namespaceis equivalent to the "default"namespace, but "default" isthe canonical representation.Not all objects are required tobe scoped to a namespace -the value of this field forthose objects will be empty.Must be a DNS_LABEL.Cannot be updated.Value length: 0 character <String length ≤ 253characters.The string must comply withregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

selfLink No String SelfLink is a URL representingthis object. Populated by thesystem. Read-only.说明

This parameter is automaticallygenerated. Do not assign valuesto this parameter. Otherwise, theAPI fails to be called.

uid No String UID is the unique in time andspace value for this object. Itis typically generated by theserver on successful creationof a resource and is notallowed to change on PUToperations. Populated by thesystem. Read-only.说明

This parameter is automaticallygenerated. Do not assign valuesto this parameter. Otherwise, theAPI fails to be called.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 665

Page 676: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

resourceVersion No String An opaque value thatrepresents the internal versionof this object that can be usedby clients to determine whenobjects have changed. May beused for optimisticconcurrency, changedetection, and the watchoperation on a resource or setof resources. Clients musttreat these values as opaqueand passed unmodified backto the server. They may onlybe valid for a particularresource or set of resources.Populated by the system.Read-only. Value must betreated as opaque by clients.说明

This parameter is automaticallygenerated. Do not assign valuesto this parameter. Otherwise, theAPI fails to be called.

generation No Integer A sequence numberrepresenting a specificgeneration of the desiredstate. Currently onlyimplemented by replicationcontrollers. Populated by thesystem. Read-only.

creationTimestamp

No String CreationTimestamp is atimestamp representing theserver time when this objectwas created. It is notguaranteed to be set inhappens-before order acrossseparate operations. Clientsmay not set this value. It isrepresented in RFC3339 formand is in UTC. Populated bythe system. Read-only. Nullfor lists.说明

This parameter is automaticallygenerated. Do not assign valuesto this parameter. Otherwise, theAPI fails to be called.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 666

Page 677: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionTimestamp

No String DeletionTimestamp is RFC3339 date and time at whichthis resource will be deleted.This field is set by the serverwhen a graceful deletion isrequested by the user, and isnot directly settable by aclient. The resource will bedeleted (no longer visiblefrom resource lists, and notreachable by name) after thetime in this field. Once set,this value may not be unsetor be set further into thefuture, although it may beshortened or the resourcemay be deleted prior to thistime. For example, a user mayrequest that a pod is deletedin 30 seconds. The Kubeletwill react by sending agraceful termination signal tothe containers in the pod.Once the resource is deletedin the API, the Kubelet willsend a hard terminationsignal to the container. If notset, graceful deletion of theobject has not beenrequested. Populated by thesystem when a gracefuldeletion is requested. Read-only.

deletionGracePeriodSeconds

No Integer Number of seconds allowedfor this object to gracefullyterminate before it will beremoved from the system.Only set whendeletionTimestamp is also set.May only be shortened. Read-only.

labels No Object Map of string keys and valuesthat can be used to organizeand categorize (scope andselect) objects. May matchselectors of replicationcontrollers and services.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 667

Page 678: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

Annotations No Object Annotations is anunstructured key value mapstored with a resource thatmay be set by external toolsto store and retrieve arbitrarymetadata. They are notqueryable and should bepreserved when modifyingobjects.

ownerReferences

No ownerReferences object

List of objects depended bythis object. If ALL objects inthe list have been deleted,this object will be garbagecollected. If this object ismanaged by a controller, thenan entry in this list will pointto this controller, with thecontroller field set to true.There cannot be more thanone managing controller.

finalizers No Array ofstrings

Must be empty before theobject is deleted from theregistry. Each entry is anidentifier for the responsiblecomponent that will removethe entry from the list. If thedeletionTimestamp of theobject is non-nil, entries inthis list can only be removed.

表 6-440 ownerReferences 字段数据结构说明

参数 是否必选 参数类型 描述

apiVersion No String API version of the referent.

kind No String Kind of the referent.

name No String Name of the referent.

uid No String UID of the referent.

controller No Boolean If true, this reference points tothe managing controller.

请求示例:{ "apiVersion": "v1",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 668

Page 679: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"kind": "Secret", "metadata": { "name": "mysecret" }, "type": "Opaque", "data": { "password": "******", #需要用Base64编码,方法:echo -n "待编码内容" | base64 "username": "*****" #需要用Base64编码,方法:echo -n "待编码内容" | base64 }}

响应消息

响应参数:

响应参数的详细描述请参见表6-438。

响应示例:

{ "kind": "Secret", "apiVersion": "v1", "metadata": { "name": "mysecret", "namespace": "default", "selfLink": "/api/v1/namespaces/default/secrets/mysecret", "uid": "597c306b-594e-11e6-b444-286ed488fafe", "resourceVersion": "10742", "creationTimestamp": "2016-08-03T07:46:12Z" }, "data": { "password": "******", "username": "*****" }, "type": "Opaque" }

状态码

表6-441描述API的状态码。

表 6-441 状态码

状态码 描述

201 This operation succeeds, and a secretresource object is returned.

异常状态码请参见9.3 状态码。

6.19.2 删除 Secret

功能介绍

该API用于删除指定Namespace下的Secret对象。

URIDELETE /api/v1/namespaces/{namespace}/secrets/{name}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 669

Page 680: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表6-442 描述该API的参数。

表 6-442 参数描述

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

name Yes Name of the Secret.

请求消息

请求参数:

请求参数如表6-443所示。

表 6-443 参数描述

参数 是否必选 参数类型 描述

kind Yes String Kind is a string valuerepresenting the RESTresource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isDeleteOptions.

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 670

Page 681: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

gracePeriodSeconds

No Integer The duration in secondsbefore the object should bedeleted. Value must be non-negative integer. The valuezero indicates deleteimmediately. If this value isnil, the default grace periodfor the specified type will beused. Defaults to a per objectvalue if not specified. zeromeans delete immediately.Value range of thisparameter: > 0.

preconditions No preconditions object

Must be fulfilled before adeletion is carried out. If notpossible, a 409 Conflict statuswill be returned.

orphanDependents

No Boolean Should the dependent objectsbe orphaned. If true/false, the"orphan" finalizer will beadded to/removed from theobject's finalizers list.

表 6-444 preconditions 字段数据结构说明

参数 是否必选 参数类型 描述

uid No String Specifies the target UID.

请求示例:

{ "kind": "DeleteOptions", "apiVersion": "v1", "gracePeriodSeconds": 10 }

响应消息

响应参数:

响应参数如表6-445所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 671

Page 682: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-445 参数描述

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

metadata metadata object -

status String Status of the operation. One of:"Success" or "Failure".

message String A human-readable description ofthe status of this operation.

reason String A machine-readable description ofwhy this operation is in the"Failure" status. If this value isempty there is no informationavailable. A Reason clarifies anHTTP status code but does notoverride it.

details details object -

code Integer Suggested HTTP return code forthis status, 0 if not set.

表 6-446 metadata 字段数据结构说明

参数 参数类型 描述

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 672

Page 683: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treated asopaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

表 6-447 details 字段数据结构说明

参数 参数类型 描述

name String The name attribute of theresource associated with thestatus StatusReason (when thereis a single name which can bedescribed).

kind String The kind attribute of the resourceassociated with the statusStatusReason. On some operationsmay differ from the requestedresource Kind.

causes causes -

retryAfterSeconds Integer If specified, the time in secondsbefore the operation should beretried.

uid String UID of the resource. (when thereis a single resource which can bedescribed).

group String The group attribute of theresource associated with thestatus StatusReason.

表 6-448 causes 字段数据结构说明

参数 参数类型 描述

reason String A machine-readable description ofthe cause of the error. If this valueis empty there is no informationavailable.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 673

Page 684: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

message String A human-readable description ofthe cause of the error. This fieldmay be presented as-is to areader.

field String The field of the resource that hascaused this error, as named by itsJSON serialization. May includedot and postfix notation fornested attributes. Arrays are zero-indexed. Fields may appear morethan once in an array of causesdue to fields having multipleerrors.

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Success", "code": 200 }

状态码

表6-449描述API的状态码。

表 6-449 状态码

状态码 描述

200 Delete a secret resource objectresuccessfully.

异常状态码请参见9.3 状态码。

6.19.3 删除所有的 Secret

功能介绍

该API用来批量删除Secret。

URI

DELETE /api/v1/namespaces/{namespace}/secrets

表6-450描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 674

Page 685: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-450 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects

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

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

RequestN/A

响应消息

Response parameters:

响应参数的详细描述请参见表6-438

Example response:

{ "kind": "SecretList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/delns-12130306/secrets", "resourceVersion": "419248" }, "items": [ { "metadata": { "name": "default-token-zx6gk",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 675

Page 686: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"namespace": "delns-12130306", "selfLink": "/api/v1/namespaces/delns-12130306/secrets/default-token-zx6gk", "uid": "025df020-dfb4-11e7-9c19-fa163e2d897b", "resourceVersion": "419149", "creationTimestamp": "2017-12-13T03:16:28Z", "annotations": { "generator": "JWT", "kubernetes.io/service-account.name": "default", "kubernetes.io/service-account.uid": "025c1f6e-dfb4-11e7-9c19-fa163e2d897b" }, "enable": true }, "data": { "ca.crt": "", "namespace": "ZGVsbnMtMTIxMzAzMDY=", "token": "" }, "type": "kubernetes.io/service-account-token" }, { "metadata": { "name": "st-del-12130306", "namespace": "delns-12130306", "selfLink": "/api/v1/namespaces/delns-12130306/secrets/st-del-12130306", "uid": "14975399-dfb4-11e7-9c19-fa163e2d897b", "resourceVersion": "419248", "creationTimestamp": "2017-12-13T03:16:59Z", "enable": true }, "data": { ".dockerconfigjson": "" }, "type": "kubernetes.io/dockerconfigjson" } ]}

状态码

表6-451描述API的状态码。

表 6-451 状态码

状态码 描述

200 批量删除secrets成功。

异常状态码请参见9.3 状态码。

6.19.4 获取 Secret 信息

功能介绍

该API用于获取指定Secret的详细信息。

URIGET /api/v1/namespaces/{namespace}/secrets/{name}

表6-452 描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 676

Page 687: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-452 参数描述

参数 是否必选 描述

pretty No If 'true', then the output ispretty printed.

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

name Yes Name of the Secret.

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 usercan not specify.

请求消息

N/A

响应消息

响应参数:

响应参数如表6-453所示。

表 6-453 参数描述

参数 类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

metadata metadata object -

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 677

Page 688: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 类型 描述

data Object ata contains the secret data. Eachkey must be a validDNS_SUBDOMAIN or leading dotfollowed by validDNS_SUBDOMAIN. The serializedform of the secret data is a base64encoded string, representing thearbitrary (possibly non-string)data value here.

type String Used to facilitate programmatichandling of secret data.

表 6-454 metadata 字段数据结构说明

参数 类型 描述

name String Name must be unique within anamespace. Is required whencreating resources, although someresources may allow a client torequest the generation of anappropriate name automatically.Name is primarily intended forcreation idempotence andconfiguration definition. Cannotbe updated.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 678

Page 689: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 类型 描述

generateName String GenerateName is an optionalprefix, used by the server, togenerate a unique name ONLY IFthe Name field has not beenprovided. If this field is used, thename returned to the client will bedifferent than the name passed.This value will also be combinedwith a unique suffix. The providedvalue has the same validationrules as the Name field, and maybe truncated by the length of thesuffix required to make the valueunique on the server.If this field is specified and thegenerated name exists, the serverwill NOT return a 409 - instead, itwill either return 201 Created or500 with Reason ServerTimeoutindicating a unique name couldnot be found in the time allotted,and the client should retry(optionally after the timeindicated in the Retry-Afterheader).Applied only if Name is notspecified.

namespace String Namespace defines the spacewithin each name must be unique.An empty namespace is equivalentto the "default" namespace, but"default" is the canonicalrepresentation. Not all objects arerequired to be scoped to anamespace - the value of this fieldfor those objects will be empty.Must be a DNS_LABEL. Cannot beupdated.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 679

Page 690: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 类型 描述

uid String UID is the unique in time andspace value for this object. It istypically generated by the serveron successful creation of aresource and is not allowed tochange on PUT operations.Populated by the system. Read-only.

resourceVersion String An opaque value that representsthe internal version of this objectthat can be used by clients todetermine when objects havechanged. May be used foroptimistic concurrency, changedetection, and the watchoperation on a resource or set ofresources. Clients must treat thesevalues as opaque and passedunmodified back to the server.They may only be valid for aparticular resource or set ofresources. Populated by thesystem. Read-only. Value must betreated as opaque by clients.

generation Integer A sequence number representing aspecific generation of the desiredstate. Currently only implementedby replication controllers.Populated by the system. Read-only.

creationTimestamp

String CreationTimestamp is atimestamp representing the servertime when this object was created.It is not guaranteed to be set inhappens-before order acrossseparate operations. Clients maynot set this value. It is representedin RFC3339 form and is in UTC.Populated by the system. Read-only. Null for lists.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 680

Page 691: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 类型 描述

deletionTimestamp

String DeletionTimestamp is RFC 3339date and time at which thisresource will be deleted. This fieldis set by the server when agraceful deletion is requested bythe user, and is not directlysettable by a client. The resourcewill be deleted (no longer visiblefrom resource lists, and notreachable by name) after the timein this field. Once set, this valuemay not be unset or be set furtherinto the future, although it may beshortened or the resource may bedeleted prior to this time. Forexample, a user may request thata pod is deleted in 30 seconds.The Kubelet will react by sendinga graceful termination signal tothe containers in the pod. Oncethe resource is deleted in the API,the Kubelet will send a hardtermination signal to thecontainer. If not set, gracefuldeletion of the object has notbeen requested. Populated by thesystem when a graceful deletion isrequested. Read-only.

deletionGracePeriodSeconds

Integer Number of seconds allowed forthis object to gracefully terminatebefore it will be removed from thesystem. Only set whendeletionTimestamp is also set.May only be shortened. Read-only.

labels Object Map of string keys and values thatcan be used to organize andcategorize (scope and select)objects. May match selectors ofreplication controllers andservices.

Annotations Object Annotations is an unstructured keyvalue map stored with a resourcethat may be set by external toolsto store and retrieve arbitrarymetadata. They are not queryableand should be preserved whenmodifying objects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 681

Page 692: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 类型 描述

ownerReferences ownerReferencesobject

List of objects depended by thisobject. If ALL objects in the listhave been deleted, this object willbe garbage collected. If this objectis managed by a controller, thenan entry in this list will point tothis controller, with the controllerfield set to true. There cannot bemore than one managingcontroller.

finalizers Array of strings Must be empty before the objectis deleted from the registry. Eachentry is an identifier for theresponsible component that willremove the entry from the list. Ifthe deletionTimestamp of theobject is non-nil, entries in this listcan only be removed.

表 6-455 ownerReferences 字段数据结构说明

参数 参数类型 描述

apiVersion String API version of the referent.

kind String Kind of the referent.

name String Name of the referent.

uid String UID of the referent.

controller Boolean If true, this reference points to themanaging controller.

响应示例:

{ "kind": "Secret", "apiVersion": "v1", "metadata": { "name": "mysecret", "namespace": "default", "selfLink": "/api/v1/namespaces/default/secrets/mysecret", "uid": "597c306b-594e-11e6-b444-286ed488fafe", "resourceVersion": "10742", "creationTimestamp": "2016-08-03T07:46:12Z" }, "data": { "password": "******", "username": "*****" }, "type": "Opaque" }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 682

Page 693: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-456描述API的状态码。

表 6-456 状态码

状态码 描述

200 接口调用成功,返回查询的secret资源对象。

异常状态码请参见9.3 状态码。

6.19.5 替换指定的 Secret

功能介绍

该API用于替换指定Namespace下的Secret对象。

其中以下字段支持更新:

● metadata.selfLink

● metadata.resourceVersion

● metadata.generation

● metadata.creationTimestamp

● metadata.deletionTimestamp

● metadata.labels

● metadata.clusterName

● metadata.generateName

● metadata.annotations

说明

● 当“type”的值为“Opaque”时,“data”的“key”和“value”都可以更新。

● 当“type”的值不为“Opaque”时,“data”的“value”可以更新。

URI

PUT /api/v1/namespaces/{namespace}/secrets/{name}

表6-457 描述该API的参数。

表 6-457 参数描述

参数 是否必选 描述

pretty No If 'true', then the outputis pretty printed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 683

Page 694: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

namespace Yes Object name and authscope, such as for teamsand projects.

name Yes Name of the Secret.

请求消息

请求参数:

请求参数的详细描述请参见表6-438。

请求示例:

{ "apiVersion": "v1", "kind": "Secret", "metadata": { "name": "mysecret" }, "type": "Opaque", "data": { "password": "******", #需要用Base64编码,方法:echo -n "待编码内容" | base64 "username": "*****" #需要用Base64编码,方法:echo -n "待编码内容" | base64 } }

响应消息

响应参数:

响应参数的详细描述请参见表6-438。

响应示例:

{ "kind": "Secret", "apiVersion": "v1", "metadata": { "name": "mysecret", "namespace": "ns-12130306-s", "selfLink": "/api/v1/namespaces/ns-12130306-s/secrets/mysecret", "uid": "0bbfb314-dfb3-11e7-9c19-fa163e2d897b", "resourceVersion": "418375", "creationTimestamp": "2017-12-13T03:09:34Z", "enable": true }, "data": { "password": "******", "username": "*****" }, "type": "Opaque", "httpcode": 200, "header": { "X-Frame-Options": "SAMEORIGIN", "Strict-Transport-Security": "max-age=31536000; includeSubdomains;", "Server": "Web Server", "X-Router-Status": "fresh,upstream return 200", "X-Content-Type-Options": "nosniff", "Connection": "keep-alive", "X-Download-Options": "noopen",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 684

Page 695: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"Set-Cookie": "******; Expires=Thu, 14-Dec-17 03:09:34 GMT; Domain=192.168.50.250; Path=/; Secure; HttpOnly", "Content-Length": "364", "X-XSS-Protection": "1; mode=block;", "Date": "Wed, 13 Dec 2017 03:09:34 GMT", "Content-Type": "application/json" }}

状态码

表6-458描述API的状态码。

表 6-458 状态码

状态码 描述

200 操作成功,返回更新后的secret资源对象

异常状态码请参见9.3 状态码。

6.19.6 列出指定 Namespace 下的 Secret

功能介绍

该API用于在指定的Namespace下列出Secret对象。

URIGET /api/v1/namespaces/{namespace}/secrets

表6-459 描述该API的参数。

表 6-459 参数描述

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 685

Page 696: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

resourceVersion No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resources andreturn them as a stream of add, update, andremove notifications. Specify resourceVersion.

请求消息

N/A

响应消息

响应参数:

表 6-460 响应参数

参数 参数类型 描述

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

metadata metadata object Standard list metadata.

items Object List of services.具体请参见表6-438。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 686

Page 697: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-461 metadata 字段数据结构说明

参数 参数类型 描述

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treatedas opaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

响应示例:

{ "kind": "SecretList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/secrets", "resourceVersion": "1810323" }, "items": [ { "metadata": { "name": "default-token-nlckn", "namespace": "default", "selfLink": "/api/v1/namespaces/default/secrets/default-token-nlckn", "uid": "23070e11-1425-11e7-96c7-fa163ec08232", "resourceVersion": "30", "creationTimestamp": "2017-03-29T02:12:19Z", "annotations": { "kubernetes.io/service-account.name": "default", "kubernetes.io/service-account.uid": "2303e59b-1425-11e7-96c7-fa163ec08232" } }, "data": { "ca.crt": "", "namespace": "ZGVmYXVsdA==", "token": "" }, "type": "kubernetes.io/service-account-token" }, { "metadata": { "name": "myregistry", "namespace": "default", "selfLink": "/api/v1/namespaces/default/secrets/myregistry", "uid": "a34ed5e4-1427-11e7-96c7-fa163ec08232", "resourceVersion": "1243", "creationTimestamp": "2017-03-29T02:30:13Z" }, "data": { ".dockercfg": "" }, "type": "kubernetes.io/hwdockercfg" }, {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 687

Page 698: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"metadata": { "name": "paas.elb", "namespace": "default", "selfLink": "/api/v1/namespaces/default/secrets/paas.elb", "uid": "a34df6f3-1427-11e7-96c7-fa163ec08232", "resourceVersion": "1242", "creationTimestamp": "2017-03-29T02:30:13Z" }, "data": { "access.key": "", "secret.key": "" }, "type": "Opaque" } ]}

状态码

表6-462描述API的状态码。

表 6-462 状态码

状态码 描述

200 This operation succeeds, and a secretresource object is returned.

异常状态码请参见9.3 状态码。

6.19.7 列出集群下的 Secret

功能介绍

该API用于列出集群中的所有Secret对象。

URIGET /api/v1/secrets

表6-463 描述该API的参数。

表 6-463 参数描述

参数 是否必选 描述

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources are includedin the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 688

Page 699: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

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

resourceVersion No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resources andreturn them as a stream of add, update, andremove notifications. Specify resourceVersion.

请求消息

N/A

响应消息

响应参数:

表 6-464 响应参数

参数 参数类型 描述

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

metadata metadata object Standard list metadata.

items Object List of services.具体请参见响应消息。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 689

Page 700: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-465 metadata 字段数据结构说明

参数 参数类型 描述

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treatedas opaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

响应示例:

{

"kind": "SecretList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/secrets", "resourceVersion": "1810858" }, "items": [ { "metadata": { "name": "default-token-nlckn", "namespace": "default", "selfLink": "/api/v1/namespaces/default/secrets/default-token-nlckn", "uid": "23070e11-1425-11e7-96c7-fa163ec08232", "resourceVersion": "30", "creationTimestamp": "2017-03-29T02:12:19Z", "annotations": { "kubernetes.io/service-account.name": "default", "kubernetes.io/service-account.uid": "2303e59b-1425-11e7-96c7-fa163ec08232" } }, "data": { "ca.crt": "", "namespace": "ZGVmYXVsdA==", "token": "" }, "type": "kubernetes.io/service-account-token" }, { "metadata": { "name": "myregistry", "namespace": "default", "selfLink": "/api/v1/namespaces/default/secrets/myregistry", "uid": "a34ed5e4-1427-11e7-96c7-fa163ec08232", "resourceVersion": "1243", "creationTimestamp": "2017-03-29T02:30:13Z" }, "data": { ".dockercfg": "" }, "type": "kubernetes.io/hwdockercfg" },

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 690

Page 701: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

{ "metadata": { "name": "paas.elb", "namespace": "default", "selfLink": "/api/v1/namespaces/default/secrets/paas.elb", "uid": "a34df6f3-1427-11e7-96c7-fa163ec08232", "resourceVersion": "1242", "creationTimestamp": "2017-03-29T02:30:13Z" }, "data": { "access.key": "", "secret.key": "" }, "type": "Opaque" }, { "metadata": { "name": "default-token-cptf1", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/secrets/default-token-cptf1", "uid": "23090a90-1425-11e7-96c7-fa163ec08232", "resourceVersion": "32", "creationTimestamp": "2017-03-29T02:12:19Z", "annotations": { "kubernetes.io/service-account.name": "default", "kubernetes.io/service-account.uid": "23046012-1425-11e7-96c7-fa163ec08232" } }, "data": { "ca.crt": "", "namespace": "a3ViZS1zeXN0ZW0=", "token": "" }, "type": "kubernetes.io/service-account-token" }, { "metadata": { "name": "token-kube-proxy", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/secrets/token-kube-proxy", "uid": "23a5f659-1425-11e7-96c7-fa163ec08232", "resourceVersion": "34", "creationTimestamp": "2017-03-29T02:12:20Z" }, "data": { "kubeconfig": "YXBpVmVyc2lvbjogdjEKa2luZDoK" }, "type": "Opaque" }, { "metadata": { "name": "token-kubelet", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/secrets/token-kubelet", "uid": "23b9cf39-1425-11e7-96c7-fa163ec08232", "resourceVersion": "36", "creationTimestamp": "2017-03-29T02:12:20Z" }, "data": { "kubeconfig": "" }, "type": "Opaque" }, { "metadata": { "name": "token-system-controller-manager", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/secrets/token-system-controller-manager", "uid": "23dc783d-1425-11e7-96c7-fa163ec08232",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 691

Page 702: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"resourceVersion": "39", "creationTimestamp": "2017-03-29T02:12:20Z" }, "data": { "kubeconfig": "" }, "type": "Opaque" }, { "metadata": { "name": "token-system-dns", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/secrets/token-system-dns", "uid": "23d31dfb-1425-11e7-96c7-fa163ec08232", "resourceVersion": "38", "creationTimestamp": "2017-03-29T02:12:20Z" }, "data": { "kubeconfig": "" }, "type": "Opaque" }, { "metadata": { "name": "token-system-scheduler", "namespace": "kube-system", "selfLink": "/api/v1/namespaces/kube-system/secrets/token-system-scheduler", "uid": "23c18f3e-1425-11e7-96c7-fa163ec08232", "resourceVersion": "37", "creationTimestamp": "2017-03-29T02:12:20Z" }, "data": { "kubeconfig": "" }, "type": "Opaque" } ] }

状态码

表6-466描述API的状态码。

表 6-466 状态码

状态码 描述

200 操作成功,返回一组secret资源对象。

异常状态码请参见9.3 状态码。

6.20 RBAC集群创建时,集群认证方式需开启“RBAC”或者“认证能力增强”,详见创建虚拟机集群。

6.20.1 ClusterRole

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 692

Page 703: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.20.1.1 创建 ClusterRole

功能介绍

This API is used to create a ClusterRole

URL

POST /apis/rbac.authorization.k8s.io/v1/clusterroles

参数解释描述该API的参数。

表 6-467 参数解释

参数 是否必选 描述

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

body Yes 请参见请求参数。

请求消息

请求参数:

请求参数如请求参数所示。

表 6-468 请求参数

参数 是否必选 参数类型 描述

aggregationRule

No AggregationRule object

AggregationRule is an optionalfield that describes how to buildthe Rules for this ClusterRole. IfAggregationRule is set, then theRules are controller managedand direct changes to Rules willbe stomped by the controller.

apiVersion No String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind No String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated. InCamelCase.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 693

Page 704: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

metadata No metadataobject

Standard object's metadata.

rules No PolicyRuleobject

Rules holds all the PolicyRules forthis ClusterRole

表 6-469 AggregationRule 字段数据结构说明

参数 是否必选 参数类型 描述

clusterRoleSelectors

No Array ofstrings

ClusterRoleSelectors holds a listof selectors which will be used tofind ClusterRoles and create therules. If any of the selectorsmatch, then the ClusterRole'spermissions will be added.

表 6-470 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

annotations No Object Annotations is an unstructuredkey value map stored with aresource that may be set byexternal tools to store andretrieve arbitrary metadata. Theyare not queryable and should bepreserved when modifyingobjects.

clusterName No String The name of the cluster whichthe object belongs to. This isused to distinguish resourceswith same name and namespacein different clusters. This field isnot set anywhere right now andapiserver is going to ignore it ifset in create or update request.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 694

Page 705: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

creationTimestamp

No String CreationTimestamp is atimestamp representing theserver time when this object wascreated. It is not guaranteed tobe set in happens-before orderacross separate operations.Clients may not set this value. Itis represented in RFC3339 formand is in UTC. Populated by thesystem. Read-only. Null for lists.

deletionGracePeriodSeconds

No Integer Number of seconds allowed forthis object to gracefullyterminate before it will beremoved from the system. Onlyset when deletionTimestamp isalso set. May only be shortened.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 695

Page 706: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionTimestamp

No String DeletionTimestamp is RFC 3339date and time at which thisresource will be deleted. Thisfield is set by the server when agraceful deletion is requested bythe user, and is not directlysettable by a client. The resourceis expected to be deleted (nolonger visible from resource lists,and not reachable by name)after the time in this field, oncethe finalizers list is empty. Aslong as the finalizers list containsitems, deletion is blocked. Oncethe deletionTimestamp is set, thisvalue may not be unset or be setfurther into the future, althoughit may be shortened or theresource may be deleted prior tothis time. For example, a usermay request that a pod is deletedin 30 seconds. The Kubelet willreact by sending a gracefultermination signal to thecontainers in the pod. After that30 seconds, the Kubelet will senda hard termination signal(SIGKILL) to the container andafter cleanup, remove the podfrom the API. In the presence ofnetwork partitions, this objectmay still exist after thistimestamp, until an administratoror automated process candetermine the resource is fullyterminated. If not set, gracefuldeletion of the object has notbeen requested. Populated by thesystem when a graceful deletionis requested. Read-only.

finalizers No Array ofstrings

Must be empty before the objectis deleted from the registry. Eachentry is an identifier for theresponsible component that willremove the entry from the list. Ifthe deletionTimestamp of theobject is non-nil, entries in thislist can only be removed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 696

Page 707: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

generateName No String GenerateName is an optionalprefix, used by the server, togenerate a unique name ONLY IFthe Name field has not beenprovided. If this field is used, thename returned to the client willbe different than the namepassed. This value will also becombined with a unique suffix.The provided value has the samevalidation rules as the Namefield, and may be truncated bythe length of the suffix requiredto make the value unique on theserver. If this field is specified andthe generated name exists, theserver will NOT return a 409 -instead, it will either return 201Created or 500 with ReasonServerTimeout indicating aunique name could not be foundin the time allotted, and theclient should retry (optionallyafter the time indicated in theRetry-After header). Applied onlyif Name is not specified.

generation No Integer A sequence number representinga specific generation of thedesired state. Populated by thesystem. Read-only.

initializers No initializersobject

An initializer is a controller whichenforces some system invariantat object creation time. This fieldis a list of initializers that havenot yet acted on this object. If nilor empty, this object has beencompletely initialized. Otherwise,the object is considereduninitialized and is hidden (inlist/watch and get calls) fromclients that haven't explicitlyasked to observe uninitializedobjects. When an object iscreated, the system will populatethis list with the current set ofinitializers. Only privileged usersmay set or modify this list. Onceit is empty, it may not bemodified further by any user.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 697

Page 708: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

labels No Object Map of string keys and valuesthat can be used to organize andcategorize (scope and select)objects. May match selectors ofreplication controllers andservices.

name No String Name must be unique within anamespace. Is required whencreating resources, althoughsome resources may allow aclient to request the generationof an appropriate nameautomatically. Name is primarilyintended for creationidempotence and configurationdefinition. Cannot be updated.

namespace No String Namespace defines the spacewithin each name must beunique. An empty namespace isequivalent to the "default"namespace, but "default" is thecanonical representation. Not allobjects are required to be scopedto a namespace - the value ofthis field for those objects will beempty. Must be a DNS_LABEL.Cannot be updated.

ownerReferences

No Array ofstrings

List of objects depended by thisobject. If ALL objects in the listhave been deleted, this objectwill be garbage collected. If thisobject is managed by a controller,then an entry in this list willpoint to this controller, with thecontroller field set to true. Therecannot be more than onemanaging controller.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 698

Page 709: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

resourceVersion No String An opaque value that representsthe internal version of this objectthat can be used by clients todetermine when objects havechanged. May be used foroptimistic concurrency, changedetection, and the watchoperation on a resource or set ofresources. Clients must treatthese values as opaque andpassed unmodified back to theserver. They may only be valid fora particular resource or set ofresources. Populated by thesystem. Read-only.

selfLink No String SelfLink is a URL representingthis object. Populated by thesystem. Read-only.

uid No String UID is the unique in time andspace value for this object. It istypically generated by the serveron successful creation of aresource and is not allowed tochange on PUT operations.Populated by the system. Read-only.

表 6-471 PolicyRule 字段数据结构说明

参数 是否必选 参数类型 描述

apiGroups No Array ofstrings

APIGroups is the name of theAPIGroup that contains theresources. If multiple API groupsare specified, any actionrequested against one of theenumerated resources in any APIgroup will be allowed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 699

Page 710: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

nonResourceURLs

No Array ofstrings

NonResourceURLs is a set ofpartial urls that a user shouldhave access to. *s are allowed,but only as the full, final step inthe path Since non-resource URLsare not namespaced, this field isonly applicable for ClusterRolesreferenced from aClusterRoleBinding. Rules caneither apply to API resources(such as "pods" or "secrets") ornon-resource URL paths (such as"/api"), but not both.

resourceNames No Array ofstrings

ResourceNames is an optionalwhite list of names that the ruleapplies to. An empty set meansthat everything is allowed.

resources No Array ofstrings

Resources is a list of resourcesthis rule applies to. ResourceAllrepresents all resources.

verbs No Array ofstrings

Verbs is a list of Verbs that applyto ALL the ResourceKinds andAttributeRestrictions contained inthis rule. VerbAll represents allkinds.

请求示例:

{ "kind": "ClusterRole", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { # 鉴于ClusterRole是集群范围对象,所以这里不需要定义"namespace"字段 "name": "secret-reader" }, "rules":[{ "apiGroups": [""], "resources": ["secrets"], "verbs": ["get", "watch", "list"] }]}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "ClusterRole",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 700

Page 711: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "name" : "secret-reader", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterroles/secret-reader", "uid" : "8d358854-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4619", "creationTimestamp" : "2018-11-27T01:55:44Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "secrets" ] }]}

状态码

状态码描述API的状态码。

表 6-472 状态码

状态码 描述

201 Created

200 OK

202 Accepted

6.20.1.2 更新指定的 ClusterRole

功能介绍

This API is used to partially update the specified ClusterRole

URLPATCH /apis/rbac.authorization.k8s.io/v1/clusterroles/{name}

参数解释描述该API的参数。

表 6-473 参数解释

参数 是否必选 描述

name Yes name of the ClusterRole.

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

body Yes -

请求消息

请求参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 701

Page 712: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "kind": "ClusterRole", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "secret-reader", "selfLink": "/apis/rbac.authorization.k8s.io/v1/clusterroles/secret-reader", "uid": "6a044ac2-f213-11e8-b449-fa163ec24e06", "resourceVersion": "44658", "creationTimestamp": "2018-11-27T07:09:43Z" }, "rules": [{ "verbs": ["get","list"], "apiGroups": [""], "resources": ["secrets"] }]}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "ClusterRole", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "secret-reader", "selfLink": "/apis/rbac.authorization.k8s.io/v1/clusterroles/secret-reader", "uid": "c5986470-f2d5-11e8-b449-fa163ec24e06", "resourceVersion": "225014", "creationTimestamp": "2018-11-28T06:20:59Z" }, "rules": [{ "verbs": ["get","list"], "apiGroups": [""], "resources": ["secrets"] }] }

状态码

状态码描述API的状态码。

表 6-474 状态码

状态码 描述

200 OK

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 702

Page 713: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.20.1.3 替换指定的 ClusterRole

功能介绍

This API is used to replace the specified ClusterRole

URLPUT /apis/rbac.authorization.k8s.io/v1/clusterroles/{name}

参数解释描述该API的参数。

表 6-475 参数解释

参数 是否必选 描述

name Yes name of the ClusterRole.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "kind": "ClusterRole", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "secret-reader", "selfLink": "/apis/rbac.authorization.k8s.io/v1/clusterroles/secret-reader", "uid": "6a044ac2-f213-11e8-b449-fa163ec24e06", "resourceVersion": "44658", "creationTimestamp": "2018-11-27T07:09:43Z" }, "rules": [{ "verbs": ["get","watch"], "apiGroups": [""], "resources": ["secrets"] }]}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "ClusterRole",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 703

Page 714: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "secret-reader", "selfLink": "/apis/rbac.authorization.k8s.io/v1/clusterroles/secret-reader", "uid": "c5986470-f2d5-11e8-b449-fa163ec24e06", "resourceVersion": "225013", "creationTimestamp": "2018-11-28T06:20:59Z" }, "rules": [{ "verbs": ["get","watch"], "apiGroups": [""], "resources": ["nodes"] }]}

状态码

状态码描述API的状态码。

表 6-476 状态码

状态码 描述

200 OK

201 Created

6.20.1.4 删除指定的 ClusterRole

功能介绍

This API is used to delete a ClusterRole

URL

DELETE /apis/rbac.authorization.k8s.io/v1/clusterroles/{name}

参数解释描述该API的参数。

表 6-477 参数解释

参数 是否必选 描述

name Yes name of the ClusterRole.

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

gracePeriodSeconds

No The duration in seconds before the objectshould be deleted. Value must be non-negativeinteger. The value zero indicates deleteimmediately. If this value is nil, the defaultgrace period for the specified type will be used.Defaults to a per object value if not specified.zero means delete immediately.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 704

Page 715: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

orphanDependents

No Deprecated: please use the PropagationPolicy,this field will be deprecated in 1.7. Should thedependent objects be orphaned. If true/false,the "orphan" finalizer will be added to/removed from the object's finalizers list. Eitherthis field or PropagationPolicy may be set, butnot both.

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field orOrphanDependents may be set, but not both.The default policy is decided by the existingfinalizer set in the metadata.finalizers and theresource-specific default policy. Acceptablevalues are: 'Orphan' - orphan the dependents;'Background' - allow the garbage collector todelete the dependents in the background;'Foreground' - a cascading policy that deletesall dependents in the foreground.

body Yes -

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "Status", "apiVersion" : "v1", "metadata" : { }, "status" : "Success", "details" : { "name" : "secret-reader", "group" : "rbac.authorization.k8s.io", "kind" : "clusterroles", "uid" : "f2cf199e-f1f0-11e8-b449-fa163ec24e06" }}

状态码

状态码描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 705

Page 716: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-478 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.1.5 批量删除 ClusterRole

功能介绍

This API is used to delete collection of ClusterRole

URL

DELETE /apis/rbac.authorization.k8s.io/v1/clusterroles

参数解释描述该API的参数。

表 6-479 参数解释

参数 是否必选 描述

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

continue - The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 706

Page 717: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 707

Page 718: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "ClusterRoleList", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterroles", "resourceVersion" : "4622" }, "items" : [ { "metadata" : { "name" : "secret-reader", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterroles/secret-reader", "uid" : "8d358854-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4619", "creationTimestamp" : "2018-11-27T01:55:44Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "secrets" ] } ] } ]}

状态码

状态码描述API的状态码。

表 6-480 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.1.6 获取指定的 ClusterRole

功能介绍

This API is used to read the specified ClusterRole

URL

GET /apis/rbac.authorization.k8s.io/v1/clusterroles/{name}

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 708

Page 719: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-481 参数解释

参数 是否必选 描述

name Yes name of the ClusterRole.

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "ClusterRole", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "name" : "secret-reader", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterroles/secret-reader", "uid" : "f2cf199e-f1f0-11e8-b449-fa163ec24e06", "resourceVersion" : "13211", "creationTimestamp" : "2018-11-27T03:03:00Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "secrets" ] } ]}

状态码

状态码描述API的状态码。

表 6-482 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.1.7 获取 ClusterRole 列表

功能介绍

This API is used to list or watch objects of kind ClusterRole

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 709

Page 720: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URLGET /apis/rbac.authorization.k8s.io/v1/clusterroles

参数解释描述该API的参数。

表 6-483 参数解释

参数 是否必选 描述

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

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 710

Page 721: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 711

Page 722: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "ClusterRoleList", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterroles", "resourceVersion" : "4622" }, "items" : [ { "metadata" : { "name" : "secret-reader", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterroles/secret-reader", "uid" : "8d358854-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4619", "creationTimestamp" : "2018-11-27T01:55:44Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "secrets" ] } ] } ]}

状态码

状态码描述API的状态码。

表 6-484 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.2 ClusterRoleBinding

6.20.2.1 创建 ClusterRoleBinding

功能介绍

This API is used to create a ClusterRoleBinding

URL

POST /apis/rbac.authorization.k8s.io/v1/clusterrolebindings

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 712

Page 723: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-485 参数解释

参数 是否必选 描述

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

body Yes 请参见请求参数

请求消息

请求参数:

请求参数如请求参数所示。

表 6-486 请求参数

参数 是否必选 参数类型 描述

apiVersion No String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind No String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated. InCamelCase.

metadata No metadataobject

Standard object's metadata.

roleRef No roleref object RoleRef can only reference aClusterRole in the globalnamespace. If the RoleRef cannotbe resolved, the Authorizer mustreturn an error.

subjects No Array ofsubjectsobjects

Subjects holds references to theobjects the role applies to.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 713

Page 724: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-487 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

annotations No Object Annotations is anunstructured key value mapstored with a resource thatmay be set by external toolsto store and retrieve arbitrarymetadata. They are notqueryable and should bepreserved when modifyingobjects.须知

通过接口或kubectl创建的clusterrolebinding,若需要在界面显示,必须在annotations字段中增加如下key/value键值对,否则后台创建的clusterrolebinding对象可能会影响界面其他clusterrolebinding的操作。"annotations": { "CCE.com/IAM" : "true"}

clusterName No String The name of the clusterwhich the object belongs to.This is used to distinguishresources with same nameand namespace in differentclusters. This field is not setanywhere right now andapiserver is going to ignore itif set in create or updaterequest.

creationTimestamp

No String CreationTimestamp is atimestamp representing theserver time when this objectwas created. It is notguaranteed to be set inhappens-before order acrossseparate operations. Clientsmay not set this value. It isrepresented in RFC3339 formand is in UTC. Populated bythe system. Read-only. Nullfor lists.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 714

Page 725: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionGracePeriodSeconds

No Integer Number of seconds allowedfor this object to gracefullyterminate before it will beremoved from the system.Only set whendeletionTimestamp is alsoset. May only be shortened.Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 715

Page 726: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionTimestamp

No String DeletionTimestamp is RFC3339 date and time at whichthis resource will be deleted.This field is set by the serverwhen a graceful deletion isrequested by the user, and isnot directly settable by aclient. The resource isexpected to be deleted (nolonger visible from resourcelists, and not reachable byname) after the time in thisfield, once the finalizers list isempty. As long as thefinalizers list contains items,deletion is blocked. Once thedeletionTimestamp is set, thisvalue may not be unset or beset further into the future,although it may be shortenedor the resource may bedeleted prior to this time. Forexample, a user may requestthat a pod is deleted in 30seconds. The Kubelet willreact by sending a gracefultermination signal to thecontainers in the pod. Afterthat 30 seconds, the Kubeletwill send a hard terminationsignal (SIGKILL) to thecontainer and after cleanup,remove the pod from the API.In the presence of networkpartitions, this object maystill exist after thistimestamp, until anadministrator or automatedprocess can determine theresource is fully terminated. Ifnot set, graceful deletion ofthe object has not beenrequested. Populated by thesystem when a gracefuldeletion is requested. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 716

Page 727: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

finalizers No Array of strings Must be empty before theobject is deleted from theregistry. Each entry is anidentifier for the responsiblecomponent that will removethe entry from the list. If thedeletionTimestamp of theobject is non-nil, entries inthis list can only be removed.

generateName No String GenerateName is an optionalprefix, used by the server, togenerate a unique nameONLY IF the Name field hasnot been provided. If this fieldis used, the name returned tothe client will be differentthan the name passed. Thisvalue will also be combinedwith a unique suffix. Theprovided value has the samevalidation rules as the Namefield, and may be truncatedby the length of the suffixrequired to make the valueunique on the server. If thisfield is specified and thegenerated name exists, theserver will NOT return a 409 -instead, it will either return201 Created or 500 withReason ServerTimeoutindicating a unique namecould not be found in thetime allotted, and the clientshould retry (optionally afterthe time indicated in theRetry-After header). Appliedonly if Name is not specified.

generation No Integer A sequence numberrepresenting a specificgeneration of the desiredstate. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 717

Page 728: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

initializers No initializers字段数据结构说object

An initializer is a controllerwhich enforces some systeminvariant at object creationtime. This field is a list ofinitializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized.Otherwise, the object isconsidered uninitialized and ishidden (in list/watch and getcalls) from clients thathaven't explicitly asked toobserve uninitialized objects.When an object is created,the system will populate thislist with the current set ofinitializers. Only privilegedusers may set or modify thislist. Once it is empty, it maynot be modified further byany user.

labels No Object Map of string keys and valuesthat can be used to organizeand categorize (scope andselect) objects. May matchselectors of replicationcontrollers and services.

name No String Name must be unique withina namespace. Is requiredwhen creating resources,although some resources mayallow a client to request thegeneration of an appropriatename automatically. Name isprimarily intended forcreation idempotence andconfiguration definition.Cannot be updated.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 718

Page 729: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

namespace No String Namespace defines the spacewithin each name must beunique. An empty namespaceis equivalent to the "default"namespace, but "default" isthe canonical representation.Not all objects are required tobe scoped to a namespace -the value of this field forthose objects will be empty.Must be a DNS_LABEL.Cannot be updated.

ownerReferences

No Array of strings List of objects depended bythis object. If ALL objects inthe list have been deleted,this object will be garbagecollected. If this object ismanaged by a controller, thenan entry in this list will pointto this controller, with thecontroller field set to true.There cannot be more thanone managing controller.

resourceVersion No String An opaque value thatrepresents the internalversion of this object that canbe used by clients todetermine when objects havechanged. May be used foroptimistic concurrency,change detection, and thewatch operation on aresource or set of resources.Clients must treat thesevalues as opaque and passedunmodified back to theserver. They may only be validfor a particular resource orset of resources. Populated bythe system. Read-only. Valuemust be treated as opaque byclients and .

selfLink No String SelfLink is a URL representingthis object. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 719

Page 730: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

uid No String UID is the unique in time andspace value for this object. Itis typically generated by theserver on successful creationof a resource and is notallowed to change on PUToperations. Populated by thesystem. Read-only.

表 6-488 roleref 字段数据结构说明

参数 是否必选 参数类型 描述

apiGroup No String APIGroup is the group for theresource being referenced.

kind No String Kind is the type of resourcebeing referenced.

name No String Name is the name of resourcebeing referenced.

表 6-489 subjects 字段数据结构说明

参数 是否必选 参数类型 描述

apiGroup No String APIGroup is the group for theresource being referenced.

kind No String Kind is the type of resourcebeing referenced.

name No String Name is the name of resourcebeing referenced.

namespace No String Namespace of the referencedobject. If the object kind isnon-namespace, such as"User" or "Group", and thisvalue is not empty theAuthorizer should report anerror.

请求示例:

# 以下`ClusterRoleBinding`对象允许在用户组"manager"中的任何用户都可以读取集群中任何名字空间中的secret。{ "kind": "ClusterRoleBinding",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 720

Page 731: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "annotations": { "CCE.com/IAM": "true" }, "name": "read-secrets-global" }, "subjects":[{ "kind": "Group", "name": "manager", "apiGroup": "rbac.authorization.k8s.io" }], "roleRef":{ "kind": "ClusterRole", "name": "secret-reader", "apiGroup": "rbac.authorization.k8s.io"}}

响应消息

响应参数:

响应参数的详细描述请参见表6-486。

响应示例:

{ "kind" : "ClusterRoleBinding", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "name" : "read-secrets-global", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings/read-secrets-global", "uid" : "8e20ec38-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4625", "creationTimestamp" : "2018-11-27T01:55:45Z" }, "subjects" : [ { "kind" : "Group", "apiGroup" : "rbac.authorization.k8s.io", "name" : "manager" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "ClusterRole", "name" : "secret-reader" }}

状态码

状态码描述API的状态码。

表 6-490 状态码

状态码 描述

201 Created

200 OK

202 Accepted

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 721

Page 732: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.20.2.2 更新指定的 ClusterRoleBinding

功能介绍

This API is used to partially update the specified ClusterRoleBinding

URLPATCH /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/{name}

参数解释描述该API的参数。

表 6-491 参数解释

参数 是否必选 描述

name Yes name of the ClusterRoleBinding.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "subjects": [{ "kind": "Group", "apiGroup": "rbac.authorization.k8s.io", "name": "pro-manager" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "ClusterRole", "name": "secret-reader" }}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "ClusterRoleBinding", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "read-secrets-global", "selfLink": "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings/read-secrets-global",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 722

Page 733: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"uid": "c384b02f-f2d7-11e8-b449-fa163ec24e06", "resourceVersion": "226911", "creationTimestamp": "2018-11-28T06:35:14Z" }, "subjects": [{ "kind": "Group", "apiGroup": "rbac.authorization.k8s.io", "name": "pro-manager" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "ClusterRole", "name": "secret-reader" }}

状态码

状态码描述API的状态码。

表 6-492 状态码

状态码 描述

200 OK

6.20.2.3 替换指定的 ClusterRoleBinding

功能介绍

This API is used to replace the specified ClusterRoleBinding

URLPUT /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/{name}

参数解释描述该API的参数。

表 6-493 参数解释

参数 是否必选 描述

name Yes name of the ClusterRoleBinding.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 723

Page 734: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求示例:

{ "kind": "ClusterRoleBinding", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": ${ clusterrolebinding_metadata }, "subjects": [{ "kind": "Group", "apiGroup": "rbac.authorization.k8s.io", "name": "group-leader" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "ClusterRole", "name": "secret-reader" }}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "ClusterRoleBinding", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "read-secrets-global", "selfLink": "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings/read-secrets-global", "uid": "c384b02f-f2d7-11e8-b449-fa163ec24e06", "resourceVersion": "226909", "creationTimestamp": "2018-11-28T06:35:14Z" }, "subjects": [{ "kind": "Group", "apiGroup": "rbac.authorization.k8s.io", "name": "group-leader" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "ClusterRole", "name": "secret-reader" }}

状态码

状态码描述API的状态码。

表 6-494 状态码

状态码 描述

200 OK

201 Created

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 724

Page 735: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.20.2.4 删除指定的 ClusterRoleBinding

功能介绍

This API is used to delete a ClusterRoleBinding

URLDELETE /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/{name}

参数解释描述该API的参数。

表 6-495 参数解释

参数 是否必选 描述

name Yes name of the ClusterRoleBinding.

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

gracePeriodSeconds

No The duration in seconds before the objectshould be deleted. Value must be non-negativeinteger. The value zero indicates deleteimmediately. If this value is nil, the defaultgrace period for the specified type will be used.Defaults to a per object value if not specified.zero means delete immediately.

orphanDependents

No Deprecated: please use the PropagationPolicy,this field will be deprecated in 1.7. Should thedependent objects be orphaned. If true/false,the "orphan" finalizer will be added to/removed from the object's finalizers list. Eitherthis field or PropagationPolicy may be set, butnot both.

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field orOrphanDependents may be set, but not both.The default policy is decided by the existingfinalizer set in the metadata.finalizers and theresource-specific default policy. Acceptablevalues are: 'Orphan' - orphan the dependents;'Background' - allow the garbage collector todelete the dependents in the background;'Foreground' - a cascading policy that deletesall dependents in the foreground.

body Yes -

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 725

Page 736: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "Status", "apiVersion" : "v1", "metadata" : { }, "status" : "Success", "details" : { "name" : "read-secrets-global", "group" : "rbac.authorization.k8s.io", "kind" : "clusterrolebindings", "uid" : "f32434e8-f1f0-11e8-b449-fa163ec24e06" }}

状态码

状态码描述API的状态码。

表 6-496 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.2.5 批量删除 ClusterRoleBinding

功能介绍

This API is used to delete collection of ClusterRoleBinding

URL

DELETE /apis/rbac.authorization.k8s.io/v1/clusterrolebindings

参数解释描述该API的参数。

表 6-497 参数解释

参数 是否必选 描述

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 726

Page 737: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

continue - The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 727

Page 738: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 728

Page 739: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "ClusterRoleBindingList", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings", "resourceVersion" : "4625" }, "items" : [ { "metadata" : { "name" : "read-secrets-global", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings/read-secrets-global", "uid" : "8e20ec38-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4625", "creationTimestamp" : "2018-11-27T01:55:45Z" }, "subjects" : [ { "kind" : "Group", "apiGroup" : "rbac.authorization.k8s.io", "name" : "manager" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "ClusterRole", "name" : "secret-reader" } } ]}

状态码

状态码描述API的状态码。

表 6-498 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.2.6 获取指定的 ClusterRoleBinding

功能介绍

This API is used to read the specified ClusterRoleBinding

URLGET /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/{name}

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 729

Page 740: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-499 参数解释

参数 是否必选 描述

name Yes name of the ClusterRoleBinding.

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "ClusterRole", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "name" : "secret-reader", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterroles/secret-reader", "uid" : "f2cf199e-f1f0-11e8-b449-fa163ec24e06", "resourceVersion" : "13211", "creationTimestamp" : "2018-11-27T03:03:00Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "secrets" ] } ]}

状态码

状态码描述API的状态码。

表 6-500 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.2.7 获取 ClusterRoleBinding 列表

功能介绍

This API is used to list or watch objects of kind ClusterRoleBinding

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 730

Page 741: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URLGET /apis/rbac.authorization.k8s.io/v1/clusterrolebindings

参数解释描述该API的参数。

表 6-501 参数解释

参数 是否必选 描述

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

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 731

Page 742: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 732

Page 743: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "ClusterRoleBindingList", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings", "resourceVersion" : "4625" }, "items" : [ { "metadata" : { "name" : "read-secrets-global", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings/read-secrets-global", "uid" : "8e20ec38-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4625", "creationTimestamp" : "2018-11-27T01:55:45Z" }, "subjects" : [ { "kind" : "Group", "apiGroup" : "rbac.authorization.k8s.io", "name" : "manager" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "ClusterRole", "name" : "secret-reader" } } ]}

状态码

状态码描述API的状态码。

表 6-502 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.3 Role

6.20.3.1 创建 Role

功能介绍

This API is used to create a Role.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 733

Page 744: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URLPOST /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles

参数解释描述该API的参数。

表 6-503 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes 请参见请求参数

请求消息

请求参数:

请求参数如请求参数所示。

表 6-504 请求参数

参数 是否必选 参数类型 描述

apiVersion No String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind No String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated. InCamelCase.

metadata No metadataobject

Standard object’s metadata.

rules No Array ofPolicyRuleobjects

Rules holds all the PolicyRules forthis Role

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 734

Page 745: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-505 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

annotations No Object Annotations is anunstructured key value mapstored with a resource thatmay be set by external toolsto store and retrieve arbitrarymetadata. They are notqueryable and should bepreserved when modifyingobjects.

clusterName No String The name of the clusterwhich the object belongs to.This is used to distinguishresources with same nameand namespace in differentclusters. This field is not setanywhere right now andapiserver is going to ignore itif set in create or updaterequest.

creationTimestamp

No String CreationTimestamp is atimestamp representing theserver time when this objectwas created. It is notguaranteed to be set inhappens-before order acrossseparate operations. Clientsmay not set this value. It isrepresented in RFC3339 formand is in UTC.Populated by the system.Read-only. Null for lists.

deletionGracePeriodSeconds

No Integer Number of seconds allowedfor this object to gracefullyterminate before it will beremoved from the system.Only set whendeletionTimestamp is alsoset. May only be shortened.Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 735

Page 746: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionTimestamp

No String DeletionTimestamp is RFC3339 date and time at whichthis resource will be deleted.This field is set by the serverwhen a graceful deletion isrequested by the user, and isnot directly settable by aclient. The resource isexpected to be deleted (nolonger visible from resourcelists, and not reachable byname) after the time in thisfield, once the finalizers list isempty. As long as thefinalizers list contains items,deletion is blocked. Once thedeletionTimestamp is set, thisvalue may not be unset or beset further into the future,although it may be shortenedor the resource may bedeleted prior to this time. Forexample, a user may requestthat a pod is deleted in 30seconds. The Kubelet willreact by sending a gracefultermination signal to thecontainers in the pod. Afterthat 30 seconds, the Kubeletwill send a hard terminationsignal (SIGKILL) to thecontainer and after cleanup,remove the pod from the API.In the presence of networkpartitions, this object maystill exist after thistimestamp, until anadministrator or automatedprocess can determine theresource is fully terminated. Ifnot set, graceful deletion ofthe object has not beenrequested.Populated by the systemwhen a graceful deletion isrequested. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 736

Page 747: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

finalizers No Array ofstrings

Must be empty before theobject is deleted from theregistry. Each entry is anidentifier for the responsiblecomponent that will removethe entry from the list. If thedeletionTimestamp of theobject is non-nil, entries inthis list can only be removed.

generateName No String If this field is specified andthe generated name exists,the server will NOT return a409 - instead, it will eitherreturn 201 Created or 500with Reason ServerTimeoutindicating a unique namecould not be found in thetime allotted, and the clientshould retry (optionally afterthe time indicated in theRetry-After header).Applied only if Name is notspecified.

generation No Integer A sequence numberrepresenting a specificgeneration of the desiredstate. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 737

Page 748: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

initializers No initializersobject

An initializer is a controllerwhich enforces some systeminvariant at object creationtime. This field is a list ofinitializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized.Otherwise, the object isconsidered uninitialized and ishidden (in list/watch and getcalls) from clients thathaven’t explicitly asked toobserve uninitialized objects.When an object is created,the system will populate thislist with the current set ofinitializers. Only privilegedusers may set or modify thislist. Once it is empty, it maynot be modified further byany user.

labels No Object Map of string keys and valuesthat can be used to organizeand categorize (scope andselect) objects. May matchselectors of replicationcontrollers and services.

name No String Name must be unique withina namespace. Is requiredwhen creating resources,although some resources mayallow a client to request thegeneration of an appropriatename automatically. Name isprimarily intended forcreation idempotence andconfiguration definition.Cannot be updated.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 738

Page 749: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

namespace No String Namespace defines the spacewithin each name must beunique. An empty namespaceis equivalent to the "default"namespace, but "default" isthe canonical representation.Not all objects are required tobe scoped to a namespace -the value of this field forthose objects will be empty.Must be a DNS_LABEL.Cannot be updated.

ownerReferences

No Array ofstrings

List of objects depended bythis object. If ALL objects inthe list have been deleted,this object will be garbagecollected. If this object ismanaged by a controller, thenan entry in this list will pointto this controller, with thecontroller field set to true.There cannot be more thanone managing controller.

resourceVersion No String An opaque value thatrepresents the internalversion of this object that canbe used by clients todetermine when objects havechanged. May be used foroptimistic concurrency,change detection, and thewatch operation on aresource or set of resources.Clients must treat thesevalues as opaque and passedunmodified back to theserver. They may only be validfor a particular resource orset of resources.Populated by the system.Read-only. Value must betreated as opaque by clientsand .

selfLink No String SelfLink is a URL representingthis object. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 739

Page 750: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

uid No String UID is the unique in time andspace value for this object. Itis typically generated by theserver on successful creationof a resource and is notallowed to change on PUToperations.Populated by the system.Read-only.

表 6-506 PolicyRule 字段数据结构说明

参数 是否必选 参数类型 描述

apiGroups No Array ofstrings

APIGroups is the name of theAPIGroup that contains theresources. If multiple APIgroups are specified, anyaction requested against oneof the enumerated resourcesin any API group will beallowed.

nonResourceURLs

No Array ofstrings

NonResourceURLs is a set ofpartial urls that a user shouldhave access to. *s are allowed,but only as the full, final stepin the path Since non-resource URLs are notnamespaced, this field is onlyapplicable for ClusterRolesreferenced from aClusterRoleBinding. Rules caneither apply to API resources(such as "pods" or "secrets")or non-resource URL paths(such as "/api"), but not both.

resourceNames No Array ofstrings

ResourceNames is anoptional white list of namesthat the rule applies to. Anempty set means thateverything is allowed.

resources No Array ofstrings

Resources is a list ofresources this rule applies to.ResourceAll represents allresources.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 740

Page 751: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

verbs No Array ofstrings

Verbs is a list of Verbs thatapply to ALL theResourceKinds andAttributeRestrictionscontained in this rule. VerbAllrepresents all kinds.

请求示例:

{ "kind": "Role", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "pod-reader", "namespace": "default" }, "rules":[{ "apiGroups": [""],# 空字符串""表明使用core API group "resources": ["pods"], "verbs": ["get", "watch", "list"] }]}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "Role", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "name" : "pod-reader", "namespace" : "default", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader", "uid" : "8e7afa24-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4627", "creationTimestamp" : "2018-11-27T01:55:46Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "pods" ] } ]}

状态码

状态码描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 741

Page 752: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-507 状态码

状态码 描述

201 Created

200 OK

202 Accepted

6.20.3.2 更新指定的 Role

功能介绍

This API is used to partially update the specified Role

URLPATCH /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name}

参数解释描述该API的参数。

表 6-508 参数解释

参数 是否必选 描述

name Yes name of the Role.

namespace Yes object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "metadata": { "name": "pod-reader", "namespace": "default", "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader", "uid": "6320bedb-f220-11e8-b449-fa163ec24e06", "resourceVersion": "56532", "creationTimestamp": "2018-11-27T08:42:35Z" }, "rules": [{ "verbs": ["get","list"],

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 742

Page 753: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiGroups": [""], "resources": ["pods"] }]}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "Role", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "pod-reader", "namespace": "default", "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader", "uid": "6320bedb-f220-11e8-b449-fa163ec24e06", "resourceVersion": "56532", "creationTimestamp": "2018-11-27T08:42:35Z" }, "rules": [{ "verbs": ["get","list"], "apiGroups": [""], "resources": ["pods"] }]}

状态码

状态码描述API的状态码。

表 6-509 状态码

状态码 描述

200 OK

6.20.3.3 替换指定的 Role

功能介绍

This API is used to replace the specified Role

URLPUT /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name}

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 743

Page 754: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-510 参数解释

参数 是否必选 描述

name Yes name of the Role.

namespace Yes object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "metadata": { "name": "pod-reader", "namespace": "default", "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader", "uid": "6320bedb-f220-11e8-b449-fa163ec24e06", "resourceVersion": "56532", "creationTimestamp": "2018-11-27T08:42:35Z" }, "rules": [{ "verbs": ["get","watch"], "apiGroups": [""], "resources": ["pods"] }]}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "Role", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "pod-reader", "namespace": "default", "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader", "uid": "6320bedb-f220-11e8-b449-fa163ec24e06", "resourceVersion": "56532", "creationTimestamp": "2018-11-27T08:42:35Z" }, "rules": [{ "verbs": ["get","watch"], "apiGroups": [""], "resources": ["pods"]

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 744

Page 755: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}]}

状态码

状态码描述API的状态码。

表 6-511 状态码

状态码 描述

200 OK

201 Created

6.20.3.4 删除指定的 Role

功能介绍

This API is used to delete a Role.

URL

DELETE /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name}

参数解释描述该API的参数。

表 6-512 参数解释

参数 是否必选 描述

name Yes name of the Role.

namespace Yes object name and auth scope, such as for teamsand projects.

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

gracePeriodSeconds

No The duration in seconds before the objectshould be deleted. Value must be non-negativeinteger. The value zero indicates deleteimmediately. If this value is nil, the defaultgrace period for the specified type will be used.Defaults to a per object value if not specified.zero means delete immediately.

orphanDependents

No Deprecated: please use the PropagationPolicy,this field will be deprecated in 1.7. Should thedependent objects be orphaned. If true/false,the "orphan" finalizer will be added to/removed from the object's finalizers list. Eitherthis field or PropagationPolicy may be set, butnot both.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 745

Page 756: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field orOrphanDependents may be set, but not both.The default policy is decided by the existingfinalizer set in the metadata.finalizers and theresource-specific default policy. Acceptablevalues are: 'Orphan' - orphan the dependents;'Background' - allow the garbage collector todelete the dependents in the background;'Foreground' - a cascading policy that deletesall dependents in the foreground.

body Yes -

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "Status", "apiVersion" : "v1", "metadata" : { }, "status" : "Success", "details" : { "name" : "pod-reader", "group" : "rbac.authorization.k8s.io", "kind" : "roles", "uid" : "f379007e-f1f0-11e8-b449-fa163ec24e06" }}

状态码

状态码描述API的状态码。

表 6-513 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 746

Page 757: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.20.3.5 批量删除 Role

功能介绍

This API is used to delete collection of Role

URLDELETE /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles

参数解释描述该API的参数。

表 6-514 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects.

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

continue - The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 747

Page 758: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 748

Page 759: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "RoleList", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles", "resourceVersion" : "4629" }, "items" : [ { "metadata" : { "name" : "pod-reader", "namespace" : "default", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader", "uid" : "8e7afa24-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4627", "creationTimestamp" : "2018-11-27T01:55:46Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "pods" ] } ] } ]}

状态码

状态码描述API的状态码。

表 6-515 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.3.6 获取指定的 Role

功能介绍

This API is used to read the specified Role.

URL

GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name}

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 749

Page 760: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-516 参数解释

参数 是否必选 描述

name Yes name of the Role.

namespace Yes object name and auth scope, such as for teamsand projects

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "Role", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "name" : "pod-reader", "namespace" : "default", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader", "uid" : "f379007e-f1f0-11e8-b449-fa163ec24e06", "resourceVersion" : "13218", "creationTimestamp" : "2018-11-27T03:03:01Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "pods" ] } ]}

状态码

状态码描述API的状态码。

表 6-517 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 750

Page 761: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.20.3.7 获取指定 namespace 下的 Role 列表

功能介绍

This API is used to list or watch objects of kind Role

URLGET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles

参数解释描述该API的参数。

表 6-518 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 751

Page 762: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No imit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 752

Page 763: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "RoleList", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles", "resourceVersion" : "4628" }, "items" : [ { "metadata" : { "name" : "pod-reader", "namespace" : "default", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader", "uid" : "8e7afa24-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4627", "creationTimestamp" : "2018-11-27T01:55:46Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "pods" ] } ] } ]}

状态码

状态码描述API的状态码。

表 6-519 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.3.8 获取 Role 列表

功能介绍

This API is used to list or watch objects of kind Role

URL

GET /apis/rbac.authorization.k8s.io/v1/roles

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 753

Page 764: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-520 参数解释

参数 是否必选 描述

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 754

Page 765: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large result canensure they see all possible objects. If objectsare updated during a chunked list the version ofthe object that was present at the time the firstlist result was calculated is returned.

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

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 755

Page 766: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "RoleList", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "selfLink" : "/apis/rbac.authorization.k8s.io/v1/roles", "resourceVersion" : "4628" }, "items" : [ { "metadata" : { "name" : "pod-reader", "namespace" : "default", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader", "uid" : "8e7afa24-f1e7-11e8-b449-fa163ec24e06", "resourceVersion" : "4627", "creationTimestamp" : "2018-11-27T01:55:46Z" }, "rules" : [ { "verbs" : [ "get", "watch", "list" ], "apiGroups" : [ "" ], "resources" : [ "pods" ] } ] }, { "metadata" : { "name" : "system:controller:bootstrap-signer", "namespace" : "kube-public", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-public/roles/system%3Acontroller%3Abootstrap-signer", "uid" : "c3c553ae-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "127", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" } }, "rules" : [ { "verbs" : [ "get", "list", "watch" ], "apiGroups" : [ "" ], "resources" : [ "configmaps" ] }, { "verbs" : [ "update" ], "apiGroups" : [ "" ], "resources" : [ "configmaps" ], "resourceNames" : [ "cluster-info" ] }, { "verbs" : [ "create", "patch", "update" ], "apiGroups" : [ "" ], "resources" : [ "events" ] } ] }, { "metadata" : { "name" : "extension-apiserver-authentication-reader", "namespace" : "kube-system", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/extension-apiserver-

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 756

Page 767: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

authentication-reader", "uid" : "c398c5a1-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "121", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" } }, "rules" : [ { "verbs" : [ "get" ], "apiGroups" : [ "" ], "resources" : [ "configmaps" ], "resourceNames" : [ "extension-apiserver-authentication" ] } ] }, { "metadata" : { "name" : "system::leader-locking-kube-controller-manager", "namespace" : "kube-system", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3A%3Aleader-locking-kube-controller-manager", "uid" : "c3bf1246-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "125", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" } }, "rules" : [ { "verbs" : [ "watch" ], "apiGroups" : [ "" ], "resources" : [ "configmaps" ] }, { "verbs" : [ "get", "update" ], "apiGroups" : [ "" ], "resources" : [ "configmaps" ], "resourceNames" : [ "kube-controller-manager" ] } ] }, { "metadata" : { "name" : "system::leader-locking-kube-scheduler", "namespace" : "kube-system", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3A%3Aleader-locking-kube-scheduler", "uid" : "c3c1ddd6-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "126", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" } }, "rules" : [ { "verbs" : [ "watch" ], "apiGroups" : [ "" ], "resources" : [ "configmaps" ] }, { "verbs" : [ "get", "update" ], "apiGroups" : [ "" ], "resources" : [ "configmaps" ], "resourceNames" : [ "kube-scheduler" ] } ]

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 757

Page 768: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, { "metadata" : { "name" : "system:controller:bootstrap-signer", "namespace" : "kube-system", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3Acontroller%3Abootstrap-signer", "uid" : "c39edcc9-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "122", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" } }, "rules" : [ { "verbs" : [ "get", "list", "watch" ], "apiGroups" : [ "" ], "resources" : [ "secrets" ] } ] }, { "metadata" : { "name" : "system:controller:cloud-provider", "namespace" : "kube-system", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3Acontroller%3Acloud-provider", "uid" : "c3a4f1e3-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "123", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" } }, "rules" : [ { "verbs" : [ "create", "get", "list", "watch" ], "apiGroups" : [ "" ], "resources" : [ "configmaps" ] } ] }, { "metadata" : { "name" : "system:controller:token-cleaner", "namespace" : "kube-system", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3Acontroller%3Atoken-cleaner", "uid" : "c3bb6b6b-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "124", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" } }, "rules" : [ { "verbs" : [ "delete", "get", "list", "watch" ], "apiGroups" : [ "" ], "resources" : [ "secrets" ] }, { "verbs" : [ "create", "patch", "update" ], "apiGroups" : [ "" ], "resources" : [ "events" ] } ]

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 758

Page 769: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} ]}

状态码

状态码描述API的状态码。

表 6-521 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.4 RoleBinding

6.20.4.1 创建 RoleBinding

功能介绍

This API is used to create a RoleBinding

URL

POST /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings

参数解释描述该API的参数。

表 6-522 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

body Yes 请参见请求参数。

请求消息

请求参数:

请求参数如请求参数所示。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 759

Page 770: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-523 请求参数

参数 是否必选 参数类型 描述

apiVersion No String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind No String Kind is a string valuerepresenting the REST resourcethis object represents. Serversmay infer this from the endpointthe client submits requests to.Cannot be updated. InCamelCase.

metadata No metadataobject

Standard object’s metadata.

roleRef No RoleRefobject

RoleRef can reference a Role inthe current namespace or aClusterRole in the globalnamespace. If the RoleRef cannotbe resolved, the Authorizer mustreturn an error.

subjects No Array ofSubjectobjects

Subjects holds references to theobjects the role applies to.

表 6-524 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

annotations No Object Annotations is anunstructured key value mapstored with a resource thatmay be set by external toolsto store and retrieve arbitrarymetadata. They are notqueryable and should bepreserved when modifyingobjects.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 760

Page 771: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

clusterName No String The name of the clusterwhich the object belongs to.This is used to distinguishresources with same nameand namespace in differentclusters. This field is not setanywhere right now andapiserver is going to ignore itif set in create or updaterequest.

creationTimestamp

No String CreationTimestamp is atimestamp representing theserver time when this objectwas created. It is notguaranteed to be set inhappens-before order acrossseparate operations. Clientsmay not set this value. It isrepresented in RFC3339 formand is in UTC.Populated by the system.Read-only. Null for lists.

deletionGracePeriodSeconds

No Integer Number of seconds allowedfor this object to gracefullyterminate before it will beremoved from the system.Only set whendeletionTimestamp is alsoset. May only be shortened.Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 761

Page 772: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionTimestamp

No String DeletionTimestamp is RFC3339 date and time at whichthis resource will be deleted.This field is set by the serverwhen a graceful deletion isrequested by the user, and isnot directly settable by aclient. The resource isexpected to be deleted (nolonger visible from resourcelists, and not reachable byname) after the time in thisfield, once the finalizers list isempty. As long as thefinalizers list contains items,deletion is blocked. Once thedeletionTimestamp is set, thisvalue may not be unset or beset further into the future,although it may be shortenedor the resource may bedeleted prior to this time. Forexample, a user may requestthat a pod is deleted in 30seconds. The Kubelet willreact by sending a gracefultermination signal to thecontainers in the pod. Afterthat 30 seconds, the Kubeletwill send a hard terminationsignal (SIGKILL) to thecontainer and after cleanup,remove the pod from the API.In the presence of networkpartitions, this object maystill exist after thistimestamp, until anadministrator or automatedprocess can determine theresource is fully terminated. Ifnot set, graceful deletion ofthe object has not beenrequested.Populated by the systemwhen a graceful deletion isrequested. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 762

Page 773: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

finalizers No Array ofstrings

Must be empty before theobject is deleted from theregistry. Each entry is anidentifier for the responsiblecomponent that will removethe entry from the list. If thedeletionTimestamp of theobject is non-nil, entries inthis list can only be removed.

generateName No String If this field is specified andthe generated name exists,the server will NOT return a409 - instead, it will eitherreturn 201 Created or 500with Reason ServerTimeoutindicating a unique namecould not be found in thetime allotted, and the clientshould retry (optionally afterthe time indicated in theRetry-After header).Applied only if Name is notspecified.

generation No Integer A sequence numberrepresenting a specificgeneration of the desiredstate. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 763

Page 774: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

initializers No initializersobject

An initializer is a controllerwhich enforces some systeminvariant at object creationtime. This field is a list ofinitializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized.Otherwise, the object isconsidered uninitialized and ishidden (in list/watch and getcalls) from clients thathaven’t explicitly asked toobserve uninitialized objects.When an object is created,the system will populate thislist with the current set ofinitializers. Only privilegedusers may set or modify thislist. Once it is empty, it maynot be modified further byany user.

labels No Object Map of string keys and valuesthat can be used to organizeand categorize (scope andselect) objects. May matchselectors of replicationcontrollers and services.

name No String Name must be unique withina namespace. Is requiredwhen creating resources,although some resources mayallow a client to request thegeneration of an appropriatename automatically. Name isprimarily intended forcreation idempotence andconfiguration definition.Cannot be updated.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 764

Page 775: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

namespace No String Namespace defines the spacewithin each name must beunique. An empty namespaceis equivalent to the "default"namespace, but "default" isthe canonical representation.Not all objects are required tobe scoped to a namespace -the value of this field forthose objects will be empty.Must be a DNS_LABEL.Cannot be updated.

ownerReferences

No Array ofstrings

List of objects depended bythis object. If ALL objects inthe list have been deleted,this object will be garbagecollected. If this object ismanaged by a controller, thenan entry in this list will pointto this controller, with thecontroller field set to true.There cannot be more thanone managing controller.

resourceVersion No String An opaque value thatrepresents the internalversion of this object that canbe used by clients todetermine when objects havechanged. May be used foroptimistic concurrency,change detection, and thewatch operation on aresource or set of resources.Clients must treat thesevalues as opaque and passedunmodified back to theserver. They may only be validfor a particular resource orset of resources.Populated by the system.Read-only. Value must betreated as opaque by clientsand .

selfLink No String SelfLink is a URL representingthis object. Populated by thesystem. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 765

Page 776: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

uid No String UID is the unique in time andspace value for this object. Itis typically generated by theserver on successful creationof a resource and is notallowed to change on PUToperations.Populated by the system.Read-only.

表 6-525 RoleRef 字段数据结构说明

参数 是否必选 参数类型 描述

apiGroup No String APIGroup is the group for theresource being referenced.

kind No String Kind is the type of resourcebeing referenced.

name No String Name is the name ofresource being referenced.

表 6-526 Subject 字段数据结构说明

参数 是否必选 参数类型 描述

apiGroup No String APIGroup holds the API groupof the referenced subject.Defaults to "" forServiceAccount subjects.Defaults to"rbac.authorization.k8s.io" forUser and Group subjects.

kind No String Kind of object beingreferenced. Values defined bythis API group are "User","Group", and"ServiceAccount". If theAuthorizer does notrecognized the kind value, theAuthorizer should report anerror.

name No String Name of the object beingreferenced.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 766

Page 777: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

namespace No String Namespace of the referencedobject. If the object kind isnon-namespace, such as"User" or "Group", and thisvalue is not empty theAuthorizer should report anerror.

请求示例:

# 以下角色绑定定义将允许用户"jane"从"default"命名空间中读取pod。{ "kind": "RoleBinding", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "read-pods", "namespace": "default" }, "subjects":[{ "kind": "User", "name": "jane", "apiGroup": "rbac.authorization.k8s.io" }], "roleRef":{ "kind": "Role", "name": "pod-reader", "apiGroup": "rbac.authorization.k8s.io"}}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "RoleBinding", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "name" : "read-pods", "namespace" : "default", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings/secret-reader", "uid" : "b3d1a49a-f1f4-11e8-b449-fa163ec24e06", "resourceVersion" : "16611", "creationTimestamp" : "2018-11-27T03:29:52Z" }, "subjects" : [ { "kind" : "User", "apiGroup" : "rbac.authorization.k8s.io", "name" : "jane" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "Role", "name" : "pod-reader" }}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 767

Page 778: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

状态码描述API的状态码。

表 6-527 状态码

状态码 描述

201 Created

200 OK

202 Accepted

6.20.4.2 更新指定的 RoleBinding

功能介绍

This API is used to partially update the specified RoleBinding

URLPATCH /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name}

参数解释描述该API的参数。

表 6-528 参数解释

参数 是否必选 描述

name Yes name of the RoleBinding.

namespace Yes object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "subjects": [{ "kind": "User", "apiGroup": "rbac.authorization.k8s.io",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 768

Page 779: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"name": "hecapi" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "Role", "name": "pod-reader" }}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "RoleBinding", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "read-pods", "namespace": "default", "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings/read-pods", "uid": "06cc94b7-f2bb-11e8-b449-fa163ec24e06", "resourceVersion": "200072", "creationTimestamp": "2018-11-28T03:09:32Z" }, "subjects": [{ "kind": "User", "apiGroup": "rbac.authorization.k8s.io", "name": "hecapi" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "Role", "name": "pod-reader" }}

状态码

状态码描述API的状态码。

表 6-529 状态码

状态码 描述

200 OK

6.20.4.3 替换指定的 RoleBinding

功能介绍

This API is used to replace the specified RoleBinding

URLPUT /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 769

Page 780: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数解释描述该API的参数。

表 6-530 参数解释

参数 是否必选 描述

name Yes name of the RoleBinding.

namespace Yes object name and auth scope, such as for teamsand projects.

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

body Yes -

请求消息

请求参数:

请求参数的详细描述请参见请求参数。

“Content-Type”的详细描述请参见 9.1 PATCH请求方法操作说明。

请求示例:

{ "kind": "RoleBinding", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "read-pods", "namespace": "default", "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings/read-pods", "uid": "301398f6-f2b9-11e8-b449-fa163ec24e06", "resourceVersion": "198279", "creationTimestamp": "2018-11-28T02:56:22Z" }, "subjects": [{ "kind": "User", "apiGroup": "rbac.authorization.k8s.io", "name": "cce20" }], "roleRef": { "kind": "Role", "name": "pod-reader", "apiGroup": "rbac.authorization.k8s.io" }}

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "RoleBinding", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "name": "read-pods", "namespace": "default",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 770

Page 781: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings/read-pods", "uid": "301398f6-f2b9-11e8-b449-fa163ec24e06", "resourceVersion": "198279", "creationTimestamp": "2018-11-28T02:56:22Z" }, "subjects": [{ "kind": "User", "apiGroup": "rbac.authorization.k8s.io", "name": "jane" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "Role", "name": "pod-reader" }}

状态码

状态码描述API的状态码。

表 6-531 状态码

状态码 描述

200 OK

201 Created

6.20.4.4 删除指定的 RoleBinding

功能介绍

This API is used to delete a RoleBinding

URL

DELETE /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name}

参数解释描述该API的参数。

表 6-532 参数解释

参数 是否必选 描述

name Yes name of the RoleBinding.

namespace Yes object name and auth scope, such as for teamsand projects.

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 771

Page 782: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

gracePeriodSeconds

No The duration in seconds before the objectshould be deleted. Value must be non-negativeinteger. The value zero indicates deleteimmediately. If this value is nil, the defaultgrace period for the specified type will be used.Defaults to a per object value if not specified.zero means delete immediately.

orphanDependents

No Deprecated: please use the PropagationPolicy,this field will be deprecated in 1.7. Should thedependent objects be orphaned. If true/false,the "orphan" finalizer will be added to/removed from the object's finalizers list. Eitherthis field or PropagationPolicy may be set, butnot both.

propagationPolicy

No Whether and how garbage collection will beperformed. Either this field orOrphanDependents may be set, but not both.The default policy is decided by the existingfinalizer set in the metadata.finalizers and theresource-specific default policy. Acceptablevalues are: 'Orphan' - orphan the dependents;'Background' - allow the garbage collector todelete the dependents in the background;'Foreground' - a cascading policy that deletesall dependents in the foreground.

body Yes -

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "Status", "apiVersion": "v1", "metadata": { }, "status": "Success", "details": { "name": "read-pods", "group": "rbac.authorization.k8s.io", "kind": "rolebindings", "uid": "b3d1a49a-f1f4-11e8-b449-fa163ec24e06"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 772

Page 783: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}}

状态码

状态码描述API的状态码。

表 6-533 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.4.5 批量删除 RoleBinding

功能介绍

This API is used to delete collection of RoleBinding

URLDELETE /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings

参数解释描述该API的参数。

表 6-534 参数解释

参数 是否必选 描述

namespace Yes object name and auth scope, such as for teamsand projects.

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 773

Page 784: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

continue - The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 774

Page 785: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 775

Page 786: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind": "RoleBindingList", "apiVersion": "rbac.authorization.k8s.io/v1", "metadata": { "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings", "resourceVersion": "16613" }, "items": null}

状态码

状态码描述API的状态码。

表 6-535 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.4.6 获取指定的 RoleBinding

功能介绍

This API is used to read the specified RoleBinding

URL

GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name}

参数解释描述该API的参数。

表 6-536 参数解释

参数 是否必选 描述

name Yes name of the RoleBinding.

namespace Yes object name and auth scope, such as for teamsand projects.

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

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 776

Page 787: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "RoleBinding", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "name" : "read-pods", "namespace" : "default", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings/secret-reader", "uid" : "b3d1a49a-f1f4-11e8-b449-fa163ec24e06", "resourceVersion" : "16611", "creationTimestamp" : "2018-11-27T03:29:52Z" }, "subjects" : [ { "kind" : "User", "apiGroup" : "rbac.authorization.k8s.io", "name" : "jane" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "Role", "name" : "pod-reader" }}

状态码

状态码描述API的状态码。

表 6-537 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.4.7 获取指定 namespace 下 RoleBinding 列表

功能介绍

This API is used to list or watch objects of kind RoleBinding

URLGET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 777

Page 788: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-538 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 778

Page 789: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No imit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large resultcan ensure they see all possible objects. Ifobjects are updated during a chunked list theversion of the object that was present at thetime the first list result was calculated isreturned.

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero,then the result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

请求消息

N/A

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 779

Page 790: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "RoleBindingList", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings", "resourceVersion" : "16611" }, "items" : [ { "metadata" : { "name" : "read-pods", "namespace" : "default", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings/secret-reader", "uid" : "b3d1a49a-f1f4-11e8-b449-fa163ec24e06", "resourceVersion" : "16611", "creationTimestamp" : "2018-11-27T03:29:52Z" }, "subjects" : [ { "kind" : "User", "apiGroup" : "rbac.authorization.k8s.io", "name" : "jane" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "Role", "name" : "pod-reader" } } ]}

状态码

状态码描述API的状态码。

表 6-539 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.20.4.8 获取 RoleBinding 列表

功能介绍

This API is used to list or watch objects of kind RoleBinding

URLGET /apis/rbac.authorization.k8s.io/v1/rolebindings

参数解释描述该API的参数。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 780

Page 791: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-540 参数解释

参数 是否必选 描述

continue No The continue option should be set whenretrieving more results from the server. Sincethis value is server defined, clients may only usethe continue value from a previous query resultwith identical query parameters (except for thevalue of continue) and the server may reject acontinue value it does not recognize. If thespecified continue value is no longer validwhether due to expiration (generally five tofifteen minutes) or a configuration change onthe server the server will respond with a 410ResourceExpired error indicating the client mustrestart their list without the continue field. Thisfield is not supported when watch is true.Clients may start a watch from the lastresourceVersion value returned by the serverand not miss any modifications.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

includeUninitialized

No If true, partially initialized resources areincluded in the response.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 781

Page 792: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 描述

limit No limit is a maximum number of responses toreturn for a list call. If more items exist, theserver will set the continue field on the listmetadata to a value that can be used with thesame initial query to retrieve the next set ofresults. Setting a limit may return fewer thanthe requested amount of items (up to zeroitems) in the event all requested objects arefiltered out and clients should only use thepresence of the continue field to determinewhether more results are available. Servers maychoose not to support the limit argument andwill return all of the available results. If limit isspecified and the continue field is empty, clientsmay assume that no more results are available.This field is not supported if watch is true. Theserver guarantees that the objects returnedwhen using continue will be identical to issuinga single list call without a limit - that is, noobjects created, modified, or deleted after thefirst request is issued will be included in anysubsequent continued requests. This issometimes referred to as a consistent snapshot,and ensures that a client that is using limit toreceive smaller chunks of a very large result canensure they see all possible objects. If objectsare updated during a chunked list the version ofthe object that was present at the time the firstlist result was calculated is returned.

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

resourceVersion No When specified with a watch call, showschanges that occur after that particular versionof a resource. Defaults to changes from thebeginning of history. When specified for list: - ifunset, then the result is returned from remotestorage based on quorum-read flag; - if it's 0,then we simply return what we currently havein cache, no guarantee; - if set to non zero, thenthe result is at least as fresh as given rv.

timeoutSeconds No Timeout for the list/watch call.

watch No Watch for changes to the described resourcesand return them as a stream of add, update,and remove notifications. SpecifyresourceVersion.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 782

Page 793: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数。

响应示例:

{ "kind" : "RoleBindingList", "apiVersion" : "rbac.authorization.k8s.io/v1", "metadata" : { "selfLink" : "/apis/rbac.authorization.k8s.io/v1/rolebindings", "resourceVersion" : "16612" }, "items" : [ { "metadata" : { "name" : "read-pods", "namespace" : "default", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings/secret-reader", "uid" : "b3d1a49a-f1f4-11e8-b449-fa163ec24e06", "resourceVersion" : "16611", "creationTimestamp" : "2018-11-27T03:29:52Z" }, "subjects" : [ { "kind" : "User", "apiGroup" : "rbac.authorization.k8s.io", "name" : "jane" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "Role", "name" : "pod-reader" } }, { "metadata" : { "name" : "system:controller:bootstrap-signer", "namespace" : "kube-public", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-public/rolebindings/system%3Acontroller%3Abootstrap-signer", "uid" : "c3e201cc-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "133", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" }, "enable" : true }, "subjects" : [ { "kind" : "ServiceAccount", "name" : "bootstrap-signer", "namespace" : "kube-system" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "Role", "name" : "system:controller:bootstrap-signer" } }, { "metadata" : { "name" : "system::leader-locking-kube-controller-manager",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 783

Page 794: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"namespace" : "kube-system", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/rolebindings/system%3A%3Aleader-locking-kube-controller-manager", "uid" : "c3c7ba3f-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "128", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" }, "enable" : true }, "subjects" : [ { "kind" : "ServiceAccount", "name" : "kube-controller-manager", "namespace" : "kube-system" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "Role", "name" : "system::leader-locking-kube-controller-manager" } }, { "metadata" : { "name" : "system::leader-locking-kube-scheduler", "namespace" : "kube-system", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/rolebindings/system%3A%3Aleader-locking-kube-scheduler", "uid" : "c3ccc50d-f1e2-11e8-b449-fa163ec24e06", "resourceVersion" : "129", "creationTimestamp" : "2018-11-27T01:21:28Z", "labels" : { "kubernetes.io/bootstrapping" : "rbac-defaults" }, "annotations" : { "rbac.authorization.k8s.io/autoupdate" : "true" }, "enable" : true }, "subjects" : [ { "kind" : "ServiceAccount", "name" : "kube-scheduler", "namespace" : "kube-system" } ], "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "Role", "name" : "system::leader-locking-kube-scheduler" } }, { "metadata": { "name": "system:controller:bootstrap-signer", "namespace": "kube-system", "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/rolebindings/system%3Acontroller%3Abootstrap-signer", "uid": "c3cfd023-f1e2-11e8-b449-fa163ec24e06", "resourceVersion": "130", "creationTimestamp": "2018-11-27T01:21:28Z", "labels": { "kubernetes.io/bootstrapping": "rbac-defaults" }, "annotations": { "rbac.authorization.k8s.io/autoupdate": "true" }, "enable": true }, "subjects": [{

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 784

Page 795: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"kind": "ServiceAccount", "name": "bootstrap-signer", "namespace": "kube-system" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "Role", "name": "system:controller:bootstrap-signer" }}, { "metadata": { "name": "system:controller:cloud-provider", "namespace": "kube-system", "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/rolebindings/system%3Acontroller%3Acloud-provider", "uid": "c3d6a8c8-f1e2-11e8-b449-fa163ec24e06", "resourceVersion": "131", "creationTimestamp": "2018-11-27T01:21:28Z", "labels": { "kubernetes.io/bootstrapping": "rbac-defaults" }, "annotations": { "rbac.authorization.k8s.io/autoupdate": "true" }, "enable": true }, "subjects": [{ "kind": "ServiceAccount", "name": "cloud-provider", "namespace": "kube-system" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "Role", "name": "system:controller:cloud-provider" } }, { "metadata": { "name": "system:controller:token-cleaner", "namespace": "kube-system", "selfLink": "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/rolebindings/system%3Acontroller%3Atoken-cleaner", "uid": "c3dbe57c-f1e2-11e8-b449-fa163ec24e06", "resourceVersion": "132", "creationTimestamp": "2018-11-27T01:21:28Z", "labels": { "kubernetes.io/bootstrapping": "rbac-defaults" }, "annotations": { "rbac.authorization.k8s.io/autoupdate": "true" }, "enable": true }, "subjects": [{ "kind": "ServiceAccount", "name": "token-cleaner", "namespace": "kube-system" }], "roleRef": { "apiGroup": "rbac.authorization.k8s.io", "kind": "Role", "name": "system:controller:token-cleaner" } } ]}

状态码

状态码描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 785

Page 796: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-541 状态码

状态码 描述

200 OK

异常状态码请参见9.3 状态码。

6.21 API groups

6.21.1 列出 APIVersions

功能介绍

This API is used to list APIversions.

URI

GET /api

请求消息

N/A.

响应消息

响应参数:

表6-542 describes the response parameters.

表 6-542 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 786

Page 797: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

serverAddressByClientCIDRs

serverAddressByClientCIDRs object

a map of client CIDR to serveraddress that is serving this group.This is to help clients reach serversin the most network-efficient waypossible. Clients can use theappropriate server address as perthe CIDR that they match. In caseof multiple matches, clients shoulduse the longest matching CIDR.The server returns only thoseCIDRs that it thinks that the clientcan match. For example: themaster will return an internal IPCIDR only, if the client reaches theserver using an internal IP. Serverlooks at X-Forwarded-For headeror X-Real-Ip header orrequest.RemoteAddr (in thatorder) to get the client IP.

versions Array of strings versions are the api versions thatare available.

表 6-543 serverAddressByClientCIDRs 字段数据结构说明

参数 参数类型 描述

clientCIDR String The CIDR with which clients canmatch their IP to figure out theserver address that they shoulduse.

serverAddress String ddress of this server, suitable for aclient that matches the aboveCIDR. This can be a hostname,hostname:port, IP or IP:port.

响应示例:

{ "kind": "APIVersions", "versions": [ "v1" ], "serverAddressByClientCIDRs": [ { "clientCIDR": "0.0.0.0/0", "serverAddress": "192.168.1.175:6443" } ]}

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 787

Page 798: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

表6-544描述API的状态码。

表 6-544 状态码

状态码 描述

200 This operation succeeds, and a groupof APIVersions resource objects isreturned.

异常状态码请参见9.3 状态码。

6.21.2 列出 APIGroups

功能介绍

This API is used to list APIGroups.

URI

GET /apis

请求消息

N/A.

响应消息

响应参数:

表6-545 describes the response parameters.

表 6-545 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

groups groups object Standard list APIGroup

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 788

Page 799: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-546 groups 字段数据结构说明

参数 参数类型 描述

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

name String name is the name of the group.

preferredVersion preferredVersionobject

preferredVersion is the versionpreferred by the API server, whichprobably is the storage version.

serverAddressByClientCIDRs

serverAddressByClientCIDRs object

a map of client CIDR to serveraddress that is serving this group.This is to help clients reachservers in the most network-efficient way possible. Clients canuse the appropriate server addressas per the CIDR that they match.In case of multiple matches,clients should use the longestmatching CIDR. The server returnsonly those CIDRs that it thinksthat the client can match. Forexample: the master will return aninternal IP CIDR only, if the clientreaches the server using aninternal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr(in that order) to get the client IP.

versions preferredVersionobject

versions are the versionssupported in this group.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 789

Page 800: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-547 serverAddressByClientCIDRs 字段数据结构说明

参数 参数类型 描述

clientCIDR String The CIDR with which clients canmatch their IP to figure out theserver address that they shoulduse.

serverAddress String ddress of this server, suitable for aclient that matches the aboveCIDR. This can be a hostname,hostname:port, IP or IP:port.

表 6-548 preferredVersion 字段数据结构说明

参数 参数类型 描述

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

version String version specifies the version in theform of "version". This is to savethe clients the trouble of splittingthe GroupVersion.

响应示例:

{ "kind": "APIGroupList", "apiVersion": "v1", "groups": [ { "name": "apiregistration.k8s.io", "versions": [ { "groupVersion": "apiregistration.k8s.io/v1beta1", "version": "v1beta1" } ], "preferredVersion": { "groupVersion": "apiregistration.k8s.io/v1beta1", "version": "v1beta1" }, "serverAddressByClientCIDRs": null }, { "name": "extensions", "versions": [ { "groupVersion": "extensions/v1beta1", "version": "v1beta1" } ], "preferredVersion": { "groupVersion": "extensions/v1beta1", "version": "v1beta1"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 790

Page 801: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "serverAddressByClientCIDRs": null }, { "name": "apps", "versions": [ { "groupVersion": "apps/v1beta1", "version": "v1beta1" } ], "preferredVersion": { "groupVersion": "apps/v1beta1", "version": "v1beta1" }, "serverAddressByClientCIDRs": null }, { "name": "authentication.k8s.io", "versions": [ { "groupVersion": "authentication.k8s.io/v1", "version": "v1" }, { "groupVersion": "authentication.k8s.io/v1beta1", "version": "v1beta1" } ], "preferredVersion": { "groupVersion": "authentication.k8s.io/v1", "version": "v1" }, "serverAddressByClientCIDRs": null }, { "name": "authorization.k8s.io", "versions": [ { "groupVersion": "authorization.k8s.io/v1", "version": "v1" }, { "groupVersion": "authorization.k8s.io/v1beta1", "version": "v1beta1" } ], "preferredVersion": { "groupVersion": "authorization.k8s.io/v1", "version": "v1" }, "serverAddressByClientCIDRs": null }, { "name": "autoscaling", "versions": [ { "groupVersion": "autoscaling/v1", "version": "v1" } ], "preferredVersion": { "groupVersion": "autoscaling/v1", "version": "v1" }, "serverAddressByClientCIDRs": null }, { "name": "batch",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 791

Page 802: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"versions": [ { "groupVersion": "batch/v1", "version": "v1" } ], "preferredVersion": { "groupVersion": "batch/v1", "version": "v1" }, "serverAddressByClientCIDRs": null }, { "name": "certificates.k8s.io", "versions": [ { "groupVersion": "certificates.k8s.io/v1beta1", "version": "v1beta1" } ], "preferredVersion": { "groupVersion": "certificates.k8s.io/v1beta1", "version": "v1beta1" }, "serverAddressByClientCIDRs": null }, { "name": "networking.k8s.io", "versions": [ { "groupVersion": "networking.k8s.io/v1", "version": "v1" } ], "preferredVersion": { "groupVersion": "networking.k8s.io/v1", "version": "v1" }, "serverAddressByClientCIDRs": null }, { "name": "policy", "versions": [ { "groupVersion": "policy/v1beta1", "version": "v1beta1" } ], "preferredVersion": { "groupVersion": "policy/v1beta1", "version": "v1beta1" }, "serverAddressByClientCIDRs": null }, { "name": "rbac.authorization.k8s.io", "versions": [ { "groupVersion": "rbac.authorization.k8s.io/v1beta1", "version": "v1beta1" }, { "groupVersion": "rbac.authorization.k8s.io/v1alpha1", "version": "v1alpha1" } ], "preferredVersion": { "groupVersion": "rbac.authorization.k8s.io/v1beta1", "version": "v1beta1"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 792

Page 803: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "serverAddressByClientCIDRs": null }, { "name": "settings.k8s.io", "versions": [ { "groupVersion": "settings.k8s.io/v1alpha1", "version": "v1alpha1" } ], "preferredVersion": { "groupVersion": "settings.k8s.io/v1alpha1", "version": "v1alpha1" }, "serverAddressByClientCIDRs": null }, { "name": "storage.k8s.io", "versions": [ { "groupVersion": "storage.k8s.io/v1", "version": "v1" }, { "groupVersion": "storage.k8s.io/v1beta1", "version": "v1beta1" } ], "preferredVersion": { "groupVersion": "storage.k8s.io/v1", "version": "v1" }, "serverAddressByClientCIDRs": null }, { "name": "apiextensions.k8s.io", "versions": [ { "groupVersion": "apiextensions.k8s.io/v1beta1", "version": "v1beta1" } ], "preferredVersion": { "groupVersion": "apiextensions.k8s.io/v1beta1", "version": "v1beta1" }, "serverAddressByClientCIDRs": null } ]}

状态码

表6-549描述API的状态码。

表 6-549 状态码

状态码 描述

200 This operation succeeds, and a groupof APIGroups resource objects isreturned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 793

Page 804: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.21.3 listing APIResources of GroupVersionapiregistration.k8s.io/v1beta1

功能介绍

This API is used to list APIGroups.

URI

GET /apis/apiregistration.k8s.io/v1beta1

请求消息

N/A.

响应消息

响应参数:

表6-550 describes the response parameters.

表 6-550 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-551 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 794

Page 805: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "apiregistration.k8s.io/v1beta1", "resources": [ { "name": "apiservices", "singularName": "", "namespaced": false, "kind": "APIService", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] }, { "name": "apiservices/status", "singularName": "", "namespaced": false, "kind": "APIService", "verbs": [ "update" ] }

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 795

Page 806: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

]}

状态码

表6-552描述API的状态码。

表 6-552 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.4 listing APIResources of GroupVersion extensions/v1beta1

功能介绍

This API is used to list APIGroups.

URI

GET /apis/extensions/v1beta1

请求消息

N/A.

响应消息

响应参数:

表6-553 describes the response parameters.

表 6-553 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 796

Page 807: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

resources resources object Standard list resource

表 6-554 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "groupVersion": "extensions/v1beta1", "resources": [ { "name": "daemonsets", "singularName": "", "namespaced": true, "kind": "DaemonSet", "verbs": [ "create", "delete",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 797

Page 808: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "ds" ] }, { "name": "daemonsets/status", "singularName": "", "namespaced": true, "kind": "DaemonSet", "verbs": [ "get", "patch", "update" ] }, { "name": "deployments", "singularName": "", "namespaced": true, "kind": "Deployment", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "deploy" ], "categories": [ "all" ] }, { "name": "deployments/rollback", "singularName": "", "namespaced": true, "kind": "DeploymentRollback", "verbs": [ "create" ] }, { "name": "deployments/scale", "singularName": "", "namespaced": true, "kind": "Scale", "verbs": [ "get", "patch", "update" ] }, { "name": "deployments/status", "singularName": "", "namespaced": true, "kind": "Deployment",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 798

Page 809: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"verbs": [ "get", "patch", "update" ] }, { "name": "ingresses", "singularName": "", "namespaced": true, "kind": "Ingress", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "ing" ] }, { "name": "ingresses/status", "singularName": "", "namespaced": true, "kind": "Ingress", "verbs": [ "get", "patch", "update" ] }, { "name": "networkpolicies", "singularName": "", "namespaced": true, "kind": "NetworkPolicy", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] }, { "name": "podsecuritypolicies", "singularName": "", "namespaced": false, "kind": "PodSecurityPolicy", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "psp"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 799

Page 810: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

] }, { "name": "replicasets", "singularName": "", "namespaced": true, "kind": "ReplicaSet", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "rs" ], "categories": [ "all" ] }, { "name": "replicasets/scale", "singularName": "", "namespaced": true, "kind": "Scale", "verbs": [ "get", "patch", "update" ] }, { "name": "replicasets/status", "singularName": "", "namespaced": true, "kind": "ReplicaSet", "verbs": [ "get", "patch", "update" ] }, { "name": "replicationcontrollers", "singularName": "", "namespaced": true, "kind": "ReplicationControllerDummy", "verbs": [] }, { "name": "replicationcontrollers/scale", "singularName": "", "namespaced": true, "kind": "Scale", "verbs": [ "get", "patch", "update" ] }, { "name": "thirdpartyresources", "singularName": "", "namespaced": false, "kind": "ThirdPartyResource",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 800

Page 811: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] } ]}

状态码

表6-555描述API的状态码。

表 6-555 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.5 listing APIResources of GroupVersion apps/v1beta1

功能介绍

This API is used to list APIResources of Group Version "apps/v1beta1".

URIGET /apis/apps/v1beta1

请求消息

N/A.

响应消息

响应参数:

表6-556 describes the response parameters.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 801

Page 812: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-556 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-557 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 802

Page 813: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "apps/v1beta1", "resources": [ { "name": "controllerrevisions", "singularName": "", "namespaced": true, "kind": "ControllerRevision", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] }, { "name": "deployments", "singularName": "", "namespaced": true, "kind": "Deployment", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "deploy" ], "categories": [ "all" ] }, { "name": "deployments/rollback", "singularName": "", "namespaced": true, "kind": "DeploymentRollback", "verbs": [ "create" ] }, { "name": "deployments/scale", "singularName": "", "namespaced": true, "kind": "Scale", "verbs": [ "get", "patch", "update" ] }, { "name": "deployments/status", "singularName": "", "namespaced": true, "kind": "Deployment",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 803

Page 814: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"verbs": [ "get", "patch", "update" ] }, { "name": "statefulsets", "singularName": "", "namespaced": true, "kind": "StatefulSet", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "sts" ], "categories": [ "all" ] }, { "name": "statefulsets/status", "singularName": "", "namespaced": true, "kind": "StatefulSet", "verbs": [ "get", "patch", "update" ] } ]}

状态码

表6-558描述API的状态码。

表 6-558 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.6 listing APIResources of GroupVersionauthentication.k8s.io/v1

功能介绍

This API is used to list APIResources of GroupVersion "authentication.k8s.io/v1".

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 804

Page 815: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

URI

GET /apis/authentication.k8s.io/v1

请求消息

N/A.

响应消息

响应参数:

表6-559 describes the response parameters.

表 6-559 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-560 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 805

Page 816: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "authentication.k8s.io/v1", "resources": [ { "name": "tokenreviews", "singularName": "", "namespaced": false, "kind": "TokenReview", "verbs": [ "create" ] } ]}

状态码

表6-561描述API的状态码。

表 6-561 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 806

Page 817: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.21.7 listing APIResources of GroupVersionauthentication.k8s.io/v1beta1

功能介绍

This API is used to list APIResources of GroupVersion "authentication.k8s.io/v1beta1".

URI

GET /apis/authentication.k8s.io/v1beta1

请求消息

N/A.

响应消息

响应参数:

表6-562 describes the response parameters.

表 6-562 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-563 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 807

Page 818: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "authentication.k8s.io/v1beta1", "resources": [ { "name": "tokenreviews", "singularName": "", "namespaced": false, "kind": "TokenReview", "verbs": [ "create" ] } ]}

状态码

表6-564描述API的状态码。

表 6-564 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 808

Page 819: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

异常状态码请参见9.3 状态码。

6.21.8 listing APIResources of GroupVersionauthorization.k8s.io/v1

功能介绍

This API is used to list APIResources of GroupVersion "authorization.k8s.io/v1".

URI

GET /apis/authorization.k8s.io/v1

请求消息

N/A.

响应消息

响应参数:

表6-565 describes the response parameters.

表 6-565 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-566 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 809

Page 820: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "authorization.k8s.io/v1", "resources": [ { "name": "localsubjectaccessreviews", "singularName": "", "namespaced": true, "kind": "LocalSubjectAccessReview", "verbs": [ "create" ] }, { "name": "selfsubjectaccessreviews", "singularName": "", "namespaced": false, "kind": "SelfSubjectAccessReview", "verbs": [ "create" ] }, { "name": "subjectaccessreviews", "singularName": "", "namespaced": false, "kind": "SubjectAccessReview", "verbs": [ "create" ]

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 810

Page 821: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} ]}

状态码

表6-567描述API的状态码。

表 6-567 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

F异常状态码请参见9.3 状态码。

6.21.9 listing APIResources of GroupVersionauthorization.k8s.io/v1beta1

功能介绍

This API is used to list APIResources of GroupVersion "authorization.k8s.io/v1beta1".

URI

GET /apis/authorization.k8s.io/v1beta1

请求消息

N/A.

响应消息

响应参数:

表6-568 describes the response parameters.

表 6-568 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 811

Page 822: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-569 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "authorization.k8s.io/v1beta1", "resources": [ { "name": "localsubjectaccessreviews",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 812

Page 823: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"singularName": "", "namespaced": true, "kind": "LocalSubjectAccessReview", "verbs": [ "create" ] }, { "name": "selfsubjectaccessreviews", "singularName": "", "namespaced": false, "kind": "SelfSubjectAccessReview", "verbs": [ "create" ] }, { "name": "subjectaccessreviews", "singularName": "", "namespaced": false, "kind": "SubjectAccessReview", "verbs": [ "create" ] } ]}

状态码

表6-570描述API的状态码。

表 6-570 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.10 listing APIResources of GroupVersion autoscaling/v1

功能介绍

This API is used to list APIResources of GroupVersion "autoscaling/v1".

URIGET /apis/autoscaling/v1

请求消息

N/A.

响应消息

响应参数:

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 813

Page 824: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表6-571 describes the response parameters.

表 6-571 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-572 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 814

Page 825: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "autoscaling/v1", "resources": [ { "name": "horizontalpodautoscalers", "singularName": "", "namespaced": true, "kind": "HorizontalPodAutoscaler", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "hpa" ], "categories": [ "all" ] }, { "name": "horizontalpodautoscalers/status", "singularName": "", "namespaced": true, "kind": "HorizontalPodAutoscaler", "verbs": [ "get", "patch", "update" ] } ]}

状态码

表6-573描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 815

Page 826: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-573 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.11 listing APIResources of GroupVersion batch/v1

功能介绍

This API is used to list APIResources of GroupVersion "batch/v1".

URIGET /apis/batch/v1

请求消息

N/A.

响应消息

响应参数:

表6-574 describes the response parameters.

表 6-574 参数解释

参数 参数类型 描述

kind String Kind is a String value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 816

Page 827: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-575 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "batch/v1", "resources": [ { "name": "jobs", "singularName": "", "namespaced": true, "kind": "Job", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ],

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 817

Page 828: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"categories": [ "all" ] }, { "name": "jobs/status", "singularName": "", "namespaced": true, "kind": "Job", "verbs": [ "get", "patch", "update" ] } ]}

状态码

表6-576描述API的状态码。

表 6-576 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.12 listing APIResources of GroupVersioncertificates.k8s.io/v1beta1

功能介绍

This API is used to list GroupVersion "certificates.k8s.io/v1beta1".

URI

GET /apis/certificates.k8s.io/v1beta1

请求消息

N/A.

响应消息

响应参数:

表6-577 describes the response parameters.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 818

Page 829: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-577 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-578 resources 字段数据结构说明

参数 Type 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 819

Page 830: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "certificates.k8s.io/v1beta1", "resources": [ { "name": "certificatesigningrequests", "singularName": "", "namespaced": false, "kind": "CertificateSigningRequest", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "csr" ] }, { "name": "certificatesigningrequests/approval", "singularName": "", "namespaced": false, "kind": "CertificateSigningRequest", "verbs": [ "update" ] }, { "name": "certificatesigningrequests/status", "singularName": "", "namespaced": false, "kind": "CertificateSigningRequest", "verbs": [ "update" ] } ]}

状态码

表6-579描述API的状态码。

表 6-579 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 820

Page 831: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.21.13 listing APIResources of GroupVersionnetworking.k8s.io/v1

功能介绍

This API is used to list APIResources of GroupVersion "networking.k8s.io/v1".

URIGET /apis/networking.k8s.io/v1

请求消息

N/A.

响应消息

响应参数:

表6-580 describes the response parameters.

表 6-580 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-581 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 821

Page 832: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "networking.k8s.io/v1", "resources": [ { "name": "networkpolicies", "singularName": "", "namespaced": true, "kind": "NetworkPolicy", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] } ]}

状态码

表6-582描述API的状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 822

Page 833: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-582 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.14 listing APIResources of GroupVersion policy/v1beta1

功能介绍

This API is used to list APIResources of GroupVersion "policy/v1beta1".

URIGET /apis/policy/v1beta1

请求消息

N/A.

响应消息

响应参数:

表6-583 describes the response parameters.

表 6-583 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 823

Page 834: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-584 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "policy/v1beta1", "resources": [ { "name": "poddisruptionbudgets", "singularName": "", "namespaced": true, "kind": "PodDisruptionBudget", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ],

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 824

Page 835: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"shortNames": [ "pdb" ] }, { "name": "poddisruptionbudgets/status", "singularName": "", "namespaced": true, "kind": "PodDisruptionBudget", "verbs": [ "get", "patch", "update" ] } ]}

状态码

表6-585描述API的状态码。

表 6-585 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.15 listing APIResources of GroupVersionrbac.authorization.k8s.io/v1beta1

功能介绍

This API is used to list APIResources of GroupVersion "rbac.authorization.k8s.io/v1beta1".

URI

GET /apis/rbac.authorization.k8s.io/v1beta1

请求消息

N/A.

响应消息

响应参数:

表6-586 describes the response parameters.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 825

Page 836: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-586 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-587 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 826

Page 837: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "rbac.authorization.k8s.io/v1beta1", "resources": [ { "name": "clusterrolebindings", "singularName": "", "namespaced": false, "kind": "ClusterRoleBinding", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] }, { "name": "clusterroles", "singularName": "", "namespaced": false, "kind": "ClusterRole", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] }, { "name": "rolebindings", "singularName": "", "namespaced": true, "kind": "RoleBinding", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] }, { "name": "roles", "singularName": "", "namespaced": true, "kind": "Role", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ]

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 827

Page 838: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

} ]}

状态码

表6-588描述API的状态码。

表 6-588 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.16 listing APIResources of GroupVersion storage.k8s.io/v1

功能介绍

This API is used to list APIResources of GroupVersion "storage.k8s.io/v1".

URI

GET /apis/storage.k8s.io/v1

请求消息

N/A.

响应消息

响应参数:

表6-589 describes the response parameters.

表 6-589 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 828

Page 839: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

resources resources object Standard list resource

表 6-590 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "storage.k8s.io/v1", "resources": [ { "name": "storageclasses", "singularName": "", "namespaced": false, "kind": "StorageClass", "verbs": [ "create",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 829

Page 840: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "sc" ] } ]}

状态码

表6-591描述API的状态码。

表 6-591 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.17 listing APIResources of GroupVersion storage.k8s.io/v1beta1

功能介绍

This API is used to list APIResources of GroupVersion "storage.k8s.io/v1beta1".

URIGET /apis/storage.k8s.io/v1beta1

请求消息

N/A.

响应消息

响应参数:

表6-592 describes the response parameters.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 830

Page 841: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-592 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-593 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 831

Page 842: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "storage.k8s.io/v1beta1", "resources": [ { "name": "storageclasses", "singularName": "", "namespaced": false, "kind": "StorageClass", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "sc" ] } ]}

状态码

表6-594描述API的状态码。

表 6-594 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.21.18 listing APIResources of GroupVersionapiextensions.k8s.io/v1beta1

功能介绍

This API is used to list APIResources of GroupVersion "apiextensions.k8s.io/v1beta1".

URIGET /apis/apiextensions.k8s.io/v1beta1

请求消息

N/A.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 832

Page 843: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应消息

响应参数:

表6-595 describes the response parameters.

表 6-595 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-596 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 833

Page 844: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "apiVersion": "v1", "groupVersion": "apiextensions.k8s.io/v1beta1", "resources": [ { "name": "customresourcedefinitions", "singularName": "", "namespaced": false, "kind": "CustomResourceDefinition", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "crd" ] }, { "name": "customresourcedefinitions/status", "singularName": "", "namespaced": false, "kind": "CustomResourceDefinition", "verbs": [ "update" ] } ]}

状态码

表6-597描述API的状态码。

表 6-597 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 834

Page 845: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.21.19 listing APIResources of GroupVersion v1

功能介绍

This API is used to list APIResources of GroupVersion "v1".

URI

GET /api/v1

请求消息

N/A.

响应消息

响应参数:

表6-598 describes the response parameters.

表 6-598 参数解释

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

groupVersion String groupVersion specifies the APIgroup and version in the form"group/version"

resources resources object Standard list resource

表 6-599 resources 字段数据结构说明

参数 参数类型 描述

categories Array of strings categories is a list of the groupedresources this resource belongs to(e.g. 'all')

kind String kind is the kind for the resource(e.g. 'Foo' is the kind for aresource 'foo')

name String name is the plural name of theresource.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 835

Page 846: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

namespaced Boolean namespaced indicates if aresource is namespaced or not.

shortNames Array of strings shortNames is a list of suggestedshort names of the resource.

singularName String singularName is the singularname of the resource. This allowsclients to handle plural andsingular opaquely. ThesingularName is more correct forreporting status on a single itemand both singular and plural areallowed from the kubectl CLIinterface.

verbs Array of strings verbs is a list of supported kubeverbs (this includes get, list,watch, create, update, patch,delete, deletecollection, andproxy)

响应示例:

{ "kind": "APIResourceList", "groupVersion": "v1", "resources": [ { "name": "bindings", "singularName": "", "namespaced": true, "kind": "Binding", "verbs": [ "create" ] }, { "name": "componentstatuses", "singularName": "", "namespaced": false, "kind": "ComponentStatus", "verbs": [ "get", "list" ], "shortNames": [ "cs" ] }, { "name": "configmaps", "singularName": "", "namespaced": true, "kind": "ConfigMap", "verbs": [ "create", "delete", "deletecollection",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 836

Page 847: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"get", "list", "patch", "update", "watch" ], "shortNames": [ "cm" ] }, { "name": "endpoints", "singularName": "", "namespaced": true, "kind": "Endpoints", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "ep" ] }, { "name": "events", "singularName": "", "namespaced": true, "kind": "Event", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "ev" ] }, { "name": "limitranges", "singularName": "", "namespaced": true, "kind": "LimitRange", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "limits" ] }, { "name": "namespaces",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 837

Page 848: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"singularName": "", "namespaced": false, "kind": "Namespace", "verbs": [ "create", "delete", "get", "list", "patch", "update", "watch" ], "shortNames": [ "ns" ] }, { "name": "namespaces/finalize", "singularName": "", "namespaced": false, "kind": "Namespace", "verbs": [ "update" ] }, { "name": "namespaces/status", "singularName": "", "namespaced": false, "kind": "Namespace", "verbs": [ "get", "patch", "update" ] }, { "name": "nodes", "singularName": "", "namespaced": false, "kind": "Node", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "proxy", "update", "watch" ], "shortNames": [ "no" ] }, { "name": "nodes/proxy", "singularName": "", "namespaced": false, "kind": "Node", "verbs": [] }, { "name": "nodes/status", "singularName": "", "namespaced": false, "kind": "Node", "verbs": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 838

Page 849: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"get", "patch", "update" ] }, { "name": "persistentvolumeclaims", "singularName": "", "namespaced": true, "kind": "PersistentVolumeClaim", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "pvc" ] }, { "name": "persistentvolumeclaims/status", "singularName": "", "namespaced": true, "kind": "PersistentVolumeClaim", "verbs": [ "get", "patch", "update" ] }, { "name": "persistentvolumes", "singularName": "", "namespaced": false, "kind": "PersistentVolume", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "pv" ] }, { "name": "persistentvolumes/status", "singularName": "", "namespaced": false, "kind": "PersistentVolume", "verbs": [ "get", "patch", "update" ] }, { "name": "pods", "singularName": "", "namespaced": true,

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 839

Page 850: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"kind": "Pod", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "proxy", "update", "watch" ], "shortNames": [ "po" ], "categories": [ "all" ] }, { "name": "pods/attach", "singularName": "", "namespaced": true, "kind": "Pod", "verbs": [] }, { "name": "pods/binding", "singularName": "", "namespaced": true, "kind": "Binding", "verbs": [ "create" ] }, { "name": "pods/eviction", "singularName": "", "namespaced": true, "kind": "Eviction", "verbs": [ "create" ] }, { "name": "pods/exec", "singularName": "", "namespaced": true, "kind": "Pod", "verbs": [] }, { "name": "pods/log", "singularName": "", "namespaced": true, "kind": "Pod", "verbs": [ "get" ] }, { "name": "pods/portforward", "singularName": "", "namespaced": true, "kind": "Pod", "verbs": [] }, { "name": "pods/proxy",

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 840

Page 851: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"singularName": "", "namespaced": true, "kind": "Pod", "verbs": [] }, { "name": "pods/status", "singularName": "", "namespaced": true, "kind": "Pod", "verbs": [ "get", "patch", "update" ] }, { "name": "podtemplates", "singularName": "", "namespaced": true, "kind": "PodTemplate", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] }, { "name": "replicationcontrollers", "singularName": "", "namespaced": true, "kind": "ReplicationController", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "rc" ], "categories": [ "all" ] }, { "name": "replicationcontrollers/scale", "singularName": "", "namespaced": true, "kind": "Scale", "verbs": [ "get", "patch", "update" ] }, { "name": "replicationcontrollers/status", "singularName": "", "namespaced": true,

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 841

Page 852: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"kind": "ReplicationController", "verbs": [ "get", "patch", "update" ] }, { "name": "resourcequotas", "singularName": "", "namespaced": true, "kind": "ResourceQuota", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [ "quota" ] }, { "name": "resourcequotas/status", "singularName": "", "namespaced": true, "kind": "ResourceQuota", "verbs": [ "get", "patch", "update" ] }, { "name": "secrets", "singularName": "", "namespaced": true, "kind": "Secret", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ] }, { "name": "serviceaccounts", "singularName": "", "namespaced": true, "kind": "ServiceAccount", "verbs": [ "create", "delete", "deletecollection", "get", "list", "patch", "update", "watch" ], "shortNames": [

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 842

Page 853: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"sa" ] }, { "name": "services", "singularName": "", "namespaced": true, "kind": "Service", "verbs": [ "create", "delete", "get", "list", "patch", "proxy", "update", "watch" ] }, { "name": "services/proxy", "singularName": "", "namespaced": true, "kind": "Service", "verbs": [] }, { "name": "services/status", "singularName": "", "namespaced": true, "kind": "Service", "verbs": [ "get", "patch", "update" ] } ]}

状态码

表6-600描述API的状态码。

表 6-600 状态码

状态码 描述

200 This operation succeeds, and a list ofAPIResources is returned.

异常状态码请参见9.3 状态码。

6.22 Event

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 843

Page 854: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

6.22.1 获取 Event

功能介绍

list or watch objects of kind Event.

URIGET /api/v1/events

GET /apis/events.k8s.io/v1beta1/events

表 6-601 Query 参数

参数 是否必选 参数类型

描述

continue 否 String The continue option should be setwhen retrieving more results from theserver. Since this value is server defined,clients may only use the continue valuefrom a previous query result withidentical query parameters (except forthe value of continue) and the servermay reject a continue value it does notrecognize. If the specified continuevalue is no longer valid whether due toexpiration (generally five to fifteenminutes) or a configuration change onthe server the server will respond witha 410 ResourceExpired error indicatingthe client must restart their list withoutthe continue field. This field is notsupported when watch is true. Clientsmay start a watch from the lastresourceVersion value returned by theserver and not miss any modifications.

fieldSelector 否 String A selector to restrict the list of returnedobjects by their fields. Defaults toeverything.

includeUninitialized

否 Boolean

If true, partially initialized resources areincluded in the response.

labelSelector 否 String A selector to restrict the list of returnedobjects by their labels. Defaults toeverything.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 844

Page 855: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型

描述

limit 否 Integer limit is a maximum number ofresponses to return for a list call. Ifmore items exist, the server will set the`continue` field on the list metadata toa value that can be used with the sameinitial query to retrieve the next set ofresults. Setting a limit may return fewerthan the requested amount of items(up to zero items) in the event allrequested objects are filtered out andclients should only use the presence ofthe continue field to determinewhether more results are available.Servers may choose not to support thelimit argument and will return all ofthe available results. If limit is specifiedand the continue field is empty, clientsmay assume that no more results areavailable. This field is not supported ifwatch is true.The server guarantees that the objectsreturned when using continue will beidentical to issuing a single list callwithout a limit - that is, no objectscreated, modified, or deleted after thefirst request is issued will be included inany subsequent continued requests.This is sometimes referred to as aconsistent snapshot, and ensures that aclient that is using limit to receivesmaller chunks of a very large resultcan ensure they see all possible objects.If objects are updated during a chunkedlist the version of the object that waspresent at the time the first list resultwas calculated is returned.

pretty 否 String If 'true', then the output is prettyprinted.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 845

Page 856: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型

描述

resourceVersion

否 String When specified with a watch call,shows changes that occur after thatparticular version of a resource.Defaults to changes from the beginningof history. When specified for list: - ifunset, then the result is returned fromremote storage based on quorum-readflag; - if it's 0, then we simply returnwhat we currently have in cache, noguarantee; - if set to non zero, then theresult is at least as fresh as given rv.

timeoutSeconds

否 Integer Timeout for the list/watch call. Thislimits the duration of the call,regardless of any activity or inactivity.

watch 否 Boolean

Watch for changes to the describedresources and return them as a streamof add, update, and removenotifications. Specify resourceVersion.

请求参数

响应参数

状态码为 200 时:

表 6-602 响应 Body 参数

参数 参数类型 描述

apiVersion String APIVersion defines the versioned schema ofthis representation of an object. Servers shouldconvert recognized schemas to the latestinternal value, and may reject unrecognizedvalues. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

items io.k8s.api.core.v1.Eventobject

List of events. More info:Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 846

Page 857: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

kind String Kind is a string value representing the RESTresource this object represents. Servers mayinfer this from the endpoint the client submitsrequests to. Cannot be updated. In CamelCase.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

metadata io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta object

Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

表 6-603 io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta

参数 参数类型 描述

continue String continue may be set if the user set a limit onthe number of items returned, and indicatesthat the server has more data available. Thevalue is opaque and may be used to issueanother request to the endpoint that servedthis list to retrieve the next set of availableobjects. Continuing a list may not be possible ifthe server configuration has changed or morethan a few minutes have passed. TheresourceVersion field returned when using thiscontinue value will be identical to the value inthe first response.

resourceVersion

String String that identifies the server's internalversion of this object that can be used byclients to determine when objects havechanged. Value must be treated as opaque byclients and passed unmodified back to theserver. Populated by the system. Read-only.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency

selfLink String selfLink is a URL representing this object.Populated by the system. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 847

Page 858: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-604 io.k8s.api.core.v1.Event

参数 参数类型 描述

action String What action was taken/failed regarding to theRegarding object.

apiVersion String APIVersion defines the versioned schema ofthis representation of an object. Servers shouldconvert recognized schemas to the latestinternal value, and may reject unrecognizedvalues. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

count Integer The number of times this event has occurred.

eventTime io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime object

MicroTime is version of Time with microsecondlevel precision.

firstTimestamp

io.k8s.apimachinery.pkg.apis.meta.v1.Time object

Time is a wrapper around time.Time whichsupports correct marshaling to YAML andJSON. Wrappers are provided for many of thefactory methods that the time package offers.

involvedObject

io.k8s.api.core.v1.ObjectReference object

The object that this event is about.

kind String Kind is a string value representing the RESTresource this object represents. Servers mayinfer this from the endpoint the client submitsrequests to. Cannot be updated. In CamelCase.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

lastTimestamp

io.k8s.apimachinery.pkg.apis.meta.v1.Time object

Time is a wrapper around time.Time whichsupports correct marshaling to YAML andJSON. Wrappers are provided for many of thefactory methods that the time package offers.

message String A human-readable description of the status ofthis operation.

metadata io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMetaobject

Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata

reason String This should be a short, machineunderstandable string that gives the reason forthe transition into the object's current status.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 848

Page 859: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

related io.k8s.api.core.v1.ObjectReference object

Optional secondary object for more complexactions.

reportingComponent

String Name of the controller that emitted this Event,e.g. `kubernetes.io/kubelet`.

reportingInstance

String ID of the controller instance, e.g. `kubelet-xyzf`.

series io.k8s.api.core.v1.EventSeries object

Data about the Event series this eventrepresents or nil if it's a singleton Event.

source io.k8s.api.core.v1.EventSource object

The component reporting this event. Should bea short machine understandable string.

type String Type of this event (Normal, Warning), newtypes could be added in the future

表 6-605 io.k8s.api.core.v1.EventSource

参数 参数类型 描述

component String Component from which the event is generated.

host String Node name on which the event is generated.

表 6-606 io.k8s.api.core.v1.EventSeries

参数 参数类型 描述

count Integer Number of occurrences in this series up to thelast heartbeat time

lastObservedTime

io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime object

MicroTime is version of Time with microsecondlevel precision.

state String State of this Series: Ongoing or Finished

表 6-607 io.k8s.api.core.v1.ObjectReference

参数 参数类型 描述

apiVersion String API version of the referent.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 849

Page 860: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

fieldPath String If referring to a piece of an object instead of anentire object, this string should contain a validJSON/Go field access statement, such asdesiredState.manifest.containers[2]. Forexample, if the object reference is to acontainer within a pod, this would take on avalue like: "spec.containers{name}" (where"name" refers to the name of the containerthat triggered the event) or if no containername is specified "spec.containers[2]"(container with index 2 in this pod). Thissyntax is chosen only to have some well-defined way of referencing a part of an object.

kind String Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

name String Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

namespace String Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

resourceVersion

String Specific resourceVersion to which this referenceis made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency

uid String UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids

表 6-608 io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta

参数 参数类型 描述

annotations Object Annotations is an unstructured key value mapstored with a resource that may be set byexternal tools to store and retrieve arbitrarymetadata. They are not queryable and shouldbe preserved when modifying objects. Moreinfo: http://kubernetes.io/docs/user-guide/annotations

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 850

Page 861: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

clusterName String The name of the cluster which the objectbelongs to. This is used to distinguish resourceswith same name and namespace in differentclusters. This field is not set anywhere rightnow and apiserver is going to ignore it if set increate or update request.

creationTimestamp

io.k8s.apimachinery.pkg.apis.meta.v1.Time object

Time is a wrapper around time.Time whichsupports correct marshaling to YAML andJSON. Wrappers are provided for many of thefactory methods that the time package offers.

deletionGracePeriodSeconds

Long Number of seconds allowed for this object togracefully terminate before it will be removedfrom the system. Only set whendeletionTimestamp is also set. May only beshortened. Read-only.

deletionTimestamp

io.k8s.apimachinery.pkg.apis.meta.v1.Time object

Time is a wrapper around time.Time whichsupports correct marshaling to YAML andJSON. Wrappers are provided for many of thefactory methods that the time package offers.

enable Boolean Enable identify whether the resource isavailable

finalizers Array ofstring

Must be empty before the object is deletedfrom the registry. Each entry is an identifier forthe responsible component that will removethe entry from the list. If thedeletionTimestamp of the object is non-nil,entries in this list can only be removed.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 851

Page 862: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

generateName

String GenerateName is an optional prefix, used bythe server, to generate a unique name ONLY IFthe Name field has not been provided. If thisfield is used, the name returned to the clientwill be different than the name passed. Thisvalue will also be combined with a uniquesuffix. The provided value has the samevalidation rules as the Name field, and may betruncated by the length of the suffix requiredto make the value unique on the server.

If this field is specified and the generatedname exists, the server will NOT return a 409 -instead, it will either return 201 Created or 500with Reason ServerTimeout indicating a uniquename could not be found in the time allotted,and the client should retry (optionally after thetime indicated in the Retry-After header).

Applied only if Name is not specified. Moreinfo: https://git.k8s.io/community/contributors/devel/api-conventions.md#idempotency

generation Long A sequence number representing a specificgeneration of the desired state. Populated bythe system. Read-only.

initializers io.k8s.apimachinery.pkg.apis.meta.v1.Initializers object

An initializer is a controller which enforcessome system invariant at object creation time.This field is a list of initializers that have notyet acted on this object. If nil or empty, thisobject has been completely initialized.Otherwise, the object is considereduninitialized and is hidden (in list/watch andget calls) from clients that haven't explicitlyasked to observe uninitialized objects.

When an object is created, the system willpopulate this list with the current set ofinitializers. Only privileged users may set ormodify this list. Once it is empty, it may not bemodified further by any user.

labels Object Map of string keys and values that can be usedto organize and categorize (scope and select)objects. May match selectors of replicationcontrollers and services. More info: http://kubernetes.io/docs/user-guide/labels

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 852

Page 863: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

name String Name must be unique within a namespace. Isrequired when creating resources, althoughsome resources may allow a client to requestthe generation of an appropriate nameautomatically. Name is primarily intended forcreation idempotence and configurationdefinition. Cannot be updated. More info:http://kubernetes.io/docs/user-guide/identifiers#names

namespace String Namespace defines the space within eachname must be unique. An empty namespace isequivalent to the "default" namespace, but"default" is the canonical representation. Notall objects are required to be scoped to anamespace - the value of this field for thoseobjects will be empty.

Must be a DNS_LABEL. Cannot be updated.More info: http://kubernetes.io/docs/user-guide/namespaces

ownerReferences

io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReferenceobject

List of objects depended by this object. If ALLobjects in the list have been deleted, thisobject will be garbage collected. If this object ismanaged by a controller, then an entry in thislist will point to this controller, with thecontroller field set to true. There cannot bemore than one managing controller.

resourceVersion

String An opaque value that represents the internalversion of this object that can be used byclients to determine when objects havechanged. May be used for optimisticconcurrency, change detection, and the watchoperation on a resource or set of resources.Clients must treat these values as opaque andpassed unmodified back to the server. Theymay only be valid for a particular resource orset of resources.

Populated by the system. Read-only. Valuemust be treated as opaque by clients and .More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency

selfLink String SelfLink is a URL representing this object.Populated by the system. Read-only.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 853

Page 864: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

uid String UID is the unique in time and space value forthis object. It is typically generated by theserver on successful creation of a resource andis not allowed to change on PUT operations.

Populated by the system. Read-only. More info:http://kubernetes.io/docs/user-guide/identifiers#uids

表 6-609 io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference

参数 参数类型 描述

apiVersion String API version of the referent.

blockOwnerDeletion

Boolean If true, AND if the owner has the"foregroundDeletion" finalizer, then the ownercannot be deleted from the key-value storeuntil this reference is removed. Defaults tofalse. To set this field, a user needs "delete"permission of the owner, otherwise 422(Unprocessable Entity) will be returned.

controller Boolean If true, this reference points to the managingcontroller.

kind String Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

name String Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names

uid String UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids

表 6-610 io.k8s.apimachinery.pkg.apis.meta.v1.Initializers

参数 参数类型 描述

pending io.k8s.apimachinery.pkg.apis.meta.v1.Initializer object

Pending is a list of initializers that mustexecute in order before this object is visible.When the last pending initializer is removed,and no failing result is set, the initializers structwill be set to nil and the object is considered asinitialized and visible to all clients.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 854

Page 865: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

result io.k8s.apimachinery.pkg.apis.meta.v1.Status object

If result is set with the Failure field, the objectwill be persisted to storage and then deleted,ensuring that other clients can observe thedeletion.

表 6-611 io.k8s.apimachinery.pkg.apis.meta.v1.Status

参数 参数类型 描述

apiVersion String APIVersion defines the versioned schema ofthis representation of an object. Servers shouldconvert recognized schemas to the latestinternal value, and may reject unrecognizedvalues. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

code Integer Suggested HTTP return code for this status, 0 ifnot set.

details io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetailsobject

Extended data associated with the reason.Each reason may define its own extendeddetails. This field is optional and the datareturned is not guaranteed to conform to anyschema except that defined by the reason type.

kind String Kind is a string value representing the RESTresource this object represents. Servers mayinfer this from the endpoint the client submitsrequests to. Cannot be updated. In CamelCase.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

message String A human-readable description of the status ofthis operation.

metadata io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta object

Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

reason String A machine-readable description of why thisoperation is in the "Failure" status. If this valueis empty there is no information available. AReason clarifies an HTTP status code but doesnot override it.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 855

Page 866: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

status String Status of the operation. One of: "Success" or"Failure". More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status

表 6-612 io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta

参数 参数类型 描述

continue String continue may be set if the user set a limit onthe number of items returned, and indicatesthat the server has more data available. Thevalue is opaque and may be used to issueanother request to the endpoint that servedthis list to retrieve the next set of availableobjects. Continuing a list may not be possible ifthe server configuration has changed or morethan a few minutes have passed. TheresourceVersion field returned when using thiscontinue value will be identical to the value inthe first response.

resourceVersion

String String that identifies the server's internalversion of this object that can be used byclients to determine when objects havechanged. Value must be treated as opaque byclients and passed unmodified back to theserver. Populated by the system. Read-only.More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency

selfLink String selfLink is a URL representing this object.Populated by the system. Read-only.

表 6-613 io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails

参数 参数类型 描述

causes io.k8s.apimachinery.pkg.apis.meta.v1.StatusCauseobject

The Causes array includes more detailsassociated with the StatusReason failure. Notall StatusReasons may provide detailed causes.

group String The group attribute of the resource associatedwith the status StatusReason.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 856

Page 867: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

kind String The kind attribute of the resource associatedwith the status StatusReason. On someoperations may differ from the requestedresource Kind. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

name String The name attribute of the resource associatedwith the status StatusReason (when there is asingle name which can be described).

retryAfterSeconds

Integer If specified, the time in seconds before theoperation should be retried. Some errors mayindicate the client must take an alternateaction - for those errors this field may indicatehow long to wait before taking the alternateaction.

uid String UID of the resource. (when there is a singleresource which can be described). More info:http://kubernetes.io/docs/user-guide/identifiers#uids

表 6-614 io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause

参数 参数类型 描述

field String The field of the resource that has caused thiserror, as named by its JSON serialization. Mayinclude dot and postfix notation for nestedattributes. Arrays are zero-indexed. Fields mayappear more than once in an array of causesdue to fields having multiple errors. Optional.Examples:"name" - the field "name" on the currentresource"items[0].name" - the field "name" on the firstarray entry in "items"

message String A human-readable description of the cause ofthe error. This field may be presented as-is to areader.

reason String A machine-readable description of the cause ofthe error. If this value is empty there is noinformation available.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 857

Page 868: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-615 io.k8s.apimachinery.pkg.apis.meta.v1.Initializer

参数 参数类型 描述

name String name of the process that is responsible forinitializing this object.

表 6-616 io.k8s.api.core.v1.ObjectReference

参数 参数类型 描述

apiVersion String API version of the referent.

fieldPath String If referring to a piece of an object instead of anentire object, this string should contain a validJSON/Go field access statement, such asdesiredState.manifest.containers[2]. Forexample, if the object reference is to acontainer within a pod, this would take on avalue like: "spec.containers{name}" (where"name" refers to the name of the containerthat triggered the event) or if no containername is specified "spec.containers[2]"(container with index 2 in this pod). Thissyntax is chosen only to have some well-defined way of referencing a part of an object.

kind String Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

name String Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

namespace String Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

resourceVersion

String Specific resourceVersion to which this referenceis made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency

uid String UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids

请求示例

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 858

Page 869: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

响应示例

状态码为 200 时:

{ "apiVersion": "v1", "items": [ { "apiVersion": "v1", "count": 9, "eventTime": null, "firstTimestamp": "2019-07-03T07:35:30Z", "involvedObject": { "apiVersion": "v1", "kind": "Pod", "name": "coredns-85cb64445b-mvthn", "namespace": "kube-system", "resourceVersion": "3714354", "uid": "225b433a-9d65-11e9-8d38-fa163eb8e88a" }, "kind": "Event", "lastTimestamp": "2019-07-03T07:40:59Z", "message": "0/1 nodes are available: 1 Insufficient memory.", "metadata": { "creationTimestamp": "2019-07-03T07:35:30Z", "name": "coredns-85cb64445b-mvthn.15add571ce713ccc", "namespace": "kube-system", "resourceVersion": "20929", "selfLink": "/api/v1/namespaces/kube-system/events/coredns-85cb64445b-mvthn.15add571ce713ccc", "uid": "225eb9ac-9d65-11e9-8d38-fa163eb8e88a" }, "reason": "FailedScheduling", "reportingComponent": "", "reportingInstance": "", "source": { "component": "default-scheduler" }, "type": "Warning" }, { "apiVersion": "v1", "count": 10, "eventTime": null, "firstTimestamp": "2019-07-03T07:35:30Z", "involvedObject": { "apiVersion": "v1", "kind": "Pod", "name": "coredns-85cb64445b-zq9hw", "namespace": "kube-system", "resourceVersion": "3714351", "uid": "225aac93-9d65-11e9-8d38-fa163eb8e88a" }, "kind": "Event", "lastTimestamp": "2019-07-03T07:40:59Z", "message": "0/1 nodes are available: 1 Insufficient memory.", "metadata": { "creationTimestamp": "2019-07-03T07:35:30Z", "name": "coredns-85cb64445b-zq9hw.15add571cd0faa51", "namespace": "kube-system", "resourceVersion": "20930", "selfLink": "/api/v1/namespaces/kube-system/events/coredns-85cb64445b-zq9hw.15add571cd0faa51", "uid": "225b53ba-9d65-11e9-8d38-fa163eb8e88a" }, "reason": "FailedScheduling", "reportingComponent": "", "reportingInstance": "", "source": {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 859

Page 870: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"component": "default-scheduler" }, "type": "Warning" }, { "apiVersion": "v1", "count": 1, "eventTime": null, "firstTimestamp": "2019-07-03T07:35:30Z", "involvedObject": { "apiVersion": "apps/v1", "kind": "ReplicaSet", "name": "coredns-85cb64445b", "namespace": "kube-system", "resourceVersion": "3714349", "uid": "22586f58-9d65-11e9-8d38-fa163eb8e88a" }, "kind": "Event", "lastTimestamp": "2019-07-03T07:35:30Z", "message": "Created pod: coredns-85cb64445b-zq9hw", "metadata": { "creationTimestamp": "2019-07-03T07:35:30Z", "name": "coredns-85cb64445b.15add571cd1f20ce", "namespace": "kube-system", "resourceVersion": "20899", "selfLink": "/api/v1/namespaces/kube-system/events/coredns-85cb64445b.15add571cd1f20ce", "uid": "225b5363-9d65-11e9-8d38-fa163eb8e88a" }, "reason": "SuccessfulCreate", "reportingComponent": "", "reportingInstance": "", "source": { "component": "replicaset-controller" }, "type": "Normal" }, { "apiVersion": "v1", "count": 1, "eventTime": null, "firstTimestamp": "2019-07-03T07:35:30Z", "involvedObject": { "apiVersion": "apps/v1", "kind": "ReplicaSet", "name": "coredns-85cb64445b", "namespace": "kube-system", "resourceVersion": "3714349", "uid": "22586f58-9d65-11e9-8d38-fa163eb8e88a" }, "kind": "Event", "lastTimestamp": "2019-07-03T07:35:30Z", "message": "Created pod: coredns-85cb64445b-mvthn", "metadata": { "creationTimestamp": "2019-07-03T07:35:30Z", "name": "coredns-85cb64445b.15add571cd6f40ae", "namespace": "kube-system", "resourceVersion": "20901", "selfLink": "/api/v1/namespaces/kube-system/events/coredns-85cb64445b.15add571cd6f40ae", "uid": "225c5dae-9d65-11e9-8d38-fa163eb8e88a" }, "reason": "SuccessfulCreate", "reportingComponent": "", "reportingInstance": "", "source": { "component": "replicaset-controller" }, "type": "Normal" }, {

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 860

Page 871: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "v1", "count": 1, "eventTime": null, "firstTimestamp": "2019-07-03T07:35:30Z", "involvedObject": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "coredns", "namespace": "kube-system", "resourceVersion": "3714347", "uid": "22573447-9d65-11e9-8d38-fa163eb8e88a" }, "kind": "Event", "lastTimestamp": "2019-07-03T07:35:30Z", "message": "Scaled up replica set coredns-85cb64445b to 2", "metadata": { "creationTimestamp": "2019-07-03T07:35:30Z", "name": "coredns.15add571cc4fcfab", "namespace": "kube-system", "resourceVersion": "20898", "selfLink": "/api/v1/namespaces/kube-system/events/coredns.15add571cc4fcfab", "uid": "22593def-9d65-11e9-8d38-fa163eb8e88a" }, "reason": "ScalingReplicaSet", "reportingComponent": "", "reportingInstance": "", "source": { "component": "deployment-controller" }, "type": "Normal" } ], "kind": "List", "metadata": { "resourceVersion": "", "selfLink": "" }}

返回值

返回值 说明

200 OK

401 Unauthorized

错误码

6.22.2 列出指定的 Event

功能介绍

This API is used to list all Event resource objects under a specified Namespace.

URI

GET /api/v1/namespaces/{namespace}/events

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 861

Page 872: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表6-617描述该API的参数。

表 6-617 参数解释

参数 是否必选 描述

namespace Yes Object name and auth scope, such as for teamsand projects.

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

includeUninitialized

No If true, partially initialized resources are includedin the response.

fieldSelector No A selector to restrict the list of returned objectsby their fields. Defaults to everything.

labelSelector No A selector to restrict the list of returned objectsby their labels. Defaults to everything.

resourceVersion

No When specified with a watch call, shows changesthat occur after that particular version of aresource. Defaults to changes from the beginningof history.

timeoutSeconds

No Timeout for the list/watch call.

watch No Watch for changes to the described resources andreturn them as a stream of add, update, andremove notifications. Specify resourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数请参见表6-618。

表 6-618 响应参数

名称 参数类型 描述

kind String A string value representing theREST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 862

Page 873: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

名称 参数类型 描述

apiVersion String Versioned schema of thisrepresentation of an object.Servers should convert recognizedschemas to the latest internalvalue, and may rejectunrecognized values.

metadata metadata object -

items items object List of replication controllers.

表 6-619 items 字段数据结构说明

名称 参数类型 描述

metadata metadata object Standard object's metadata.

involvedObject involvedObject object The object that this event is about.

kind String Kind is a string value representingthe REST resource this objectrepresents.

reason String This should be a short, machineunderstandable string that givesthe reason for the transition intothe object's current status.

message String A human-readable description ofthe status of this operation.

source source object The component reporting thisevent. Should be a short machineunderstandable string.

firstTimestamp Time The time at which the event wasfirst recorded. (Time of serverreceipt is in TypeMeta.)

lastTimestamp Time The time at which the most recentoccurrence of this event wasrecorded.

count Integer The number of times this eventhas occurred.

type String Type of this event (Normal,Warning), new types could beadded in the future.

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 863

Page 874: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 6-620 involvedObject 字段数据结构说明

名称 参数类型 描述

kind String Kind of the referent.

namespace String Namespace of the referent.

name String Name of the referent.

uid String UID of the referent.

apiVersion String API version of the referent.

resourceVersion String Specific resourceVersion to whichthis reference is made.

fieldPath String If referring to a piece of an objectinstead of an entire object, thisstring should contain a validJSON/Go field access statement,such asdesiredState.manifest.containers[2]. For example, if the objectreference is to a container within apod, this would take on a valuelike: "spec.containers{name}"(where "name" refers to the nameof the container that triggered theevent) or if no container name isspecified "spec.containers[2]"(container with index 2 in thispod). This syntax is chosen only tohave some well-defined way ofreferencing a part of an object.

表 6-621 source 字段数据结构说明

名称 参数类型 描述

component String Component from which the eventis generated.

host String Node name on which the event isgenerated.

响应示例:

{ "kind": "EventList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/events", "resourceVersion": "6218"

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 864

Page 875: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}, "items": [ { "metadata": { "name": "asdf-554b5dfc44-7mm4f.152b13061a06a7c2", "namespace": "default", "selfLink": "/api/v1/namespaces/default/events/asdf-554b5dfc44-7mm4f.152b13061a06a7c2", "uid": "9e033be0-4ea6-11e8-8c02-fa163e69d0fd", "resourceVersion": "6218", "creationTimestamp": "2018-05-03T07:50:15Z", "enable": true }, "involvedObject": { "kind": "Pod", "namespace": "default", "name": "asdf-554b5dfc44-7mm4f", "uid": "9dff08f2-4ea6-11e8-8c02-fa163e69d0fd", "apiVersion": "v1", "resourceVersion": "1767656" }, "reason": "FailedScheduling", "message": "0/1 nodes are available: 1 Insufficient memory.", "source": { "component": "default-scheduler" }, "firstTimestamp": "2018-05-03T07:50:15Z", "lastTimestamp": "2018-05-03T07:50:22Z", "count": 5, "type": "Warning", "eventTime": null, "reportingComponent": "", "reportingInstance": "" } ]}

状态码

表6-622描述API的状态码。

表 6-622 状态码

状态码 描述

200 This operation succeeds, and a Eventresource object is returned.

异常状态码请参见9.3 状态码。

云容器引擎API 参考 6 Kubernetes API

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 865

Page 876: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

7 数据结构

7.1 请求数据结构

表 7-1 v1.ReplicationController 请求参数

参数 是否必选 参数类型 描述

kind Yes String A string value representingthe REST resource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isReplicationController.

apiVersion Yes String Versioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

metadata Yes metadataobject

-

spec Yes spec object -

status No status object -

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 866

Page 877: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-2 v1.PodTemplate 请求参数

参数 是否必选 参数类型 描述

kind Yes String A string value representingthe REST resource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isPodTemplate.

apiVersion Yes String Versioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

metadata Yes metadataobject

-

template Yes templateobject

-

表 7-3 v1.Pod 请求参数

参数 是否必选 参数类型 描述

kind Yes String A string value representingthe REST resource this objectrepresents. Servers may inferthis from the endpoint theclient submits requests to.Cannot be updated. InCamelCase.The value of this parameter isPod.

apiVersion Yes String Versioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.The value of this parameter isv1.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 867

Page 878: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

metadata Yes metadataobject

-

spec Yes spec object -

status No status object -

表 7-4 status 字段数据结构说明

参数 是否必选 参数类型 描述

phase No String Current condition of the pod.

conditions No conditionsobject

Current service state of thepod.

message No String A human readable messageindicating details about whythe pod is in this condition.

reason No String A brief CamelCase messageindicating details about whythe pod is in this state. e.g.'OutOfDisk'

hostIP No String IP address of the host towhich the pod is assigned.Empty if not yet scheduled.

podIP No String IP address allocated to thepod. Routable at least withinthe cluster. Empty if not yetallocated.

startTime No String RFC 3339 date and time atwhich the object wasacknowledged by the Kubelet.This is before the Kubeletpulled the container image(s)for the pod.

containerStatuses

No containerStatuses object

The list has one entry percontainer in the manifest.Each entry is currently theoutput of docker inspect.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 868

Page 879: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-5 conditions 字段数据结构说明

参数 是否必选 参数类型 描述

type No String Type of the condition.Currently only Ready.

status No String Status of the condition. Canbe True, False, or Unknown.

lastProbeTime No String Last time we probed thecondition.

lastTransitionTime

No String Last time the conditiontransitioned from one statusto another.

reason No String Unique, one-word, CamelCasereason for the condition's lasttransition.

message No String Human-readable messageindicating details about lasttransition.

表 7-6 containerStatuses 字段数据结构说明

参数 是否必选 参数类型 描述

name Yes String This must be a DNS_LABEL.Each container in a pod musthave a unique name. Cannotbe updated.

state No state/lastStateobject

-

lastState No state/lastStateobject

-

ready No Boolean Specifies whether thecontainer has passed itsreadiness probe.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 869

Page 880: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

restartCount No Integer The number of times thecontainer has been restarted,currently based on thenumber of dead containersthat have not yet beenremoved. Note that this iscalculated from deadcontainers. However, thosecontainers are subject togarbage collection. This valuewill get capped at 5 by GC.

image Yes String The image the container isrunning.

imageID No String ID of the container's image.

containerID No String Container's ID in the format'docker://'.

表 7-7 state/lastState 字段数据结构说明

参数 是否必选 参数类型 描述

waiting No waitingobject

-

running No runningobject

-

terminated No terminatedobject

-

表 7-8 waiting 字段数据结构说明

参数 是否必选 参数类型 描述

reason No String (Brief) Reason the containeris not yet running.

message No String Message regarding why thecontainer is not yet running.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 870

Page 881: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-9 running 字段数据结构说明

参数 是否必选 参数类型 描述

startedAt No String Time at which the containerwas last (re-)started.

表 7-10 terminated 字段数据结构说明

参数 是否必选 参数类型 描述

startedAt No Integer Exit status from the lasttermination of the container.

signal No Integer Signal from the lasttermination of the container.

reason No String (Brief) reason from the lasttermination of the container.

message No String Message regarding the lasttermination of the container.

startedAt No String Time at which previousexecution of the containerstarted.

finishedAt No String Time at which the containerlast terminated.

containerID No String Container's ID in the format'docker://'

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 871

Page 882: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-11 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

name Yes String Name must be unique withina namespace. Is requiredwhen creating resources,although some resources mayallow a client to request thegeneration of an appropriatename automatically. Name isprimarily intended forcreation idempotence andconfiguration definition.Cannot be updated.0 characters < name length ≤253 characters.The name must be a regularexpression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

clusterName No String The name of the clusterwhich the object belongs to.This is used to distinguishresources with same nameand namespace in differentclusters. This field is not setanywhere right now andapiserver is going to ignore itif set in create or updaterequest.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 872

Page 883: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

initializers No initializersobject

An initializer is a controllerwhich enforces some systeminvariant at object creationtime. This field is a list ofinitializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized.Otherwise, the object isconsidered uninitialized and ishidden (in list/watch and getcalls) from clients thathaven't explicitly asked toobserve uninitialized objects.When an object is created,the system will populate thislist with the current set ofinitializers. Only privilegedusers may set or modify thislist. Once it is empty, it maynot be modified further byany user.

enable No Boolean Enable identify whether theresource is available.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 873

Page 884: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

generateName No String An optional prefix used bythe server to generate aunique name ONLY IF theName field has not beenprovided. If this field is used,the name returned to theclient will be different thanthe name passed. This valuewill also be combined with aunique suffix. The providedvalue has the same validationrules as the Name field, andmay be truncated by thelength of the suffix requiredto make the value unique onthe server.If this field is specified andthe generated name exists,the server will NOT return a409. Instead, it will eitherreturn 201 Created or 500with Reason ServerTimeoutindicating a unique namecould not be found in thetime allotted, and the clientshould retry (optionally afterthe time indicated in theRetry-After header).Applied only if Name is notspecified.0 characters < generatedname length ≤ 253characters.The generated name must bea regular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 874

Page 885: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

namespace No String Namespace defines the spacewithin each name must beunique. An empty namespaceis equivalent to the "default"namespace, but "default" isthe canonical representation.Not all objects are required tobe scoped to a namespace -the value of this field forthose objects will be empty.Must be a DNS_LABEL.Cannot be updated.0 characters < namespacelength ≤ 63 characters.The namespace must be aregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

selfLink No String A URL representing thisobject. Populated by thesystem. Read-only.说明

This field is automaticallygenerated. Do not assign anyvalue to this field. Otherwise,API calls would fail.

uid No String UID is the unique in time andspace value for this object. Itis typically generated by theserver on successful creationof a resource and is notallowed to change on PUToperations. Populated by thesystem. Read-only.说明

This field is automaticallygenerated. Do not assign anyvalue to this field. Otherwise,API calls would fail.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 875

Page 886: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

resourceVersion

No String An opaque value thatrepresents the internalversion of this object that canbe used by clients todetermine when objects havechanged. May be used foroptimistic concurrency,change detection, and thewatch operation on aresource or set of resources.Clients must treat thesevalues as opaque and passedunmodified back to theserver. They may only be validfor a particular resource orset of resources. Populated bythe system. Read-only. Valuemust be treated as opaque byclients.说明

This field is automaticallygenerated. Do not assign anyvalue to this field. Otherwise,API calls would fail.

generation No Integer A sequence numberrepresenting a specificgeneration of the desiredstate. Currently onlyimplemented by replicationcontrollers. Populated by thesystem. Read-only.

creationTimestamp

No String A timestamp representing theserver time when this objectwas created. It is notguaranteed to be set inhappens-before order acrossseparate operations. Clientsmay not set this value. It isrepresented in RFC3339 formand is in UTC. Populated bythe system. Read-only. Nullfor lists.说明

This field is automaticallygenerated. Do not assign anyvalue to this field. Otherwise,API calls would fail.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 876

Page 887: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

deletionTimestamp

No String RFC 3339 date and time atwhich this resource will bedeleted. This field is set bythe server when a gracefuldeletion is requested by theuser, and is not directlysettable by a client. Theresource will be deleted (nolonger visible from resourcelists, and not reachable byname) after the time in thisfield. Once set, this value maynot be unset or be set furtherinto the future, although itmay be shortened or theresource may be deleted priorto this time. For example, auser may request that a podis deleted in 30 seconds. TheKubelet will react by sendinga graceful termination signalto the containers in the pod.Once the resource is deletedin the API, the Kubelet willsend a hard terminationsignal to the container. If notset, graceful deletion of theobject has not beenrequested. Populated by thesystem when a gracefuldeletion is requested. Read-only.

deletionGracePeriodSeconds

No Integer Number of seconds allowedfor this object to gracefullyterminate before it will beremoved from the system.Only set whendeletionTimestamp is alsoset. May only be shortened.Read-only.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 877

Page 888: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

labels Yes Object Map of string keys and valuesthat can be used to organizeand categorize (scope andselect) objects. May matchselectors of replicationcontrollers and services.说明

This field should be filled in tocreate the real storagedynamically.The value of thefield is according to the realregion and zone.

annotations No annotationsobject

An unstructured key valuemap stored with a resourcethat may be set by externaltools to store and retrievearbitrary metadata. They arenot queryable and should bepreserved when modifyingobjects.说明

This field should be filled in tocreate the real storagedynamically.This filed indicatesthe storage plugin and theStorageClass.

ownerReferences

No ownerReferences object

List of objects depended bythis object. If ALL objects inthe list have been deleted,this object will be garbagecollected. If this object ismanaged by a controller, thenan entry in this list will pointto this controller, with thecontroller field set to true.There cannot be more thanone managing controller.

finalizers No Array ofstrings

Must be empty before theobject is deleted from theregistry. Each entry is anidentifier for the responsiblecomponent that will removethe entry from the list. If thedeletionTimestamp of theobject is non-nil, entries inthis list can only be removed.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 878

Page 889: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-12 annotations 字段数据结构说明

参数 是否必须

参数类型

描述

volume.beta.kubernetes.io/storage-class

Yes String 存储类型。

● 云硬盘存储卷(EVS)当前支持高I/O(sas)、超高I/O(ssd)和普通I/O(sata)

● 文件存储卷(SFS)当前支持标准文件协议类型(nfs-rw)

● 对象存储卷(OBS)当前支持标准(obs-standard)和低频(obs-standard-ia)

volume.beta.kubernetes.io/storage-provisioner

Yes String 挂载路径。

● 存储类型为EVS时,配置为flexvolume-huawei.com/fuxivol

● 存储类型为SFS时,配置为flexvolume-huawei.com/fuxinfs

● 存储类型为OBS时,配置为flexvolume-huawei.com/fuxiobs

paas.storage.io/cryptKeyId

No String 加密密钥ID。

存储类型为SFS或EVS且需创建加密卷时,才需配置该参数。

密钥ID可从“安全控制台 > 数据加密服务 > 密钥管理”页面获取。

paas.storage.io/cryptAlias

No String 加密密钥别名。

存储类型为SFS且需创建加密卷时,才需配置该参数。

密钥名称可从“安全控制台 > 数据加密服务 > 密钥管理”页面获取。

paas.storage.io/cryptDomainId

No String 租户的DomainId存储类型为SFS且需创建加密卷时,才需配置该参数。

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 879

Page 890: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-13 initializers 字段数据结构说明

参数 是否必选 参数类型 描述

pending No pendingobject

Pending is a list of initializersthat must execute in orderbefore this object is visible.When the last pendinginitializer is removed, and nofailing result is set, theinitializers struct will be set tonil and the object isconsidered as initialized andvisible to all clients.

result No result object If result is set with the Failurefield, the object will bepersisted to storage and thendeleted, ensuring that otherclients can observe thedeletion.

表 7-14 pending 字段数据结构说明

参数 是否必选 参数类型 描述

name No String name of the process that isresponsible for initializing thisobject.

表 7-15 result 字段数据结构说明

参数 是否必选 参数类型 描述

apiVersion Yes String APIVersion defines theversioned schema of thisrepresentation of an object.Servers should convertrecognized schemas to thelatest internal value, and mayreject unrecognized values.

code No Integer Suggested HTTP return codefor this status, 0 if not set.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 880

Page 891: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

details No details object Extended data associated withthe reason. Each reason maydefine its own extendeddetails. This field is optionaland the data returned is notguaranteed to conform to anyschema except that defined bythe reason type.

kind Yes String Kind is a string valuerepresenting the RESTresource this object represents.Servers may infer this fromthe endpoint the clientsubmits requests to. Cannotbe updated.

message No String A human-readable descriptionof the status of this operation.

metadata Yes metadataobject

Standard list metadata.

reason No String A machine-readabledescription of why thisoperation is in the "Failure"status. If this value is emptythere is no informationavailable. A Reason clarifiesan HTTP status code but doesnot override it.

status No String Status of the operation. Oneof: "Success" or "Failure".

表 7-16 details 字段数据结构说明

参数 是否必选 参数类型 描述

causes No causes object The Causes array includesmore details associated withthe StatusReason failure. Notall StatusReasons may providedetailed causes.

group No String The group attribute of theresource associated with thestatus StatusReason.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 881

Page 892: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

kind No String The kind attribute of theresource associated with thestatus StatusReason. On someoperations may differ fromthe requested resource Kind.

name No String The name attribute of theresource associated with thestatus StatusReason (whenthere is a single name whichcan be described).

retryAfterSeconds

No Integer If specified, the time inseconds before the operationshould be retried.

uid No String UID of the resource. (whenthere is a single resourcewhich can be described).

表 7-17 metadata 字段数据结构说明

参数 是否必选 参数类型 描述

resourceVersion No String String that identifies theserver's internal version of thisobject that can be used byclients to determine whenobjects have changed. Valuemust be treated as opaque byclients and passed unmodifiedback to the server. Populatedby the system. Read-only.

selfLink No String SelfLink is a URL representingthis object. Populated by thesystem. Read-only.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 882

Page 893: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-18 causes 字段数据结构说明

参数 是否必选 参数类型 描述

field No String The field of the resource thathas caused this error, asnamed by its JSONserialization. May include dotand postfix notation fornested attributes. Arrays arezero-indexed. Fields mayappear more than once in anarray of causes due to fieldshaving multiple errors.Optional. Examples: "name" -the field "name" on thecurrent resource"items[0].name" - the field"name" on the first arrayentry in "items"

message No String A human-readable descriptionof the cause of the error. Thisfield may be presented as-isto a reader.

reason No String A machine-readabledescription of the cause of theerror. If this value is emptythere is no informationavailable.

表 7-19 ownerReferences 字段数据结构说明

参数 是否必选 参数类型 描述

apiVersion Yes String API version of the referent.

blockOwnerDeletion

No Boolean If true, AND if the owner hasthe "foregroundDeletion"finalizer, then the ownercannot be deleted from thekey-value store until thisreference is removed. Defaultsto false. To set this field, auser needs "delete"permission of the owner,otherwise 422 (UnprocessableEntity) will be returned.

kind Yes String Kind of the referent.

name Yes String Name of the referent.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 883

Page 894: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

uid No String UID of the referent.

controller No Boolean If true, this reference points tothe managing controller.

表 7-20 spec 字段数据结构说明

参数 是否必选 参数类型 描述

replicas No Integer The number of desiredreplicas. This is a pointer todistinguish between explicitzero and unspecified.Value range: ≥ 0.Default : 1

minReadySeconds

No Integer Minimum number of secondsfor which a newly created podshould be ready without anyof its container crashing, for itto be considered available.Defaults to 0 (pod will beconsidered available as soonas it is ready)

template Yes templateobject

-

selector Yes Object A label query over pods thatshould match the Replicascount. If Selector is empty, itis defaulted to the labelspresent on the Pod template.Label keys and values thatmust match in order to becontrolled by this replicationcontroller, if empty defaultedto labels on Pod template.

表 7-21 status 字段数据结构说明

参数 是否必选 参数类型 描述

replicas No Integer The most recently observednumber of replicas.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 884

Page 895: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

availableReplicas

No Integer The number of availablereplicas (ready for at leastminReadySeconds) for thisreplication controller.

readyReplicas No Integer The number of ready replicasfor this replication controller.

conditions No conditionobject

Represents the latestavailable observations of areplication controller's currentstate.

observedGeneration

No Integer Reflects the generation of themost recently observedreplication controller.

FullylabeledReplicas

No Object -

表 7-22 template 字段数据结构说明

参数 是否必选 参数类型 描述

metadata No metadataobject

-

spec Yes spec object -

表 7-23 condition 字段数据结构说明

参数 是否必选 参数类型 描述

lastTransitionTime

No Time The last time the conditiontransitioned from one statusto another.

message No String A human readable messageindicating details about thetransition.

reason No String The reason for the condition'slast transition.

status No String Status of the condition, oneof True, False, Unknown.

type No String Type of replication controllercondition.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 885

Page 896: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-24 spec 字段数据结构说明

参数 是否必选 参数类型 描述

volumes No volumesobject

List of volumes that can bemounted by containersbelonging to the pod.

affinity No affinityobject

If specified, the pod'sscheduling constraints

containers Yes containersobject

List of containers belongingto the pod. Containers cannotcurrently be added orremoved. There must be atleast one container in a pod.Cannot be updated.

restartPolicy No String Restart policy for allcontainers within the pod.Value:● Always● OnFailure● NeverDefault: Always.

terminationGracePeriodSeconds

No Integer Optional duration in secondsthe pod needs to terminategracefully. May be decreasedin delete request. Value mustbe a non-negative integer.The value zero indicatesdelete immediately. If thisvalue is nil, the default graceperiod will be used instead.The grace period is theduration in seconds after theprocesses running in the podare sent a termination signaland the time when theprocesses are forcibly haltedwith a kill signal. Set thisvalue longer than theexpected cleanup time foryour process. Defaults to 30seconds.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 886

Page 897: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

activeDeadlineSeconds

No Integer Optional duration in secondsthe pod may be active on thenode relative to StartTimebefore the system willactively try to mark it failedand kill associated containers.Value must be a positiveinteger.Value range of thisparameter: > 0.

dnsPolicy No String Set DNS policy for containerswithin the pod.Value:● ClusterFirst● DefaultDefault: ClusterFirst.

hostAliases No hostAliasesobject

HostAliases is an optional listof hosts and IPs that will beinjected into the pod's hostsfile if specified. This is onlyvalid for non-hostNetworkpods.

serviceAccountName

No String Name of the ServiceAccountused to run this pod.0 characters < service accountname length ≤ 253characters.The service account namemust be a regular expression[a-z0-9]([-a-z0-9]*[a-z0-9])?.

serviceAccount No String DeprecatedServiceAccount isa depreciated alias forServiceAccountName.Deprecated: UseserviceAccountName instead.

schedulerName

No String If specified, the pod will bedispatched by specifiedscheduler. If not specified, thepod will be dispatched bydefault scheduler.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 887

Page 898: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

nodeName No String A request to schedule thispod onto a specific node. If itis non-empty, the schedulersimply schedules this podonto that node, assumingthat it fits resourcerequirements.0 characters < node namelength ≤ 253 characters.The node name must be aregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

nodeSelector No Object NodeSelector is a selectorwhich must be true for thepod to fit on a node. Selectorwhich must match a node'slabels for the pod to bescheduled on that node.

automountServiceAccountToken

No Boolean AutomountServiceAccountToken indicates whether aservice account token shouldbe automatically mounted.

hostNetwork No Boolean Host networking requestedfor this pod. Use the host'snetwork namespace. If thisoption is set, the ports thatwill be used must bespecified. Default to false.说明

The hostport of thehostNetwork must be differentfrom the containerport.

hostPID No Boolean A flag indicating whether touse the host's pid namespace.Optional: Default to false.

hostIPC No Boolean A flag indicating whether touse the host's ipc namespace.Optional: Default to false.

securityContext

No securityContext object

-

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 888

Page 899: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

imagePullSecrets

No imagePullSecrets object

An optional list of referencesto secrets in the samenamespace to use for pullingany of the images used bythis PodSpec. If specified,these secrets will be passedto individual pullerimplementations for them touse. For example, in the caseof docker, only DockerConfigtype secrets are honored.

initContainers No containersobject

List of initialization containersbelonging to the pod. Initcontainers are executed inorder prior to containersbeing started. If any initcontainer fails, the pod isconsidered to have failed andis handled according to itsrestartPolicy. The name for aninit container or normalcontainer must be uniqueamong all containers. Initcontainers may not haveLifecycle actions, Readinessprobes, or Liveness probes.The resourceRequirements ofan init container are takeninto account duringscheduling by finding thehighest request/limit for eachresource type, and then usingthe max of of that value orthe sum of the normalcontainers. Limits are appliedto init containers in a similarfashion. Init containerscannot currently be added orremoved.

hostname No String Specifies the hostname of thePod. If not specified, the pod'shostname will be set to asystem-defined value.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 889

Page 900: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

subdomain No String If specified, the fully qualifiedPod hostname willbe"<hostname>.<subdomain>.<pod namespace>.svc<clusterdomain>".If not specified, thepod will not have adomainname at all.

tolerations No tolerationsobject

If specified, the pod'stolerations.

表 7-25 volumes 字段数据结构说明

参数 是否必选 参数类型 描述

name Yes String Volume name. Must be aDNS_LABEL and uniquewithin the pod.0 characters < volume namelength ≤ 63 characters.The volume name must be aregular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

hostPath No hostPathobject

-

emptyDir No emptyDirobject

-

gitRepo No gitRepoobject

-

secret No secret object -

nfs No nfs object -

iscsi No iscsi object -

glusterfs No glusterfsobject

-

persistentVolumeClaim

No persistentVolumeClaimobject

-

rbd No rbd object -

cinder No cinder object -

cephfs No cephfs object -

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 890

Page 901: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

flocker No flocker object -

downwardAPI No downwardAPI object

-

fc No fc object -

vsphereVolume

No vsphereVolume object

-

表 7-26 containers 字段数据结构说明

参数 是否必选 参数类型 描述

name Yes String Name of the containerspecified as a DNS_LABEL.Each container in a pod musthave a unique name(DNS_LABEL). Cannot beupdated.0 characters < containername length ≤ 63 characters.The container name must bea regular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

image Yes String Docker image name.

command No Array ofstrings

Entrypoint array. Notexecuted within a shell. Thedocker image's entrypoint isused if this is not provided.Variable references $(VAR_NAME) are expandedusing the container'senvironment. If a variablecannot be resolved, thereference in the input stringwill be unchanged. The $(VAR_NAME) syntax can beescaped with a double $$, forexample, $$(VAR_NAME).Escaped references will neverbe expanded, regardless ofwhether the variable exists ornot. Cannot be updated.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 891

Page 902: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

args No Array ofstrings

Arguments to the entrypoint.The docker image's cmd isused if this is not provided.Variable references $(VAR_NAME) are expandedusing the container'senvironment. If a variablecannot be resolved, thereference in the input stringwill be unchanged. The $(VAR_NAME) syntax can beescaped with a double $$, forexample, $$(VAR_NAME).Escaped references will neverbe expanded, regardless ofwhether the variable exists ornot. Cannot be updated.

workingDir No String Container's working directory.Defaults to Docker's default.Defaults to image's default.Cannot be updated.

ports No ports object List of ports to expose fromthe container. Cannot beupdated.

env No env object List of environment variablesto set in the container. Cannotbe updated.

envFrom No envFromobject

List of sources to populateenvironment variables in thecontainer. The keys definedwithin a source must be aC_IDENTIFIER. All invalid keyswill be reported as an eventwhen the container isstarting. When a key exists inmultiple sources, the valueassociated with the lastsource will take precedence.Values defined by an Env witha duplicate key will takeprecedence. Cannot beupdated.

resources No resourcesobject

Minimum resources thevolume should have.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 892

Page 903: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

volumeMounts No volumeMounts object

Pod volumes to mount intothe container's filesystem.Cannot be updated.

livenessProbe No livenessProbe object

-

readinessProbe No livenessProbe object

-

lifecycle No lifecycleobject

-

terminationMessagePath

No String Path at which the file towhich the container'stermination message will bewritten is mounted into thecontainer's filesystem.Message written is intendedto be brief final status, suchas an assertion failuremessage. Defaults to /dev/termination-log. Cannot beupdated.

imagePullPolicy

No String Image pull policy. Defaults toAlways if the :latest tag isspecified, or IfNotPresentotherwise. Cannot beupdated.Value:● Always● Never● IfNotPresent

securityContext

No securityContext object

-

stdin No Boolean A flag indicating whether thiscontainer should allocate abuffer for stdin in thecontainer runtime. If this isnot set, reads from stdin inthe container will alwaysresult in EOF. Default is false.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 893

Page 904: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

stdinOnce No Boolean A flag indicating whether thecontainer runtime shouldclose the stdin channel afterit has been opened by asingle attach. When stdin istrue, the stdin stream willremain open across multipleattach sessions. If stdinOnceis set to true, stdin is openedon container start, is emptyuntil the first client attachesto stdin, and then remainsopen and accepts data untilthe client disconnects, atwhich time stdin is closed andremains closed until thecontainer is restarted. If thisflag is false, a containerprocess that reads from stdinwill never receive an EOF.Default is false.

tty No Boolean A flag indicating whether thiscontainer should allocate aTTY for itself, also requires'stdin' to be true. Default isfalse.

表 7-27 securityContext 字段数据结构说明

参数 是否必选 参数类型 描述

seLinuxOptions No seLinuxOptions object

-

runAsUser No Integer The UID to run the entrypointof the container process.Defaults to user specified inimage metadata ifunspecified. May also be setin SecurityContext. If set inboth SecurityContext andPodSecurityContext, the valuespecified in SecurityContexttakes precedence for thatcontainer.Value length: > 0 characters.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 894

Page 905: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

runAsNonRoot No Boolean Indicates that the containermust run as a non-root user.If true, the Kubelet willvalidate the image at runtimeto ensure that it does not runas UID 0 (root) and fail tostart the container if it does.If unset or false, no suchvalidation will be performed.May also be set inSecurityContext. If set in bothSecurityContext andPodSecurityContext, the valuespecified in SecurityContexttakes precedence.

supplementalGroups

No Array ofintegers

A list of groups applied to thefirst process run in eachcontainer, in addition to thecontainer's primary GID. Ifunspecified, no groups will beadded to any container.

fsGroup No Integer A special supplemental groupthat applies to all containersin a pod. Some volume typesallow the Kubelet to changethe ownership of that volumeto be owned by the pod:The owning GID will be theFSGroup 2. The setgid bit isset (new files created in thevolume will be owned byFSGroup) 3. The permissionbits are OR'd with rw-rw.

表 7-28 imagePullSecrets 字段数据结构说明

参数 是否必选 参数类型 描述

name No String Name of the referent.须知

创建工作负载时,使用的镜像是容器镜像服务界面上的“我的镜像”页签中的镜像,那么该参数的值必须设置为“default-secret ”。“default-secret”是拉取容器镜像服务的默认密钥,第三方镜像的密钥创建请参考使用kubectl创建第三方镜像仓库的密钥。

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 895

Page 906: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-29 hostPath 字段数据结构说明

参数 是否必选 参数类型 描述

path No String Path of the directory on thehost.

表 7-30 emptyDir 字段数据结构说明

参数 是否必选 参数类型 描述

medium No String What type of storage mediumshould back this directory.The default is "" which meansto use the node's defaultmedium. Must be an emptystring (default) or Memory.

表 7-31 gitRepo 字段数据结构说明

参数 是否必选 参数类型 描述

repository No String Repository URL.

revision No String Commit hash for the specifiedrevision.

表 7-32 secret 字段数据结构说明

参数 是否必选 参数类型 描述

secretName No String Name of a secret in the pod'snamespace.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 896

Page 907: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

items No items(KeyToPath) object

If unspecified, each key-valuepair in the Data field of thereferenced. Secret will beprojected into the volume asa file whose name is the keyand content is the value. Ifspecified, the listed keys willbe projected into the specifiedpaths, and unlisted keys willnot be present. If a key isspecified which is not presentin the Secret, the volumesetup will error. Paths mustbe relative and may notcontain the '..' path or startwith '..'.

表 7-33 nfs 字段数据结构说明

参数 是否必选 参数类型 描述

server No String Hostname or IP address ofthe NFS server.

path No String Path that is exported by theNFS server.

readOnly No Boolean readOnly here will force theNFS export to be mountedwith read-only permissions.Value:● true● falseDefault: false.

表 7-34 iscsi 字段数据结构说明

参数 是否必选 参数类型 描述

targetPortal No String iSCSI target portal. The portalis either an IP or ip_addr:portif the port is other thandefault (typically TCP ports860 and 3260).

iqn No String Target iSCSI Qualified Name.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 897

Page 908: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

lun No Integer iSCSI target lun number.Value range: (0, 255].

fsType No String Filesystem type of the volumethat you want to mount.Tip: Ensure that the filesystemtype is supported by the hostoperating system.Examples: "ext4", "xfs", "ntfs".

readOnly No Boolean readOnly here will force theReadOnly setting inVolumeMounts.Value● true● falseDefault: false.

表 7-35 glusterfs 字段数据结构说明

参数 是否必选 参数类型 描述

endpoints No String Endpoint name that detailsGlusterfs topology.

path No String Glusterfs volume path.

readOnly No Boolean readOnly here will force theGlusterfs volume to bemounted with read-onlypermissions.Value:● true● falseDefault: false.

表 7-36 persistentVolumeClaim 字段数据结构说明

参数 是否必选 参数类型 描述

claimName No String Name of aPersistentVolumeClaim in thesame namespace as the podusing this volume.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 898

Page 909: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

readOnly No Boolean readOnly here will force theReadOnly setting inVolumeMounts.Value:● true● falseDefault: false.

表 7-37 rbd 字段数据结构说明

参数 是否必选 参数类型 描述

monitors No Array ofstrings

A collection of Ceph monitors.

image Yes String The rados image name.Value length: > 0 characters.

fsType No String Filesystem type of the volumethat you want to mount.Tip: Ensure that the filesystemtype is supported by the hostoperating system.Examples: "ext4", "xfs", "ntfs".

pool No String The rados pool name. Defaultis rbd.

user No String The rados user name. Defaultis admin.

keyring No String Path to key ring for RBDUser.Default is /etc/ceph/keyring.

secretRef No imagePullSecrets object

-

readOnly No Boolean readOnly here will force theReadOnly setting inVolumeMounts.Value:● true● falseDefault: false.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 899

Page 910: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-38 cinder 字段数据结构说明

参数 是否必选 参数类型 描述

volumeID No Array ofstrings

The volume ID used toidentify the volume in cinder.Value length: > 0 characters.

fsType No String Filesystem type to mount.Must be a filesystem typesupported by the hostoperating system. Only ext3and ext4 are allowed.

readOnly No Boolean Defaults to false (read/write).readOnly here will force theReadOnly setting inVolumeMounts.Value:● true● false

表 7-39 cephfs 字段数据结构说明

参数 是否必选 参数类型 描述

monitors No Array ofstrings

A collection of Ceph monitors.

user No String rados user name. The defaultis admin.

secretFile No String Path to key ring for User. Thedefault is /etc/ceph/user.

secretRef No imagePullSecrets object

-

readOnly No Boolean Defaults to false (read/write).readOnly here will force theReadOnly setting inVolumeMounts.Value:● true● false

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 900

Page 911: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-40 flocker 字段数据结构说明

参数 是否必选 参数类型 描述

datasetName No String Volume name. This is goingto be store on metadata ->name on the payload forFlocker.

表 7-41 downwardAPI 字段数据结构说明

参数 是否必选 参数类型 描述

items No items object A list of downward APIvolume file.

表 7-42 fc 字段数据结构说明

参数 是否必选 参数类型 描述

targetWWNs No Array ofstrings

FC target world wide names(WWNs).

lun No Integer FC target lun number.

fsType No String Filesystem type to mount.Must be a filesystem typesupported by the hostoperating system. Ex. "ext4","xfs", "ntfs".

readOnly No Boolean Defaults to false (read/write).readOnly here will force theReadOnly setting inVolumeMounts.Value:● true● false

表 7-43 vsphereVolume 字段数据结构说明

参数 是否必选 参数类型 描述

volumePath No String Path that identifies vSpherevolume vmdk.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 901

Page 912: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

fsType No String Filesystem type to mount.Must be a filesystem typesupported by the hostoperating system.Ex. "ext4","xfs", "ntfs". Implicitlyinferred to be "ext4" ifunspecified.

表 7-44 items(KeyToPath)字段数据结构说明

参数 是否必选 参数类型 描述

key No String The key to project.

path No String The relative path of the fileto map the key to. May notbe an absolute path. May notcontain the path element '..'.May not start with the string'..'.

表 7-45 ports 字段数据结构说明

参数 是否必选 参数类型 描述

name No String If specified, this must be anIANA_SVC_NAME and uniquewithin the pod. Each namedport in a pod must have aunique name. Name for theport that can be referred toby services.0 characters < name length ≤15 characters.The name must be a regularexpression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

hostPort No Integer Number of port to expose onthe host. If specified, thismust be a valid port number,0 < x < 65536. If HostNetworkis specified, this must matchContainerPort. Mostcontainers do not need this.Value range: [1, 65535].

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 902

Page 913: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

containerPort No Integer Number of port to expose onthe pod's IP address. Thismust be a valid port number,0 < x < 65536.Value range: [1, 65535].

protocol No String Protocol for port.Value:● TCP● UDPDefault: TCP.

hostIP No String What host IP to bind theexternal port to.

表 7-46 env 字段数据结构说明

参数 是否必选 参数类型 描述

name Yes String Name of the environmentvariable. Must be aC_IDENTIFIER.

value No String Variable references $(VAR_NAME) are expandedusing the previous definedenvironment variables in thecontainer and any serviceenvironment variables. If avariable cannot be resolved,the reference in the inputstring will be unchanged. The$(VAR_NAME) syntax can beescaped with a double $$, forexample, $$(VAR_NAME).Escaped references will neverbe expanded, regardless ofwhether the variable exists ornot. Defaults to "".

valueFrom No valueFromobject

-

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 903

Page 914: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-47 resources 字段数据结构说明

参数 是否必选 参数类型 描述

limits No Object Maximum amount ofcompute resources allowed.

requests No Object Minimum amount of computeresources required. If Requestsis omitted for a container, itdefaults to Limits if that isexplicitly specified, otherwiseto an implementation-definedvalue.

表 7-48 volumeMounts 字段数据结构说明

参数 是否必选 参数类型 描述

name Yes String This must match the Name ofa Volume.0 character < name length ≤253 characters.The name must be a regularexpression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

readOnly No Boolean Mounted read-only if true,read-write otherwise (false orunspecified).Value:● true● falseDefault: false.

mountPath No String Path within the container atwhich the volume should bemounted.Value length: > 0 characters.

subPath No String Path within the volume fromwhich the container's volumeshould be mounted. Defaultsto "" (volume's root).

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 904

Page 915: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-49 livenessProbe 字段数据结构说明

参数 是否必选 参数类型 描述

exec No exec object -

httpGet No httpGetobject

-

tcpSocket No tcpSocketobject

-

initialDelaySeconds

No Integer Number of seconds after thecontainer has started beforeliveness probes are initiated.Value range: ≥ 0.

timeoutSeconds

No Integer Number of seconds afterwhich the probe times out.Value range: ≥ 0.Default: 1.

periodSeconds No Integer How often (in seconds) toperform the probe. Default to10 seconds. Minimum value is1.Value range: ≥ 0.Default: 10.

successThreshold

No Integer Minimum consecutivesuccesses for the probe to beconsidered successful afterhaving failed. Defaults to 1.Must be 1 for liveness.Minimum value is 1.Value range: ≥ 0.Default: 1.

failureThreshold

No Integer Minimum consecutive failuresfor the probe to be consideredfailed after having succeeded.Defaults to 3. Minimum valueis 1.Value range: ≥ 0.Default: 3.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 905

Page 916: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-50 lifecycle 字段数据结构说明

参数 是否必选 参数类型 描述

postStart No postStart/preStopobject

-

preStop No postStart/preStopobject

-

表 7-51 securityContext 字段数据结构说明

参数 是否必选 参数类型 描述

capabilities No capabilitiesobject

-

privileged No Boolean Run container in privilegedmode. Processes in privilegedcontainers are essentiallyequivalent to root on thehost.Value:● true● falseDefault: false.

seLinuxOptions No seLinuxOptions object

-

runAsUser No Integer The UID to run the entrypointof the container process.Defaults to user specified inimage metadata ifunspecified. May also be setin PodSecurityContext. If setin both SecurityContext andPodSecurityContext, the valuespecified in SecurityContexttakes precedence.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 906

Page 917: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

runAsNonRoot No Boolean Indicates that the containermust run as a non-root user.If true, the Kubelet willvalidate the image at runtimeto ensure that it does not runas UID 0 (root) and fail tostart the container if it does.If unset or false, no suchvalidation will be performed.May also be set inPodSecurityContext. If set inboth SecurityContext andPodSecurityContext, the valuespecified in SecurityContexttakes precedence.Value:● true● false

表 7-52 seLinuxOptions 字段数据结构说明

参数 是否必选 参数类型 描述

user No String SELinux user label thatapplies to the container.

role No String SELinux role label that appliesto the container.

type No String SELinux type label thatapplies to the container.

level No String SELinux level label thatapplies to the container.

表 7-53 items 字段数据结构说明

参数 是否必选 参数类型 描述

path No String Relative path name of the fileto be created. Must not beabsolute or contain the '..'path. Must be utf-8 encoded.The first item of the relativepath must not start with '..'

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 907

Page 918: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

fieldRef No fieldRefobject

-

resourceFieldRef

No resourceFieldRef object

Selects a resource of thecontainer: only resourceslimits and requests.(limits.cpu, limits.memory,requests.cpu andrequests.memory) arecurrently supported.

表 7-54 valueFrom 字段数据结构说明

参数 是否必选 参数类型 描述

fieldRef No fieldRefobject

-

resourceFieldRef

No resourceFieldRef object

Selects a resource of thecontainer: only resourceslimits and requests.(limits.cpu, limits.memory,requests.cpu andrequests.memory) arecurrently supported.

表 7-55 exec 字段数据结构说明

参数 是否必选 参数类型 描述

command No Array ofstrings

Command is the commandline to execute inside thecontainer, the workingdirectory for the command isroot ('/') in the container'sfilesystem. The command issimply exec'd, it is not runinside a shell, so traditionalshell instructions ('|', etc) donot work. To use a shell, youneed to explicitly call out tothat shell. Exit status of 0 istreated as live/healthy andnon-zero is unhealthy.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 908

Page 919: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-56 httpGet 字段数据结构说明

参数 是否必选 参数类型 描述

path No String Path to access on the HTTPserver.

port Yes String Name or number of the portto access on the container.The port number must be inthe range 1 to 65535. Theport name must be anIANA_SVC_NAME.

host No String Host name to connect to.Defaults to the pod IPaddress.

scheme No String Scheme to use for connectingto the host. Defaults to HTTP.

表 7-57 tcpSocket 字段数据结构说明

参数 是否必选 参数类型 描述

port Yes String Number or name of the portto access on the container.The port number must be inthe range 1 to 65535. Theport name must be anIANA_SVC_NAME.

表 7-58 postStart/preStop 字段数据结构说明

参数 是否必选 参数类型 描述

exec No exec object -

httpGet No httpGetobject

-

tcpSocket No tcpSocketobject

TCPSocket specifies an actioninvolving a TCP port. TCPhooks not yet supported.

表 7-59 capabilities 字段数据结构说明

参数 是否必选 参数类型 描述

add No add object Added capabilities.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 909

Page 920: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

drop No add object Removed capabilities.

表 7-60 fieldRef 字段数据结构说明

参数 是否必选 参数类型 描述

apiVersion No String Version of the schema theFieldPath is written in termsof. Defaults to "v1".

fieldPath No String Path of the field to select inthe specified API version.

表 7-61 resourceFieldRef 字段数据结构说明

参数 是否必选 参数类型 描述

containerName

No String Container name: required forvolumes, optional for env vars.

resource Yes String Required: resource to select.

divisor No String Specifies the output format ofthe exposed resources,defaults to "1".

表 7-62 add 字段数据结构说明

参数 是否必选 参数类型 描述

name Yes String Name of the resource.

namespaced No Boolean A flag indicating whether aresource is namespaced ornot.Default: false.

kind No String kind of the resource.

表 7-63 affinity 字段数据结构说明

参数 是否必选 参数类型 描述

nodeAffinity No nodeAffinityobject

Describes node affinityscheduling rules for the pod.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 910

Page 921: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

podAffinity No podAffinityobject

Describes pod affinityscheduling rules (e.g. co-locate this pod in the samenode, zone, etc. as someother pod(s)).

podAntiAffinity No podAffinityobject

Describes pod anti-affinityscheduling rules (e.g. avoidputting this pod in the samenode, zone, etc. as someother pod(s)).

表 7-64 nodeAffinity 字段数据结构说明

参数 是否必选 参数类型 描述

preferredDuringSchedulingIgnoredDuringExecution

No preferredDuringSchedulingIgnoredDuringExecutionobject

The scheduler will prefer toschedule pods to nodes thatsatisfy the affinity expressionsspecified by this field, but itmay choose a node thatviolates one or more of theexpressions. The node that ismost preferred is the one withthe greatest sum of weights,i.e. for each node that meetsall of the schedulingrequirements (resourcerequest,requiredDuringSchedulingaffinity expressions, etc.),compute a sum by iteratingthrough the elements of thisfield and adding "weight" tothe sum if the node matchesthe correspondingmatchExpressions; thenode(s) with the highest sumare the most preferred.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 911

Page 922: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

requiredDuringSchedulingIgnoredDuringExecution

No requiredDuringSchedulingIgnoredDuringExecutionobject

If the affinity requirementsspecified by this field are notmet at scheduling time, thepod will not be scheduledonto the node. If the affinityrequirements specified by thisfield cease to be met at somepoint during pod execution(e.g. due to an update), thesystem may or may not try toeventually evict the pod fromits node.

表 7-65 podAffinity 字段数据结构说明

参数 是否必选 参数类型 描述

preferredDuringSchedulingIgnoredDuringExecution

No preferredDuringSchedulingIgnoredDuringExecutionobject

The scheduler will prefer toschedule pods to nodes thatsatisfy the affinity expressionsspecified by this field, but itmay choose a node thatviolates one or more of theexpressions. The node that ismost preferred is the one withthe greatest sum of weights,i.e. for each node that meetsall of the schedulingrequirements (resourcerequest,requiredDuringSchedulingaffinity expressions, etc.),compute a sum by iteratingthrough the elements of thisfield and adding "weight" tothe sum if the node has podswhich matches thecorrespondingpodAffinityTerm; the node(s)with the highest sum are themost preferred.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 912

Page 923: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

requiredDuringSchedulingIgnoredDuringExecution

No podAffinityTerm object

NOT YET IMPLEMENTED.TODO: Uncomment field onceit is implemented. If theaffinity requirements specifiedby this field are not met atscheduling time, the pod willnot be scheduled onto thenode. If the affinityrequirements specified by thisfield cease to be met at somepoint during pod execution(e.g. due to a pod labelupdate), the system will try toeventually evict the pod fromits node. When there aremultiple elements, the lists ofnodes corresponding to eachpodAffinityTerm areintersected, i.e. all terms mustbe satisfied.RequiredDuringSchedulingRequiredDuringExecution[]PodAffinityTermjson:"requiredDuringSchedulingRequiredDuringExecution,omitempty" If the affinityrequirements specified by thisfield are not met atscheduling time, the pod willnot be scheduled onto thenode. If the affinityrequirements specified by thisfield cease to be met at somepoint during pod execution(e.g. due to a pod labelupdate), the system may ormay not try to eventuallyevict the pod from its node.When there are multipleelements, the lists of nodescorresponding to eachpodAffinityTerm areintersected, i.e. all terms mustbe satisfied.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 913

Page 924: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-66 preferredDuringSchedulingIgnoredDuringExecution 字段数据结构说明

参数 是否必选 参数类型 描述

preference No preferenceobject

A node selector term,associated with thecorresponding weight.

weight No Integer Weight associated withmatching the correspondingnodeSelectorTerm, in therange 1-100.

表 7-67 requiredDuringSchedulingIgnoredDuringExecution 字段数据结构说明

参数 是否必选 参数类型 描述

nodeSelectorTerms

No preferenceobject

Required. A list of nodeselector terms. The terms areORed.

表 7-68 preference 字段数据结构说明

参数 是否必选 参数类型 描述

matchExpressions

No matchExpressions object

Required. A list of nodeselector requirements. Therequirements are ANDed.

表 7-69 matchExpressions 字段数据结构说明

参数 是否必选 参数类型 描述

key No String The label key that theselector applies to.

operator No String Represents a key'srelationship to a set of values.Valid operators are In, NotIn,Exists, DoesNotExist. Gt, andLt.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 914

Page 925: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

values No String An array of string values. Ifthe operator is In or NotIn,the values array must be non-empty. If the operator is Existsor DoesNotExist, the valuesarray must be empty. If theoperator is Gt or Lt, thevalues array must have asingle element, which will beinterpreted as an integer. Thisarray is replaced during astrategic merge patch.

表 7-70 preferredDuringSchedulingIgnoredDuringExecution 字段数据结构说明

参数 是否必选 参数类型 描述

podAffinityTerm

No podAffinityTerm object

Required. A pod affinity term,associated with thecorresponding weight.

weight No Integer weight associated withmatching the correspondingpodAffinityTerm, in the range1-100.

表 7-71 podAffinityTerm 字段数据结构说明

参数 是否必选 参数类型 描述

labelSelector No labelSelectorobject

A label query over a set ofresources, in this case pods.

namespaces No Array ofstrings

namespaces specifies whichnamespaces the labelSelectorapplies to (matches against);null or empty list means "thispod's namespace"

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 915

Page 926: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

topologyKey No String This pod should be co-located(affinity) or not co-located(anti-affinity) with the podsmatching the labelSelector inthe specified namespaces,where co-located is definedas running on a node whosevalue of the label with keytopologyKey matches that ofany node on which any of theselected pods is running. ForPreferredDuringSchedulingpod anti-affinity, emptytopologyKey is interpreted as"all topologies" ("alltopologies" here means allthe topologyKeys indicated byscheduler command-lineargument --failure-domains);for affinity and forRequiredDuringSchedulingpod anti-affinity, emptytopologyKey is not allowed.

表 7-72 labelSelector 字段数据结构说明

参数 是否必选 参数类型 描述

matchExpressions

No matchExpressions object

matchExpressions is a list oflabel selector requirements.The requirements are ANDed.

matchLabels No Object matchLabels is a map of{key,value} pairs. A single{key,value} in thematchLabels map isequivalent to an element ofmatchExpressions, whose keyfield is "key", the operator is"In", and the values arraycontains only "value". Therequirements are ANDed.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 916

Page 927: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-73 matchExpressions 字段数据结构说明

参数 是否必选 参数类型 描述

key No String key is the label key that theselector applies to.

operator No String operator represents a key'srelationship to a set of values.Valid operators ard In, NotIn,Exists and DoesNotExist.

values No Array ofstrings

values is an array of stringvalues. If the operator is In orNotIn, the values array mustbe non-empty. If the operatoris Exists or DoesNotExist, thevalues array must be empty.This array is replaced during astrategic merge patch.

表 7-74 hostAliases 字段数据结构说明

名称 是否必选 参数类型 描述

hostnames No Array ofstrings

Hostnames for the above IPaddress.

ip No String IP address of the host fileentry.

表 7-75 envFrom 字段数据结构说明

参数 是否必选 参数类型 描述

configMapRef No configMapRef object

The ConfigMap to select from

prefix No String An optional identifer toprepend to each key in theConfigMap. Must be aC_IDENTIFIER.

secretRef No secretRefobject

-

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 917

Page 928: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-76 configMapRef 字段数据结构说明

参数 是否必选 参数类型 描述

name No String Name of the referent.

optional No Boolean Specify whether theConfigMap must be defined

表 7-77 secretRef 字段数据结构说明

参数 是否必选 参数类型 描述

name No String Name of the referent.

optional No Boolean Specify whether theConfigMap must be defined

表 7-78 tolerations 字段数据结构说明

参数 是否必选 参数类型 描述

effect No String Effect indicates the tainteffect to match. Empty meansmatch all taint effects. Whenspecified, allowed values areNoSchedule,PreferNoSchedule andNoExecute.

key No String Key is the taint key that thetoleration applies to. Emptymeans match all taint keys. Ifthe key is empty, operatormust be Exists; thiscombination means to matchall values and all keys.

operator No String Operator represents a key'srelationship to the value.Valid operators are Exists andEqual. Defaults to Equal.Exists is equivalent towildcard for value, so that apod can tolerate all taints ofa particular category.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 918

Page 929: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 是否必选 参数类型 描述

tolerationSeconds

No Integer TolerationSeconds representsthe period of time thetoleration (which must be ofeffect NoExecute, otherwisethis field is ignored) toleratesthe taint. By default, it is notset, which means tolerate thetaint forever (do not evict).Zero and negative values willbe treated as 0 (evictimmediately) by the system.

value No String Value is the taint value thetoleration matches to. If theoperator is Exists, the valueshould be empty, otherwisejust a regular string.

7.2 响应数据结构

表 7-79 v1.ReplicationController 响应参数

参数 参数类型 描述

kind String A string value representing theREST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String Versioned schema of thisrepresentation of an object.Servers should convert recognizedschemas to the latest internalvalue, and may rejectunrecognized values.

metadata metadata object -

spec spec object -

status status object -

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 919

Page 930: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-80 v1.ReplicationControllerList 响应参数

参数 参数类型 描述

kind String A string value representing theREST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String Versioned schema of thisrepresentation of an object.Servers should convert recognizedschemas to the latest internalvalue, and may rejectunrecognized values.

metadata metadata object -

items items object List of replication controllers.

表 7-81 v1.Pod 响应参数

参数 参数类型 描述

kind String A string value representing theREST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String Versioned schema of thisrepresentation of an object.Servers should convert recognizedschemas to the latest internalvalue, and may rejectunrecognized values.

metadata metadata object -

spec spec object -

status status object -

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 920

Page 931: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-82 v1.PodList 响应参数

参数 参数类型 描述

kind String A string value representing theREST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String Versioned schema of thisrepresentation of an object.Servers should convert recognizedschemas to the latest internalvalue, and may rejectunrecognized values.

metadata metadata object -

items items object List of pods.

表 7-83 v1.PodTemplate 响应参数

参数 参数类型 描述

kind String A string value representing theREST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String Versioned schema of thisrepresentation of an object.Servers should convert recognizedschemas to the latest internalvalue, and may rejectunrecognized values.

metadata metadata object -

template template object -

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 921

Page 932: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-84 v1.PodTemplateList 响应参数

参数 参数类型 描述

kind String A string value representing theREST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String Versioned schema of thisrepresentation of an object.Servers should convert recognizedschemas to the latest internalvalue, and may rejectunrecognized values.

metadata metadata object -

items v1.PodTemplateobject

List of pod templates.

表 7-85 items 字段数据结构说明

参数 参数类型 描述

kind String A string value representing theREST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String Versioned schema of thisrepresentation of an object.Servers should convert recognizedschemas to the latest internalvalue, and may rejectunrecognized values.

metadata metadata object -

spec spec object -

status status object -

表 7-86 status 字段数据结构说明

参数 参数类型 描述

phase String Current condition of the pod.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 922

Page 933: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

conditions conditions object Current service state of the pod.

message String A human readable messageindicating details about why thepod is in this condition.

reason String A brief CamelCase messageindicating details about why thepod is in this state. e.g.'OutOfDisk'

hostIP String IP address of the host to which thepod is assigned. Empty if not yetscheduled.

podIP String IP address allocated to the pod.Routable at least within thecluster. Empty if not yet allocated.

startTime String RFC 3339 date and time at whichthe object was acknowledged bythe Kubelet. This is before theKubelet pulled the containerimage(s) for the pod.

containerStatuses containerStatusesobject

The list has one entry percontainer in the manifest. Eachentry is currently the output ofdocker inspect.

表 7-87 conditions 字段数据结构说明

参数 参数类型 描述

type String Type of the condition. Currentlyonly Ready.

status String Status of the condition. Can beTrue, False, or Unknown.

lastProbeTime String Last time we probed the condition.

lastTransitionTime String Last time the conditiontransitioned from one status toanother.

reason String Unique, one-word, CamelCasereason for the condition's lasttransition.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 923

Page 934: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

message String Human-readable messageindicating details about lasttransition.

表 7-88 containerStatuses 字段数据结构说明

参数 参数类型 描述

name String This must be a DNS_LABEL. Eachcontainer in a pod must have aunique name. Cannot be updated.

state state/lastState object -

lastState state/lastState object -

ready Boolean A flag indicating whether thecontainer has passed its readinessprobe.

restartCount Integer The number of times thecontainer has been restarted,currently based on the number ofdead containers that have not yetbeen removed. Note that this iscalculated from dead containers.However, those containers aresubject to garbage collection. Thisvalue will get capped at 5 by GC.

image String Image that the container isrunning.

imageID String ID of the container's image.

containerID String Container's ID in the format'docker://'.

表 7-89 state/lastState 字段数据结构说明

参数 参数类型 描述

waiting waiting object -

running running object -

terminated terminated object -

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 924

Page 935: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-90 waiting 字段数据结构说明

参数 参数类型 描述

reason String (brief) reason the container is notyet running.

message String Message regarding why thecontainer is not yet running.

表 7-91 running 字段数据结构说明

参数 参数类型 描述

startedAt String Time at which the container waslast (re-)started.

表 7-92 terminated 字段数据结构说明

参数 参数类型 描述

startedAt Integer Exit status from the lasttermination of the container.

signal Integer Signal from the last termination ofthe container.

reason String (brief) reason from the lasttermination of the container.

message String Message regarding the lasttermination of the container.

startedAt String Time at which previous executionof the container started.

finishedAt String Time at which the container lastterminated.

containerID String Container's ID in the format'docker://'.

表 7-93 metadata 字段数据结构说明

参数 参数类型 描述

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 925

Page 936: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treated asopaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

表 7-94 items 字段数据结构说明

参数 参数类型 描述

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated. In CamelCase.

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

metadata metadata object -

spec spec object -

status status object -

表 7-95 metadata 字段数据结构说明

参数 参数类型 描述

name String Name must be unique within anamespace. Is required whencreating resources, although someresources may allow a client torequest the generation of anappropriate name automatically.Name is primarily intended forcreation idempotence andconfiguration definition. Cannot beupdated.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 926

Page 937: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

clusterName String The name of the cluster which theobject belongs to. This is used todistinguish resources with samename and namespace in differentclusters. This field is not setanywhere right now and apiserveris going to ignore it if set in createor update request.

initializers initializers object An initializer is a controller whichenforces some system invariant atobject creation time. This field is alist of initializers that have not yetacted on this object. If nil orempty, this object has beencompletely initialized. Otherwise,the object is considereduninitialized and is hidden (in list/watch and get calls) from clientsthat haven't explicitly asked toobserve uninitialized objects.When an object is created, thesystem will populate this list withthe current set of initializers. Onlyprivileged users may set or modifythis list. Once it is empty, it maynot be modified further by anyuser.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 927

Page 938: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

generateName String GenerateName is an optionalprefix, used by the server, togenerate a unique name ONLY IFthe Name field has not beenprovided. If this field is used, thename returned to the client will bedifferent than the name passed.This value will also be combinedwith a unique suffix. The providedvalue has the same validationrules as the Name field, and maybe truncated by the length of thesuffix required to make the valueunique on the server.If this field is specified and thegenerated name exists, the serverwill NOT return a 409 - instead, itwill either return 201 Created or500 with Reason ServerTimeoutindicating a unique name couldnot be found in the time allotted,and the client should retry(optionally after the timeindicated in the Retry-Afterheader).Applied only if Name is notspecified.

namespace String Namespace defines the spacewithin each name must be unique.An empty namespace is equivalentto the "default" namespace, but"default" is the canonicalrepresentation. Not all objects arerequired to be scoped to anamespace - the value of this fieldfor those objects will be empty.Must be a DNS_LABEL. Cannot beupdated.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 928

Page 939: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

uid String UID is the unique in time andspace value for this object. It istypically generated by the serveron successful creation of aresource and is not allowed tochange on PUT operations.Populated by the system. Read-only.

resourceVersion String An opaque value that representsthe internal version of this objectthat can be used by clients todetermine when objects havechanged. May be used foroptimistic concurrency, changedetection, and the watchoperation on a resource or set ofresources. Clients must treat thesevalues as opaque and passedunmodified back to the server.They may only be valid for aparticular resource or set ofresources. Populated by thesystem. Read-only. Value must betreated as opaque by clients.

generation Integer A sequence number representing aspecific generation of the desiredstate. Currently only implementedby replication controllers.Populated by the system. Read-only.

creationTimestamp

String CreationTimestamp is a timestamprepresenting the server time whenthis object was created. It is notguaranteed to be set in happens-before order across separateoperations. Clients may not setthis value. It is represented inRFC3339 form and is in UTC.Populated by the system. Read-only. Null for lists.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 929

Page 940: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

deletionTimestamp

String DeletionTimestamp is RFC 3339date and time at which thisresource will be deleted. This fieldis set by the server when agraceful deletion is requested bythe user, and is not directlysettable by a client. The resourcewill be deleted (no longer visiblefrom resource lists, and notreachable by name) after the timein this field. Once set, this valuemay not be unset or be set furtherinto the future, although it may beshortened or the resource may bedeleted prior to this time. Forexample, a user may request thata pod is deleted in 30 seconds. TheKubelet will react by sending agraceful termination signal to thecontainers in the pod. Once theresource is deleted in the API, theKubelet will send a hardtermination signal to thecontainer. If not set, gracefuldeletion of the object has notbeen requested. Populated by thesystem when a graceful deletion isrequested. Read-only.

deletionGracePeriodSeconds

Integer Number of seconds allowed forthis object to gracefully terminatebefore it will be removed from thesystem. Only set whendeletionTimestamp is also set.May only be shortened. Read-only.

labels Object Map of string keys and values thatcan be used to organize andcategorize (scope and select)objects. May match selectors ofreplication controllers and services.

annotations Object Annotations is an unstructured keyvalue map stored with a resourcethat may be set by external toolsto store and retrieve arbitrarymetadata. They are not queryableand should be preserved whenmodifying objects.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 930

Page 941: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

ownerReferences ownerReferencesobject

List of objects depended by thisobject. If ALL objects in the listhave been deleted, this object willbe garbage collected. If this objectis managed by a controller, thenan entry in this list will point tothis controller, with the controllerfield set to true. There cannot bemore than one managingcontroller.

finalizers Array of strings Must be empty before the object isdeleted from the registry. Eachentry is an identifier for theresponsible component that willremove the entry from the list. Ifthe deletionTimestamp of theobject is non-nil, entries in this listcan only be removed.

表 7-96 spec 字段数据结构说明

参数 类型 描述

replicas Integer Replicas is the number of desiredreplicas. This is a pointer todistinguish between explicit zeroand unspecified. Defaults to 1.

selector object Selector is a label query over podsthat should match the Replicascount. If Selector is empty, it isdefaulted to the labels present onthe Pod template. Label keys andvalues that must match in order tobe controlled by this replicationcontroller, if empty defaulted tolabels on Pod template.

minReadySeconds Integer Minimum number of seconds forwhich a newly created pod shouldbe ready without any of itscontainer crashing, for it to beconsidered available. Defaults to 0(pod will be considered availableas soon as it is ready)

template template object -

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 931

Page 942: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-97 status 字段数据结构说明

参数 参数类型 描述

replicas Integer Replicas is the most recentlyobserved number of replicas.

availableReplicas Integer The number of available replicas(ready for at leastminReadySeconds) for thisreplication controller.

readyReplicas Integer The number of ready replicas forthis replication controller.

fullyLabeledReplicas

Integer The number of pods that havelabels matching the labels of thepod template of the replicationcontroller.

conditions ReplicationControllerCondition object

Represents the latest availableobservations of a replicationcontroller's current state.

observedGeneration

Integer ObservedGeneration reflects thegeneration of the most recentlyobserved replication controller.

表 7-98 initializers 字段数据结构说明

参数 参数类型 描述

pending pending object Pending is a list of initializers thatmust execute in order before thisobject is visible. When the lastpending initializer is removed,and no failing result is set, theinitializers struct will be set to niland the object is considered asinitialized and visible to all clients.

result result object If result is set with the Failurefield, the object will be persistedto storage and then deleted,ensuring that other clients canobserve the deletion.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 932

Page 943: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-99 pending 字段数据结构说明

参数 参数类型 描述

name String name of the process that isresponsible for initializing thisobject.

表 7-100 result 字段数据结构说明

参数 参数类型 描述

apiVersion String APIVersion defines the versionedschema of this representation ofan object. Servers should convertrecognized schemas to the latestinternal value, and may rejectunrecognized values.

code Integer Suggested HTTP return code forthis status, 0 if not set.

details details object Extended data associated with thereason. Each reason may define itsown extended details. This field isoptional and the data returned isnot guaranteed to conform to anyschema except that defined by thereason type.

kind String Kind is a string value representingthe REST resource this objectrepresents. Servers may infer thisfrom the endpoint the clientsubmits requests to. Cannot beupdated.

message String A human-readable description ofthe status of this operation.

metadata metadata object Standard list metadata.

reason String A machine-readable description ofwhy this operation is in the"Failure" status. If this value isempty there is no informationavailable. A Reason clarifies anHTTP status code but does notoverride it.

status String Status of the operation. One of:"Success" or "Failure".

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 933

Page 944: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-101 details 字段数据结构说明

参数 参数类型 描述

causes causes object The Causes array includes moredetails associated with theStatusReason failure. Not allStatusReasons may providedetailed causes.

group String The group attribute of theresource associated with the statusStatusReason.

kind String The kind attribute of the resourceassociated with the statusStatusReason. On some operationsmay differ from the requestedresource Kind.

name String The name attribute of the resourceassociated with the statusStatusReason (when there is asingle name which can bedescribed).

retryAfterSeconds Integer If specified, the time in secondsbefore the operation should beretried.

uid String UID of the resource. (when there isa single resource which can bedescribed).

表 7-102 metadata 字段数据结构说明

参数 参数类型 描述

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treated asopaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 934

Page 945: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-103 causes 字段数据结构说明

参数 参数类型 描述

field String The field of the resource that hascaused this error, as named by itsJSON serialization. May include dotand postfix notation for nestedattributes. Arrays are zero-indexed.Fields may appear more than oncein an array of causes due to fieldshaving multiple errors. Optional.Examples: "name" - the field"name" on the current resource"items[0].name" - the field "name"on the first array entry in "items"

message String A human-readable description ofthe cause of the error. This fieldmay be presented as-is to a reader.

reason String A machine-readable description ofthe cause of the error. If this valueis empty there is no informationavailable.

表 7-104 ownerReferences 字段数据结构说明

参数 参数类型 描述

apiVersion String API version of the referent.

blockOwnerDeletion

Boolean If true, AND if the owner has the"foregroundDeletion" finalizer,then the owner cannot be deletedfrom the key-value store until thisreference is removed. Defaults tofalse. To set this field, a user needs"delete" permission of the owner,otherwise 422 (UnprocessableEntity) will be returned.

kind String Kind of the referent.

name String Name of the referent.

uid String UID of the referent.

controller Boolean If true, this reference points to themanaging controller.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 935

Page 946: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-105 template 字段数据结构说明

参数 参数类型 描述

metadata metadata object -

spec spec object -

表 7-106 spec 字段数据结构说明

参数 参数类型 描述

volumes volumes object List of volumes that can bemounted by containers belongingto the pod.

containers containers object List of containers belonging to thepod. Containers cannot currentlybe added or removed. There mustbe at least one container in a Pod.Cannot be updated.

restartPolicy String Restart policy for all containerswithin the pod. One of Always,OnFailure, Never. Default toAlways.

terminationGracePeriodSeconds

Integer Optional duration in seconds thepod needs to terminate gracefully.May be decreased in deleterequest. Value must be non-negative integer. The value zeroindicates delete immediately. Ifthis value is nil, the default graceperiod will be used instead. Thegrace period is the duration inseconds after the processesrunning in the pod are sent atermination signal and the timewhen the processes are forciblyhalted with a kill signal. Set thisvalue longer than the expectedcleanup time for your process.Defaults to 30 seconds.

activeDeadlineSeconds

Integer Optional duration in seconds thepod may be active on the noderelative to StartTime before thesystem will actively try to mark itfailed and kill associatedcontainers. Value must be apositive integer.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 936

Page 947: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

dnsPolicy String Set DNS policy for containerswithin the pod. One of'ClusterFirst' or 'Default'. Defaultsto "ClusterFirst".

serviceAccountName

String ServiceAccountName is the nameof the ServiceAccount to use torun this pod.

serviceAccount String DeprecatedServiceAccount is adepreciated alias forServiceAccountName. Deprecated:Use serviceAccountName instead.

nodeName String NodeName is a request toschedule this pod onto a specificnode. If it is non-empty, thescheduler simply schedules thispod onto that node, assumingthat it fits resource requirements.

hostNetwork Boolean Host networking requested for thispod. Use the host's networknamespace. If this option is set,the ports that will be used mustbe specified. Default to false.

hostPID Boolean Use the host's pid namespace.Optional: Default to false.

hostIPC Boolean Use the host's ipc namespace.Optional: Default to false.

securityContext securityContextobject

-

imagePullSecrets imagePullSecretsobject

ImagePullSecrets is an optional listof references to secrets in thesame namespace to use forpulling any of the images used bythis PodSpec. If specified, thesesecrets will be passed to individualpuller implementations for themto use. For example, in the case ofdocker, only DockerConfig typesecrets are honored.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 937

Page 948: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-107 volumes 字段数据结构说明

参数 参数类型 描述

name String Volume's name. Must be aDNS_LABEL and unique within thepod.

hostPath hostPath object -

emptyDir emptyDir object -

gitRepo gitRepo object -

secret secret object -

nfs nfs object -

iscsi iscsi object -

glusterfs glusterfs object -

persistentVolumeClaim

persistentVolumeClaim object

-

rbd rbd object -

cinder cinder object -

cephfs cephfs object -

flocker flocker object -

downwardAPI downwardAPI object -

fc fc object -

vsphereVolume vsphereVolumeobject

-

表 7-108 containers 字段数据结构说明

参数 参数类型 描述

name String Name of the container specifiedas a DNS_LABEL. Each containerin a pod must have a uniquename (DNS_LABEL). Cannot beupdated.

image String Docker image name.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 938

Page 949: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

command Array of strings Entrypoint array. Not executedwithin a shell. The docker image'sentrypoint is used if this is notprovided. Variable references $(VAR_NAME) are expanded usingthe container's environment. If avariable cannot be resolved, thereference in the input string willbe unchanged. The $(VAR_NAME)syntax can be escaped with adouble $$, for example, $$(VAR_NAME). Escaped referenceswill never be expanded, regardlessof whether the variable exists ornot. Cannot be updated.

args Array of strings Arguments to the entrypoint. Thedocker image's cmd is used if thisis not provided. Variablereferences $(VAR_NAME) areexpanded using the container'senvironment. If a variable cannotbe resolved, the reference in theinput string will be unchanged.The $(VAR_NAME) syntax can beescaped with a double $$, forexample, $$(VAR_NAME). Escapedreferences will never be expanded,regardless of whether the variableexists or not. Cannot be updated.

workingDir String Container's working directory.Defaults to Docker's default.Defaults to image's default.Cannot be updated.

ports ports object List of ports to expose from thecontainer. Cannot be updated.

env env object List of environment variables toset in the container. Cannot beupdated.

resources resources object Resources represents theminimum resources the volumeshould have.

volumeMounts volumeMounts object Pod volumes to mount into thecontainer's file system. Cannot beupdated.

livenessProbe livenessProbe object -

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 939

Page 950: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

readinessProbe readinessProbe object -

lifecycle lifecycle object -

terminationMessagePath

String Path at which the file to which thecontainer's termination messagewill be written is mounted intothe container's file system.Message written is intended to bebrief final status, such as anassertion failure message.Defaults to /dev/termination-log.Cannot be updated.

imagePullPolicy String Image pull policy. One of Always,Never, IfNotPresent. Defaults toAlways if the latest tag isspecified, or IfNotPresentotherwise. Cannot be updated.

securityContext securityContextobject

-

stdin Boolean Whether this container shouldallocate a buffer for stdin in thecontainer runtime. If this is notset, reads from stdin in thecontainer will always result in EOF.Default is false.

stdinOnce Boolean Whether the container runtimeshould close the stdin channelafter it has been opened by asingle attach. When stdin is truethe stdin stream will remain openacross multiple attach sessions. IfstdinOnce is set to true, stdin isopened on container start, isempty until the first clientattaches to stdin, and thenremains open and accepts datauntil the client disconnects, atwhich time stdin is closed andremains closed until the containeris restarted. If this flag is false, acontainer process that reads fromstdin will never receive an EOF.Default is false.

tty Boolean Whether this container shouldallocate a TTY for itself, alsorequires 'stdin' to be true. Defaultis false.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 940

Page 951: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-109 securityContext 字段数据结构说明

参数 参数类型 描述

seLinuxOptions seLinuxOptionsobject

-

runAsUser Integer The UID to run the entrypoint ofthe container process. Defaults touser specified in image metadataif unspecified. May also be set inSecurityContext. If set in bothSecurityContext andPodSecurityContext, the valuespecified in SecurityContext takesprecedence for that container.

runAsNonRoot Boolean Indicates that the container mustrun as a non-root user. If true, theKubelet will validate the image atruntime to ensure that it does notrun as UID 0 (root) and fail tostart the container if it does. Ifunset or false, no such validationwill be performed. May also be setin SecurityContext. If set in bothSecurityContext andPodSecurityContext, the valuespecified in SecurityContext takesprecedence.

supplementalGroups

Array of integers A list of groups applied to the firstprocess run in each container, inaddition to the container's primaryGID. If unspecified, no groups willbe added to any container.

fsGroup Integer A special supplemental group thatapplies to all containers in a pod.Some volume types allow theKubelet to change the ownershipof that volume to be owned bythe pod:The owning GID will be theFSGroup 2. The setgid bit is set(new files created in the volumewill be owned by FSGroup) 3. Thepermission bits are OR'd with rw-rw.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 941

Page 952: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-110 imagePullSecrets 字段数据结构说明

参数 参数类型 描述

name String Name of the referent.

表 7-111 hostPath 字段数据结构说明

参数 参数类型 描述

path String Path of the directory on the host.

表 7-112 emptyDir 字段数据结构说明

参数 参数类型 描述

medium String What type of storage mediumshould back this directory. Thedefault is "" which means to usethe node's default medium. Mustbe an empty string (default) orMemory.

表 7-113 gitRepo 字段数据结构说明

参数 类型 描述

repository String Repository URL

revision String Commit hash for the specifiedrevision.

表 7-114 secret 字段数据结构说明

参数 参数类型 描述

secretName String SecretName is the name of asecret in the pod's namespace.

表 7-115 nfs 字段数据结构说明

参数 参数类型 描述

server String Server is the hostname or IPaddress of the NFS server.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 942

Page 953: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

path String Path that is exported by the NFSserver.

readOnly Boolean ReadOnly here will force the NFSexport to be mounted with read-only permissions. Defaults to false.

表 7-116 iscsi 字段数据结构说明

参数 参数类型 描述

targetPortal String iSCSI target portal. The portal iseither an IP or ip_addr:port if theport is other than default(typically TCP ports 860 and3260).

iqn String Target iSCSI Qualified Name.

lun Integer iSCSI target lun number.

fsType String Filesystem type of the volume thatyou want to mount. Tip: Ensurethat the filesystem type issupported by the host operatingsystem. Examples: "ext4", "xfs","ntfs".

readOnly Boolean ReadOnly here will force theReadOnly setting inVolumeMounts. Defaults to false.

表 7-117 glusterfs 字段数据结构说明

参数 参数类型 描述

endpoints String EndpointsName is the endpointname that details Glusterfstopology.

path String Path is the Glusterfs volume path.

readOnly Boolean ReadOnly here will force theGlusterfs volume to be mountedwith read-only permissions.Defaults to false.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 943

Page 954: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-118 persistentVolumeClaim 字段数据结构说明

参数 参数类型 描述

claimName String ClaimName is the name of aPersistentVolumeClaim in thesame namespace as the pod usingthis volume.

readOnly Boolean Will force the ReadOnly setting inVolumeMounts. Default false.

表 7-119 rbd 字段数据结构说明

参数 参数类型 描述

monitors Array of strings A collection of Ceph monitors.

image String The rados image name.

fsType String Filesystem type of the volume thatyou want to mount. Tip: Ensurethat the filesystem type issupported by the host operatingsystem. Examples: "ext4", "xfs","ntfs".

pool String The rados pool name. Default isrbd.

user String The rados user name. Default isadmin.

keyring String Keyring is the path to key ring forRBDUser. Default is /etc/ceph/keyring.

secretRef imagePullSecretsobject

-

readOnly Boolean ReadOnly here will force theReadOnly setting inVolumeMounts. Defaults to false.

表 7-120 cinder 字段数据结构说明

参数 参数类型 描述

volumeID Array of strings volume id used to identify thevolume in cinder

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 944

Page 955: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

fsType String Required: Filesystem type tomount. Must be a filesystem typesupported by the host operatingsystem. Only ext3 and ext4 areallowed.

readOnly Boolean Optional: Defaults to false (read/write). ReadOnly here will forcethe ReadOnly setting inVolumeMounts.

表 7-121 cephfs 字段数据结构说明

参数 参数类型 描述

monitors Array of strings Required: Monitors is a collectionof Ceph monitors

user String Optional: User is the rados username, default is admin

secretFile String SecretFile is the path to key ringfor User, default is /etc/ceph/user.

secretRef imagePullSecretsobject

-

readOnly Boolean Optional: Defaults to false (read/write). ReadOnly here will forcethe ReadOnly setting inVolumeMounts.

表 7-122 flocker 字段数据结构说明

参数 参数类型 描述

datasetName String Required: the volume name. Thisis going to be store on metadata -> name on the payload forFlocker.

表 7-123 downwardAPI 字段数据结构说明

参数 参数类型 描述

items items object Items is a list of downward APIvolume file.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 945

Page 956: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-124 fc 字段数据结构说明

参数 参数类型 描述

targetWWNs Array of strings Required: FC target world widenames (WWNs)

lun Integer Required: FC target lun number

fsType String Required: Filesystem type tomount. Must be a filesystem typesupported by the host operatingsystem. Ex. "ext4", "xfs", "ntfs"

readOnly Boolean Optional: Defaults to false (read/write). ReadOnly here will forcethe ReadOnly setting inVolumeMounts.

表 7-125 vsphereVolume 字段数据结构说明

参数 参数类型 描述

volumePath String Path that identifies vSpherevolume vmdk.

fsType String Filesystem type to mount.Must be a filesystem typesupported by the host operatingsystem.Ex. "ext4", "xfs", "ntfs".Implicitly inferred to be "ext4" ifunspecified.

表 7-126 ports 字段数据结构说明

参数 参数类型 描述

name String If specified, this must be anIANA_SVC_NAME and uniquewithin the pod. Each named portin a pod must have a uniquename. Name for the port that canbe referred to by services.

hostPort Integer Number of port to expose on thehost. If specified, this must be avalid port number, 0 < x < 65536.If HostNetwork is specified, thismust match ContainerPort. Mostcontainers do not need this.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 946

Page 957: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

参数 参数类型 描述

containerPort Integer Number of port to expose on thepod's IP address. This must be avalid port number, 0 < x < 65536.

protocol String Protocol for port. Must be UDP orTCP. Defaults to "TCP".

hostIP String What host IP to bind the externalport to.

表 7-127 env 字段数据结构说明

参数 参数类型 描述

name String Name of the environmentvariable. Must be a C_IDENTIFIER.

value String Variable references $(VAR_NAME)are expanded using the previousdefined environment variables inthe container and any serviceenvironment variables. If avariable cannot be resolved, thereference in the input string willbe unchanged. The $(VAR_NAME)syntax can be escaped with adouble $$, for example, $$(VAR_NAME). Escaped referenceswill never be expanded, regardlessof whether the variable exists ornot. Defaults to "".

valueFrom valueFrom object -

表 7-128 resources 字段数据结构说明

参数 参数类型 描述

limits object Limits describes the maximumamount of compute resourcesallowed.

requests object Requests describes the minimumamount of compute resourcesrequired. If Requests is omitted fora container, it defaults to Limits ifthat is explicitly specified,otherwise to an implementation-defined value.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 947

Page 958: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-129 volumeMounts 字段数据结构说明

参数 参数类型 描述

name String This must match the Name of aVolume.

readOnly Boolean Mounted read-only if true, read-write otherwise (false orunspecified). Defaults to false.

mountPath String Path within the container at whichthe volume should be mounted.

subPath String Path within the volume fromwhich the container's volumeshould be mounted.Defaults to "" (volume's root).

表 7-130 livenessProbe 字段数据结构说明

参数 参数类型 描述

exec exec object -

httpGet httpGet object -

tcpSocket tcpSocket object -

initialDelaySeconds

Integer Number of seconds after thecontainer has started beforeliveness probes are initiated.

timeoutSeconds Integer Number of seconds after whichthe probe times out. Defaults to 1second. Minimum value is 1.

periodSeconds Integer How often (in seconds) toperform the probe. Default to 10seconds. Minimum value is 1.

successThreshold Integer Minimum consecutive successesfor the probe to be consideredsuccessful after having failed.Defaults to 1. Must be 1 forliveness. Minimum value is 1.

failureThreshold Integer Minimum consecutive failures forthe probe to be considered failedafter having succeeded. Defaultsto 3. Minimum value is 1.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 948

Page 959: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-131 lifecycle 字段数据结构说明

参数 参数类型 描述

postStart postStart/preStopobject

-

preStop postStart/preStopobject

-

表 7-132 securityContext 字段数据结构说明

参数 类型 描述

capabilities capabilities object -

privileged Boolean Run container in privileged mode.Processes in privileged containersare essentially equivalent to rooton the host. Defaults to false.

seLinuxOptions seLinuxOptionsobject

-

runAsUser Integer The UID to run the entrypoint ofthe container process. Defaults touser specified in image metadataif unspecified. May also be set inPodSecurityContext. If set in bothSecurityContext andPodSecurityContext, the valuespecified in SecurityContext takesprecedence.

runAsNonRoot Boolean Indicates that the container mustrun as a non-root user. If true, theKubelet will validate the image atruntime to ensure that it does notrun as UID 0 (root) and fail tostart the container if it does. Ifunset or false, no such validationwill be performed. May also be setin PodSecurityContext. If set inboth SecurityContext andPodSecurityContext, the valuespecified in SecurityContext takesprecedence.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 949

Page 960: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-133 seLinuxOptions 字段数据结构说明

参数 参数类型 描述

user String User is a SELinux user label thatapplies to the container.

role String Role is a SELinux role label thatapplies to the container.

type String Type is a SELinux type label thatapplies to the container.

level String Level is SELinux level label thatapplies to the container.

表 7-134 items 字段数据结构说明

参数 参数类型 描述

path String Required: Path is the relative pathname of the file to be created.Must not be absolute or containthe '..' path. Must be utf-8encoded. The first item of therelative path must not start with'..'

fieldRef fieldRef object -

表 7-135 valueFrom 字段数据结构说明

参数 参数类型 描述

fieldRef fieldRef object -

resourceFieldRef resourceFieldRefobject

Selects a resource of thecontainer: only resources limitsand requests (limits.cpu,limits.memory, requests.cpu andrequests.memory) are currentlysupported.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 950

Page 961: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-136 exec 字段数据结构说明

参数 参数类型 描述

command Array of strings Command is the command line toexecute inside the container, theworking directory for thecommand is root ('/') in thecontainer's filesystem. Thecommand is simply exec'd, it is notrun inside a shell, so traditionalshell instructions ('|', etc) do notwork. To use a shell, you need toexplicitly call out to that shell. Exitstatus of 0 is treated as live/healthy and non-zero is unhealthy.

表 7-137 httpGet 字段数据结构说明

参数 参数类型 描述

path String Path to access on the HTTP server.

port String Name or number of the port toaccess on the container. Numbermust be in the range 1 to 65535.Name must be anIANA_SVC_NAME.

host String Host name to connect to, defaultsto the pod IP.

scheme String Scheme to use for connecting tothe host. Defaults to HTTP.

表 7-138 tcpSocket 字段数据结构说明

参数 参数类型 描述

port String Number or name of the port toaccess on the container. Numbermust be in the range 1 to 65535.Name must be anIANA_SVC_NAME.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 951

Page 962: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-139 postStart/preStop 字段数据结构说明

参数 参数类型 描述

exec exec object -

httpGet httpGet object -

tcpSocket tcpSocket object TCPSocket specifies an actioninvolving a TCP port. TCP hooksnot yet supported.

表 7-140 capabilities 字段数据结构说明

参数 参数类型 描述

add Table68 Datastructure of the addfield

Added capabilities

drop 表7-143 Removed capabilities

表 7-141 fieldRef 字段数据结构说明

参数 参数类型 描述

apiVersion String Version of the schema theFieldPath is written in terms of,defaults to "v1"

fieldPath String Path of the field to select in thespecified API version.

表 7-142 resourceFieldRef 字段数据结构说明

参数 类型 描述

containerName String Container name: required forvolumes, optional for env vars.

resource String Required: resource to select.

divisor String Specifies the output format of theexposed resources, defaults to "1".

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 952

Page 963: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 7-143 add 字段数据结构说明

参数 参数类型 描述

name String name is the name of the resource.

namespaced Boolean namespaced indicates if a resourceis namespaced or not.Default: false.

kind String kind is the kind for the resource.

表 7-144 ReplicationControllerCondition 字段数据结构说明

参数 参数类型 描述

lastTransitionTime String The last time the conditiontransitioned from one status toanother.

message String A human readable messageindicating details about thetransition.

reason String The reason for the condition's lasttransition.

status String Status of the condition, one ofTrue, False, Unknown.

type String Type of replication controllercondition.

表 7-145 metadata 字段数据结构说明

参数 参数类型 描述

resourceVersion String String that identifies the server'sinternal version of this object thatcan be used by clients todetermine when objects havechanged. Value must be treated asopaque by clients and passedunmodified back to the server.Populated by the system. Read-only.

selfLink String SelfLink is a URL representing thisobject. Populated by the system.Read-only.

云容器引擎API 参考 7 数据结构

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 953

Page 964: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

8 权限和授权项

如果您需要对您所拥有的云容器引擎(CCE)进行精细的权限管理,您可以使用统一身份认证服务(Identity and Access Management,简称IAM),如果华为云账号已经能满足您的要求,不需要创建独立的IAM用户,您可以跳过本章节,不影响您使用CCE服务的其它功能。

默认情况下,新建的IAM用户没有任何权限,您需要将其加入用户组,并给用户组授予策略或角色,才能使用户组中的用户获得相应的权限,这一过程称为授权。授权后,用户就可以基于已有的权限对云服务进行操作。关于策略的语法结构及示例,请参见IAM权限管理说明。

权限根据授权的精细程度,分为角色和策略。角色以服务为粒度,是IAM 初提供的一种根据用户的工作职能定义权限的粗粒度授权机制。策略以API接口为粒度进行权限拆分,授权更加精细,可以精确到某个操作、资源和条件,能够满足企业对权限 小化的安全管控要求。

说明

● 基于策略的访问控制是针对需要精细化控制权限的用户设计的一种授权方式,当前处于公测阶段,推荐您开通,开通后可永久免费使用,开通方法请参见:申请基于策略的访问控制公测。

● 如果您要允许或是禁止某个接口的操作权限,请使用策略。

账号具备所有接口的调用权限,如果使用账号下的IAM用户发起API请求时,该IAM用户必须具备调用该接口所需的权限,否则,API请求将调用失败。每个接口所需要的权限,与各个接口所对应的授权项相对应,只有发起请求的用户被授予授权项所对应的策略,该用户才能成功调用该接口。例如,用户要调用接口来查询云服务器列表,那么这个IAM用户被授予的策略中必须包含允许“ecs:servers:list”的授权项,该接口才能调用成功。

支持的授权项

策略包含系统策略和自定义策略,如果系统策略不满足授权要求,管理员可以创建自定义策略,并通过给用户组授予自定义策略来进行精细的访问控制。策略支持的操作与API相对应,授权项列表说明如下:

● 权限:允许或拒绝某项操作。

● 授权项:自定义策略中支持的Action,在自定义策略中的Action中写入授权项,可以实现授权项对应的权限功能。

云容器引擎API 参考 8 权限和授权项

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 954

Page 965: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

● 授权范围:自定义策略的授权范围,包括IAM项目与企业项目。授权范围如果同时支持IAM项目和企业项目,表示此授权项对应的自定义策略,可以在IAM和企业管理两个服务中给用户组授权并生效。如果仅支持IAM项目,不支持企业项目,表示仅能在IAM中给用户组授权并生效,如果在企业管理中授权,则该自定义策略不生效。关于IAM项目与企业项目的区别,详情请参见:IAM与企业管理的区别。

● 对应API接口:自定义策略实际调用的API接口。

表 8-1 CCE 授权项明细

权限 授权项 授权范围 对应API接口

获取指定项目下的集群

cce:cluster:list 支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

GET /api/v3/projects/{project_id}/clusters

获取指定的集群

cce:cluster:get 支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

GET /api/v3/projects/{project_id}/clusters/{cluster_id}

创建集群 cce:cluster:create

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

POST /api/v3/projects/{project_id}/clusters

更新指定的集群

cce:cluster:update

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

PUT /api/v3/projects/{project_id}/clusters/{cluster_id}

删除集群 cce:cluster:delete

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

DELETE /api/v3/projects/{project_id}/clusters/{cluster_id}

云容器引擎API 参考 8 权限和授权项

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 955

Page 966: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

权限 授权项 授权范围 对应API接口

获取集群证书 cce:cluster:get 支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/clustercert

获取集群下所有节点

cce:node:list 支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes

获取指定的节点

cce:node:get 支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/{node_id}

创建节点 cce:node:create

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes

更新指定的节点

cce:node:update

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

PUT /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/{node_id}

删除节点 cce:node:delete

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

DELETE /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/{node_id}

云容器引擎API 参考 8 权限和授权项

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 956

Page 967: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

权限 授权项 授权范围 对应API接口

查询作业进度 cce:job:get 支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

GET /api/v3/projects/{project_id}/jobs/{job_id}

获取集群下所有节点池

cce:nodepool:list

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/nodepools

创建PersistentVolumeClaim

cce:storage:create

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

POST /api/v1/namespaces/{namespace}/cloudpersistentvolumeclaims

删除PersistentVolumeClaim

cce:storage:delete

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

DELETE /api/v1/namespaces/{namespace}/cloudpersistentvolumeclaims/{name}

创建PersistentVolume

cce:storage:create

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

POST /api/v1/cloudpersistentvolumes

删除PersistentVolume

cce:storage:delete

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

DELETE /api/v1/cloudpersistentvolumes/{name}

云容器引擎API 参考 8 权限和授权项

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 957

Page 968: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

权限 授权项 授权范围 对应API接口

操作kubernetes资源

cce:kubernetes:*

支持:

● IAM项目(Project)

● 企业项目(EnterpriseProject)

● /api/*● /apis/*

云容器引擎API 参考 8 权限和授权项

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 958

Page 969: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

9 附录

9.1 PATCH 请求方法操作说明对于PATCH请求方法的操作,Kubernetes API通过相应的HTTP头域“Content-Type”对其进行识别。

操作说明

目前支持三种类型的PATCH请求方法的操作。

1. JSON Patch, Content-Type: application/json-patch+json在RFC6902协议的定义中,JSON Patch是执行在资源对象上的一系列操作,如下所示。{ "op": "add", "path": "/spec/containers/0/image", "value": "busybox:latest"}

其中:

– “op”表示对资源对象的操作,主要有以下六种操作。

▪ add

▪ replace

▪ remove(不可用)

▪ move(不可用)

▪ copy(不可用)

▪ test(不可用)

– “path”表示被操作资源对象的路径.例如“/spec/containers/0/image”表示要操作的对象是“spec.containers[0].image”,可以对其进行修改。

– “value”表示预修改的值。

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 959

Page 970: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

2. Merge Patch, Content-Type: application/merge-patch+json在RFC7386协议的定义中,Merge Patch必须包含对一个资源对象的部分描述,即为JSON对象。该JSON对象被提交到服务端后与服务端的当前对象合并,即替换当前资源对象中的列表域,从而创建一个新的对象。

3. Strategic Merge Patch, Content-Type: application/strategic-merge-patch+jsonStrategic Merge Patch是添加合法的元数据到API对象中,并通过这些新的元数据来决定哪个列表被合并,哪个列表不该被合并。当前这些元数据则作为结构标签。

“Merge Patch”与“Strategic Merge Patch”的操作区别请参见9.2 PATCH请求方法操作示例。

9.2 PATCH 请求方法操作示例本章节主要介绍PATCH请求方法中,“Merge Patch”与“Strategic Merge Patch”类型的操作示例。

操作示例

以创建ReplicationController资源对象为例。

请求示例

{ "apiVersion": "v1", "kind": "ReplicationController", "metadata": { "name": "frontend-controller" }, "spec": { "replicas": 2, "selector": { "app": "nginx" }, "template": { "metadata": { "labels": { "app": "nginx" } }, "spec": { "containers": [ { "name": "redis", "image": "redis:latest", "ports": [ { "containerPort": 80 } ] } ] } } }}

响应示例

{ "kind": "ReplicationController",

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 960

Page 971: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"apiVersion": "v1", "metadata": { "name": "frontend-controller", "namespace": "default", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/nginx-controller", "uid": "549b2234-5d46-11e6-aeb9-286ed488fafe", "resourceVersion": "4110", "generation": 1, "creationTimestamp": "2016-08-08T08:58:52Z", "labels": { "app": "nginx" } }, "spec": { "replicas": 2, "selector": { "app": "nginx" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "nginx" } }, "spec": { "containers": [ { "name": "redis", "image": "redis:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } } }, "status": { "replicas": 0 }}

● 如果使用“Merge Patch”类型操作,添加一个容器到指定ReplicationController的“template”参数中,则其中的整个容器列表将被新添加的容器所替换。

Merge Patch请求{ "spec": { "template": { "spec": { "containers": [ { "name": "hello-world", "image": "busybox:latest" } ] } }

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 961

Page 972: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

}}

Merge Patch响应{ "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "frontend-controller", "namespace": "default", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/nginx-controller", "uid": "549b2234-5d46-11e6-aeb9-286ed488fafe", "resourceVersion": "4159", "generation": 2, "creationTimestamp": "2016-08-08T08:58:52Z", "labels": { "app": "nginx" } }, "spec": { "replicas": 2, "selector": { "app": "nginx" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "nginx" } }, "spec": { "containers": [ { "name": "hello-world", "image": "busybox:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } } }, "status": { "replicas": 2, "fullyLabeledReplicas": 2, "observedGeneration": 1 }}

其中“containers”参数列表被新添加的内容所替换。

● 而使用“Strategic Merge Patch”类型操作,是添加元数据到资源对象中,并通过这些新元数据来决定各个列表是否需要被合并。

Strategic Merge Patch请求{ "spec": { "template": { "spec": { "containers": [ { "name": "hello-world", "image": "busybox:latest" }

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 962

Page 973: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

] } } }}'

Strategic Merge Patch响应{ "kind": "ReplicationController", "apiVersion": "v1", "metadata": { "name": "frontend-controller", "namespace": "default", "selfLink": "/api/v1/namespaces/default/replicationcontrollers/nginx-controller", "uid": "f2e048bb-5d46-11e6-aeb9-286ed488fafe", "resourceVersion": "4250", "generation": 2, "creationTimestamp": "2016-08-08T09:03:18Z", "labels": { "app": "nginx" } }, "spec": { "replicas": 2, "selector": { "app": "nginx" }, "template": { "metadata": { "creationTimestamp": null, "labels": { "app": "nginx" } }, "spec": { "containers": [ { "name": "redis", "image": "redis:latest", "ports": [ { "containerPort": 80, "protocol": "TCP" } ], "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" }, { "name": "hello-world", "image": "busybox:latest", "resources": {}, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "Always" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {} } } }, "status": { "replicas": 2, "fullyLabeledReplicas": 2, "observedGeneration": 1 }}

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 963

Page 974: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

其中“containers”参数列表与新添加的内容合并,而不是替换,合并的依据为“name”域的值。

9.3 状态码状态码如表9-1所示

表 9-1 状态码

状态码

编码 状态说明

100 Continue 继续请求。

这个临时响应用来通知客户端,它的部分请求已经被服务器接收,且仍未被拒绝。

101 Switching Protocols 切换协议。只能切换到更高级的协议。

例如,切换到HTTP的新版本协议。

201 Created 创建类的请求完全成功。

202 Accepted 已经接受请求,但未处理完成。

203 Non-AuthoritativeInformation

非授权信息,请求成功。

204 NoContent 请求完全成功,同时HTTP响应不包含响应体。

在响应OPTIONS方法的HTTP请求时返回此状态码。

205 Reset Content 重置内容,服务器处理成功。

206 Partial Content 服务器成功处理了部分GET请求。

300 Multiple Choices 多种选择。请求的资源可包括多个位置,相应可返回一个资源特征与地址的列表用于用户终端(例如:浏览器)选择。

301 Moved Permanently 永久移动,请求的资源已被永久的移动到新的URI,返回信息会包括新的URI。

302 Found 资源被临时移动。

303 See Other 查看其它地址。

使用GET和POST请求查看。

304 Not Modified 所请求的资源未修改,服务器返回此状态码时,不会返回任何资源。

305 Use Proxy 所请求的资源必须通过代理访问。

306 Unused 已经被废弃的HTTP状态码。

400 BadRequest 非法请求。

建议直接修改该请求,不要重试该请求。

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 964

Page 975: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

编码 状态说明

401 Unauthorized 在客户端提供认证信息后,返回该状态码,表明服务端指出客户端所提供的认证信息不正确或非法。

402 Payment Required 保留请求。

403 Forbidden 请求被拒绝访问。

返回该状态码,表明请求能够到达服务端,且服务端能够理解用户请求,但是拒绝做更多的事情,因为该请求被设置为拒绝访问,建议直接修改该请求,不要重试该请求。

404 NotFound 所请求的资源不存在。

建议直接修改该请求,不要重试该请求。

405 MethodNotAllowed 请求中带有该资源不支持的方法。

建议直接修改该请求,不要重试该请求。

406 Not Acceptable 服务器无法根据客户端请求的内容特性完成请求。

407 Proxy AuthenticationRequired

请求要求代理的身份认证,与401类似,但请求者应当使用代理进行授权。

408 Request Time-out 服务器等候请求时发生超时。

客户端可以随时再次提交该请求而无需进行任何更改。

409 Conflict 服务器在完成请求时发生冲突。

返回该状态码,表明客户端尝试创建的资源已经存在,或者由于冲突请求的更新操作不能被完成。

410 Gone 客户端请求的资源已经不存在。

返回该状态码,表明请求的资源已被永久删除。

411 Length Required 服务器无法处理客户端发送的不带Content-Length的请求信息。

412 Precondition Failed 未满足前提条件,服务器未满足请求者在请求中设置的其中一个前提条件。

413 Request Entity TooLarge

由于请求的实体过大,服务器无法处理,因此拒绝请求。为防止客户端的连续请求,服务器可能会关闭连接。如果只是服务器暂时无法处理,则会包含一个Retry-After的响应信息。

414 Request-URI Too Large 请求的URI过长(URI通常为网址),服务器无法处理。

415 Unsupported MediaType

服务器无法处理请求附带的媒体格式。

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 965

Page 976: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

状态码

编码 状态说明

416 Requested range notsatisfiable

客户端请求的范围无效。

417 Expectation Failed 服务器无法满足Expect的请求头信息。

422 UnprocessableEntity 请求格式正确,但是由于含有语义错误,无法响应。

429 TooManyRequests 表明请求超出了客户端访问频率的限制或者服务端接收到多于它能处理的请求。建议客户端读取相应的Retry-After首部,然后等待该首部指出的时间后再重试。

500 InternalServerError 表明服务端能被请求访问到,但是不能理解用户的请求。

501 Not Implemented 服务器不支持请求的功能,无法完成请求。

502 Bad Gateway 充当网关或代理的服务器,从远端服务器接收到了一个无效的请求。

503 ServiceUnavailable 被请求的服务无效。

建议直接修改该请求,不要重试该请求。

504 ServerTimeout 请求在给定的时间内无法完成。客户端仅在为请求指定超时(Timeout)参数时会得到该响应。

505 HTTP Version notsupported

服务器不支持请求的HTTP协议的版本,无法完成处理。

9.4 获取项目 ID

调用 API 获取项目 ID项目ID可以通过调用查询指定条件下的项目信息API获取。

获取项目ID的接口为“GET https://{Endpoint}/v3/projects”,其中{Endpoint}为IAM的终端节点,可以从地区和终端节点获取。接口的认证鉴权请参见3.2 认证鉴权。

响应示例如下,其中projects下的“id”即为项目ID。

{ "projects": [ { "domain_id": "65382450e8f64ac0870cd180d14e684b", "is_domain": false, "parent_id": "65382450e8f64ac0870cd180d14e684b", "name": "cn-north-4", "description": "", "links": { "next": null, "previous": null, "self": "https://www.example.com/v3/projects/a4a5d4098fb4474fa22cd05f897d6b99" },

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 966

Page 977: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

"id": "a4a5d4098fb4474fa22cd05f897d6b99", "enabled": true } ], "links": { "next": null, "previous": null, "self": "https://www.example.com/v3/projects" }}

从控制台获取项目 ID在调用接口的时候,部分URL中需要填入项目编号,所以需要获取到项目编号。项目编号获取步骤如下:

步骤1 注册并登录管理控制台。

步骤2 单击用户名,在下拉列表中单击“基本信息”。

步骤3 在基本信息页面单击“管理我的凭证”。

在“API凭证”页面的项目列表中查看项目ID。

图 9-1 查看项目 ID

----结束

9.5 获取账号 ID在调用接口的时候,部分URL中需要填入账号ID(domain-id),所以需要先在管理控制台上获取到账号ID。账号ID获取步骤如下:

1. 注册并登录管理控制台。

2. 单击用户名,在下拉列表中单击“我的凭证”。

在“API凭证”页面的项目列表中查看账号ID。

图 9-2 获取账号 ID

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 967

Page 978: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

9.6 集群中使用 ELB 的操作方法本章节介绍在CCE创建的集群中使用ELB时的操作方法。

操作方法

创建对应的service。开源接口的使用方法请参见6.13.1 创建Service。

说明

若需要开启会话保持,需要满足如下条件:

● 工作负载协议为TCP。

● 工作负载的各实例已设置反亲和部署,即所有的实例都部署在不同节点上。详细请参见工作负载和节点的反亲和性。

自动创建ELB:apiVersion: v1 kind: Service metadata: annotations: kubernetes.io/elb.class: union kubernetes.io/session-affinity-mode: SOURCE_IP kubernetes.io/elb.subnet-id: 5083f225-9bf8-48fa-9c8b-67bd9693c4c0 kubernetes.io/elb.autocreate: "{\"type\":\"public\",\"bandwidth_name\":\"cce-bandwidth-1551163379627\",\"bandwidth_chargemode\":\"bandwidth\",\"bandwidth_size\":5,\"bandwidth_sharetype\":\"PER\",\"eip_type\":\"5_bgp\",\"name\":\"james\"}" labels: app: nginx name: nginx spec: externalTrafficPolicy: Local ports: - name: service0 port: 80 protocol: TCP targetPort: 80 selector: app: nginx type: LoadBalancer

使用已有ELB:apiVersion: v1 kind: Service metadata: annotations: kubernetes.io/elb.class: union kubernetes.io/session-affinity-mode: SOURCE_IP kubernetes.io/elb.id: 3c7caa5a-a641-4bff-801a-feace27424b6 kubernetes.io/elb.subnet-id: 5083f225-9bf8-48fa-9c8b-67bd9693c4c0 labels: app: nginx name: nginx spec: loadBalancerIP: 10.78.42.242 externalTrafficPolicy: Local ports: - name: service0 port: 80 protocol: TCP targetPort: 80 selector: app: nginx type: LoadBalancer

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 968

Page 979: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 9-2 关键参数说明

参数 参数类型 描述

kubernetes.io/elb.class String 对接增强型负载均衡时需要增加此参数,值为“union”。

kubernetes.io/session-affinity-mode

String 可选,若需要开启会话保持,需增加该参数。

取值“SOURCE_IP”表示基于源IP。

kubernetes.io/elb.id String 可选,但使用已有ELB时必填。

为增强型负载均衡实例的ID。

kubernetes.io/elb.subnet-id

String 可选,但自动创建时必填,Kubernetesv1.11.7-r0以上版本的集群可不填。

kubernetes.io/elb.autocreate

elb.autocreateobject

可选,但公网自动创建时必填,将自动创建ELB所绑定的EIP。私网自动创建时必填,将自动创建ELB。

示例:

● 公网自动创建:值为 "{\"type\":\"public\",\"bandwidth_name\":\"cce-bandwidth-1551163379627\",\"bandwidth_chargemode\":\"bandwidth\",\"bandwidth_size\":5,\"bandwidth_sharetype\":\"PER\",\"eip_type\":\"5_bgp\",\"name\":\"james\"}"

● 私网自动创建:值为 "{\"type\":\"inner\"}"

loadBalancerIP String 配置为ELB的IP地址,私网ELB配置私有IP,公网ELB配置为公网IP。

externalTrafficPolicy String 可选,若需要开启会话保持,需增加该参数,表示请求转到固定节点;若某个服务发布成ELB服务且为Local模式,客户端如果在集群内,那么必须与服务端在同一个节点上才能正常访问。

port Integer 集群虚拟IP的访问端口,也是注册到负载均衡上的端口。

targetPort String 对应界面上的容器端口

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 969

Page 980: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

表 9-3 elb.autocreate 字段数据结构说明

参数 参数类型 描述

name String 自动创建的负载均衡的名称。

取值范围:1-64个字符,中英文,数字,下划线,中划线。

type String 负载均衡实例网络类型,公网或者私网。

● public:公网型负载均衡

● inner:私网型负载均衡

bandwidth_name String 带宽的名称,默认值为:cce-bandwidth-******。1-64 字符,中文、英文字符、数字、下划线、中划线或点组成。

bandwidth_chargemode

String 带宽付费模式。

● bandwidth:按带宽计费

● traffic:按流量计费

bandwidth_size Integer 带宽大小,请根据具体region带宽支持范围设置,详情请参考申请弹性公网IP中表4 bandwidth字段说明中size字段。

bandwidth_sharetype String 带宽共享方式。

● PER:共享带宽

● WHOLE:共享带宽

eip_type String 弹性公网IP类型,请参考ELB支持的弹性公网IP类型,详情请参考申请弹性公网IP中表3 publicip字段说明type字段。

9.7 如何获取接口 URI 中参数

project_id

步骤1 登录CCE控制台,单击界面右上角的用户名,选择“我的凭证”。

步骤2 在“项目列表”页签,获取对应区域的项目ID。

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 970

Page 981: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

图 9-3 获取 project_id

----结束

cluster_id

步骤1 登录CCE控制台,在左侧导航栏中单击“资源管理 > 集群管理”。

步骤2 单击所创建集群的名称,进入集群详情页面,获取集群ID。

图 9-4 获取 cluster_id

----结束

node_id

步骤1 登录CCE控制台,在左侧导航栏中单击“资源管理 > 节点管理”。

步骤2 单击对应节点的名称,进入节点详情页面,获取节点ID。

图 9-5 获取 node_id

----结束

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 971

Page 982: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

job_id

步骤1 登录CCE控制台,在左侧导航栏中单击“资源管理 > 集群管理”或“资源管理 > 节点管理”。

步骤2 以集群管理为例,进入集群管理界面后,单击正在创建中的集群的集群状态,跳转到集群创建任务详情界面。

图 9-6 创建集群

步骤3 获取job_id。

以Chrome浏览器为例,F12打开浏览器Console,单击“Network”。在“Filter”栏里输入“jobs”,过滤出job列表,在左侧列表任意选择其中一条job,单击“Preview”,其中uid字段即为job的uid。

图 9-7 获取 job_id

----结束

9.8 API 授权项列表

模块 API API功能 授权项

集群管理

GET /api/v3/projects/{project_id}/clusters

获取指定项目下的集群

cce:cluster:list

POST /api/v3/projects/{project_id}/clusters

创建集群 cce:cluster:create

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 972

Page 983: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

GET /api/v3/projects/{project_id}/clusters/{cluster_id}

获取指定的集群 cce:cluster:get

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/clustercert

获取集群证书

PUT /api/v3/projects/{project_id}/clusters/{cluster_id}

更新指定的集群 cce:cluster:update

DELETE /api/v3/projects/{project_id}/clusters/{cluster_id}

删除集群 cce:cluster:delete

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes

获取集群下所有节点

cce:node:list

POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes

创建节点 cce:node:create

PUT /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/{node_id}

更新指定的节点 cce:node:update

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/{node_id}

获取指定的节点 cce:node:get

DELETE /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/{node_id}

删除节点 cce:node:delete

GET /api/v3/projects/{project_id}/jobs/{job_id}

查询作业进度 cce:job:get

GET /api/v3/projects/{project_id}/clusters/{cluster_id}/nodepools

获取集群下所有节点池

cce:nodepool:list

存储管理

POST /api/v1/namespaces/{namespace}/cloudpersistentvolumeclaims

创建PersistentVolumeClaim

cce:storage:create

POST /api/v1/cloudpersistentvolumes

创建PersistentVolume

DELETE /api/v1/namespaces/{namespace}/cloudpersistentvolumeclaims/{name}

删除PersistentVolumeClaim

cce:storage:delete

DELETE /api/v1/cloudpersistentvolumes/{name}

删除PersistentVolume

kubernetes

/api/* 操作kubernetes资源

cce:kubernetes:*

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 973

Page 984: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

原生接口

/apis/*

9.9 创建 VPC 和子网

背景信息

在创建集群之前,您需要创建虚拟私有云(VPC),为CCE服务提供一个安全、隔离的网络环境。

如果用户已有VPC,可重复使用,不需多次创建。

创建 VPC

步骤1 登录管理控制台,选择“网络 > 虚拟私有云 VPC”。

步骤2 在虚拟私有云控制台,单击右上角的“创建虚拟私有云”,按照提示完成创建。

步骤3 创建完成后返回虚拟私有云列表,单击创建的VPC名称,在详情页获取VPC的ID,后续5.1.1 创建集群时需要使用。

图 9-8 获取 VPC 的 ID

----结束

创建子网

步骤1 登录管理控制台,选择“网络 > 虚拟私有云 VPC”。

步骤2 在“虚拟私有云”列表页面,单击VPC的名称,在详情页中单击“子网”页签下的“创建子网”。

步骤3 创建完成后,单击子网的名称,获取子网的“网络ID”,后续5.1.1 创建集群时需要使用。

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 974

Page 985: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

图 9-9 获取子网的网络 ID

----结束

9.10 创建高速网络(可选)

背景信息

在创建裸金属集群之前,除创建VPC之外,还需要为集群创建一个高速网络,并获取高速网络的子网ID。

须知

请务必确保新创建的高速网络的子网网段不能与已有VPC的网段相冲突。

操作步骤

步骤1 登录管理控制台,在服务列表中选择“计算 > 裸金属服务器”。

步骤2 在“裸金属服务器”界面,单击“高速网络”页签后,单击“创建高速网络”。

请务必确保新创建的高速网络的子网网段不能与已有VPC的网段相冲突。

步骤3 参照4 快速入门,获取当前环境下VPC服务的Endpoint。

步骤4 执行以下命令,获取当前用户创建的所有高速网络的信息。

curl -i -k -H "Content-Type:application/json" -H "X-Auth-Token:${Token}" -X GEThttps://{Endpoint}/{URI}

● Token:普通用户的token。

● Endpoint:VPC服务的endpoint。

● URI:用于获取高速网络信息的URI,此处为v2.0/networks?provider:network_type=geneve

步骤5 在返回的响应体中找到步骤2中创建的高速网络及该高速网络的subnets字段,该字段的值即为高速网络的子网ID。

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 975

Page 986: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

假设创建的高速网络名称为highway-ec86,请记录其对应的子网ID(红色部分)。后续5.1.1 创建集群时如果集群的类型为裸金属集群,需要使用该子网ID。

{ "networks": [ { "id": "3cfe3cf3-4354-4924-9f4b-818e0d307833", "name": "highway-ec86", "status": "ACTIVE", "shared": false, "subnets": [ "86208959-1b1e-46dc-b7de-b815d7a323c2" ], "availability_zone_hints": [], "availability_zones": [ "az1.dc1", "kvmxen.dc1", "ceshishouqing" ], "admin_state_up": false, "tenant_id": "aef929d2de9249d6ae55466a72b6be25", "provider:network_type": "geneve", "router:external": false, "port_security_enabled": true, "dns_domain": "southchina.compute.internal." }, { "id": "f17e2a39-a7e3-4438-a866-e8b362df5fcf", "name": "highway-0405", "status": "ACTIVE", "shared": false, "subnets": [ "c0c564fd-f25a-466a-827c-ee4d3aa51a6a" ], "availability_zone_hints": [], "availability_zones": [ "az1.dc1", "kvmxen.dc1", "ceshishouqing" ], "admin_state_up": false, "tenant_id": "aef929d2de9249d6ae55466a72b6be25", "provider:network_type": "geneve", "router:external": false, "port_security_enabled": true, "dns_domain": "southchina.compute.internal." } ]}

----结束

9.11 创建密钥对

背景信息

在创建集群之前,您需要创建密钥对,用于登录node节点时的身份验证。

如果用户已有密钥对,可重复使用,不需多次创建。

操作步骤

步骤1 登录管理控制台,选择“计算 > 弹性云服务器”。

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 976

Page 987: API · 2020-01-23 · 云容器引擎 api参考 文档版本 01 发布日期 2020-01-22 华为技术有限公司

步骤2 在左侧导航树中,选择“密钥对”。

步骤3 单击“创建密钥对”。

图 9-10 创建密钥对

步骤4 输入密钥对名称后,单击“确定”。

名称只能由英文字母,数字,下划线,中划线组成,且长度小于等于64个字符。

步骤5 在弹出的对话框中,单击“确定”。

系统生成密钥文件,自动保存在系统默认目录下。

----结束

云容器引擎API 参考 9 附录

文档版本 01 (2020-03-12) 版权所有 © 华为技术有限公司 977