Skip to main content

clusters

Creates, updates, deletes, gets or lists a clusters resource.

Overview

Nameclusters
TypeResource
Iddigitalocean.kubernetes.clusters

Fields

NameDatatypeDescription
column_anon``

Methods

NameAccessible byRequired ParamsDescription
kubernetes_get_clusterSELECTcluster_idTo show information about an existing Kubernetes cluster, send a GET request to /v2/kubernetes/clusters/$K8S_CLUSTER_ID.
kubernetes_list_clustersSELECTTo list all of the Kubernetes clusters on your account, send a GET request to /v2/kubernetes/clusters.
kubernetes_create_clusterINSERTdata__name, data__node_pools, data__region, data__versionTo create a new Kubernetes cluster, send a POST request to /v2/kubernetes/clusters. The request must contain at least one node pool with at least one worker. The request may contain a maintenance window policy describing a time period when disruptive maintenance tasks may be carried out. Omitting the policy implies that a window will be chosen automatically. See here for details.
kubernetes_delete_clusterDELETEcluster_idTo delete a Kubernetes cluster and all services deployed to it, send a DELETE request to /v2/kubernetes/clusters/$K8S_CLUSTER_ID. A 204 status code with no body will be returned in response to a successful request.
kubernetes_destroy_associated_resources_dangerousEXECcluster_idTo delete a Kubernetes cluster with all of its associated resources, send a DELETE request to /v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/dangerous. A 204 status code with no body will be returned in response to a successful request.
kubernetes_destroy_associated_resources_selectiveEXECcluster_idTo delete a Kubernetes cluster along with a subset of its associated resources, send a DELETE request to /v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective. The JSON body of the request should include load_balancers, volumes, or volume_snapshots keys each set to an array of IDs for the associated resources to be destroyed. The IDs can be found by querying the cluster's associated resources endpoint. Any associated resource not included in the request will remain and continue to accrue changes on your account.
kubernetes_get_kubeconfigEXECcluster_idThis endpoint returns a kubeconfig file in YAML format. It can be used to connect to and administer the cluster using the Kubernetes command line tool, kubectl, or other programs supporting kubeconfig files (e.g., client libraries). The resulting kubeconfig file uses 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 a kubeconfig file for use with a Kubernetes cluster, send a GET request to /v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig. 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/kubeconfig?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.
kubernetes_update_clusterEXECcluster_id, data__nameTo update a Kubernetes cluster, send a PUT request to /v2/kubernetes/clusters/$K8S_CLUSTER_ID and specify one or more of the attributes below.
kubernetes_upgrade_clusterEXECcluster_idTo immediately upgrade a Kubernetes cluster to a newer patch release of Kubernetes, send a POST request to /v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade. The body of the request must specify a version attribute. Available upgrade versions for a cluster can be fetched from /v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades.

SELECT examples

To list all of the Kubernetes clusters on your account, send a GET request to /v2/kubernetes/clusters.

SELECT
column_anon
FROM digitalocean.kubernetes.clusters
;

INSERT example

Use the following StackQL query and manifest file to create a new clusters resource.

/*+ create */
INSERT INTO digitalocean.kubernetes.clusters (
data__name,
data__region,
data__version,
data__cluster_subnet,
data__service_subnet,
data__vpc_uuid,
data__tags,
data__node_pools,
data__maintenance_policy,
data__auto_upgrade,
data__surge_upgrade,
data__ha,
data__control_plane_firewall
)
SELECT
'{{ name }}',
'{{ region }}',
'{{ version }}',
'{{ cluster_subnet }}',
'{{ service_subnet }}',
'{{ vpc_uuid }}',
'{{ tags }}',
'{{ node_pools }}',
'{{ maintenance_policy }}',
'{{ auto_upgrade }}',
'{{ surge_upgrade }}',
'{{ ha }}',
'{{ control_plane_firewall }}'
;

DELETE example

Deletes the specified clusters resource.

/*+ delete */
DELETE FROM digitalocean.kubernetes.clusters
WHERE cluster_id = '{{ cluster_id }}';