How to Enable High Availability

DigitalOcean Kubernetes (DOKS) is a managed Kubernetes service. Deploy Kubernetes clusters with a fully managed control plane, high availability, autoscaling, and native integration with DigitalOcean Load Balancers and volumes. DOKS clusters are compatible with standard Kubernetes toolchains and the DigitalOcean API and CLI.


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
  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, run doctl kubernetes cluster update. Basic usage looks like this, but you can 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:

                  doctl kubernetes cluster update example-cluster --auto-upgrade --maintenance-window saturday=02:00
                
How to Update a Kubernetes Cluster Using the DigitalOcean API
  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

    Using cURL:

                    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

    Using Godo, the official DigitalOcean V2 API client for Go:

                    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

    Using DropletKit, the official DigitalOcean V2 API client for Ruby:

                    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.