前提条件
管控实例已添加至少2个接入集群。具体操作请参见接入集群管理。
操作指引
管理多集群应用,依赖集群和命名空间两个资源,总结分为以下三个步骤。
- 集群管理:集群通过CCSE ONE控制台接入管控集群,可通过api接口查询接入集群列表。
- 命名空间管理:多集群统一建立命名空间,通过CCSE ONE控制台创建全局命名空间,也可以通过api接口进行管理。
- 多集群应用管理:多集群应用通过api接入进行管理(新建/更新、查询)。
OpenAPI接口说明
一、集群管理
获取接入集群列表:
GET /ccseone/openapi/v1/k8sclusters/listManaged
请求参数:
名称 位置 类型 必选 说明 pageNow query integer 否 页编号,从1开始, 默认值1 pageSize query integer 否 页大小,默认值10 hubName query string 否
返回示例:
{
"statusCode": 0,
"message": "操作成功",
"returnObj": {
"pages": 1,
"total": 2,
"size": 10,
"current": 1,
"records": [
{
"name": "ccseone-managed",
"uid": "a3e41c1d-05c6-4c47-b6c1-a6ae09dcd784",
"creationTimestamp": "2024-09-14 15:27:23",
"labels": {
"type": "managedCluster"
},
"taints": null,
"clusterStatus": "Ready",
"managedClusterStatus": {
"capacity": {
"cpu": "8",
"ephemeral-storage": "251575280Ki",
"memory": "16276020Ki",
"pods": "220"
},
"allocatable": {
"cpu": "8",
"ephemeral-storage": "244732432194",
"memory": "15833312244",
"pods": "220"
}
}
},
{
"name": "ccseone-managed2",
"uid": "2287bb8d-b629-451b-aa9c-b3c7cb2fbb19",
"creationTimestamp": "2024-09-14 16:19:05",
"labels": {
"type": "managedCluster"
},
"taints": null,
"clusterStatus": "Ready",
"managedClusterStatus": {
"capacity": {
"cpu": "8",
"ephemeral-storage": "251575280Ki",
"memory": "16276012Ki",
"pods": "220"
},
"allocatable": {
"cpu": "8",
"ephemeral-storage": "244732432194",
"memory": "15833304462",
"pods": "220"
}
}
}
]
}
}
返回数据结构:
名称 类型 必选 statusCode integer true message string false returnObj object false pages integer true total integer true size integer true current integer true records [object] true name string true uid string true creationTimestamp string true labels object true type string true taints object true clusterStatus string true managedClusterStatus object true capacity object true cpu string true ephemeral-storage string true memory string true pods string true allocatable object true cpu string true ephemeral-storage string true memory string true pods string true
二、全局命名空间管理
1、获取创建全局命名空间
POST /ccseone/openapi/v1/globalnamespaces
Body请求参数:
{
"name": "global-ns-01",
"priority": 59,
"userLabels": {
"key1": "v1",
"key2": "v2"
},
"limits": {
"cpu": "1",
"memory": "4Gi"
}
}
请求参数:
名称 类型 必选 body object 否 name string 是 priority integer 否 userLabels object 否 limits object 否 cpu string 否 memory string 否
返回示例:
{
"statusCode": "0",
"message": "操作成功",
}
返回数据结构:
名称 类型 必选 statusCode string true message string false
2. 获取创建全局命名空间
GET /ccseone/openapi/v1/globalnamespaces
请求参数:
名称 位置 类型 必选 说明 pageNow query integer 否 页编号,从1开始, 默认值1 pageSize query integer 否 页大小,默认值10
返回示例:
{
"statusCode": "0",
"message": "操作成功",
"returnObj": {
"pages": 1,
"total": 1,
"size": 10,
"current": 1,
"records": [
{
"name": "prod",
"priority": 0,
"limits": {
"cpu": "",
"memory": ""
},
"userLabels": {"key1":"v1","key2":"v2"},
"creationTimestamp": "2024-09-18 09:53:20",
"status": "Ready",
"openLimit": false
}
]
}
}
返回数据结构:
名称 类型 必选 statusCode string true message string false returnObj object false pages integer true total integer true size integer true current integer true records array true name string false priority integer false limits object false cpu string true memory string true userLabels object false creationTimestamp string false status string false openLimit boolean false
三、应用集合管理
1. 创建/更新应用集合
POST /ccseone/openapi/v1/hub/{hubName}/argocd/api/v1/applicationsets
Body请求参数:
{
"metadata": {
"name": "s1",
"namespace": "argocd"
},
"spec": {
"generators": [
{
"list": {
"elements": [
{
"name": "ccseone-managed"
},
{
"name": "ccseone-managed-02"
},
],
"template": {
"metadata": {
"name": "s1-2c0f13"
},
"spec": {
"source": {
"repoURL": ""
},
"destination": {
"namespace": "ns-ccseone",
"name": "{{name}}"
},
"project": ""
}
}
}
}
],
"template": {
"metadata": {
"name": "s1-{{uuid}}",
"annotations": {
"publishVersion": ""
}
},
"spec": {
"source": {
"repoURL": "https://gitee.com/ccseone/argocd-example-apps.git",
"targetRevision": "master",
"path": "guestbook"
},
"destination": {
"namespace": "{{namespace}}",
"name": "{{name}}"
},
"project": "default",
"syncPolicy": {}
}
}
}
}
请求参数:
名称 位置 类型 必须 说明 hubName path string 是 upsert query string 否 更新时传递true body body object 否 metadata body object 是 name body string 是 namespace body string 是 spec body object 是 generators body [object] 是 list body object 否 elements body [object] 是 name body string 否 template body object 是 metadata body object 是 name body string 是 spec body object 是 source body object 是 repoURL body string 是 destination body object 是 namespace body string 是 name body string 是 project body string 是 template body object 是 metadata body object 是 name body string 是 annotations body object 是 publishVersion body string 是 spec body object 是 source body object 是 repoURL body string 是 targetRevision body string 是 path body string 是 destination body object 是 namespace body string 是 name body string 是 project body string 是 syncPolicy body object 是
返回示例:
{
"statusCode": "0",
"message": "操作成功",
}
返回数据结构:
名称 类型 必选 statusCode string true message string false
2. 查询应用集合列表
GET /ccseone/openapi/v1/hub/{hubName}/argocd/api/v1/applicationsets
请求参数:
名称 位置 类型 必选 hubName path string 是
返回示例:
{
"statusCode": 0,
"message": "操作成功",
"returnObj": {
"items": [
{
"metadata": {
"creationTimestamp": "2024-09-18T09:58:29Z",
"generation": 1,
"name": "s1",
"namespace": "argocd",
"resourceVersion": "12011188",
"uid": "9a27aaac-9e37-408c-8f7b-3547c1fba61c"
},
"spec": {
"generators": [
{
"list": {
"elements": [
{
"name": "ccseone-01"
}
],
"template": {
"metadata": {
"name": "s1-2c0f13"
},
"spec": {
"destination": "[Object]",
"project": "",
"source": "[Object]"
}
}
}
}
],
"template": {
"metadata": {
"annotations": {
"publishVersion": ""
},
"name": "s1-{{uuid}}"
},
"spec": {
"destination": {
"name": "{{name}}"
},
"project": "default",
"source": {
"path": "guestbook",
"repoURL": "https://gitee.com/ccseone/argocd-example-apps.git",
"targetRevision": "master"
},
"syncPolicy": {}
}
}
},
"status": {
"conditions": [
{
"lastTransitionTime": "2024-09-18T09:58:25Z",
"message": "error while wrapping using MutateFn: Object argocd/s1-2c0f13 is already owned by another ApplicationSet controller s2",
"reason": "UpdateApplicationError",
"status": "True",
"type": "ErrorOccurred"
}
]
}
}
],
"metadata": {}
}
}
返回数据结构:
名称 类型 必选 statusCode integer true message string true returnObj object true items [object] true metadata object false creationTimestamp string true generation integer true name string true namespace string true resourceVersion string true uid string true spec object false generators [object] true list object false elements [object] true name string false template object true metadata object true name string true spec object true destination object true name string true namespace string true project string true source object true repoURL string true template object true metadata object true annotations object true publishVersion string true name string true spec object true destination object true name string true project string true source object true path string true repoURL string true targetRevision string true syncPolicy object true status object false conditions [object] true lastTransitionTime string true message string true reason string true status string true type string true metadata object true
3. 查询应用集合详情
GET /ccseone/openapi/v1/hub/{hubName}/argocd/api/v1/applicationsets/{appset}
请求参数:
名称 位置 类型 必选 hubName path string 是 appset path string 是
返回示例:
{
"statusCode": 0,
"message": "操作成功",
"returnObj": {
"metadata": {
"creationTimestamp": "2024-09-18T09:58:29Z",
"generation": 1,
"name": "s1",
"namespace": "argocd",
"resourceVersion": "12011188",
"uid": "9a27aaac-9e37-408c-8f7b-3547c1fba61c"
},
"spec": {
"generators": [
{
"list": {
"elements": [
{
"name": "ccseone-01"
}
],
"template": {
"metadata": {
"name": "s1-2c0f13"
},
"spec": {
"destination": {
"name": "{{name}}",
"namespace": "ns-ccseone"
},
"project": "",
"source": {
"repoURL": ""
}
}
}
}
}
],
"template": {
"metadata": {
"annotations": {
"publishVersion": ""
},
"name": "s1-{{uuid}}"
},
"spec": {
"destination": {
"name": "{{name}}"
},
"project": "default",
"source": {
"path": "guestbook",
"repoURL": "https://gitee.com/ccseone/argocd-example-apps.git",
"targetRevision": "master"
},
"syncPolicy": {}
}
}
},
"status": {
"conditions": [
{
"lastTransitionTime": "2024-09-18T09:58:25Z",
"message": "error while wrapping using MutateFn: Object argocd/s1-2c0f13 is already owned by another ApplicationSet controller s2",
"reason": "UpdateApplicationError",
"status": "True",
"type": "ErrorOccurred"
}
]
}
}
}
返回数据结构:
名称 类型 必选 requestId string true statusCode integer true message string true returnObj object true metadata object true creationTimestamp string true generation integer true name string true namespace string true resourceVersion string true uid string true spec object true generators [object] true list object false elements [object] true name string false template object true metadata object true name string true spec object true destination object true name string true namespace string true project string true source object true repoURL string true template object true metadata object true annotations object true publishVersion string true name string true spec object true destination object true name string true project string true source object true path string true repoURL string true targetRevision string true syncPolicy object true status object true conditions [object] true lastTransitionTime string true message string true reason string true status string true type string true