Reviewed-by: Gergo-Bence Lorincz <a200452876@noreply.gitea.eco.tsi-dev.otc-service.com> Co-authored-by: qiujiandong1 <qiujiandong1@huawei.com> Co-committed-by: qiujiandong1 <qiujiandong1@huawei.com>
28 KiB
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
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
X-Auth-Token |
Yes |
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. |
Content-Type |
Yes |
String |
Message body type (format). Only application/json is supported. |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
kind |
No |
String |
Resource type. For a registered cluster, set this parameter to Cluster. This parameter is optional for a CCE cluster and mandatory for an attached cluster. |
apiVersion |
No |
String |
API version. The current version is v1. This parameter is optional for a CCE cluster and mandatory for an attached cluster. |
metadata |
Yes |
metadata object |
Cluster metadata information |
spec |
Yes |
spec object |
Cluster specifications |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
uid |
No |
String |
Cluster ID. This parameter is used only when a CCE cluster is imported for registration. For other types of clusters, you do not need to set this parameter. |
name |
No |
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 blank. If this parameter is not left blank, the value must comply with the Kubernetes label specifications. A maximum of 100 labels are supported. |
annotations |
No |
Map<String,String> |
Cluster annotations. The kubeconfig field is mandatory for an attached cluster, and its value is the content of the kubeconfig file. |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
clusterGroupID |
No |
String |
Fleet ID. |
category |
Yes |
String |
Cluster category. 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 |
No |
String |
Provider. The value must meet the requirements for category and type. For details, see Cluster Categories and Types. |
country |
No |
String |
Country code This parameter is optional for a CCE cluster and mandatory for an attached cluster. |
city |
No |
String |
City code (consistent with the country) This parameter is optional for a CCE cluster and mandatory for an attached cluster. |
region |
No |
String |
Region information. This parameter is used only when a CCE cluster is imported 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 used only when a CCE cluster is imported 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 management type. Options:
|
network |
No |
NetworkConfig object |
Network configuration of a multi-cloud cluster. You do not need to set this parameter for other types of clusters. |
Response Parameters
Status code: 201
Parameter |
Type |
Description |
|---|---|---|
uid |
String |
Cluster ID |
Example Requests
- Registering a CCE cluster
{ "metadata" : { "uid" : "44052cdd-8cd2-11ee-abd1-0255ac1001bd" }, "spec" : { "region" : "cidc-rp-12", "category" : "self", "type" : "turbo", "projectID" : "05495693df80d3c92fa1c01795c2be02", "clusterGroupID" : "", "manageType" : "discrete" } }
Example Responses
Status code: 201
The cluster has been registered, and 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, and 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 |
Resources not found. |
409 |
There was a request conflict. |
500 |
Internal server error. |
Error Codes
See Error Codes.