Updated on 2024-04-30 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

Yes

String

Identity authentication information

Minimum: 1

Maximum: 16384

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. This parameter is used only when a CCE cluster is imported during registration. For other types of clusters, you do not need to set this parameter.

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.

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

Example Requests

  • Registering a Huawei Cloud CCE cluster

    POST https://ucs.myhuaweicloud.com/v1/clusters
    
    {
      "metadata" : {
        "uid" : "44052cdd-8cd2-11ee-abd1-0255ac1001bd"
      },
      "spec" : {
        "region" : "cn-north-7",
        "category" : "self",
        "type" : "turbo",
        "projectID" : "05495693df80d3c92fa1c01795c2be02",
        "clusterGroupID" : "",
        "manageType" : "discrete"
      }
    }
  • 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\":\"eyJhbGciOiJSUzI1NiIsImtpZCI6Ik9IT0RDSVhaa3BmQTNVWUNyRVFIYktQZGVtcFJISjNsZUctbjdsT1Z3ZzAifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6InVjcy11c2VyLXRva2VuIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6InVjcy11c2VyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiY2QzMmRmODEtY2NlOC00MTRlLWFjMTUtNzE5ZThmOWU0MjJjIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50OmRlZmF1bHQ6dWNzLXVzZXIifQ.n7m_9THJMrNQzNMh06RBLJpf328a227ZFnNFwNJ26E-SUnIzovtZ2BFQsFIpewXsHZ1OrW5dTcYfaCp50vplmplWdWWPYdgMoSGBu7IIauPmd2lQisDRXoqvYrL8v-xSSf3fbEnaPZH9T0KKk7pilfVyW8sDQME5K-JqzFTgo7mEUeEOK7mAnp9ZsdJegYUWYgrltbL78eglKDUOdV4CI7CbA47-E13UW5kLaIxDmDxI-s3jzXwt47372CXbwqjThZ6QiG_YJu8YtGL-lySIwAuqGXCzJVldWONffQRp7XWjdcC3V5yWX9737DieH5TN8dor1dLQMTAMCUfIAU6T3Q\"}}],\"contexts\":[{\"name\":\"internal\",\"context\":{\"cluster\":\"internalCluster\",\"user\":\"ucs-user\"}}],\"current-context\":\"internal\"}"
        },
        "labels" : { }
      },
      "spec" : {
        "category" : "attachedcluster",
        "clusterGroupID" : "",
        "manageType" : "discrete",
        "city" : "110000",
        "country" : "CN",
        "CLUSTER_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.