Skip to content

dstack-cloud: honor gcp_config.private_ip (bind static internal IP)#709

Merged
kvinwang merged 1 commit into
Dstack-TEE:masterfrom
kvinwang:fix/dstack-cloud-private-ip
Jun 4, 2026
Merged

dstack-cloud: honor gcp_config.private_ip (bind static internal IP)#709
kvinwang merged 1 commit into
Dstack-TEE:masterfrom
kvinwang:fix/dstack-cloud-private-ip

Conversation

@kvinwang

@kvinwang kvinwang commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

GcpConfig has no private_ip field, so a private_ip set in an app's app.json is silently dropped when the config is loaded (from_dict filters to known dataclass fields), and prepare/deploy then rewrite app.json stripping the field. The VM is also never created with --private-network-ip, so it always gets an ephemeral internal IP.

This breaks any deployment that addresses a VM by a stable internal IP across remove+deploy — e.g. an in-VPC KMS whose TLS cert SAN / kms_urls pin a fixed RFC1918 address. After a redeploy the IP changes and clients can no longer reach (or verify) the service.

Fix

  • Add private_ip: str = "" to GcpConfig (and to get_template()).
  • In the instance create_args, when private_ip is set, pass --private-network-ip=<ip> (and default --subnet=default when the user didn't name a subnet, since gcloud requires the subnet for a custom internal IP).

Reserve the address first, e.g.:

gcloud compute addresses create my-kms-ip --region=us-central1 --subnet=default --addresses=10.128.15.220

then set gcp_config.private_ip = "10.128.15.220" in app.json. The VM now keeps that address across redeploys.

Testing

Deployed two CVMs with reserved static IPs (10.128.15.220 / 10.128.15.230); deploy output's Internal IP matched the reserved addresses, and they stayed stable across remove+deploy. Without the patch the same configs produced ephemeral IPs.

Backwards compatible: when private_ip is empty (the default), behavior is unchanged.

GcpConfig had no private_ip field, so a private_ip set in app.json was silently
dropped on load (and prepare/deploy rewrite app.json, stripping it), and the VM
was never created with --private-network-ip — it always got an ephemeral internal
IP. That breaks any service addressed by a stable internal IP across remove/deploy
(e.g. an in-VPC KMS whose TLS cert SAN / kms_urls pin a fixed address).

Add the field and pass --private-network-ip (defaulting --subnet=default when the
user didn't name one, since gcloud requires the subnet for a custom internal IP).
Copilot AI review requested due to automatic review settings June 4, 2026 08:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kvinwang kvinwang enabled auto-merge June 4, 2026 08:17
@kvinwang kvinwang merged commit b086a7c into Dstack-TEE:master Jun 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants