Help Center/ Cloud Container Engine/ API Reference/ APIs/ Add-on Management/ Creating Add-on Check Tasks in Batches
Updated on 2026-01-08 GMT+08:00

Creating Add-on Check Tasks in Batches

Function

This API is used to create add-on check tasks in batches in a specified cluster.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, no identity policy-based permission required for calling this API.

URI

POST /api/v3/projects/{project_id}/clusters/{cluster_id}/addons/precheck

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Details:

Project ID. For details about how to obtain the value, see How to Obtain Parameters in the API URI.

Constraints:

None

Options:

Project IDs of the account

Default value:

N/A

cluster_id

Yes

String

Details:

Cluster ID. For details about how to obtain the value, see How to Obtain Parameters in the API URI.

Constraints:

None

Options:

Cluster IDs

Default value:

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Details:

The request body type or format

Constraints:

The GET method is not verified.

Options:

  • application/json

  • application/json;charset=utf-8

  • application/x-pem-file

  • multipart/form-data (used when the FormData parameter is present)

Default value:

N/A

X-Auth-Token

Yes

String

Details:

Requests for calling an API can be authenticated using either a token or AK/SK. If token-based authentication is used, this parameter is mandatory and must be set to a user token. For details, see Obtaining a User Token.

Constraints:

None

Options:

N/A

Default value:

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

kind

Yes

String

Definition

API type.

Constraints

The value cannot be changed.

Range

The value is fixed at AddonCheck.

Default Value

AddonCheck

apiVersion

Yes

String

Definition

API version.

Constraints

The value cannot be changed.

Range

The value is fixed at v3.

Default Value

v3

spec

Yes

AddonCheckSpec object

Definition

Details of an add-on check.

Constraints

N/A

Table 4 AddonCheckSpec

Parameter

Mandatory

Type

Description

clusterID

Yes

String

Definition

Cluster ID.

Constraints

N/A

Range

N/A

Default Value

N/A

addonList

Yes

Array of AddonInfo objects

Definition

Add-on check information list, including the name of the add-on template to be checked, add-on instance ID, and add-on upgrade configuration.

Constraints

N/A

Table 5 AddonInfo

Parameter

Mandatory

Type

Description

addonTemplateName

Yes

String

Definition

Add-on template name.

Constraints

N/A

Range

Add-on template supported by CCE.

Default Value

N/A

addonInstanceID

Yes

String

Definition

Add-on instance ID, which can be obtained from the items[].metadata.uid field in Listing Add-on Instances.

Constraints

This parameter is mandatory.

Range

N/A

Default Value

N/A

targetVersion

No

String

Definition

Target version of an add-on upgrade.

Constraints

This parameter is mandatory in the add-on upgrade scenario.

Range

Add-on version provided by CCE. You can obtain the value from the items[].spec.versions.version field in Listing Add-on Templates.

Default Value

N/A

type

Yes

String

Definition

Add-on check type.

Constraints

This parameter is mandatory.

Range

  • addonStatic: add-on check when the add-on is running

  • addonUpgrade: add-on check before an upgrade

Default Value

N/A

values

No

Map<String,Object>

Definition

Add-on template edit or upgrade parameters (which vary depending on add-ons). Set the parameters accordingly.

Constraints

N/A

Response Parameters

Status code: 201

Table 6 Response body parameters

Parameter

Type

Description

kind

String

Definition

API type.

Constraints

The value cannot be changed.

Range

The value is fixed at AddonCheck.

Default Value

AddonCheck

apiVersion

String

Definition

API version.

Constraints

The value cannot be changed.

Range

The value is fixed at v3.

Default Value

v3

spec

AddonCheckSpec object

Definition

Details of an add-on check.

Constraints

N/A

status

AddonCheckStatus object

Definition

Results of creating an add-on check task, including the task ID for querying the add-on check result.

Constraints

N/A

Table 7 AddonCheckSpec

Parameter

Type

Description

clusterID

String

Definition

Cluster ID.

Constraints

N/A

Range

N/A

Default Value

N/A

addonList

Array of AddonInfo objects

Definition

Add-on check information list, including the name of the add-on template to be checked, add-on instance ID, and add-on upgrade configuration.

Constraints

N/A

Table 8 AddonInfo

Parameter

Type

Description

