Skip to content

Commit

Permalink
Configure scheduler internal/external ip with public_ingress option (#…
Browse files Browse the repository at this point in the history
…164)

* configure scheduler internal/external ip with public_ingress option

* Black

* do not create public address if public_ingress is false

* Bump GHA setup-miniconda version

* Bump GHA setup-miniconda version for imports too

Co-authored-by: Jacob Tomlinson <jtomlinson@nvidia.com>
  • Loading branch information
quasiben and jacobtomlinson committed Nov 17, 2020
1 parent 861b92c commit d5dfd99
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v2

- name: Setup Conda Environment
uses: goanpeca/setup-miniconda@v1.7.0
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
uses: actions/checkout@v2

- name: Setup Conda Environment
uses: goanpeca/setup-miniconda@v1.7.0
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
python-version: "3.7"
Expand Down
1 change: 1 addition & 0 deletions dask_cloudprovider/cloudprovider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ cloudprovider:
gpu_type: "" # type of gpus to use: nvidia-tesla-k80, nvidia-tesla-p100, nvidia-tesla-t4
docker_image: "daskdev/dask:latest" # docker image to use
auto_shutdown: true # Shutdown instances automatically if the scheduler or worker services time out.
public_ingress: true # configure the scheduler to be externally accessible. This assumes firefwall rules for 8787 and 8786
37 changes: 26 additions & 11 deletions dask_cloudprovider/gcp/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ def create_gcp_config(self):
{
"kind": "compute#networkInterface",
"subnetwork": f"projects/{self.projectid}/regions/{self.general_zone}/subnetworks/default",
"accessConfigs": [
{
"kind": "compute#accessConfig",
"name": "External NAT",
"type": "ONE_TO_ONE_NAT",
"networkTier": "PREMIUM",
}
],
"aliasIpRanges": [],
}
],
Expand Down Expand Up @@ -162,6 +154,16 @@ def create_gcp_config(self):
"reservationAffinity": {"consumeReservationType": "ANY_RESERVATION"},
}

if self.config.get("public_ingress", True):
config["networkInterfaces"][0]["accessConfigs"] = [
{
"kind": "compute#accessConfig",
"name": "External NAT",
"type": "ONE_TO_ONE_NAT",
"networkTier": "PREMIUM",
}
]

if self.ngpus:
config["guestAccelerators"] = [
{
Expand Down Expand Up @@ -201,7 +203,10 @@ async def create_vm(self):
await asyncio.sleep(0.5)

self.internal_ip = self.get_internal_ip()
self.external_ip = self.get_external_ip()
if self.config.get("public_ingress", True):
self.external_ip = self.get_external_ip()
else:
self.external_ip = None
self.cluster._log(
f"{self.name}\n\tInternal IP: {self.internal_ip}\n\tExternal IP: {self.external_ip}"
)
Expand Down Expand Up @@ -272,7 +277,13 @@ async def start_scheduler(self):
)
self.cluster._log("Creating scheduler instance")
self.internal_ip, self.external_ip = await self.create_vm()
self.address = f"tcp://{self.external_ip}:8786"

if self.config.get("public_ingress", True):
# scheduler is publicly available
self.address = f"tcp://{self.external_ip}:8786"
else:
# scheduler is only accessible within VPC
self.address = f"tcp://{self.internal_ip}:8786"
await self.wait_for_scheduler()

# need to reserve internal IP for workers
Expand Down Expand Up @@ -325,7 +336,11 @@ async def start(self):
async def start_worker(self):
self.cluster._log("Creating worker instance")
self.internal_ip, self.external_ip = await self.create_vm()
self.address = self.external_ip
if self.config.get("public_ingress", True):
# scheduler is publicly available
self.address = self.external_ip
else:
self.address = self.internal_ip


class GCPCluster(VMCluster):
Expand Down

0 comments on commit d5dfd99

Please sign in to comment.