Skip to main content

Run a dstack-kms CVM on GCP

Run your own dstack-kms instance on GCP so you have full control over key policy. This page covers the production deployment workflow: bootstrap the KMS, register its attestation on-chain, and verify it’s serving keys correctly.
Reference: This guide is based on the official deployment guide.
Platform Requirement: dstack-cloud deploy must be run on Linux. macOS is not supported because the FAT32 shared disk image created by macOS dosfstools fails GCP image validation.

Prerequisites

  • A GCP project with Confidential VM (TDX) quota
  • gcloud CLI installed and authenticated (gcloud auth login)
  • gsutil available in PATH (required by dstack-cloud deploy for GCS upload)
  • docker / docker compose
  • node + npm (for smart contract deployment)
  • jq
  • mtools (provides mcopy)
  • dosfstools (provides mkfs.fat)
  • dstack-cloud CLI installed:
  • For on-chain governance mode:
    • A blockchain RPC endpoint (e.g., https://sepolia.base.org)
    • A wallet with sufficient balance
    • Deployed smart contracts (DstackKms, DstackApp) — see Deploy On-chain KMS Smart Contracts
    • You’ll need KMS_CONTRACT_ADDR and APP_CONTRACT_ADDR before KMS bootstrap/finish
Note: This guide uses pre-built KMS Docker images. If you need to build KMS from source or customize configuration, see the official KMS build guide.

Step 1: Configure dstack-cloud

Follow the same steps as Run a Workload on GCP to set up your global config and GCS bucket.

Step 2: Pull the OS Images

Follow the same steps as Run a Workload on GCP to download the dstack-cloud-0.6.0 images.
If disk.raw is missing, deployment may create a VM that cannot boot (UEFI loop: Failed to load image).

Step 3: Create a KMS Project

Generated files include:
  • app.json
  • docker-compose.yaml
  • prelaunch.sh

Step 4: Build or Select KMS Docker Image

Use pre-built image or build your own:

Step 5: Configure KMS Runtime

Replace generated compose/prelaunch with KMS config.
The compose templates below come from:
Phala-Network/dstack-cloud-deployment-guide
Clone that repo first if you only cloned this docs repo.

Option A: Direct RPC

Create prelaunch.sh:

Option B: Light Client (Helios)

prelaunch.sh can stay the same unless your template requires different vars.

Step 6: Deploy KMS CVM

If bucket does not exist, create explicitly first:

Step 7: Open Firewall

For light-client mode:
Port notes:
  • 12001/tcp: KMS API (required)
  • 18000/tcp: auth-api debug endpoint (optional)
  • 18545/tcp: helios RPC (light mode only)

Step 8: Bootstrap (First-time)

8.1 Check KMS endpoint

8.2 Get attestation info

Capture:
  • device_id
  • mr_aggregated
  • os_image_hash

8.3 Register measurements on-chain (required for on-chain mode)

device_id must come from Onboard.GetAttestationInfo (not dummy serial-console value).

8.4 Run bootstrap

8.5 Finish


Step 9: Verify


Common Issues


Cleanup

Or manually:

Next Steps