API v2 Changelog

< Back to Changelog

API Support for DigitalOcean Kubernetes

Date: December 11, 2018

Tagged In: API v2

Author Andrew Starr-Bochicchio

Today we opened up access to the DigitalOcean Kubernetes service for all users. As part of this release, the API is now also available to all. While still in Limited Availability, you must first enable Kubernetes on your account by opting-in via the cloud control panel to access these endpoints.

Once enabled, you will be able to list, create, or delete clusters as well as scale node pools up and down, recycle individual nodes, and retrieve the kubeconfig file for use with a cluster via the API. For example, to create a new cluster with a node pool using three s-2vcpu-2gb Droplets, make a POST to the /v2/kubernetes/clusters endpoint with a JSON body like:

{
  "name": "prod-cluster-01",
  "region": "nyc1",
  "version": "1.12.1-do.2",
  "tags": ["production"],
  "node_pools": [
    {
      "size": "s-2vcpu-2gb",
      "count": 3,
      "name": "woker-pool"
    }
  ]
}

The response will include a full JSON representation of the cluster. The initial value of the cluster’s status.state attribute will be “provisioning.” When the cluster is ready for use, this will transition to “running.” You can use the /v2/kubernetes/options endpoint to find the available versions of Kubernetes as well as the supported regions and Droplet sizes.

Once ready, you can retrieve the credentials for use with the cluster by sending a GET request to /v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig. The response will be a kubeconfig file in yaml format. This file can be used to connect to and administer the cluster using the Kubernetes command line tool, kubectl. For more information, see “How to Connect to a DigitalOcean Kubernetes Cluster with kubectl.”

For the all the details, see the full API reference documentation for DigitalOcean Kubernetes.