How to Enable High Availability

DigitalOcean Kubernetes (DOKS) is a managed Kubernetes service that lets you deploy Kubernetes clusters without the complexities of handling the control plane and containerized infrastructure. Clusters are compatible with standard Kubernetes toolchains, integrate natively with DigitalOcean Load Balancers and volumes, and can be managed programmatically using the API and command line. For critical workloads, add the high-availability control plane to increase uptime with 99.95% SLA.


DigitalOcean Kubernetes provides a high availability (HA) option that provides 99.95% SLA uptime for control planes by creating multiple backup replicas of each control plane component. You can enable high availability for your Kubernetes cluster during cluster creation or on an existing cluster on version 1.22 and later. This guide describes how to enable HA in the control panel; however, you can also do so through command line by using doctl v1.87.0 or later.

Enable High Availability Using Automation

You can enable high availability using the DigitalOcean Kubernetes doctl update command or API endpoint by setting the ha value to true.

How to update a Kubernetes cluster using the DigitalOcean CLI

To update a Kubernetes cluster via the command-line, follow these steps:

  1. Install doctl, the DigitalOcean command-line tool.

  2. Create a personal access token, and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

                  doctl auth init
                
  4. Finally, update a Kubernetes cluster with doctl kubernetes cluster update. The basic usage looks like this, but you'll want to read the usage docs for more details:

                  doctl kubernetes cluster update <id|name> [flags]
                

    The following example updates a cluster named example-cluster to enable automatic upgrades and sets the maintenance window to `saturday=02

                  00`
                
How to update a Kubernetes cluster using the DigitalOcean API

To update a Kubernetes cluster using the DigitalOcean API, follow these steps:

  1. Create a personal access token, and save it for use with the API.

  2. Send a PUT request to https://api.digitalocean.com/v2/kubernetes/clusters/{cluster_id}

    cURL

    To update a Kubernetes cluster with cURL, call:

    
                    curl -X PUT \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      -d '{"name": "stage-cluster-01", "tags":["staging", "web-team"]}' \
      "https://api.digitalocean.com/v2/kubernetes/clusters/bd5f5959-5e1e-4205-a714-a914373942af"

    Go

    Go developers can use Godo, the official DigitalOcean V2 API client for Go. To update a Kubernetes cluster with Godo, use the following code:

    
                    import (
        "context"
        "os"
    
        "github.com/digitalocean/godo"
    )
    
    func main() {
        token := os.Getenv("DIGITALOCEAN_TOKEN")
    
        client := godo.NewFromToken(token)
        ctx := context.TODO()
    
        updateRequest := &godo.KubernetesClusterUpdateRequest{
            Name: "stage-cluster-01",
            Tags: []string{"staging", "web-team"},
        }
    
        cluster, _, err := client.Kubernetes.Update(ctx, "bd5f5959-5e1e-4205-a714-a914373942af", updateRequest)
    }

    Ruby

    Ruby developers can use DropletKit, the official DigitalOcean V2 API client for Ruby. To update a Kubernetes cluster with DropletKit, use the following code:

    
                    require 'droplet_kit'
    token = ENV['DIGITALOCEAN_TOKEN']
    client = DropletKit::Client.new(access_token: token)
    
    cluster = DropletKit::KubernetesCluster.new(
      name: 'foo',
      tags: ['staging', 'web-team']
    )
    
    client.kubernetes_clusters.update(cluster, id: 'bd5f5959-5e1e-4205-a714-a914373942af')

    Python

    
                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    req = {
      "name": "prod-cluster-01",
      "tags": [
        "k8s",
        "k8s:bd5f5959-5e1e-4205-a714-a914373942af",
        "production",
        "web-team"
      ],
      "maintenance_policy": {
        "start_time": "12:00",
        "day": "any"
      },
      "auto_upgrade": True,
      "surge_upgrade": True,
      "ha": True
    }
    
    resp = client.kubernetes.update_cluster(cluster_id="1fd32a", body=req)

Enable High Availability Using the Control Panel

To enable high availability on an existing cluster, go to the control panel and click on the cluster you want to enable high availability on. Then, in the Overview tab, scroll down and find the following card.

Add high availability
I can’t find this card.

DigitalOcean Kubernetes clusters originally created with version 1.20 or older have a version of the control plane which does not allow you to enable high availability. If you cannot find this card, upgrade your control plane.

To check whether you can upgrade your cluster to the new control plane, see Upgrading to New Control Plane.

In the card, click Add high availability. This opens a pop-up window where you can confirm your change. Once enabled, you cannot disable high availability in the future.