How to Integrate with a DigitalOcean Container Registry

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.


On DigitalOcean, you can integrate your Kubernetes cluster with a container registry via the control panel. This process requires you to have an existing container registry. If you don’t have an existing registry, first create one.

To integrate a cluster, go to the control panel and click the Kubernetes cluster you want to integrate. Then, click the Settings tab, scroll down to the DigitalOcean Container Registry Integration section, and click Edit to the right.

Check your container registry and click Save to confirm your change.

Settings tab in the control panel, the DigitalOcean Container Registry Integration section

For instructions on integrating a Kubernetes cluster and container registry via generated secrets or kubectl, see our guide.

Add a Container Registry to a Cluster Using Automation

How to add a container registry using the DigitalOcean CLI

To add a container registry 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, add a container registry with doctl kubernetes cluster registry add. The basic usage looks like this, but you'll want to read the usage docs for more details:

                  doctl kubernetes cluster registry add <cluster-id|cluster-name> <cluster-id|cluster-name> [flags]
                

    The following example adds container registry support to a cluster named example-cluster

                       doctl kubernetes cluster registry add example-cluster
                    
How to add a container registry using the DigitalOcean API

To add a container registry using the DigitalOcean API, follow these steps:

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

  2. Send a POST request to https://api.digitalocean.com/v2/kubernetes/registry

    cURL

    To add a container registry with cURL, call:

    
                    curl -X POST \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      -d '{"cluster_uuids": ["bd5f5959-5e1e-4205-a714-a914373942af", "50c2f44c-011d-493e-aee5-361a4a0d1844"]}' \
      "https://api.digitalocean.com/v2/kubernetes/registry"

    Go

    Go developers can use Godo, the official DigitalOcean V2 API client for Go. To add a container registry 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()
    
        _, err := client.Kubernetes.AddRegistry(ctx, &godo.KubernetesClusterRegistryRequest{ClusterUUIDs: []string{"bd5f5959-5e1e-4205-a714-a914373942af"}})
    }

    Python

    
                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    req = {
      "cluster_uuids": [
        "bd5f5959-5e1e-4205-a714-a914373942af",
        "50c2f44c-011d-493e-aee5-361a4a0d1844"
      ]
    }
    
    resp = client.kubernetes.add_registry(body=req)