Pulumi Project Setup and Integration with DigitalOcean CLI (doctl)
This document provides a step-by-step guide on how to start and set up a Pulumi project and integrate it with the DigitalOcean CLI (doctl) for managing infrastructure on DigitalOcean.
Prerequisites
Before you begin, ensure you have the following tools installed on your machine:
- Pulumi CLI
- Node.js (Required if using JavaScript/TypeScript for Pulumi)
- Python (Required if using Python for Pulumi)
- doctl (DigitalOcean CLI)
- Git
In our example we are using the typescript option
Step 1: Install Pulumi
Follow the official Pulumi installation guide to install Pulumi on your system. You can verify the installation by running:
Step 2: Set Up a New Pulumi Project in case you need
mkdir my-pulumi-project
cd my-pulumi-project
pulumi new typescriptStep 3: Install doctl https://docs.digitalocean.com/reference/doctl/how-to/install/
STEP 4: Generate doctl token on the API section on Digital Ocean
STEP 5: Export the token just generated:
export DIGITALOCEAN_TOKEN="YOUR_TOKEN_HERE"
STEP 6: Authenticate doctl with your Digital Ocean token just generated
STEP 6.1: Authenticate with docker and digital ocean registry
docker login -u "youruser" -p "yourtoken" registry.digitalocean.com
STEP 7: Tag the image of your application:
docker tag YOUR_IMAGE registry.digitalocean.com/YOUR_REGISTRY/YOUR_IMAGE
STEP 8: Push your image to the Digital Ocean Docker Registry
docker push registry.digitalocean.com/YOUR_REGISTRY/YOUR_IMAGE
STEP 09: Go to the project infra repository and run the following commands to first create the cluster, make sure to have export the env for the digitalocean token Kubeconfig path:
To make sure we are using the right cluster versions run:
doctl kubernetes options versions
pulumi up doctl kubernetes cluster kubeconfig save the clusteName
STEP 10: Run the following command to see if the current cluster is the same you created:
kubectl config current-context
STEP 11: run the following command to add this a secret to the cluster:
kubectl create secret generic digitalocean-dns --from-literal=access-token="yourtoken" --namespace defaultStep 12: After creating the cluster secret responsible to verify the DNS you can go to the service-infra repo and run:
Made with ❤️ by Stoix

