Skip to content

Commit 3e98afe

Browse files
[GCP] Add gVNIC support (#4095)
* add gvnic support through config.yaml * lint * docs
1 parent 724e97e commit 3e98afe

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

docs/source/reference/config.rst

+9
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,15 @@ Available fields and semantics:
419419
# Default: 'LOCAL_CREDENTIALS'.
420420
remote_identity: LOCAL_CREDENTIALS
421421
422+
# Enable gVNIC (optional).
423+
#
424+
# Set to true to use gVNIC on GCP instances. gVNIC offers higher performance
425+
# for multi-node clusters, but costs more.
426+
# Reference: https://cloud.google.com/compute/docs/networking/using-gvnic
427+
#
428+
# Default: false.
429+
enable_gvnic: false
430+
422431
# Advanced Azure configurations (optional).
423432
# Apply to all new instances but not existing ones.
424433
azure:

sky/clouds/gcp.py

+5
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,11 @@ def _failover_disk_tier() -> Optional[resources_utils.DiskTier]:
546546
resources_vars[
547547
'force_enable_external_ips'] = skypilot_config.get_nested(
548548
('gcp', 'force_enable_external_ips'), False)
549+
550+
# Add gVNIC from config
551+
resources_vars['enable_gvnic'] = skypilot_config.get_nested(
552+
('gcp', 'enable_gvnic'), False)
553+
549554
return resources_vars
550555

551556
def _get_feasible_launchable_resources(

sky/provision/gcp/config.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,12 @@ def _configure_subnet(region: str, cluster_name: str,
670670
'accessConfigs': [{
671671
'name': 'External NAT',
672672
'type': 'ONE_TO_ONE_NAT',
673-
}],
673+
}]
674674
}]
675+
# Add gVNIC if specified in config
676+
enable_gvnic = config.provider_config.get('enable_gvnic', False)
677+
if enable_gvnic:
678+
default_interfaces[0]['nicType'] = 'gVNIC'
675679
enable_external_ips = _enable_external_ips(config)
676680
if not enable_external_ips:
677681
# Removing this key means the VM will not be assigned an external IP.

sky/templates/gcp-ray.yml.j2

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ provider:
6464
# leakage.
6565
disable_launch_config_check: true
6666
use_managed_instance_group: {{ gcp_use_managed_instance_group }}
67+
{%- if enable_gvnic %}
68+
enable_gvnic: {{ enable_gvnic }}
69+
{%- endif %}
6770

6871
auth:
6972
ssh_user: gcpuser

sky/utils/schemas.py

+3
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,9 @@ def get_config_schema():
755755
'force_enable_external_ips': {
756756
'type': 'boolean'
757757
},
758+
'enable_gvnic': {
759+
'type': 'boolean'
760+
},
758761
**_LABELS_SCHEMA,
759762
**_NETWORK_CONFIG_SCHEMA,
760763
},

0 commit comments

Comments
 (0)