addonTemplateName

String

Definition

Add-on template name.

Constraints

N/A

Range

Add-on template supported by CCE.

Default Value

N/A

addonInstanceID

String

Definition

Add-on instance ID, which can be obtained from the items[].metadata.uid field in Listing Add-on Instances.

Constraints

This parameter is mandatory.

Range

N/A

Default Value

N/A

targetVersion

String

Definition

Target version of an add-on upgrade.

Constraints

This parameter is mandatory in the add-on upgrade scenario.

Range

Add-on version provided by CCE. You can obtain the value from the items[].spec.versions.version field in Listing Add-on Templates.

Default Value

N/A

type

String

Definition

Add-on check type.

Constraints

This parameter is mandatory.

Range

  • addonStatic: add-on check when the add-on is running

  • addonUpgrade: add-on check before an upgrade

Default Value

N/A

values

Map<String,Object>

Definition

Add-on template edit or upgrade parameters (which vary depending on add-ons). Set the parameters accordingly.

Constraints

N/A

Table 9 AddonCheckStatus

Parameter

Type

Description

items

Array of AddonCheckTask objects

Definition

Add-on check task list, including the add-on check task ID, add-on template name, and add-on instance ID.

Constraints

N/A

Table 10 AddonCheckTask

Parameter

Type

Description

metadata

CheckTaskMetadata object

Definition

Basic information. Metadata is a collection of attributes.

Constraints

N/A

spec

CheckTaskSpec object

Definition

Target information of an add-on check, including the target version of an add-on upgrade.

Constraints

N/A

status

CheckTaskStatus object

Definition

Add-on check task status.

Constraints

N/A

Table 11 CheckTaskMetadata

Parameter

Type

Description

type

String

Definition

Add-on check type.

Range

  • addonStatic: add-on check when the add-on is running

  • addonUpgrade: add-on check before an upgrade

taskID

String

Definition

Add-on check task ID, which is used to query the task check result.

Range

N/A

addonTemplateName

String

Definition

Add-on template name.

Range

Add-on template provided by CCE. You can obtain the value from the items[].metadata.name field in Listing Add-on Templates.

addonInstanceName

String

Definition

Add-on instance name.

Range

N/A

addonInstanceID

String

Definition

Add-on instance ID.

Range

N/A

createTimeStamp

String

Definition

Creation time of an add-on check task.

Range

N/A

expireTimeStamp

String

Definition

Timeout duration of an add-on check task. This field is available only for tasks in the Failed or Success state.

Range

N/A

Table 12 CheckTaskSpec

Parameter

Type

Description

addonTargetVersion

String

Definition

Target version of an add-on upgrade.

Range

N/A

Table 13 CheckTaskStatus

Parameter

Type

Description

status

String

Definition

Status of an add-on check.

Range

  • Init: The add-on check is initialized.

  • Running: The add-on check is in progress.

  • Failed: The add-on check is complete, and risks are found.

  • Success: The add-on check is complete, and no risks are found.

message

String

Definition

Add-on check results.

Range

N/A

riskList

Array of CheckTaskRisk objects

Definition

List of risk items during an add-on check. The risk items vary according to add-ons.

Constraints

N/A

Table 14 CheckTaskRisk

Parameter

Type

Description

riskName

String

Definition

Risk item name.

Range

N/A

level

String

Definition

Risk level.

Range

  • Warning: medium risk, which can be skipped

  • Fatal: high risk, which cannot be skipped

status

String

Definition

Risk item check status.

Range

  • Init: The risk item check is initialized.

  • Running: The risk item check is in progress.

  • Failed: The risk item check is complete, and risks are found.

  • Success: The risk item check is complete, and no risks are found.

message

String

Definition

Risk check result description.

Range

N/A

