v8

latestOpenAPI 3.0.0Apache 2.0raw.githubusercontent.com2025-10-165266542.4 MB
DigitalOcean-public.v2-new_Kubernetes

Retrieve Credentials for a Kubernetes Cluster

This endpoint returns a JSON object . It can be used to programmatically construct Kubernetes clients which cannot parse kubeconfig files.

The resulting JSON object contains token-based authentication for clusters supporting it, and certificate-based authentication otherwise. For a list of supported versions and more information, see "How to Connect to a DigitalOcean Kubernetes Cluster".

To retrieve credentials for accessing a Kubernetes cluster, send a GET request to /v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials.

Clusters supporting token-based authentication may define an expiration by passing a duration in seconds as a query parameter to /v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials?expiry_seconds=$DURATION_IN_SECONDS. If not set or 0, then the token will have a 7 day expiry. The query parameter has no impact in certificate-based authentication.

get/v2/kubernetes/clusters/{cluster_id}/credentials

Path parameters

cluster_idstring uuid required

A unique ID that can be used to reference a Kubernetes cluster.

Query parameters

expiry_secondsinteger

The duration in seconds that the returned Kubernetes credentials will be valid. If not set or 0, the credentials will have a 7 day expiry.

Response

A JSON object containing credentials for a cluster.

serverstring uri

The URL used to access the cluster API server.

certificate_authority_datastring byte

A base64 encoding of bytes representing the certificate authority data for accessing the cluster.

client_certificate_datastring byte nullable

A base64 encoding of bytes representing the x509 client certificate data for access the cluster. This is only returned for clusters without support for token-based authentication.

Newly created Kubernetes clusters do not return credentials using certificate-based authentication. For additional information, see here.

client_key_datastring byte nullable

A base64 encoding of bytes representing the x509 client key data for access the cluster. This is only returned for clusters without support for token-based authentication.

Newly created Kubernetes clusters do not return credentials using certificate-based authentication. For additional information, see here.

tokenstring

An access token used to authenticate with the cluster. This is only returned for clusters with support for token-based authentication.

expires_atstring date-time

A time value given in ISO8601 combined date and time format that represents when the access token expires.

Example response

{
  "server": "https://bd5f5959-5e1e-4205-a714-a914373942af.k8s.ondigitalocean.com",
  "certificate_authority_data": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURKekNDQW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