更新指定的集群 - UpdateCluster
功能介绍
该API用于更新指定的集群。
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
- 如果使用身份策略授权,需具备如下身份策略权限。
URI
PUT /api/v3/projects/{project_id}/clusters/{cluster_id}
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| project_id | 是 | String | 参数解释: 项目ID,获取方式请参见如何获取接口URI中参数。 约束限制: 不涉及 取值范围: 账号的项目ID 默认取值: 不涉及 |
| cluster_id | 是 | String | 参数解释: 集群ID,获取方式请参见如何获取接口URI中参数。 约束限制: 不涉及 取值范围: 集群ID 默认取值: 不涉及 |
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| Content-Type | 是 | String | 参数解释: 消息体的类型(格式),默认为application/json,有其他取值时会在具体接口中专门说明。 约束限制: GET方法不做校验 取值范围: 不涉及 默认取值: 不涉及 |
| X-Auth-Token | 是 | String | 参数解释: 调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| spec | 是 | ClusterInformationSpec object | 参数解释: 具体集群参数。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| metadata | 否 | ClusterMetadataForUpdate object | 参数解释: 集群基本信息,包含与名称相关的字段。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| agencyName | 否 | String | 参数解释: 指定集群使用的委托。该委托用于生成集群中组件使用的临时访问凭证,在集群中自动创建其他相关云服务的资源时会使用该委托权限。当不传或为空时,集群将自动选择使用CCE的系统委托cce_admin_trust或cce_cluster_agency。 说明: 关于CCE系统委托的说明详情参见系统委托说明 约束限制: 仅1.27及以上版本集群支持该参数 取值范围: 不涉及 默认取值: 空 |
| description | 否 | String | 参数解释: 集群的描述信息。 约束限制: 仅运行和扩容状态(Available、ScalingUp、ScalingDown)的集群允许修改。 取值范围: 字符取值范围[0,200]。不包含~$%^&*<>[]{}()'"#\等特殊字符。 默认取值: 无 |
| customSan | 否 | Array of strings | 参数解释: 集群的API Server服务端证书中的自定义SAN(Subject Alternative Name)字段,遵从SSL标准X509定义的格式规范。 约束限制: 不允许出现同名重复。 取值范围: 格式符合IP和域名格式。 默认取值: 不涉及 示例: SAN 1: DNS Name=example.com SAN 2: DNS Name=www.example.com SAN 3: DNS Name=example.net SAN 4: IP Address=93.184.216.34 |
| containerNetwork | 否 | ContainerNetworkUpdate object | 参数解释: 容器网络参数,包含容器网段的信息。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| eniNetwork | 否 | EniNetworkUpdate object | 参数解释: 云原生网络2.0网络配置,包含CCE Turbo集群的容器子网信息。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| deletionProtection | 否 | Boolean | 参数解释: 集群删除保护,如果开启后用户将无法删除该集群。 约束限制: 不涉及 取值范围: 默认取值: 默认false |
| hostNetwork | 否 | hostNetwork object | 参数解释: 节点网络参数,包含了Node节点默认安群组设置。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| secretConfig | 否 | SecretConfigUpdate object | 参数解释: secret禁用配置,控制是否在集群中禁用以Secret形式静态存储的临时凭据。 约束限制: 支持的集群版本如下: 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| cidrs | 否 | Array of ContainerCIDR objects | 参数解释: 容器网络网段列表。1.21及新版本集群,当集群网络类型为vpc-router时,支持增量添加容器网段,最多配置20个。 约束限制: 此参数在集群更新后不可更改,请谨慎选择。(已废弃,建议使用containercidrs字段替代) 取值范围: 不涉及 默认取值: 不涉及 |
| containercidrs | 否 | Array of strings | 参数解释: 容器网络网段列表。当集群网络类型为vpc-router时,支持添加或删除容器网段。支持的集群版本如下: 支持修改集群容器网段的顺序,顺序在前的容器网段优先被使用。 约束限制: 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| cidr | 是 | String | 参数解释: 容器网络网段,建议使用网段10.0.0.0/12~19,172.16.0.0/16~19,192.168.0.0/16~19。 约束限制: 如存在网段冲突,将会报错。 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| subnets | 否 | Array of NetworkSubnet objects | 参数解释: IPv4子网ID列表。1.19.10及以上版本的CCE Turbo集群支持多容器子网,同时支持增量更新容器子网列表。 约束限制: 请求体中需包含所有已经存在的subnet。 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| subnetID | 是 | String | 参数解释: 用于创建容器网卡的子网的IPv4子网ID。 约束限制: 暂不支持IPv6 取值范围: 不涉及 默认取值: 不涉及 获取方法如下: 链接请参见查询子网列表。 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| SecurityGroup | 否 | String | 参数解释: 集群默认Node节点安全组需要放通部分端口来保证正常通信,详细设置请参考集群安全组规则配置。 约束限制: 修改后的安全组只作用于新创建的节点和新纳管的节点,存量节点的安全组需手动修改。 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| disableDefaultAddonCredSecret | 否 | Boolean | 参数解释: 是否在集群中禁用默认插件凭证(paas.elb、paas.aksk secret)。该Secret的data内容是临时AK/SK数据,部分插件在未配置自定义委托时会使用它作为IAM凭证访问其他云服务。 更多信息请参见禁用集群中静态存储的临时凭据说明。 约束限制: 仅当集群中所有需要访问云服务的插件均已配置自定义委托后,才能禁用该Secret。 取值范围: 默认取值: 不涉及,未指定则不更新此参数 |
| disableNodeAgencyCredSecret | 否 | Boolean | 参数解释: 是否在集群中禁用节点凭证(node-agency-cred secret)。该Secret的data内容是临时AK/SK数据,节点上安装的系统组件默认使用该凭证。 更多信息请参见禁用集群中静态存储的临时凭据说明。 约束限制: 需确保已为每个节点/节点池配置委托,且委托至少具备cce:node:get、cce::assumeAgencyForPodIdentity权限,否则禁用该Secret会导致节点安装、运行异常。 取值范围: 默认取值: false |
| disableDefaultImagePullSecret | 否 | Boolean | 参数解释: 是否在集群中禁用默认镜像访问凭证(default-secret secret)。该Secret的data内容是SWR临时登录指令,用于SWR的私有镜像拉取。 更多信息请参见禁用集群中静态存储的临时凭据说明。 约束限制: 需确保集群中的工作负载不使用default-secret作为镜像拉取凭证(配置了镜像免密下载或者使用自定义镜像拉取凭证),否则禁用该Secret后可能会导致镜像拉取失败。 取值范围: 默认取值: false |
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| kind | String | 参数解释: API类型。 取值范围: |
| apiVersion | String | 参数解释: API版本。 取值范围: |
| metadata | ClusterMetadata object | 参数解释: 集群的基本信息,为集合类的元素类型,包含一组由不同名称定义的属性。 |
| spec | ClusterSpec object | 参数解释: spec是集合类的元素类型,您对需要管理的集群对象进行详细描述的主体部分都在spec中给出。CCE通过spec的描述来创建或更新对象。 |
| status | ClusterStatus object | 参数解释: 不涉及集合类的元素类型,用于记录对象在系统中的当前状态信息,包含了集群状态和本次创建集群作业的jobID |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| name | String | 参数解释: 集群名称。 取值范围: 以小写字母开头,由小写字母、数字、中划线(-)组成,长度范围4-128位,且不能以中划线(-)结尾。 |
| uid | String | 参数解释: 集群ID,资源唯一标识。 取值范围: 不涉及 |
| alias | String | 参数解释: 集群显示名,用于在 CCE 界面显示,该名称创建后可修改。显示名和其他集群的名称、显示名不可以重复。 取值范围: 以中文或英文字符开头,由数字、中文、英文字符、中划线(-)组成,长度范围 4-128位,且不能以中划线(-)开头和结尾。 |
| annotations | Map<String,String> | 参数解释: 集群注解,由key/value组成: "annotations": {
"key1" : "value1",
"key2" : "value2"
} 取值范围: 不涉及 |
| labels | Map<String,String> | 参数解释: 集群标签,key/value对格式。 取值范围: 不涉及 |
| creationTimestamp | String | 参数解释: 集群创建时间。 取值范围: 不涉及 |
| updateTimestamp | String | 参数解释: 集群更新时间。 取值范围: 不涉及 |
| timezone | String | 参数解释: 集群时区。IANA Time Zone Database中收录的时区名称, 例如:"Asia/Shanghai"。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| category | String | 参数解释: 集群类别。 取值范围: CCE集群支持虚拟机与裸金属服务器混合、GPU、NPU等异构节点的混合部署,基于高性能网络模型提供全方位、多场景、安全稳定的容器运行环境。 全面基于云原生基础设施构建的云原生2.0的容器引擎服务,具备软硬协同、网络无损、安全可靠、调度智能的优势,为用户提供一站式、高性价比的全新容器服务体验。 |
| agencyName | String | 参数解释: 指定集群使用的委托。该委托用于生成集群中组件使用的临时访问凭证,在集群中自动创建其他相关云服务的资源时会使用该委托权限。当不传或为空时,集群将自动选择使用CCE的系统委托cce_admin_trust或cce_cluster_agency。 说明: 关于CCE系统委托的说明详情参见系统委托说明 取值范围: 不涉及 |
| type | String | 参数解释: 集群Master节点架构 取值范围: |
| flavor | String | 参数解释: 集群规格,当集群为v1.15及以上版本时支持创建后变更,详情请参见变更集群规格。请按实际业务需求进行选择 取值范围: 专属云特殊规格如下: |
| version | String | 参数解释: 集群版本,与Kubernetes社区基线版本保持一致,建议选择最新商用版本。 说明: 关于Kubernetes版本策略,请参见Kubernetes版本策略 在CCE控制台支持创建三种最新版本的集群。可登录CCE控制台创建集群,在“版本”处获取到集群版本。 其它集群版本,当前仍可通过api创建,但后续会逐渐下线,具体下线策略请关注CCE官方公告。 取值范围: 不涉及 |
| platformVersion | String | 参数解释: CCE集群平台版本号,表示集群版本(version)下的内部版本。用于跟踪某一集群版本内的迭代,集群版本内唯一,跨集群版本重新计数。 取值范围: platformVersion格式为:cce.X.Y |
| legacyVersion | String | 参数解释: CCE集群旧版本(已废弃),无实际功能,仅用于集群version与platformVersion组合展示,该版本号全局内唯一。如集群version为va.b, platformVersion为cce.X.Y,则legacyVersion值为va.b.X-rY。 取值范围: 不涉及 |
| description | String | 参数解释: 集群描述,对于集群使用目的的描述,可根据实际情况自定义,默认为空。集群创建成功后可通过接口更新指定的集群来做出修改,也可在CCE控制台中对应集群的“集群详情”下的“描述”处进行修改。 取值范围: 不涉及 |
| customSan | Array of strings | 参数解释: 集群的API Server服务端证书中的自定义SAN(Subject Alternative Name)字段,遵从SSL标准X509定义的格式规范。 取值范围: 格式符合IP和域名格式。 |
| ipv6enable | Boolean | 参数解释: 集群是否使用IPv6模式,1.15版本及以上支持。 取值范围: |
| hostNetwork | HostNetwork object | 参数解释: 节点网络参数,包含了虚拟私有云VPC和子网的ID信息,而VPC是集群内节点之间的通信依赖,所以是必选的参数集。 |
| containerNetwork | ContainerNetwork object | 参数解释: 容器网络参数,包含了容器网络类型和容器网段的信息。 |
| eniNetwork | EniNetwork object | 参数解释: 云原生网络2.0网络配置,创建CCE Turbo集群时指定。 |
| serviceNetwork | ServiceNetwork object | 参数解释: 服务网段参数,包含IPv4 CIDR。 |
| publicAccess | PublicAccess object | 参数解释: 集群API访问控制。 |
| authentication | Authentication object | 参数解释: 集群认证方式相关配置。 |
| billingMode | Integer | 参数解释: 集群的计费方式。 取值范围: |
| masters | Array of MasterSpec objects | 参数解释: 集群控制节点的高级配置,支持指定控制节点的可用区。 |
| kubernetesSvcIpRange | String | 参数解释: 服务网段参数,kubernetes clusterIP取值范围,1.11.7版本及以上支持。创建集群时如若未传参,默认为"10.247.0.0/16"。该参数废弃中,推荐使用新字段serviceNetwork,包含IPv4服务网段。 取值范围: 不涉及 |
| clusterTags | Array of ResourceTag objects | 参数解释: 集群资源标签。 |
| kubeProxyMode | String | 参数解释: 服务转发模式。 取值范围:
|
| az | String | 参数解释: 可用区(废弃中)。 CCE支持的可用区请参考地区和终端节点。 |
| extendParam | ClusterExtendParam object | 参数解释: 集群扩展字段,可配置多可用区集群、专属CCE集群,以及将集群创建在特定的企业项目下等。 |
| supportIstio | Boolean | 参数解释: 支持Istio。 取值范围: |
| enableDistMgt | Boolean | 参数解释: 集群开启对分布式云支持。 取值范围: |
| deletionProtection | Boolean | 参数解释: 集群删除保护,如果开启后用户将无法删除该集群。 取值范围: |
| configurationsOverride | Array of PackageConfiguration objects | 参数解释: 覆盖集群默认组件配置。 当前支持的可配置组件及其参数详见配置管理。 |
| clusterOps | ClusterOps object | 参数解释: 集群运维相关配置。 |
| encryptionConfig | EncryptionConfig object | 参数解释: secret资源落盘加密配置,当前仅支持配置一种加密方式。默认使用cce托管密钥(用户侧不感知该密钥)进行加密。 取值范围: 不涉及 |
| secretConfig | SecretConfig object | 参数解释: secret禁用配置,控制是否在集群中禁用以Secret形式静态存储的临时凭据。 取值范围: 不涉及 |
| certificateAuthority | CertificateAuthority object | 参数解释: CCE集群的证书信息 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| vpc | String | 参数解释: 用于创建节点的VPC的ID。 取值范围: 不涉及 |
| subnet | String | 参数解释: 用于创建节点的子网的网络ID。 取值范围: 不涉及 |
| SecurityGroup | String | 参数解释: 集群默认的Node节点安全组ID。 取值范围: 不涉及 |
| controlPlaneSecurityGroup | String | 参数解释: 集群控制面节点安全组ID。 取值范围: 不涉及 |
| autoGenerateSecurityGroupHardeningConfig | 参数解释: 自动创建安全组时的安全加固策略。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| portsToDisable | Array of strings | 参数解释: 自动创建安全组时可选择不开放node节点相关端口,支持单端口和端口段两种形式。示例如下: "portsToDisable": ["22", "4090-4099"] 取值范围: 端口号仅支持整数,范围[1-65535] |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| mode | String | 参数解释: 容器网络类型。 取值范围: |
| cidr | String | 参数解释: 容器网络网段,建议使用网段10.0.0.0/12~19,172.16.0.0/16~19,192.168.0.0/16~19,如存在网段冲突,将会报错。 取值范围: 满足IPv4 CIDR格式 |
| cidrs | Array of ContainerCIDR objects | 参数解释: 容器网络网段列表。1.21及新版本集群使用cidrs字段,当集群网络类型为vpc-router类型时,支持多个容器网段,最多配置20个;1.21之前版本若使用cidrs字段,则取值cidrs数组中的第一个cidr元素作为容器网络网段地址。 |
| enableContainerCIDRsReservation | Boolean | 参数解释: VPC容器网段预留。在VPC的默认路由表中添加容器网段路由,避免创建与容器网段冲突的子网。支持的集群版本如下: 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| cidr | String | 参数解释: 容器网络网段,建议使用网段10.0.0.0/12~19,172.16.0.0/16~19,192.168.0.0/16~19。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| eniSubnetId | String | 参数解释: ENI所在子网的IPv4子网ID。 取值范围: 不涉及 |
| eniSubnetCIDR | String | 参数解释: ENI子网CIDR。 取值范围: 不涉及 |
| subnets | Array of NetworkSubnet objects | 参数解释: IPv4子网ID列表。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| IPv4CIDR | String | 参数解释: kubernetes clusterIP IPv4 CIDR取值范围。 取值范围: 不涉及 |
| IPv6CIDR | String | 参数解释: kubernetes clusterIP IPv6 CIDR取值范围。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| cidrs | Array of strings | 参数解释: 允许访问集群API的白名单网段列表,建议对VPC网段、容器网段放通。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| mode | String | 参数解释: 集群认证模式。 取值范围: |
| authenticatingProxy | AuthenticatingProxy object | 参数解释: authenticatingProxy模式相关配置。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| ca | String | 参数解释: authenticating_proxy模式配置的x509格式CA证书(base64编码)。 取值范围: 最大长度:1M。 |
| cert | String | 参数解释: authenticating_proxy模式配置的x509格式CA证书签发的客户端证书,用于kube-apiserver到扩展apiserver的认证。(base64编码)。 取值范围: 最大长度:1M。 |
| privateKey | String | 参数解释: authenticating_proxy模式配置的x509格式CA证书签发的客户端证书时对应的私钥,用于kube-apiserver到扩展apiserver的认证。Kubernetes集群使用的私钥尚不支持密码加密,请使用未加密的私钥。(base64编码)。 取值范围: 最大长度:1M。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| availabilityZone | String | 参数解释: 控制节点所在的可用区,需要指定可用区(AZ)的名称。 CCE支持的可用区请参考地区和终端节点 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| clusterAZ | String | 参数解释: 集群控制节点可用区配置。 CCE支持的可用区请参考地区和终端节点。 取值范围: |
| dssMasterVolumes | String | 参数解释: 用于指定控制节点的系统盘和数据盘使用专属分布式存储,未指定或者值为空时,默认使用EVS云硬盘。 取值范围: 不涉及 |
| enterpriseProjectId | String | 参数解释: 集群所属的企业项目ID。 取值范围: 不涉及 |
| kubeProxyMode | String | 参数解释: 服务转发模式,支持以下两种实现: 取值范围:
|
| clusterExternalIP | String | 参数解释: 集群控制节点弹性公网IP,绑定后可以通过该弹性公网IP访问集群管控面API。 取值范围: 不涉及 |
| alpha.cce/fixPoolMask | String | 参数解释: 容器网络固定IP池掩码位数,该参数决定节点可分配容器IP数量,与创建节点时设置的maxPods参数共同决定节点最多可以创建多少个Pod, 具体请参见节点可创建的最大Pod数量说明。 取值范围: 整数字符串取值范围: 24 ~ 28 |
| decMasterFlavor | String | 参数解释: 专属CCE集群指定可控制节点的规格。 取值范围: 不涉及 |
| dockerUmaskMode | String | 参数解释: 集群默认Docker的UmaskMode配置。 取值范围: |
| kubernetes.io/cpuManagerPolicy | String | 参数解释: 集群CPU管理策略。 取值范围: |
| orderID | String | 参数解释: 订单ID。 取值范围: 不涉及 |
| periodType | String | 参数解释: 订购周期单位。 取值范围: |
| periodNum | Integer | 参数解释: 订购周期数 取值范围: |
| isAutoRenew | String | 参数解释: 是否自动续订 取值范围: |
| isAutoPay | String | 参数解释: 是否自动扣款。 取值范围: |
| upgradefrom | String | 参数解释: 记录集群通过何种升级方式升级到当前版本。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| name | String | 参数解释: 组件名称。 取值范围: 不涉及 |
| configurations | Array of ConfigurationItem objects | 参数解释: 组件配置项。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| name | String | 参数解释: 组件配置参数名称。 当前集群支持的可配置组件及其参数详见修改CCE集群配置,当前节点池支持的可配置组件及其参数详见修改节点池配置。 取值范围: 不涉及 |
| value | Object | 参数解释: 组件配置参数值。 当前集群支持的可配置组件及其参数详见修改CCE集群配置,当前节点池支持的可配置组件及其参数详见修改节点池配置。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| alarm | AlarmInfo object | 参数解释: 告警助手参数配置。基于AOM服务的告警能力实现,提供集群内的告警快速检索、告警快速配置的能力,告警中心的指标类告警规则依赖云原生监控插件上报数据到AOM实例。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| topics | Array of strings | 参数解释: 联系组列表。填写SMN主题名称,通过配置告警联系组,分组管理订阅终端,接收告警信息。 |
| alarmRuleTemplateId | String | 参数解释: 开启告警助手时传入告警模板ID。默认采用容器场景下的告警规则模板。 取值范围: 不涉及 |
| promInstanceID | String | 参数解释: 开启告警助手时传入AOM普罗实例的id。若未安装普罗插件或者未对接AOM实例,此参数无需指定,告警中心将不会创建指标类告警规则。 取值范围: 不涉及 |
| promEnterpriseProjectID | String | 参数解释: 开启告警助手时传入AOM普罗实例的企业项目id。若未安装普罗插件或者未对接AOM实例,此参数无需指定,告警中心将不会创建指标类告警规则。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| disableDefaultAddonCredSecret | Boolean | 参数解释: 是否在集群中禁用默认插件凭证(paas.elb、paas.aksk secret)。该Secret的data内容是临时AK/SK数据,部分插件在未配置自定义委托时会使用它作为IAM凭证访问其他云服务。 更多信息请参见禁用集群中静态存储的临时凭据说明。 取值范围: |
| disableNodeAgencyCredSecret | Boolean | 参数解释: 是否在集群中禁用节点凭证(node-agency-cred secret)。该Secret的data内容是临时AK/SK数据,节点上安装的系统组件默认使用该凭证。 更多信息请参见禁用集群中静态存储的临时凭据说明。 取值范围: |
| disableDefaultImagePullSecret | Boolean | 参数解释: 是否在集群中禁用默认镜像访问凭证(default-secret secret)。该Secret的data内容是SWR临时登录指令,用于SWR的私有镜像拉取。 更多信息请参见禁用集群中静态存储的临时凭据说明。 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| phase | String | 参数解释: 集群状态。 取值范围: |
| jobID | String | 参数解释: 任务ID,集群当前状态关联的任务ID。当前支持: 取值范围: 不涉及 说明: 任务信息具有一定时效性,仅用于短期跟踪任务进度,请勿用于集群状态判断等额外场景。 |
| reason | String | 参数解释: 集群变为当前状态的原因,在集群在非“Available”状态下时,会返回此参数。 取值范围: 不涉及 |
| message | String | 参数解释: 集群变为当前状态的原因的详细信息,在集群在非“Available”状态下时,会返回此参数。 取值范围: 不涉及 |
| endpoints | Array of ClusterEndpoints objects | 参数解释: 集群中 kube-apiserver 的访问地址。 |
| isLocked | Boolean | 参数解释: CBC资源锁定 取值范围: |
| lockScene | String | 参数解释: CBC资源锁定场景 取值范围: 不涉及 |
| lockSource | String | 参数解释: 锁定资源 取值范围: 不涉及 |
| lockSourceId | String | 参数解释: 锁定的资源ID 取值范围: 不涉及 |
| deleteOption | Object | 参数解释: 删除配置状态(仅删除请求响应包含) 取值范围: 不涉及 |
| deleteStatus | Object | 参数解释: 删除状态信息(仅删除请求响应包含) 取值范围: 不涉及 |
| conditions | Array of ClusterCondition objects | 参数解释: 集群当前详细状态列表,详情参见Condition类型定义。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| url | String | 参数解释: 集群中 kube-apiserver 的访问地址。 取值范围: 不涉及 |
| type | String | 参数解释: 集群访问地址的类型。 取值范围: |
请求示例
-
{ "spec" : { "description" : "new description" } } -
{ "spec" : { "customSan" : [ "192.168.1.0", "example.com" ] } } -
{ "spec" : { "description" : "new description", "customSan" : [ "192.168.1.0", "example.com" ] } } -
添加集群容器网段(v1.21版本以上VPC网络模型的集群适用)
{ "spec" : { "containerNetwork" : { "cidrs" : [ { "cidr" : "10.10.0.0/16" }, { "cidr" : "10.11.0.0/16" } ] } } } -
/api/v3/projects/{project_id}/clusters/{cluster_id} { "spec" : { "hostNetwork" : { "SecurityGroup" : "6ee29825-8f49-4796-b33a-fc76f84a59ae" } } }
响应示例
状态码:200
表示更新指定集群成功。
{
"kind" : "Cluster",
"apiVersion" : "v3",
"metadata" : {
"alias" : "mycluster",
"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",
"customSan" : [ "192.168.1.0", "example.com" ],
"hostNetwork" : {
"vpc" : "4d1ecb2c-229a-11e8-9c75-0255ac100ceb",
"subnet" : "4d1ecb2c-229a-11e8-9c75-0255ac100ceb",
"SecurityGroup" : "6ee29825-8f49-4796-b33a-fc76f84a59ae"
},
"containerNetwork" : {
"mode" : "overlay_l2",
"cidr" : "172.17.0.0/16"
},
"authentication" : {
"mode" : "x509",
"authenticatingProxy" : { }
},
"billingMode" : 0
},
"status" : {
"phase" : "Available",
"endpoints" : [ {
"url" : "https://192.168.0.11:5443",
"type" : "Internal"
} ]
}
} SDK代码示例
SDK代码示例如下。
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cce.v3.region.CceRegion; import com.huaweicloud.sdk.cce.v3.*; import com.huaweicloud.sdk.cce.v3.model.*; public class UpdateClusterSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); CceClient client = CceClient.newBuilder() .withCredential(auth) .withRegion(CceRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withDescription("new description"); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cce.v3.region.CceRegion; import com.huaweicloud.sdk.cce.v3.*; import com.huaweicloud.sdk.cce.v3.model.*; import java.util.List; import java.util.ArrayList; public class UpdateClusterSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); CceClient client = CceClient.newBuilder() .withCredential(auth) .withRegion(CceRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); List<String> listSpecCustomSan = new ArrayList<>(); listSpecCustomSan.add("192.168.1.0"); listSpecCustomSan.add("example.com"); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withCustomSan(listSpecCustomSan); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cce.v3.region.CceRegion; import com.huaweicloud.sdk.cce.v3.*; import com.huaweicloud.sdk.cce.v3.model.*; import java.util.List; import java.util.ArrayList; public class UpdateClusterSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); CceClient client = CceClient.newBuilder() .withCredential(auth) .withRegion(CceRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); List<String> listSpecCustomSan = new ArrayList<>(); listSpecCustomSan.add("192.168.1.0"); listSpecCustomSan.add("example.com"); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withDescription("new description") .withCustomSan(listSpecCustomSan); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
-
添加集群容器网段(v1.21版本以上VPC网络模型的集群适用)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cce.v3.region.CceRegion; import com.huaweicloud.sdk.cce.v3.*; import com.huaweicloud.sdk.cce.v3.model.*; import java.util.List; import java.util.ArrayList; public class UpdateClusterSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); CceClient client = CceClient.newBuilder() .withCredential(auth) .withRegion(CceRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); List<ContainerCIDR> listContainerNetworkCidrs = new ArrayList<>(); listContainerNetworkCidrs.add( new ContainerCIDR() .withCidr("10.10.0.0/16") ); listContainerNetworkCidrs.add( new ContainerCIDR() .withCidr("10.11.0.0/16") ); ContainerNetworkUpdate containerNetworkSpec = new ContainerNetworkUpdate(); containerNetworkSpec.withCidrs(listContainerNetworkCidrs); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withContainerNetwork(containerNetworkSpec); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cce.v3.region.CceRegion; import com.huaweicloud.sdk.cce.v3.*; import com.huaweicloud.sdk.cce.v3.model.*; public class UpdateClusterSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); CceClient client = CceClient.newBuilder() .withCredential(auth) .withRegion(CceRegion.valueOf("<YOUR REGION>")) .build(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); ClusterInformationSpecHostNetwork hostNetworkSpec = new ClusterInformationSpecHostNetwork(); hostNetworkSpec.withSecurityGroup("6ee29825-8f49-4796-b33a-fc76f84a59ae"); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withHostNetwork(hostNetworkSpec); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcce.v3.region.cce_region import CceRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcce.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = CceClient.new_builder() \ .with_credentials(credentials) \ .with_region(CceRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterRequest() request.cluster_id = "{cluster_id}" specbody = ClusterInformationSpec( description="new description" ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcce.v3.region.cce_region import CceRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcce.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = CceClient.new_builder() \ .with_credentials(credentials) \ .with_region(CceRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterRequest() request.cluster_id = "{cluster_id}" listCustomSanSpec = [ "192.168.1.0", "example.com" ] specbody = ClusterInformationSpec( custom_san=listCustomSanSpec ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcce.v3.region.cce_region import CceRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcce.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = CceClient.new_builder() \ .with_credentials(credentials) \ .with_region(CceRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterRequest() request.cluster_id = "{cluster_id}" listCustomSanSpec = [ "192.168.1.0", "example.com" ] specbody = ClusterInformationSpec( description="new description", custom_san=listCustomSanSpec ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
添加集群容器网段(v1.21版本以上VPC网络模型的集群适用)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcce.v3.region.cce_region import CceRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcce.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = CceClient.new_builder() \ .with_credentials(credentials) \ .with_region(CceRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterRequest() request.cluster_id = "{cluster_id}" listCidrsContainerNetwork = [ ContainerCIDR( cidr="10.10.0.0/16" ), ContainerCIDR( cidr="10.11.0.0/16" ) ] containerNetworkSpec = ContainerNetworkUpdate( cidrs=listCidrsContainerNetwork ) specbody = ClusterInformationSpec( container_network=containerNetworkSpec ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcce.v3.region.cce_region import CceRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcce.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = CceClient.new_builder() \ .with_credentials(credentials) \ .with_region(CceRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateClusterRequest() request.cluster_id = "{cluster_id}" hostNetworkSpec = ClusterInformationSpecHostNetwork( security_group="6ee29825-8f49-4796-b33a-fc76f84a59ae" ) specbody = ClusterInformationSpec( host_network=hostNetworkSpec ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := cce.NewCceClient(hcClient) request := &model.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" descriptionSpec:= "new description" specbody := &model.ClusterInformationSpec{ Description: &descriptionSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := cce.NewCceClient(hcClient) request := &model.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" var listCustomSanSpec = []string{ "192.168.1.0", "example.com", } specbody := &model.ClusterInformationSpec{ CustomSan: &listCustomSanSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := cce.NewCceClient(hcClient) request := &model.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" var listCustomSanSpec = []string{ "192.168.1.0", "example.com", } descriptionSpec:= "new description" specbody := &model.ClusterInformationSpec{ Description: &descriptionSpec, CustomSan: &listCustomSanSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
添加集群容器网段(v1.21版本以上VPC网络模型的集群适用)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := cce.NewCceClient(hcClient) request := &model.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" var listCidrsContainerNetwork = []model.ContainerCidr{ { Cidr: "10.10.0.0/16", }, { Cidr: "10.11.0.0/16", }, } containerNetworkSpec := &model.ContainerNetworkUpdate{ Cidrs: &listCidrsContainerNetwork, } specbody := &model.ClusterInformationSpec{ ContainerNetwork: containerNetworkSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := cce.NewCceClient(hcClient) request := &model.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" securityGroupHostNetwork:= "6ee29825-8f49-4796-b33a-fc76f84a59ae" hostNetworkSpec := &model.ClusterInformationSpecHostNetwork{ SecurityGroup: &securityGroupHostNetwork, } specbody := &model.ClusterInformationSpec{ HostNetwork: hostNetworkSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
| 状态码 | 描述 |
|---|---|
| 200 | 表示更新指定集群成功。 |
错误码
请参见错误码。