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.
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)
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
.
Unauthorized
API Rate limit exceeded
Server error.
Unexpected error