GCE: add use-internal-ip option
This adds an option to the GCE driver to tell nodepool to use the private ip address even when an external one is provided. Also add a missing schema entry for rate-limit. Change-Id: Ib15bdc76fe500dc0fe6bb98f870514e9e157c1a5
This commit is contained in:
parent
13104ab0ff
commit
f343dbb05a
@ -2007,6 +2007,12 @@ section of the configuration.
|
||||
booted. This might be needed if nodepool-launcher and the nodes it
|
||||
launches are on different networks. The default value is True.
|
||||
|
||||
.. attr:: use-internal-ip
|
||||
:default: False
|
||||
|
||||
Whether to access the instance with the internal or external IP
|
||||
address.
|
||||
|
||||
.. attr:: labels
|
||||
:type: list
|
||||
|
||||
|
@ -80,6 +80,7 @@ class ProviderPool(ConfigPool):
|
||||
def __init__(self):
|
||||
self.name = None
|
||||
self.host_key_checking = True
|
||||
self.use_internal_ip = False
|
||||
self.labels = None
|
||||
# The ProviderConfig object that owns this pool.
|
||||
self.provider = None
|
||||
@ -94,6 +95,8 @@ class ProviderPool(ConfigPool):
|
||||
|
||||
self.host_key_checking = bool(
|
||||
pool_config.get('host-key-checking', True))
|
||||
self.use_internal_ip = bool(
|
||||
pool_config.get('use-internal-ip', False))
|
||||
|
||||
for label in pool_config.get('labels', []):
|
||||
pl = ProviderLabel()
|
||||
@ -124,6 +127,7 @@ class ProviderPool(ConfigPool):
|
||||
return (super().__eq__(other)
|
||||
and other.name == self.name
|
||||
and other.host_key_checking == self.host_key_checking
|
||||
and other.use_internal_ip == self.use_internal_ip
|
||||
and other.labels == self.labels)
|
||||
return False
|
||||
|
||||
@ -218,6 +222,7 @@ class GCEProviderConfig(ProviderConfig):
|
||||
pool.update({
|
||||
v.Required('name'): str,
|
||||
v.Required('labels'): [pool_label],
|
||||
'use-internal-ip': bool,
|
||||
})
|
||||
|
||||
provider_cloud_images = {
|
||||
@ -239,6 +244,7 @@ class GCEProviderConfig(ProviderConfig):
|
||||
'cloud-images': [provider_cloud_images],
|
||||
'boot-timeout': int,
|
||||
'launch-retries': int,
|
||||
'rate-limit': int,
|
||||
})
|
||||
return v.Schema(provider)
|
||||
|
||||
|
@ -106,7 +106,10 @@ class SimpleTaskManagerLauncher(NodeLauncher):
|
||||
|
||||
self.log.debug("Created instance %s", repr(instance))
|
||||
|
||||
server_ip = instance.interface_ip
|
||||
if self.pool.use_internal_ip:
|
||||
server_ip = instance.private_ipv4
|
||||
else:
|
||||
server_ip = instance.interface_ip
|
||||
|
||||
self.node.connection_port = self.label.cloud_image.connection_port
|
||||
self.node.connection_type = self.label.cloud_image.connection_type
|
||||
|
Loading…
x
Reference in New Issue
Block a user