6. Deployment to Kubernetes on DigitalOcean#

It’s time to bring your workspace to the cloud! You will install packages that contain providers necessary for this deployment, and then you will build and apply deployment just like you did with local deployment.

But before that, you have to take care of a few things. The list includes:

  1. You need a DigitalOcean account.

  2. You need to obtain a DigitalOcean Personal Access Token.

If you don’t already have a DigitalOcean account, you can use our referral link and get $200 worth of credits: Use Torque’s Referral

(You can learn more about DigitalOcean’s referral program at DigitalOcean Referral Program )


How much will this cost me?

When you sign up for DigitalOcean, it will ask you for your credit card as a part of the account verification. If you use our referral link and get $200 worth of credits, your credit card won’t be charged for following this “Getting Started” guide.

On the other hand, here is an estimate of how much does it cost to deploy the workspace from this guide to DigitalOcean and to keep it up and running for a whole month:



Container Registy (Starter)


Kubernetes (1 Basic Node)


Load Balancer (starts from)


Managed Database (PostgreSQL Basic)


Total if kept running for 1 month.


It takes only one command to take all DigitalOcean provisioned resources down. The 8. “Deleting” the Deployment section introduces you to the way to strip the resources down with one command. You do not need to worry about dangling resources on DigitalOcean after finishing this tutorial.

Estimates were calculated from DigitalOcean’s pricing page: https://www.digitalocean.com/pricing

Next, you’ll need your DigitalOcean Personal Access Token. With your Personal Access Token, the DigitalOcean provider can deploy your workspace to DigitalOcean. Please follow the official guide: https://docs.digitalocean.com/reference/api/create-personal-access-token/

Now that you have a DigitalOcean Personal Access Token, you can use it for the DO_TOKEN environment variable used by the Torque CLI.

Installing packages#

Let’s install K8s and DigitalOcean packages that will enable the deployment.

torque package install git+https://github.com/torquetech/torque-do-provider && \
torque package install git+https://github.com/torquetech/torque-do-domains-provider && \
torque package install git+https://github.com/torquetech/torque-do-certificates-provider && \
torque package install git+https://github.com/torquetech/torque-do-managed-k8s-provider && \
torque package install git+https://github.com/torquetech/torque-do-managed-postgres-provider && \
torque package install git+https://github.com/torquetech/torque-do-managed-container-registry-provider && \
torque package install git+https://github.com/torquetech/torque-container-registry-provider && \
torque package install git+https://github.com/torquetech/torque-k8s-provider && \
torque package install git+https://github.com/torquetech/torque-k8s-do-volume-provider && \
torque package install git+https://github.com/torquetech/torque-k8s-do-hlb-provider && \
torque package install git+https://github.com/torquetech/torque-k8s-basics-provider

Creating deployment#

The deployment will use a combination of multiple providers related to DigitalOcean and Kubernetes. This trivial change makes all the difference. With just one parameter change, you will deploy your system on DigitalOcean using Kubernete instead of Docker Compose.

torque deployment create prod \
  torque.do.V1Provider torque.do_certificates.V1Provider torque.do_managed_k8s.V1Provider torque.do_managed_postgres.V1Provider torque.do_managed_container_registry.V1Provider torque.container_registry.V1Provider torque.k8s.V1Provider torque.k8s_do_volume.V1Provider torque.k8s_do_hlb.V1Provider torque.k8s_basics.V1Provider \
  --extra-config do.yaml

Notice that we referred to an additional configuration file do.yaml, and this file should be in your root directory. You can create do.yaml file:

touch do.yaml

And add the following content into it:

      quiet: false
      overrides: {}
      region: nyc3
      quiet: false
      overrides: {}
      subscription_tier_slug: basic
            domain: torquetech.io
            certificate_type: external
            key_file: key.pem
            certificate_file: server.pem

Or you can download it from do.yaml.

curl -L https://github.com/torquetech/docs-examples/releases/download/docs/do.yaml > do.yaml

And for the SSL to work properly you need to add a couple of pem files mentioned in the configuration. You can download them from key.pem and server.pem.

curl -L https://github.com/torquetech/docs-examples/releases/download/docs/key.pem > key.pem && \
curl -L https://github.com/torquetech/docs-examples/releases/download/docs/server.pem > server.pem

As mentioned, a new chapter on configurations and customizations is coming soon.

Deploying to DigitalOcean#

Once you have your DigitalOcean Personal Access Token, use this command to set DO_TOKEN environment variable run:

export DO_TOKEN=<dop_v1_replace_with_your_personal_access_token>

After you set DO_TOKEN, we are ready to build and apply prod deployment:

torque deployment build prod
torque deployment apply prod

The apply command will be waiting for all instances to be created on DigitalOcean and it might take up to half an hour until everything is up and running. But you do not need to worry about it, providers will do all the work.

After the apply command finishes, you can visit your DigitalOcean Dashboard to check created K8s cluster. DigitalOcean does a great job of explaining how to set up the kubectl config and use it to observe your K8s cluster.

Note: The same rules for managing infrastructure with Infrastructure as Code solutions apply: do not change anything manually. If you need to change something, do it through torque commands.

The IP address of your K8s cluster can be found at the DigitalOcean Dashboard. Open your project, select the prod-k8s cluster, and then the Resources tab. There is lb balancer inside the Load Balancers group. Select it, and the IP address will be at the top line. You can click it to copy it and then execute

curl -H "Host: api.torquetech.io" https://<IP address>/backend_srv -k

The output should be the current database time.

Database time: 2022-11-17T21:41:19.371349Z%