Skip to content
DigitalOcean

Deploy Your First Cluster

Validated on 31 May 2023 · Last edited on 10 Oct 2023

DigitalOcean Kubernetes gives you a managed control plane and a set of worker nodes you pay for as Droplets. You choose the version, the region and the shape of the node pools; the control plane itself is operated for you.


Getting to a running workload is three steps: create the cluster, point kubectl at it, and apply a manifest.

Create a Cluster

In the control panel, click Create and choose Kubernetes.

  1. Kubernetes version. You can pick any of the three most recent minor versions. The latest stable release is selected by default and is the right choice for a new cluster.
  2. Datacenter region. This is where both the control plane and the worker nodes live. Check that the region offers the node types you want before committing to it.
  3. VPC network. Use the default network for the region or choose an existing VPC.
  4. Node pools. Name the pool, choose a machine type, and either fix the node count or turn on autoscaling and give it a range.
  5. Cluster details. Name the cluster, assign it to a project, add any tags, then create it. Provisioning takes a few minutes.

On Kubernetes 1.31 and later you also choose pod and service subnets in CIDR notation. DigitalOcean suggests non-overlapping ranges for you. These cannot be widened later, so if you expect the cluster to grow, take the larger suggestion rather than the tighter one.

The equivalent command needs a name, a region and a version:

doctl kubernetes cluster create example-cluster --region nyc1 --version latest

Connect kubectl to the Cluster

You need kubectl installed and within one minor version of the cluster, and doctl authenticated. One command then downloads the cluster’s credentials, merges them into your existing ~/.kube/config and switches to that context:

doctl kubernetes cluster kubeconfig save example-cluster

Check that it worked:

kubectl get nodes

You should see one line per worker node, each in the Ready state. If a node is still showing NotReady a minute after the cluster reports as provisioned, give it a moment longer before investigating: nodes finish joining slightly after the cluster is considered up.

Deploy Your Application

With a working context, deploying is ordinary Kubernetes. Apply a manifest:

kubectl apply -f deployment.yaml

To reach the application from outside the cluster, expose it with a service of type LoadBalancer. DigitalOcean provisions a real load balancer to match, and its public IP appears against the service once it is ready:

kubectl get service --watch

That load balancer is a billed resource in its own right, created and destroyed with the service. Deleting the service deletes the load balancer; deleting the cluster without deleting the service can leave it behind, so check your resources after tearing a cluster down.