diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 691b05c09..e0babd759 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -1800,6 +1800,14 @@ section of the configuration. configured entry from the ``cloud-images`` section of the provider. See :attr:`providers.[aws].cloud-images`. + .. attr:: ebs-optimized + :type: bool + :default: False + + Indicates whether EBS optimization + (additional, dedicated throughput between Amazon EC2 and Amazon EBS,) + has been enabled for the instance. + .. attr:: instance-type :type: str :required: diff --git a/nodepool/driver/aws/config.py b/nodepool/driver/aws/config.py index e9cc21ce2..d1c4fe5f2 100644 --- a/nodepool/driver/aws/config.py +++ b/nodepool/driver/aws/config.py @@ -52,6 +52,7 @@ class ProviderLabel(ConfigValue): def __init__(self): self.name = None self.cloud_image = None + self.ebs_optimized = None self.instance_type = None self.key_name = None self.volume_size = None @@ -67,6 +68,7 @@ class ProviderLabel(ConfigValue): # since this causes recursive checks with ProviderPool. return (other.name == self.name and other.cloud_image == self.cloud_image + and other.ebs_optimized == self.ebs_optimized and other.instance_type == self.instance_type and other.key_name == self.key_name and other.volume_size == self.volume_size @@ -123,6 +125,7 @@ class ProviderPool(ConfigPool): else: cloud_image = None pl.cloud_image = cloud_image + pl.ebs_optimized = bool(label.get('ebs-optimized', False)) pl.instance_type = label['instance-type'] pl.key_name = label['key-name'] pl.volume_type = label.get('volume-type') @@ -236,6 +239,7 @@ class AwsProviderConfig(ProviderConfig): v.Exclusive('cloud-image', 'label-image'): str, v.Required('instance-type'): str, v.Required('key-name'): str, + 'ebs-optimized': bool, 'volume-type': str, 'volume-size': int, 'userdata': str, diff --git a/nodepool/driver/aws/provider.py b/nodepool/driver/aws/provider.py index 387341031..170b01840 100644 --- a/nodepool/driver/aws/provider.py +++ b/nodepool/driver/aws/provider.py @@ -167,6 +167,7 @@ class AwsProvider(Provider): MinCount=1, MaxCount=1, KeyName=label.key_name, + EbsOptimized=label.ebs_optimized, InstanceType=label.instance_type, NetworkInterfaces=[{ 'AssociatePublicIpAddress': label.pool.public_ip, diff --git a/nodepool/tests/fixtures/aws.yaml b/nodepool/tests/fixtures/aws.yaml index 8caebe34f..0e5a7ac9c 100644 --- a/nodepool/tests/fixtures/aws.yaml +++ b/nodepool/tests/fixtures/aws.yaml @@ -9,6 +9,7 @@ labels: - name: ubuntu1404-by-filters - name: ubuntu1404-by-capitalized-filters - name: ubuntu1404-bad-config + - name: ubuntu1404-ebs-optimized - name: ubuntu1404-non-host-key-checking - name: ubuntu1404-private-ip - name: ubuntu1404-userdata @@ -45,6 +46,16 @@ providers: - ubuntu* username: ubuntu pools: + - name: ebs-optimized + max-servers: 1 + subnet-id: null + security-group-id: null + labels: + - name: ubuntu1404-ebs-optimized + cloud-image: ubuntu1404 + ebs-optimized: True + instance-type: t3.medium + key-name: zuul - name: main max-servers: 1 subnet-id: null @@ -105,4 +116,4 @@ providers: instance-type: t3.medium key-name: zuul tags: - has-tags: true + has-tags: true \ No newline at end of file diff --git a/nodepool/tests/unit/test_driver_aws.py b/nodepool/tests/unit/test_driver_aws.py index f6805fae2..5e51cb0a2 100644 --- a/nodepool/tests/unit/test_driver_aws.py +++ b/nodepool/tests/unit/test_driver_aws.py @@ -88,6 +88,8 @@ class TestDriverAws(tests.DBTestCase): raw_config['providers'][0]['pools'][2]['security-group-id'] = sg_id raw_config['providers'][0]['pools'][3]['subnet-id'] = subnet_id raw_config['providers'][0]['pools'][3]['security-group-id'] = sg_id + raw_config['providers'][0]['pools'][4]['subnet-id'] = subnet_id + raw_config['providers'][0]['pools'][4]['security-group-id'] = sg_id with tempfile.NamedTemporaryFile() as tf: tf.write(yaml.safe_dump( diff --git a/releasenotes/notes/aws-ec2-ebs-optimized-03258a047edb272d.yaml b/releasenotes/notes/aws-ec2-ebs-optimized-03258a047edb272d.yaml new file mode 100644 index 000000000..9015a2105 --- /dev/null +++ b/releasenotes/notes/aws-ec2-ebs-optimized-03258a047edb272d.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add optional ebs-optimized on ec2 instances. \ No newline at end of file