Example Requests

  • Create a CoreDNS add-on check task and set the check type to add-on upgrade.

    POST /api/v3/projects/{project_id}/clusters/{cluster_id}/addons/precheck
    
    {
      "kind" : "AddonCheck",
      "apiVersion" : "v3",
      "spec" : {
        "clusterID" : "6b400e1c-4368-11f0-ba56-0255ac100037",
        "addonList" : [ {
          "addonTemplateName" : "coredns",
          "addonInstanceID" : "8fcaa506-809d-4f33-91b3-b27efcbeb540",
          "type" : "addonUpgrade",
          "values" : {
            "basic" : {
              "cluster_ip" : "10.247.3.10",
              "image_version" : "1.17.15",
              "platform" : "linux-amd64",
              "rbac_enabled" : true,
              "swr_addr" : "",
              "swr_user" : "hwofficial"
            },
            "custom" : {
              "cluster_id" : "8fcaa506-809d-4f33-91b3-b27efcbeb540",
              "stub_domains" : { },
              "tenant_id" : "0504201b6c80256b2f08c0099f0c8fe4",
              "upstream_nameservers" : [ ]
            },
            "flavor" : {
              "name" : 2500,
              "replicas" : 2,
              "resources" : [ {
                "limitsCpu" : "500m",
                "limitsMem" : "512Mi",
                "name" : "coredns",
                "requestsCpu" : "500m",
                "requestsMem" : "512Mi"
              } ]
            }
          }
        } ]
      }
    }
  • Create a CoreDNS add-on check task and set the check type to add-on inspection.

    POST /api/v3/projects/{project_id}/clusters/{cluster_id}/addons/precheck
    
    {
      "kind" : "AddonCheck",
      "apiVersion" : "v3",
      "spec" : {
        "clusterID" : "6b400e1c-4368-11f0-ba56-0255ac100037",
        "addonList" : [ {
          "addonTemplateName" : "coredns",
          "addonInstanceID" : "8fcaa506-809d-4f33-91b3-b27efcbeb540",
          "type" : "addonStatic"
        } ]
      }
    }

Example Responses

Status code: 201

The add-on check tasks have been created in batches in the cluster.

{
  "kind" : "AddonCheck",
  "apiVersion" : "v3",
  "spec" : {
    "clusterID" : "6b400e1c-4368-11f0-ba56-0255ac100037",
    "addonList" : [ {
      "addonTemplateName" : "coredns",
      "addonInstanceID" : "8fcaa506-809d-4f33-91b3-b27efcbeb540",
      "type" : "addonUpgrade",
      "values" : {
        "basic" : {
          "cluster_ip" : "10.247.3.10",
          "image_version" : "1.17.15",
          "platform" : "linux-amd64",
          "rbac_enabled" : true,
          "swr_addr" : "",
          "swr_user" : "hwofficial"
        },
        "custom" : {
          "cluster_id" : "8fcaa506-809d-4f33-91b3-b27efcbeb540",
          "stub_domains" : { },
          "tenant_id" : "0504201b6c80256b2f08c0099f0c8fe4",
          "upstream_nameservers" : [ ]
        },
        "flavor" : {
          "name" : 2500,
          "replicas" : 2,
          "resources" : [ {
            "limitsCpu" : "500m",
            "limitsMem" : "512Mi",
            "name" : "coredns",
            "requestsCpu" : "500m",
            "requestsMem" : "512Mi"
          } ]
        }
      }
    } ]
  },
  "status" : {
    "items" : [ {
      "metadata" : {
        "type" : "addonUpgrade",
        "taskID" : "22386048-d955-4409-bc71-20cc2b774245",
        "addonTemplateName" : "coredns",
        "addonInstanceName" : "cceaddon-coredns",
        "addonInstanceID" : "8fcaa506-809d-4f33-91b3-b27efcbeb540",
        "createTimeStamp" : "2025-08-13T11:24:37.312017086+08:00"
      },
      "spec" : {
        "addonTargetVersion" : "1.27.1"
      },
      "status" : {
        "status" : "Init",
        "riskList" : [ {
          "riskName" : "K8sResourceModified",
          "status" : "Init",
          "level" : "Warning"
        }, {
          "riskName" : "AddonValidate",
          "status" : "Init",
          "level" : "Warning"
        }, {
          "riskName" : "AddonStatus",
          "status" : "Init",
          "level" : "Warning"
        } ]
      }
    } ]
  }
}

SDK Sample Code

