集群升级 - UpgradeCluster
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
- 如果使用身份策略授权,需具备如下身份策略权限。
URI
POST /api/v3/projects/{project_id}/clusters/{cluster_id}/operation/upgrade
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| project_id | 是 | String | 参数解释: 项目ID,获取方式请参见如何获取接口URI中参数。 约束限制: 不涉及 取值范围: 账号的项目ID 默认取值: 不涉及 |
| cluster_id | 是 | String | 参数解释: 集群ID,获取方式请参见如何获取接口URI中参数。 约束限制: 不涉及 取值范围: 集群ID 默认取值: 不涉及 |
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| metadata | 是 | 参数解释: 集群升级元数据信息。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 | |
| spec | 是 | UpgradeSpec object | 参数解释: 升级配置信息,CCE通过spec的描述来升级集群 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| apiVersion | 是 | String | 参数解释: API版本,固定值"v3",该值不可修改。 约束限制: 该值不可修改 取值范围: 默认取值: v3 |
| kind | 是 | String | 参数解释: API类型,固定值"UpgradeTask",该值不可修改。 约束限制: 该值不可修改 取值范围: 默认取值: UpgradeTask |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| clusterUpgradeAction | 否 | ClusterUpgradeAction object | 参数解释: 集群升级详细配置信息。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| addons | 否 | Array of UpgradeAddonConfig objects | 参数解释: 插件配置列表,CCE会在集群升级过程中按照配置对插件进行升级 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| nodeOrder | 否 | Map<String,Array<NodePriority>> | 参数解释: 节点池内节点升级顺序配置。key表示节点池ID,默认节点池取值为"DefaultPool" 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| nodePoolOrder | 否 | Map<String,Integer> | 参数解释: 节点池升级顺序配置,key/value对格式。key表示节点池ID,默认节点池取值为"DefaultPool",value表示对应节点池的优先级,默认值为0,优先级最低,数值越大优先级越高 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| strategy | 是 | UpgradeStrategy object | 参数解释: 集群升级策略。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| targetVersion | 是 | String | 参数解释: 升级的目标集群版本,例如"v1.23" 约束限制: 只能升级到高版本,不允许填写等于或低于当前集群版本的值 取值范围: CCE支持的集群版本 默认取值: 不涉及 |
| isOnlyUpgrade | 否 | Boolean | 参数解释: 是否在集群升级流程中跳过升级前检查。 约束限制: 不涉及 取值范围: 默认取值: false |
| agencyName | 否 | String | 参数解释: 指定集群使用的委托。该委托用于生成集群中组件使用的临时访问凭证,在集群中自动创建其他相关云服务的资源时会使用该委托权限。 当不传时,集群将优先继承原有配置,若原先未配置,则自动选择使用CCE的默认委托CCEAutoClusterAgency;当传空时,自动选择使用CCE的默认委托CCEAutoClusterAgency。 说明: 关于CCE系统委托的说明详情参见系统委托说明 约束限制: 仅v1.28.15-r90、v1.29.15-r50、v1.30.14-r50、v1.31.14-r10、v1.32.9-r10、v1.33.7-r10、v1.34.3-r0及以上版本集群支持该参数 取值范围: 不涉及 默认取值: 空 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| addonTemplateName | 是 | String | 参数解释: CCE插件名称 约束限制: 不涉及 取值范围: 集群中已安装的插件名称。集群中已安装插件详情见获取AddonInstance列表 默认取值: 不涉及 |
| operation | 是 | String | 参数解释: 升级插件的执行动作 约束限制: 不涉及 取值范围: 默认取值: 不涉及 |
| version | 是 | String | 参数解释: 目标插件版本号 约束限制: 目标插件版本必须与目标集群版本配套。集群版本配套关系见查询AddonTemplates列表 取值范围: 不涉及 默认取值: 不涉及 |
| values | 否 | Map<String,Object> | 参数解释: 插件参数列表,Key:Value格式。 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| nodeSelector | 是 | NodeSelector object | 参数解释: 节点标签选择器,选择一批节点 约束限制: 节点上存在的标签 取值范围: 不涉及 默认取值: 不涉及 |
| priority | 是 | Integer | 参数解释: 该批次节点的优先级,数值越大优先级越高 约束限制: 不涉及 取值范围: 非负整数 默认取值: 0 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| key | 是 | String | 参数解释: 标签键 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| value | 否 | Array of strings | 参数解释: 标签值列表 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| operator | 是 | String | 参数解释: 标签逻辑运算符 约束限制: 不涉及 取值范围: 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| type | 是 | String | 参数解释: 升级策略类型 约束限制: 当前仅支持inPlaceRollingUpdate类型 取值范围: 默认取值: 不涉及 |
| inPlaceRollingUpdate | 否 | InPlaceRollingUpdate object | 参数解释: 原地升级策略详细配置 约束限制: 指定原地升级策略类型时必填 取值范围: 不涉及 默认取值: 不涉及 |
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| metadata | 参数解释: 升级任务元数据信息 取值范围: 不涉及 | |
| spec | UpgradeResponseSpec object | 参数解释: 升级配置信息 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| uid | String | 参数解释: 升级任务ID,可通过调用获取集群升级任务详情API查询进展 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| clusterUpgradeAction | ClusterUpgradeResponseAction object | 参数解释: 集群升级配置 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| version | String | 参数解释: 当前集群版本 取值范围: 不涉及 |
| targetVersion | String | 参数解释: 目标集群版本,例如"v1.23" 取值范围: 不涉及 |
| targetPlatformVersion | String | 参数解释: 目标集群的平台版本号,表示集群版本(version)下的内部版本,不支持用户指定。 取值范围: 不涉及 |
| strategy | UpgradeStrategyResponse object | 参数解释: 升级策略 取值范围: 不涉及 |
| config | Object | 参数解释: 升级过程中指定的集群配置 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| type | String | 参数解释: 升级策略类型,当前仅支持原地升级类型"inPlaceRollingUpdate" 取值范围: |
| inPlaceRollingUpdate | InPlaceRollingUpdateResponse object | 参数解释: 原地升级策略详细配置 取值范围: 不涉及 |
请求示例
升级集群至v1.23版本,并设置节点升级步长为20。
POST /api/v3/projects/{project_id}/clusters/{cluster_id}/operation/upgrade
{
"metadata" : {
"apiVersion" : "v3",
"kind" : "UpgradeTask"
},
"spec" : {
"clusterUpgradeAction" : {
"strategy" : {
"type" : "inPlaceRollingUpdate",
"inPlaceRollingUpdate" : {
"userDefinedStep" : 20
}
},
"targetVersion" : "v1.23"
}
}
} 响应示例
状态码:200
表示集群升级任务下发成功。
{
"metadata" : {
"uid" : "976a33e2-f545-11ed-87af-0255ac1002c2"
},
"spec" : {
"clusterUpgradeAction" : {
"version" : "v1.19.16-r20",
"targetVersion" : "v1.23.8-r0",
"targetPlatformVersion" : "cce.10",
"strategy" : {
"type" : "inPlaceRollingUpdate",
"inPlaceRollingUpdate" : {
"userDefinedStep" : 20
}
},
"config" : { }
}
}
} SDK代码示例
SDK代码示例如下。
升级集群至v1.23版本,并设置节点升级步长为20。
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 | 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 UpgradeClusterSolution { 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(); UpgradeClusterRequest request = new UpgradeClusterRequest(); request.withClusterId("{cluster_id}"); UpgradeClusterRequestBody body = new UpgradeClusterRequestBody(); InPlaceRollingUpdate inPlaceRollingUpdateStrategy = new InPlaceRollingUpdate(); inPlaceRollingUpdateStrategy.withUserDefinedStep(20); UpgradeStrategy strategyClusterUpgradeAction = new UpgradeStrategy(); strategyClusterUpgradeAction.withType("inPlaceRollingUpdate") .withInPlaceRollingUpdate(inPlaceRollingUpdateStrategy); ClusterUpgradeAction clusterUpgradeActionSpec = new ClusterUpgradeAction(); clusterUpgradeActionSpec.withStrategy(strategyClusterUpgradeAction) .withTargetVersion("v1.23"); UpgradeSpec specbody = new UpgradeSpec(); specbody.withClusterUpgradeAction(clusterUpgradeActionSpec); UpgradeClusterRequestMetadata metadatabody = new UpgradeClusterRequestMetadata(); metadatabody.withApiVersion("v3") .withKind("UpgradeTask"); body.withSpec(specbody); body.withMetadata(metadatabody); request.withBody(body); try { UpgradeClusterResponse response = client.upgradeCluster(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.23版本,并设置节点升级步长为20。
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 | # 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 = UpgradeClusterRequest() request.cluster_id = "{cluster_id}" inPlaceRollingUpdateStrategy = InPlaceRollingUpdate( user_defined_step=20 ) strategyClusterUpgradeAction = UpgradeStrategy( type="inPlaceRollingUpdate", in_place_rolling_update=inPlaceRollingUpdateStrategy ) clusterUpgradeActionSpec = ClusterUpgradeAction( strategy=strategyClusterUpgradeAction, target_version="v1.23" ) specbody = UpgradeSpec( cluster_upgrade_action=clusterUpgradeActionSpec ) metadatabody = UpgradeClusterRequestMetadata( api_version="v3", kind="UpgradeTask" ) request.body = UpgradeClusterRequestBody( spec=specbody, metadata=metadatabody ) response = client.upgrade_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.23版本,并设置节点升级步长为20。
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 68 69 70 71 72 73 | 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.UpgradeClusterRequest{} request.ClusterId = "{cluster_id}" userDefinedStepInPlaceRollingUpdate:= int32(20) inPlaceRollingUpdateStrategy := &model.InPlaceRollingUpdate{ UserDefinedStep: &userDefinedStepInPlaceRollingUpdate, } strategyClusterUpgradeAction := &model.UpgradeStrategy{ Type: "inPlaceRollingUpdate", InPlaceRollingUpdate: inPlaceRollingUpdateStrategy, } clusterUpgradeActionSpec := &model.ClusterUpgradeAction{ Strategy: strategyClusterUpgradeAction, TargetVersion: "v1.23", } specbody := &model.UpgradeSpec{ ClusterUpgradeAction: clusterUpgradeActionSpec, } metadatabody := &model.UpgradeClusterRequestMetadata{ ApiVersion: "v3", Kind: "UpgradeTask", } request.Body = &model.UpgradeClusterRequestBody{ Spec: specbody, Metadata: metadatabody, } response, err := client.UpgradeCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
| 状态码 | 描述 |
|---|---|
| 200 | 表示集群升级任务下发成功。 |
错误码
请参见错误码。
