Skip to content

Commit

Permalink
Added support for availability zones again in AWS (#2979) (#2980)
Browse files Browse the repository at this point in the history
* Fix for #2979
* Added changelog
* Fix unittests.
  • Loading branch information
seriva authored Feb 15, 2022
1 parent e9e2482 commit a5fb61a
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cli/src/providers/aws/InfrastructureBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def get_vm(self, component_key, vm_config, subnet, public_key_config, security_g
vm.specification.subnet_name = subnet.specification.name
vm.specification.key_name = public_key_config.specification.key_name
vm.specification.use_network_security_groups = self.use_network_security_groups
vm.specification.availability_zone = subnet.specification.availability_zone
if self.use_network_security_groups:
vm.specification.security_groups = [security_group.specification.name]
vm.specification.associate_public_ip = self.cluster_model.specification.cloud.use_public_ips
Expand All @@ -152,7 +153,7 @@ def get_subnet(self, subnet_definition, component_key, vpc_name, index):
subnet = self.get_config_or_default(self.docs, 'infrastructure/subnet')
subnet.specification.vpc_name = vpc_name
subnet.specification.cidr_block = subnet_definition['address_pool']

subnet.specification.availability_zone = subnet_definition['availability_zone']
subnet.specification.name = resource_name(self.cluster_prefix, self.cluster_name, 'subnet' + '-' + str(index), component_key)
subnet.specification.cluster_name = self.cluster_name
return subnet
Expand Down
1 change: 1 addition & 0 deletions docs/changelogs/CHANGELOG-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [#2945](https://github.com/epiphany-platform/epiphany/issues/2945) - epicli apply sleeps 10 seconds after creating inventory
- [#2968](https://github.com/epiphany-platform/epiphany/issues/2968) - `epicli init` should generate `specification.cloud.subscription_name` for minimal cluster config
- [#2940](https://github.com/epiphany-platform/epiphany/issues/2940) - firewalld.service unit could not be found on host however ansible_facts sees it as defined
- [#2979](https://github.com/epiphany-platform/epiphany/issues/2979) - Restore the possibility of choosing the availability zone in AWS

### Updated

Expand Down
11 changes: 11 additions & 0 deletions schema/aws/defaults/epiphany-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,63 +26,74 @@ specification:
configuration: default
subnets:
- address_pool: 10.1.1.0/24
availability_zone: eu-west-2a
kubernetes_node:
count: 2
machine: kubernetes-node-machine
configuration: default
subnets:
- address_pool: 10.1.1.0/24
availability_zone: eu-west-2a
logging:
count: 1
machine: logging-machine
configuration: default
subnets:
- address_pool: 10.1.3.0/24
availability_zone: eu-west-2a
monitoring:
count: 1
machine: monitoring-machine
configuration: default
subnets:
- address_pool: 10.1.4.0/24
availability_zone: eu-west-2a
kafka:
count: 2
machine: kafka-machine
configuration: default
subnets:
- address_pool: 10.1.5.0/24
availability_zone: eu-west-2a
postgresql:
count: 0
machine: postgresql-machine
configuration: default
subnets:
- address_pool: 10.1.6.0/24
availability_zone: eu-west-2a
load_balancer:
count: 1
machine: load-balancer-machine
configuration: default
subnets:
- address_pool: 10.1.7.0/24
availability_zone: eu-west-2a
rabbitmq:
count: 0
machine: rabbitmq-machine
configuration: default
subnets:
- address_pool: 10.1.8.0/24
availability_zone: eu-west-2a
opendistro_for_elasticsearch:
count: 0
machine: logging-machine
configuration: default
subnets:
- address_pool: 10.1.10.0/24
availability_zone: eu-west-2a
repository:
count: 1
machine: repository-machine
configuration: default
subnets:
- address_pool: 10.1.11.0/24
availability_zone: eu-west-2a
single_machine:
count: 0
machine: single-machine
configuration: default
subnets:
- address_pool: 10.1.1.0/24
availability_zone: eu-west-2a
1 change: 1 addition & 0 deletions schema/aws/defaults/infrastructure/subnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ specification:
vpc_name: SET_BY_AUTOMATION
cidr_block: SET_BY_AUTOMATION
cluster_name: SET_BY_AUTOMATION
availability_zone: SET_BY_AUTOMATION
1 change: 1 addition & 0 deletions schema/aws/defaults/infrastructure/virtual-machine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ specification:
subnet_name: SET_BY_AUTOMATION
associate_public_ip: SET_BY_AUTOMATION
use_network_security_groups: SET_BY_AUTOMATION
availability_zone: SET_BY_AUTOMATION
security_groups: [] # SET_BY_AUTOMATION
authorized_to_efs: false
mount_efs: false
Expand Down
2 changes: 2 additions & 0 deletions schema/aws/validation/infrastructure/subnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ properties:
type: string
cluster_name:
type: string
availability_zone:
type: string
2 changes: 2 additions & 0 deletions schema/aws/validation/infrastructure/virtual-machine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ properties:
type: boolean
use_network_security_groups:
type: boolean
availability_zone:
type: string
security_groups:
type: array
items:
Expand Down
1 change: 1 addition & 0 deletions terraform/aws/infrastructure/subnet.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
resource "aws_subnet" "{{ specification.name }}" {
vpc_id = aws_vpc.{{ specification.vpc_name }}.id
cidr_block = "{{ specification.cidr_block }}"
availability_zone = "{{ specification.availability_zone }}"

tags = {
cluster_name = "{{ specification.cluster_name }}"
Expand Down
1 change: 1 addition & 0 deletions terraform/aws/infrastructure/virtual-machine.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resource "aws_instance" "{{ specification.name }}" {
{%- if specification.use_network_security_groups == true %}
vpc_security_group_ids = [{% for security_group in specification.security_groups %}aws_security_group.{{ security_group }}.id{% if not loop.last %}, {% endif %}{% endfor %}]
{%- endif %}
availability_zone = "{{ specification.availability_zone }}"

# storage
ebs_optimized = "{{ specification.ebs_optimized | lower }}"
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/providers/aws/test_AWSConfigBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def test_get_efs_config_should_set_proper_values_to_model():
def test_get_subnet_config_should_set_proper_values_to_model():
cluster_model = get_cluster_model(cluster_name='TestCluster')
component_value = dict_to_objdict({
'address_pool': '10.20.0.0/24'
'address_pool': '10.20.0.0/24',
'availability_zone': 'eu-westa'
})
builder = InfrastructureBuilder([cluster_model])

Expand All @@ -57,6 +58,7 @@ def test_get_subnet_config_should_set_proper_values_to_model():
assert actual.specification.name == 'prefix-testcluster-component-subnet-1'
assert actual.specification.vpc_name == 'my-test-vpc'
assert actual.specification.cidr_block == '10.20.0.0/24'
assert actual.specification.availability_zone == 'eu-westa'


def test_get_security_group_should_set_proper_values_to_model():
Expand Down

0 comments on commit a5fb61a

Please sign in to comment.