Skip to content

Commit b086a7c

Browse files
authored
Merge pull request #709 from kvinwang/fix/dstack-cloud-private-ip
dstack-cloud: honor gcp_config.private_ip (bind static internal IP)
2 parents 8f86e43 + 1b1b505 commit b086a7c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

scripts/bin/dstack-cloud

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class GcpConfig:
196196
# Network settings
197197
network: str = "default"
198198
subnet: str = ""
199+
private_ip: str = "" # static internal IP to bind (--private-network-ip)
199200

200201
# Identity settings
201202
service_account: str = ""
@@ -236,6 +237,7 @@ class GcpConfig:
236237
"bucket": "",
237238
"network": "default",
238239
"subnet": "",
240+
"private_ip": "",
239241
"service_account": "",
240242
"scopes": [],
241243
"tags": [],
@@ -1408,6 +1410,13 @@ class CloudDeploymentManager:
14081410
create_args.append(f"--network={config.network}")
14091411
if config.subnet:
14101412
create_args.append(f"--subnet={config.subnet}")
1413+
if config.private_ip:
1414+
# Bind a reserved static internal IP so the VM keeps the same RFC1918
1415+
# address across remove/deploy. --private-network-ip needs the subnet
1416+
# named, so default it when the user didn't set one.
1417+
if not config.subnet:
1418+
create_args.append("--subnet=default")
1419+
create_args.append(f"--private-network-ip={config.private_ip}")
14111420
if config.service_account:
14121421
create_args.append(f"--service-account={config.service_account}")
14131422
if config.scopes:

0 commit comments

Comments
 (0)