Skip to content
Tutorials Center
My learning

Topics

Lesson 19 of 35 ยท Kubernetes

DigitalOcean Kubernetes: Clusters and Node Pools

Learn how DigitalOcean Kubernetes (DOKS) clusters work: the managed control plane, node pools, doctl commands, kubeconfig and how pods fit onto nodes.

DigitalOcean Kubernetes (DOKS) is a managed Kubernetes service. DigitalOcean runs the control plane for you (the API server, scheduler, etcd and controllers), and you pay for the worker nodes, which are ordinary Droplets. You get a real, conformant Kubernetes cluster, but you never patch or back up the control plane yourself.

This lesson explains the pieces of a cluster, how to create one with doctl, and how the scheduler decides where pods go. Remember that DigitalOcean itself cannot run on this site, so the commands are shown as read-only text and the runnable examples are clearly labelled Python stand-ins that teach the same ideas.

Every command below is shown without output on purpose. Cloud output contains IDs and versions that change, so we only show text we can be certain about. The Python blocks are stand-ins: they model the scheduling logic, not the real DigitalOcean service.

The shape of a DOKS cluster

A cluster has two halves. The control plane is managed and invisible: you do not see its machines in your Droplet list. The node pools are groups of identical worker Droplets that you do see (they are labelled as belonging to the cluster, and you should not edit them by hand in the Droplet UI).

flowchart LR
  subgraph DO["Managed by DigitalOcean"]
    CP["Control plane<br/>API server, scheduler, etcd"]
  end
  subgraph YOU["Your account"]
    P1["Node pool: web<br/>3 x s-2vcpu-4gb"]
    P2["Node pool: jobs<br/>2 x s-4vcpu-8gb"]
  end
  CP --> P1
  CP --> P2
  kubectl["kubectl / doctl"] --> CP

The control plane schedules pods onto the nodes of your pools; you talk to the API server with kubectl.

Some facts worth remembering:

  • The standard control plane is included at no charge. An optional high-availability control plane has a monthly fee and spreads the API server across several machines.
  • Worker nodes are billed like Droplets, so a node pool of three 2 vCPU / 4 GB nodes costs three times one node.
  • Nodes sit in a VPC, so pods and nodes can talk to your other resources over the private network (see the networking lessons).
  • Every node pool has a size (Droplet slug), a count or an autoscale range, and optional labels and taints.

Creating a cluster with doctl

You need an API token and doctl auth init first (covered in the doctl lesson). Then:

Terminal
doctl kubernetes options versions
doctl kubernetes options regions
doctl kubernetes options sizes

doctl kubernetes cluster create shop-cluster \
  --region nyc1 \
  --version latest \
  --node-pool "name=web;size=s-2vcpu-4gb;count=3" \
  --node-pool "name=jobs;size=s-4vcpu-8gb;count=1;label=workload=batch"

The options commands list what is currently valid, which is better than memorising slugs. A --node-pool value is a semicolon-separated list of key=value pairs. By default doctl also saves the cluster credentials into your kubeconfig and switches the current context to the new cluster. To do that for an existing cluster:

Terminal
doctl kubernetes cluster kubeconfig save shop-cluster
kubectl config current-context
kubectl get nodes

The saved kubeconfig uses doctl to fetch short-lived credentials, so keep doctl installed and authenticated on the machine where you run kubectl.

A stand-in parser for --node-pool

The string format is easy to get wrong. This stand-in parses it and flags mistakes, which is exactly the kind of checking doctl does for you.

Python Stand-in: parse a --node-pool string

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

How the scheduler places pods

Each node reserves some CPU and memory for the operating system, the kubelet and system pods, so the allocatable amount is lower than the Droplet size. Pods declare requests (what they need to be scheduled) and the scheduler only places a pod on a node with enough unreserved allocatable capacity. A pod that fits nowhere stays Pending, which is the most common reason people add nodes.

Here is a deliberately simple first-fit scheduler. The real one scores nodes with many rules, but the core "does it fit" check is the same.

Python Stand-in: first-fit pod scheduling

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Run it and note which pod stays Pending. Adding a third node to the pool, or giving pods smaller requests, would fix it. That is the daily tradeoff: requests that are too large waste money, requests that are too small cause noisy neighbours.

Choosing node pool sizes

  • Several small pools beat one big pool. Put web pods on one pool and batch jobs on another so a runaway job cannot starve your site. Use labels plus nodeSelector, or taints and tolerations, to steer pods.
  • Pick node sizes with headroom. Three 2 vCPU nodes tolerate losing one node better than one 6 vCPU node does.
  • Check regions and versions. Pods in a cluster are in a single region; the Kubernetes version you pick receives patches, and old minor versions are retired (see scaling and upgrades).
  • Do not manage nodes by hand. Resize or delete nodes through the cluster or node pool, never from the Droplet page, or the cluster will recreate them.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Who operates the DOKS control plane?

    DOKS is managed Kubernetes: DigitalOcean runs the API server, scheduler and etcd, and you pay for the worker nodes.
  2. 2. A pod stays Pending because no node has enough free CPU. What is a valid fix?

    The scheduler needs a node with enough unreserved allocatable capacity, so you add capacity or reduce the request.
  3. 3. What does doctl kubernetes cluster kubeconfig save do?

    It writes a context for the cluster into your kubeconfig so kubectl can talk to it.
  4. 4. Why use separate node pools for web and batch workloads?

    Pools let you size, scale and isolate workloads independently.

Summary

  • DOKS gives you a managed control plane; you pay for worker nodes (Droplets), grouped in node pools.
  • doctl kubernetes cluster create takes one or more --node-pool specs; doctl kubernetes options lists valid sizes, regions and versions.
  • The scheduler places pods using requests against allocatable capacity; unplaceable pods stay Pending.
  • Use several pools with labels or taints, and manage nodes only through the cluster.

Next: Deployments and Services on DOKS