pydo.kubernetes.create_cluster()

Description

To 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.

Request Sample

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "name": "prod-cluster-01",
  "region": "nyc1",
  "version": "1.18.6-do.0",
  "node_pools": [
    {
      "size": "s-1vcpu-2gb",
      "count": 3,
      "name": "worker-pool"
    }
  ]
}

resp = client.kubernetes.create_cluster(body=req)

Responses

See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.

The response will be a JSON object with a key called kubernetes_cluster. The value of this will be an object containing the standard attributes of a Kubernetes cluster.

The IP address and cluster API server endpoint will not be available until the cluster has finished provisioning. The initial value of the cluster’s status.state attribute will be provisioning. When the cluster is ready, this will transition to running.

Click to expand an example response for Kubernetes Cluster Response.
{
  "value": {
    "kubernetes_cluster": {
      "id": "bd5f5959-5e1e-4205-a714-a914373942af",
      "name": "prod-cluster-01",
      "region": "nyc1",
      "version": "1.18.6-do.0",
      "cluster_subnet": "10.244.0.0/16",
      "service_subnet": "10.245.0.0/16",
      "vpc_uuid": "c33931f2-a26a-4e61-b85c-4e95a2ec431b",
      "ipv4": "",
      "endpoint": "",
      "tags": [
        "k8s",
        "k8s:bd5f5959-5e1e-4205-a714-a914373942af"
      ],
      "node_pools": [
        {
          "id": "cdda885e-7663-40c8-bc74-3a036c66545d",
          "name": "worker-pool",
          "size": "s-1vcpu-2gb",
          "count": 3,
          "tags": [
            "k8s",
            "k8s:bd5f5959-5e1e-4205-a714-a914373942af",
            "k8s:worker"
          ],
          "labels": null,
          "taints": [],
          "auto_scale": false,
          "min_nodes": 0,
          "max_nodes": 0,
          "nodes": [
            {
              "id": "478247f8-b1bb-4f7a-8db9-2a5f8d4b8f8f",
              "name": "",
              "status": {
                "state": "provisioning"
              },
              "droplet_id": "",
              "created_at": "2018-11-15T16:00:11Z",
              "updated_at": "2018-11-15T16:00:11Z"
            },
            {
              "id": "ad12e744-c2a9-473d-8aa9-be5680500eb1",
              "name": "",
              "status": {
                "state": "provisioning"
              },
              "droplet_id": "",
              "created_at": "2018-11-15T16:00:11Z",
              "updated_at": "2018-11-15T16:00:11Z"
            },
            {
              "id": "e46e8d07-f58f-4ff1-9737-97246364400e",
              "name": "",
              "status": {
                "state": "provisioning"
              },
              "droplet_id": "",
              "created_at": "2018-11-15T16:00:11Z",
              "updated_at": "2018-11-15T16:00:11Z"
            }
          ]
        }
      ],
      "maintenance_policy": {
        "start_time": "00:00",
        "duration": "4h0m0s",
        "day": "any"
      },
      "auto_upgrade": false,
      "status": {
        "state": "provisioning",
        "message": "provisioning"
      },
      "created_at": "2018-11-15T16:00:11Z",
      "updated_at": "2018-11-15T16:00:11Z",
      "surge_upgrade": false,
      "registry_enabled": false,
      "ha": false,
      "control_plane_firewall": {
        "enabled": true,
        "allowed_addresses": [
          "1.2.3.4/32",
          "1.1.0.0/16"
        ]
      }
    }
  }
}
Click to expand an example response for Kubernetes Cluster with Multiple Node Pools Response.
{
  "value": {
    "kubernetes_clusters": {
      "id": "bd5f5959-5e1e-4205-a714-a914373942af",
      "name": "prod-cluster-01",
      "region": "nyc1",
      "version": "1.18.6-do.0",
      "cluster_subnet": "10.244.0.0/16",
      "service_subnet": "10.245.0.0/16",
      "vpc_uuid": "c33931f2-a26a-4e61-b85c-4e95a2ec431b",
      "ipv4": "",
      "endpoint": "",
      "tags": [
        "production",
        "web-team",
        "k8s",
        "k8s:bd5f5959-5e1e-4205-a714-a914373942af"
      ],
      "node_pools": [
        {
          "id": "cdda885e-7663-40c8-bc74-3a036c66545d",
          "name": "frontend-pool",
          "size": "s-1vcpu-2gb",
          "count": 3,
          "tags": [
            "production",
            "web-team",
            "frontend",
            "k8s",
            "k8s:bd5f5959-5e1e-4205-a714-a914373942af",
            "k8s:worker"
          ],
          "labels": null,
          "taints": [],
          "auto_scale": false,
          "min_nodes": 0,
          "max_nodes": 0,
          "nodes": [
            {
              "id": "478247f8-b1bb-4f7a-8db9-2a5f8d4b8f8f",
              "name": "",
              "status": {
                "state": "provisioning"
              },
              "droplet_id": "",
              "created_at": "2018-11-15T16:00:11Z",
              "updated_at": "2018-11-15T16:00:11Z"
            },
            {
              "id": "ad12e744-c2a9-473d-8aa9-be5680500eb1",
              "name": "",
              "status": {
                "state": "provisioning"
              },
              "droplet_id": "",
              "created_at": "2018-11-15T16:00:11Z",
              "updated_at": "2018-11-15T16:00:11Z"
            },
            {
              "id": "e46e8d07-f58f-4ff1-9737-97246364400e",
              "name": "",
              "status": {
                "state": "provisioning"
              },
              "droplet_id": "",
              "created_at": "2018-11-15T16:00:11Z",
              "updated_at": "2018-11-15T16:00:11Z"
            }
          ]
        },
        {
          "id": "f49f4379-7e7f-4af5-aeb6-0354bd840778",
          "name": "backend-pool",
          "size": "g-4vcpu-16gb",
          "count": 2,
          "tags": [
            "production",
            "web-team",
            "k8s",
            "k8s:bd5f5959-5e1e-4205-a714-a914373942af",
            "k8s:worker"
          ],
          "labels": {
            "service": "backend",
            "priority": "high"
          },
          "taints": [],
          "auto_scale": true,
          "min_nodes": 2,
          "max_nodes": 5,
          "nodes": [
            {
              "id": "3385619f-8ec3-42ba-bb23-8d21b8ba7518",
              "name": "",
              "status": {
                "state": "provisioning"
              },
              "droplet_id": "",
              "created_at": "2018-11-15T16:00:11Z",
              "updated_at": "2018-11-15T16:00:11Z"
            },
            {
              "id": "4b8f60ff-ba06-4523-a6a4-b8148244c7e6",
              "name": "",
              "status": {
                "state": "provisioning"
              },
              "droplet_id": "",
              "created_at": "2018-11-15T16:00:11Z",
              "updated_at": "2018-11-15T16:00:11Z"
            }
          ]
        }
      ],
      "maintenance_policy": {
        "start_time": "12:00",
        "duration": "4h0m0s",
        "day": "any"
      },
      "auto_upgrade": false,
      "status": {
        "state": "provisioning",
        "message": "provisioning"
      },
      "created_at": "2018-11-15T16:00:11Z",
      "updated_at": "2018-11-15T16:00:11Z",
      "surge_upgrade": false,
      "registry_enabled": false,
      "ha": false,
      "control_plane_firewall": {
        "enabled": true,
        "allowed_addresses": [
          "1.2.3.4/32",
          "1.1.0.0/16"
        ]
      }
    }
  }
}

Unauthorized

Click to expand an example response.
{
  "id": "unauthorized",
  "message": "Unable to authenticate you."
}

API Rate limit exceeded

Click to expand an example response.
{
  "id": "too_many_requests",
  "message": "API Rate limit exceeded."
}

Server error.

Click to expand an example response.
{
  "id": "server_error",
  "message": "Unexpected server-side error"
}

Unexpected error

Click to expand an example response.
{
  "id": "example_error",
  "message": "some error message"
}