All Products
Search
Document Center

:Query the kubeconfig file of a cluster

更新時間:Aug 31, 2023

You can call the DescribeClusterUserKubeconfig operation to query the kubeconfig file of a Container Service for Kubernetes (ACK) cluster. The kubeconfig file contains the details of the current user and is used to configure access to a cluster.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request syntax

GET /k8s/ClusterId/user_config?PrivateIpAddress=Boolean&TemporaryDurationMinutes=Long HTTP/1.1
Content-Type:application/json

Request parameters

Table 1. Request path parameters
ParameterTypeRequiredExampleDescription
ClusterIdStringYesc5b5e80b0b64a4bf6939d2d8fbbc5****

The ID of the ACK cluster that you want to query

Table 2. Request query parameters
ParameterTypeRequiredExampleDescription
PrivateIpAddressBooleanNotrue

Specifies whether to obtain the credential that is used to connect to the cluster over the internal network. Valid values:

  • true: obtains the credential that is used to connect to the cluster over the internal network.
  • false: obtains the credential that is used to connect to the cluster over the Internet.

Default value: false.

TemporaryDurationMinutesLongNo15

The validity period of a temporary kubeconfig file. Unit: minutes. Valid values: 15 to 4320.

Note If you do not specify this parameter, the system automatically specifies a validity period, which is indicated by the expiration field in the response.

Response syntax

HTTP/1.1 200 OK
Content-Type:application/json

{
  "config" : "String",
  "expiration" : "String"
}

Response parameters

Table 3. Response body parameters
ParameterType ExampleDescription
configStringapiVersion: v1****

The content of the kubeconfig file. For more information about the content of the kubeconfig file, see Configure cluster credentials.

expirationString2024-03-10T09:56:17Z

The expiration time of the kubeconfig file. The value is the UTC time displayed in RFC3339 format.

Examples

Sample requests

GET /k8s/c5b5e80b0b64a4bf6939d2d8fbbc5****/user_config?PrivateIpAddress=true&TemporaryDurationMinutes=15 HTTP/1.1
Host:cs.aliyuncs.com
Content-Type:application/json

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<config>
apiVersion: v1
clusters:
- cluster:
...
</config>
<expiration>2021-03-25T10:01:20Z</expiration>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "config" : "\napiVersion: v1\nclusters:\n- cluster:\n...\n",
  "expiration" : "2021-03-25T10:01:20Z"
}

Error codes

For a list of error codes, visit the API Error Center.