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 |
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 |
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 |
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 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. For details about how to obtain the kubeconfig file, see Obtaining a 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 |
Yes |
String |
Provider. The value must the requirements for category and type. For details, see Cluster Categories and Types. |
country |
Yes |
String |
Country code. |
city |
Yes |
String |
City code. For details, see City Codes. Only cities in China are supported. |
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 are not 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 are not registered with UCS. |
manageType |
Yes |
String |
Cluster management type. Options: |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
podCIDR |
No |
String |
Container CIDR block |
serviceCIDR |
No |
String |
Service CIDR block |
Response Parameters
Status code: 201
Parameter |
Type |
Description |
---|---|---|
uid |
String |
Cluster ID |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
- |
String |
Status code: 403
Parameter |
Type |
Description |
---|---|---|
- |
String |
Status code: 404
Parameter |
Type |
Description |
---|---|---|
- |
String |
Status code: 409
Parameter |
Type |
Description |
---|---|---|
- |
String |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
- |
String |
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 Response
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
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot