You need to enable JavaScript to run this app.
导航

CreateKubeconfig

最近更新时间2024.02.26 20:17:38

首次发布时间2022.12.14 14:54:08

生成集群的 Kubeconfig 凭证。

使用说明

此接口为异步接口,当此接口返回成功时,不代表 Kubeconfig 立刻可以使用,需要您调用 ListKubeconfigs 接口,成功获取该 Kubeconfig 的文本信息并稍等 5 秒后尝试使用。

请求参数

调用该 API 时的请求参数如下,除此之外还需传入公共请求参数。公共请求参数说明,请参见 公共参数

参数名称类型是否必选示例值描述
ActionStringCreateKubeconfig公共参数,本接口值:CreateKubeconfig。
VersionString2022-05-12公共参数,本接口值:2022-05-12。

ClusterId

String

cc8oo0ivqtofnisb7****

集群 ID。
可以调用 ListClusters 接口,获取集群 ID。

注意

集群必须处于{Running,[Ok]}{Updating,[Progressing]}状态。可调用 ListClusters 接口获取集群当前的状态。

Type

String

Private

集群 Kubeconfig 文件类型,取值:

  • Private:私网访问类型的 Kubeconfig。
  • Public:公网访问类型的 Kubeconfig。

ValidDuration

Integer

43800

Kubeconfig 文件有效期。

  • 取值范围:1~43800。
  • 单位:小时。
  • 默认值:26280(3年)。

请求示例

POST /?Action=CreateKubeconfig&Version=2022-05-12
Content-Type:application/json
{
    "ClusterId": "cc8oo0ivqtofnisb7****",
    "Type": "Private",
    "ValidDuration": 43800
}

返回参数

本接口返回参数如下表所示,公共返回参数请参见 返回结果

参数名称类型示例值描述

Id

String

kc5silumrsfeq****

Kubeconfig ID。

注意

建议您妥善保存 Kubeconfig ID 信息,以备后续使用。

返回示例

HTTP/1.1 200 OK
Content-Type:application/json
{
    "ResponseMetadata": {
        "RequestId": "021635330810134****",
        "Action": "CreateKubeconfig",
        "Version": "2022-05-12",
        "Service": "vke",
        "Region": "cn-beijing"
    },
    "Result": {
        "Id": "kc5silumrsfeq****"
    }
}

错误码

本接口错误码如下表所示,公共错误码请参见 公共错误码

HTTP 状态码错误码错误信息描述
400OperationDenied.ClusterStatusThe action has been denied due to wrong cluster status {{statusPhase}} and [{{statusConditions}}].指定集群的当前状态不支持该操作。请确认该接口依赖的集群状态后重试。
400LimitExceeded.KubeconfigNumberYou have reached the limit of the number of kubeconfig that you can create.可生成的 Kubeconfig 文件数量已达到上限。产品限制说明,请参见 使用限制