Updated on 2025-12-01 GMT+08:00

Registering a Cluster

Function

This API is used to register a cluster. Third-party clusters and CCE clusters can be registered.

URI

POST /v1/clusters

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

Identity authentication information. 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.

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

kind

Yes

String

Resource type. For a registered cluster, set this parameter to Cluster.

apiVersion

Yes

String

API version. The current version is v1.

metadata

Yes

metadata object

Cluster metadata information

spec

Yes

spec object

Cluster specifications

Table 3 metadata

Parameter

Mandatory

Type

Description

uid

No

String

Cluster ID

name

Yes

String

CCE cluster name or a custom cluster name (for other types of clusters).

labels

No

Map<String,String>

Label information. This parameter can be left empty. If it is not left empty, the value must comply with the Kubernetes label specifications. A maximum of 100 labels can be added.

annotations

No

Map<String,String>

Cluster annotations information.

The kubeconfig field is mandatory for an attached cluster, and its value is the content of the kubeconfig file. For details about how to obtain the kubeconfig file, see Obtaining the kubeconfig File.

Table 4 spec

Parameter

Mandatory

Type

Description

clusterGroupID

No

String

Container fleet ID

category

Yes

String

Cluster type. The value must meet the requirements for provider and type. For details, see Cluster Categories and Types.

type

Yes

String

Cluster type. The value must meet the requirements for provider and category. For details, see Cluster Categories and Types.

provider

Yes

String

Provider. The value must the requirements for category and type. For details, see Cluster Categories and Types.

country

Yes

String

Country code. For details, see Country Codes.

city

Yes

String

City code. For details, see City Codes. Only cities in China are supported. If it is a foreign city, you do not need to set this parameter.

region

No

String

Region information. This parameter is only used when a cluster is imported to CCE for registration. You can obtain the value from the region field in the API for querying CCE clusters that have not been registered with UCS.

projectID

No

String

Project ID. This parameter is only used when a cluster is imported to CCE for registration. You can obtain the value from the projectID field in the API for querying CCE clusters that have not been registered with UCS.

manageType

Yes

String

Cluster type.

  • grouped: clusters added to a fleet

  • discrete: clusters not in any fleet

network

No

NetworkConfig object

Network configuration of a multi-cloud cluster. You do not need to set this parameter for other types of clusters.

Table 5 NetworkConfig

Parameter

Mandatory

Type

Description

podCIDR

No

String

Pod CIDR block

serviceCIDR

No

String

Service CIDR block

Response Parameters

Status code: 201

Table 6 Response body parameters

Parameter

Type

Description

uid

String

Cluster ID

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

-

String

-

Status code: 403

Table 8 Response body parameters

Parameter

Type

Description

-

String

-

Status code: 404

Table 9 Response body parameters

Parameter

Type

Description

-

String

-

Status code: 409

Table 10 Response body parameters

Parameter

Type

Description

-

String

-

Status code: 500

Table 11 Response body parameters

Parameter

Type

Description

-

String

-

Example Requests

  • Registering a Huawei Cloud CCE cluster

    POST https://ucs.myhuaweicloud.com/v1/clusters
    
    {
      "kind" : "Cluster",
      "apiVersion" : "v1",
      "metadata" : {
        "name" : "cce-cluster",
        "uid" : "44052cdd-8cd2-11ee-abd1-0255ac1001bd"
      },
      "spec" : {
        "region" : "cn-north-4",
        "category" : "self",
        "type" : "turbo",
        "projectID" : "05495693df80d3c92fa1c01795c2be02",
        "clusterGroupID" : "",
        "manageType" : "discrete",
        "city" : "110000",
        "country" : "CN",
        "provider" : {
          "CCE" : "cce"
        }
      }
    }
  • Registering an attached cluster

    POST https://ucs.myhuaweicloud.com/v1/clusters
    
    {
      "kind" : "Cluster",
      "apiVersion" : "v1",
      "metadata" : {
        "name" : "ack-cluster",
        "annotations" : {
          "kubeconfig" : "{\"kind\":\"Config\",\"apiVersion\":\"v1\",\"preferences\":{},\"clusters\":[{\"name\":\"internalCluster\",\"cluster\":{\"server\":\"https://kubernetes.default.svc.cluster.local:443\",\"insecure-skip-tls-verify\":true}}],\"users\":[{\"name\":\"ucs-user\",\"user\":{\"token\":\"token-string\"}}],\"contexts\":[{\"name\":\"internal\",\"context\":{\"cluster\":\"internalCluster\",\"user\":\"ucs-user\"}}],\"current-context\":\"internal\"}"
        },
        "labels" : { }
      },
      "spec" : {
        "category" : "attachedcluster",
        "clusterGroupID" : "",
        "manageType" : "discrete",
        "city" : "110000",
        "country" : "CN",
        "provider" : {
          "ALI" : "aliyun",
          "TENCENT" : "tencentcloud",
          "AWS" : "aws",
          "GOOGLE" : "googlecloud",
          "AZURE" : "azure",
          "OPENSHIFT" : "openshift",
          "HUAWEISTACK" : "huaweicloudstack",
          "HUAWEI" : "huaweicloud",
          "PRIVATEK8S" : "privatek8s",
          "OTHER" : "other",
          "FLEXIBLEENGINE" : "FlexibleEngine",
          "FLEXIBLEENGINESTACK" : "FlexibleEngineStack",
          "OPENTELEKOMCLOUD" : "OpenTelekomCloud",
          "OPENTELEKOMCLOUDSTACK" : "OpenTelekomCloudStack",
          "TIANYI" : "ctcloud",
          "MOBILE" : "cmcloud"
        },
        "type" : "ack"
      }
    }

Example Responses

Status code: 201

The cluster has been registered (the ID of the registered cluster is returned).

{
  "uid" : "b0d1ecb5-7947-11ee-9467-0255ac1001bf"
}

Status Codes

Status Code

Description

201

The cluster has been registered (the ID of the registered cluster is returned).

400

Client request error. The server could not execute the request.

403

The server refused the request.

404

Resource not found.

409

There was a request conflict.

500

Internal server error.

Error Codes

See Error Codes.