The SDK sample code is as follows.

  • Create a CoreDNS add-on check task and set the check type to add-on upgrade.

     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
    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;
    import java.util.Map;
    import java.util.HashMap;
    
    public class BatchCreateAddonPrecheckSolution {
    
        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();
            BatchCreateAddonPrecheckRequest request = new BatchCreateAddonPrecheckRequest();
            request.withClusterId("{cluster_id}");
            AddonCheckRequest body = new AddonCheckRequest();
            Map<String, Object> listAddonListValues = new HashMap<>();
            listAddonListValues.put("basic", "{\"rbac_enabled\":true,\"swr_user\":\"hwofficial\",\"image_version\":\"1.17.15\",\"cluster_ip\":\"10.247.3.10\",\"platform\":\"linux-amd64\",\"swr_addr\":\"\"}");
            listAddonListValues.put("custom", "{\"tenant_id\":\"0504201b6c80256b2f08c0099f0c8fe4\",\"cluster_id\":\"8fcaa506-809d-4f33-91b3-b27efcbeb540\",\"stub_domains\":{},\"upstream_nameservers\":[]}");
            listAddonListValues.put("flavor", "{\"replicas\":2,\"name\":2500,\"resources\":[{\"limitsCpu\":\"500m\",\"name\":\"coredns\",\"limitsMem\":\"512Mi\",\"requestsMem\":\"512Mi\",\"requestsCpu\":\"500m\"}]}");
            List<AddonInfo> listSpecAddonList = new ArrayList<>();
            listSpecAddonList.add(
                new AddonInfo()
                    .withAddonTemplateName("coredns")
                    .withAddonInstanceID("8fcaa506-809d-4f33-91b3-b27efcbeb540")
                    .withType(AddonInfo.TypeEnum.fromValue("addonUpgrade"))
                    .withValues(listAddonListValues)
            );
            AddonCheckSpec specbody = new AddonCheckSpec();
            specbody.withClusterID("6b400e1c-4368-11f0-ba56-0255ac100037")
                .withAddonList(listSpecAddonList);
            body.withSpec(specbody);
            body.withApiVersion("v3");
            body.withKind("AddonCheck");
            request.withBody(body);
            try {
                BatchCreateAddonPrecheckResponse response = client.batchCreateAddonPrecheck(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());
            }
        }
    }
    
  • Create a CoreDNS add-on check task and set the check type to add-on inspection.

     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.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class BatchCreateAddonPrecheckSolution {
    
        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();
            BatchCreateAddonPrecheckRequest request = new BatchCreateAddonPrecheckRequest();
            request.withClusterId("{cluster_id}");
            AddonCheckRequest body = new AddonCheckRequest();
            List<AddonInfo> listSpecAddonList = new ArrayList<>();
            listSpecAddonList.add(
                new AddonInfo()
                    .withAddonTemplateName("coredns")
                    .withAddonInstanceID("8fcaa506-809d-4f33-91b3-b27efcbeb540")
                    .withType(AddonInfo.TypeEnum.fromValue("addonStatic"))
            );
            AddonCheckSpec specbody = new AddonCheckSpec();
            specbody.withClusterID("6b400e1c-4368-11f0-ba56-0255ac100037")
                .withAddonList(listSpecAddonList);
            body.withSpec(specbody);
            body.withApiVersion("v3");
            body.withKind("AddonCheck");
            request.withBody(body);
            try {
                BatchCreateAddonPrecheckResponse response = client.batchCreateAddonPrecheck(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());
            }
        }
    }
    
  • Create a CoreDNS add-on check task and set the check type to add-on upgrade.

     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 = BatchCreateAddonPrecheckRequest()
            request.cluster_id = "{cluster_id}"
            listValuesAddonList = {
                "basic": "{\"rbac_enabled\":true,\"swr_user\":\"hwofficial\",\"image_version\":\"1.17.15\",\"cluster_ip\":\"10.247.3.10\",\"platform\":\"linux-amd64\",\"swr_addr\":\"\"}",
                "custom": "{\"tenant_id\":\"0504201b6c80256b2f08c0099f0c8fe4\",\"cluster_id\":\"8fcaa506-809d-4f33-91b3-b27efcbeb540\",\"stub_domains\":{},\"upstream_nameservers\":[]}",
                "flavor": "{\"replicas\":2,\"name\":2500,\"resources\":[{\"limitsCpu\":\"500m\",\"name\":\"coredns\",\"limitsMem\":\"512Mi\",\"requestsMem\":\"512Mi\",\"requestsCpu\":\"500m\"}]}"
            }
            listAddonListSpec = [
                AddonInfo(
                    addon_template_name="coredns",
                    addon_instance_id="8fcaa506-809d-4f33-91b3-b27efcbeb540",
                    type="addonUpgrade",
                    values=listValuesAddonList
                )
            ]
            specbody = AddonCheckSpec(
                cluster_id="6b400e1c-4368-11f0-ba56-0255ac100037",
                addon_list=listAddonListSpec
            )
            request.body = AddonCheckRequest(
                spec=specbody,
                api_version="v3",
                kind="AddonCheck"
            )
            response = client.batch_create_addon_precheck(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Create a CoreDNS add-on check task and set the check type to add-on inspection.

     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
    # 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 = BatchCreateAddonPrecheckRequest()
            request.cluster_id = "{cluster_id}"
            listAddonListSpec = [
                AddonInfo(
                    addon_template_name="coredns",
                    addon_instance_id="8fcaa506-809d-4f33-91b3-b27efcbeb540",
                    type="addonStatic"
                )
            ]
            specbody = AddonCheckSpec(
                cluster_id="6b400e1c-4368-11f0-ba56-0255ac100037",
                addon_list=listAddonListSpec
            )
            request.body = AddonCheckRequest(
                spec=specbody,
                api_version="v3",
                kind="AddonCheck"
            )
            response = client.batch_create_addon_precheck(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Create a CoreDNS add-on check task and set the check type to add-on upgrade.

     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 := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := cce.NewCceClient(
            cce.CceClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.BatchCreateAddonPrecheckRequest{}
    	request.ClusterId = "{cluster_id}"
    	var listValuesAddonList = map[string]interface{}{
            "basic": "{\"rbac_enabled\":true,\"swr_user\":\"hwofficial\",\"image_version\":\"1.17.15\",\"cluster_ip\":\"10.247.3.10\",\"platform\":\"linux-amd64\",\"swr_addr\":\"\"}",
            "custom": "{\"tenant_id\":\"0504201b6c80256b2f08c0099f0c8fe4\",\"cluster_id\":\"8fcaa506-809d-4f33-91b3-b27efcbeb540\",\"stub_domains\":{},\"upstream_nameservers\":[]}",
            "flavor": "{\"replicas\":2,\"name\":2500,\"resources\":[{\"limitsCpu\":\"500m\",\"name\":\"coredns\",\"limitsMem\":\"512Mi\",\"requestsMem\":\"512Mi\",\"requestsCpu\":\"500m\"}]}",
        }
    	var listAddonListSpec = []model.AddonInfo{
            {
                AddonTemplateName: "coredns",
                AddonInstanceID: "8fcaa506-809d-4f33-91b3-b27efcbeb540",
                Type: model.GetAddonInfoTypeEnum().ADDON_UPGRADE,
                Values: listValuesAddonList,
            },
        }
    	specbody := &model.AddonCheckSpec{
    		ClusterID: "6b400e1c-4368-11f0-ba56-0255ac100037",
    		AddonList: listAddonListSpec,
    	}
    	request.Body = &model.AddonCheckRequest{
    		Spec: specbody,
    		ApiVersion: "v3",
    		Kind: "AddonCheck",
    	}
    	response, err := client.BatchCreateAddonPrecheck(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create a CoreDNS add-on check task and set the check type to add-on inspection.

     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
    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 := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := cce.NewCceClient(
            cce.CceClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.BatchCreateAddonPrecheckRequest{}
    	request.ClusterId = "{cluster_id}"
    	var listAddonListSpec = []model.AddonInfo{
            {
                AddonTemplateName: "coredns",
                AddonInstanceID: "8fcaa506-809d-4f33-91b3-b27efcbeb540",
                Type: model.GetAddonInfoTypeEnum().ADDON_STATIC,
            },
        }
    	specbody := &model.AddonCheckSpec{
    		ClusterID: "6b400e1c-4368-11f0-ba56-0255ac100037",
    		AddonList: listAddonListSpec,
    	}
    	request.Body = &model.AddonCheckRequest{
    		Spec: specbody,
    		ApiVersion: "v3",
    		Kind: "AddonCheck",
    	}
    	response, err := client.BatchCreateAddonPrecheck(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

201

The add-on check tasks have been created in batches in the cluster.

Error Codes

See Error Codes.