Skip to content

Commit

Permalink
[GCP] Add gVNIC support (#4095)
Browse files Browse the repository at this point in the history
* add gvnic support through config.yaml

* lint

* docs
  • Loading branch information
romilbhardwaj authored Oct 17, 2024
1 parent 724e97e commit 3e98afe
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/source/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,15 @@ Available fields and semantics:
# Default: 'LOCAL_CREDENTIALS'.
remote_identity: LOCAL_CREDENTIALS
# Enable gVNIC (optional).
#
# Set to true to use gVNIC on GCP instances. gVNIC offers higher performance
# for multi-node clusters, but costs more.
# Reference: https://cloud.google.com/compute/docs/networking/using-gvnic
#
# Default: false.
enable_gvnic: false
# Advanced Azure configurations (optional).
# Apply to all new instances but not existing ones.
azure:
Expand Down
5 changes: 5 additions & 0 deletions sky/clouds/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ def _failover_disk_tier() -> Optional[resources_utils.DiskTier]:
resources_vars[
'force_enable_external_ips'] = skypilot_config.get_nested(
('gcp', 'force_enable_external_ips'), False)

# Add gVNIC from config
resources_vars['enable_gvnic'] = skypilot_config.get_nested(
('gcp', 'enable_gvnic'), False)

return resources_vars

def _get_feasible_launchable_resources(
Expand Down
6 changes: 5 additions & 1 deletion sky/provision/gcp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,12 @@ def _configure_subnet(region: str, cluster_name: str,
'accessConfigs': [{
'name': 'External NAT',
'type': 'ONE_TO_ONE_NAT',
}],
}]
}]
# Add gVNIC if specified in config
enable_gvnic = config.provider_config.get('enable_gvnic', False)
if enable_gvnic:
default_interfaces[0]['nicType'] = 'gVNIC'
enable_external_ips = _enable_external_ips(config)
if not enable_external_ips:
# Removing this key means the VM will not be assigned an external IP.
Expand Down
3 changes: 3 additions & 0 deletions sky/templates/gcp-ray.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ provider:
# leakage.
disable_launch_config_check: true
use_managed_instance_group: {{ gcp_use_managed_instance_group }}
{%- if enable_gvnic %}
enable_gvnic: {{ enable_gvnic }}
{%- endif %}

auth:
ssh_user: gcpuser
Expand Down
3 changes: 3 additions & 0 deletions sky/utils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ def get_config_schema():
'force_enable_external_ips': {
'type': 'boolean'
},
'enable_gvnic': {
'type': 'boolean'
},
**_LABELS_SCHEMA,
**_NETWORK_CONFIG_SCHEMA,
},
Expand Down

0 comments on commit 3e98afe

Please sign in to comment.