From a0f4415cc756113781dfb5e06544edc131ba0c59 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Tue, 18 May 2021 18:28:07 +0200 Subject: [PATCH 01/23] First commit. --- core/src/epicli/cli/engine/ApplyEngine.py | 35 ++++++++++++------- .../providers/any/InfrastructureBuilder.py | 4 ++- .../providers/aws/InfrastructureBuilder.py | 16 +++++++-- .../providers/azure/InfrastructureBuilder.py | 16 +++++++-- core/src/epicli/cli/helpers/build_saver.py | 4 +++ .../azure/test_AzureConfigBuilder.py | 4 +-- 6 files changed, 58 insertions(+), 21 deletions(-) diff --git a/core/src/epicli/cli/engine/ApplyEngine.py b/core/src/epicli/cli/engine/ApplyEngine.py index 8cab9a9bef..89ea827980 100644 --- a/core/src/epicli/cli/engine/ApplyEngine.py +++ b/core/src/epicli/cli/engine/ApplyEngine.py @@ -5,7 +5,8 @@ from cli.helpers.Step import Step from cli.helpers.doc_list_helpers import select_single, select_all -from cli.helpers.build_saver import save_manifest, get_inventory_path +from cli.helpers.build_saver import save_manifest, get_inventory_path, get_manifest_path, get_build_path +from cli.helpers.data_loader import load_manifest_docs from cli.helpers.yaml_helpers import safe_load_all from cli.helpers.Log import Log from cli.helpers.os_images import get_os_distro_normalized @@ -17,6 +18,8 @@ from cli.engine.terraform.TerraformFileCopier import TerraformFileCopier from cli.engine.terraform.TerraformRunner import TerraformRunner from cli.engine.ansible.AnsibleRunner import AnsibleRunner +from cli.helpers.query_yes_no import query_yes_no +from cli.version import VERSION class ApplyEngine(Step): @@ -31,6 +34,8 @@ def __init__(self, input_data): self.input_docs = [] self.configuration_docs = [] self.infrastructure_docs = [] + self.manifest_docs = [] + self.preserve_os = False def __enter__(self): return self @@ -61,9 +66,12 @@ def process_input_docs(self): schema_validator.run() def process_infrastructure_docs(self): + # Load any posible existing manifest docs + self.load_manifest_docs() + # Build the infrastructure docs with provider_class_loader(self.cluster_model.provider, 'InfrastructureBuilder')( - self.input_docs) as infrastructure_builder: + self.input_docs, self.manifest_docs, self.preserve_os) as infrastructure_builder: self.infrastructure_docs = infrastructure_builder.run() # Validate infrastructure documents @@ -84,16 +92,19 @@ def collect_infrastructure_config(self): [*self.configuration_docs, *self.infrastructure_docs]) as config_collector: config_collector.run() - def validate(self): - self.process_input_docs() - - self.process_configuration_docs() - - self.process_infrastructure_docs() - - save_manifest([*self.input_docs, *self.configuration_docs, *self.infrastructure_docs], self.cluster_model.specification.name) - - return 0 + def load_manifest_docs(self): + path_to_manifest = get_manifest_path(self.cluster_model.specification.name) + if os.path.isfile(path_to_manifest): + self.manifest_docs = load_manifest_docs(get_build_path(self.cluster_model.specification.name)) + + # If we can load manifest docs it means we are re-applying the config. + # We ask here if we want to preserve the OS base image to avoid Terraform issues with the re-apply + if self.manifest_docs: + manifest_cluster_model = select_single(self.manifest_docs, lambda x: x.kind == 'epiphany-cluster') + if manifest_cluster_model.version != VERSION and manifest_cluster_model.provider != 'any': + self.preserve_os = query_yes_no("""You are about to re-apply a configuration with a different version of Epiphany then the cluster was originally created with. +This version might try and apply different OS images for your virtual machines which might cause issues and/or data loss. +Do you want to preserve the OS images used during the first cluster creation?""" ) def assert_no_master_downscale(self): components = self.cluster_model.specification.components diff --git a/core/src/epicli/cli/engine/providers/any/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/any/InfrastructureBuilder.py index 1602157a7a..59df11e0d1 100644 --- a/core/src/epicli/cli/engine/providers/any/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/any/InfrastructureBuilder.py @@ -3,10 +3,12 @@ from cli.version import VERSION class InfrastructureBuilder(Step): - def __init__(self, docs): + def __init__(self, docs, manifest_docs=[], preserve_os=False): super().__init__(__name__) self.cluster_model = select_single(docs, lambda x: x.kind == 'epiphany-cluster') self.docs = docs + self.manifest_docs = manifest_docs + self.preserve_os = preserve_os def run(self): infrastructure_docs = select_all(self.docs, lambda x: x.kind.startswith('infrastructure/')) diff --git a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py index cfee23af68..cad421c0d6 100644 --- a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py @@ -16,13 +16,15 @@ class InfrastructureBuilder(Step): - def __init__(self, docs): + def __init__(self, docs, manifest_docs=[], preserve_os=False): super().__init__(__name__) self.cluster_model = select_single(docs, lambda x: x.kind == 'epiphany-cluster') self.cluster_name = self.cluster_model.specification.name.lower() self.cluster_prefix = self.cluster_model.specification.prefix.lower() self.use_network_security_groups = self.cluster_model.specification.cloud.network.use_network_security_groups self.docs = docs + self.manifest_docs = manifest_docs + self.preserve_os = preserve_os def run(self): infrastructure = [] @@ -136,7 +138,7 @@ def get_efs_config(self): return efs_config def get_autoscaling_group(self, component_key, component_value, subnets_to_create, index): - autoscaling_group = dict_to_objdict(deepcopy(self.get_virtual_machine(component_value, self.cluster_model, self.docs))) + autoscaling_group = dict_to_objdict(deepcopy(self.get_virtual_machine(component_value, self.cluster_model, self.docs, self.manifest_docs, self.preserve_os))) autoscaling_group.specification.cluster_name = self.cluster_name autoscaling_group.specification.name = resource_name(self.cluster_prefix, self.cluster_name, 'asg' + '-' + str(index), component_key) autoscaling_group.specification.count = component_value.count @@ -276,7 +278,7 @@ def get_config_or_default(docs, kind): return config @staticmethod - def get_virtual_machine(component_value, cluster_model, docs): + def get_virtual_machine(component_value, cluster_model, docs, manifest_docs, preserve_os): machine_selector = component_value.machine model_with_defaults = select_first(docs, lambda x: x.kind == 'infrastructure/virtual-machine' and x.name == machine_selector) @@ -284,6 +286,14 @@ def get_virtual_machine(component_value, cluster_model, docs): model_with_defaults = merge_with_defaults(cluster_model.provider, 'infrastructure/virtual-machine', machine_selector, docs) + if manifest_docs and preserve_os: + manifest_vm_config = select_first(manifest_docs, lambda x: x.name == machine_selector and x.kind == 'infrastructure/virtual-machine') + manifest_first_config = select_first(manifest_docs, lambda x: x.kind == 'infrastructure/virtual-machine') + if manifest_vm_config is not None: + model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_vm_config.specification.storage_image_reference)) + else: + model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_first_config.specification.storage_image_reference)) + return model_with_defaults @staticmethod diff --git a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py index 8cb2069ef8..97340df31b 100644 --- a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py @@ -12,7 +12,7 @@ from cli.version import VERSION class InfrastructureBuilder(Step): - def __init__(self, docs): + def __init__(self, docs, manifest_docs=[], preserve_os=False): super().__init__(__name__) self.cluster_model = select_single(docs, lambda x: x.kind == 'epiphany-cluster') self.cluster_name = self.cluster_model.specification.name.lower() @@ -22,6 +22,8 @@ def __init__(self, docs): self.use_network_security_groups = self.cluster_model.specification.cloud.network.use_network_security_groups self.use_public_ips = self.cluster_model.specification.cloud.use_public_ips self.docs = docs + self.manifest_docs = manifest_docs + self.preserve_os = preserve_os def run(self): infrastructure = [] @@ -44,7 +46,7 @@ def run(self): # The vm config also contains some other stuff we use for network and security config. # So get it here and pass it allong. - vm_config = self.get_virtual_machine(component_value, self.cluster_model, self.docs) + vm_config = self.get_virtual_machine(component_value, self.cluster_model, self.docs, self.manifest_docs, self.preserve_os) # Set property that controls cloud-init. vm_config.specification['use_cloud_init_custom_data'] = cloud_init_custom_data.specification.enabled @@ -230,7 +232,7 @@ def get_config_or_default(docs, kind): return config @staticmethod - def get_virtual_machine(component_value, cluster_model, docs): + def get_virtual_machine(component_value, cluster_model, docs, manifest_docs, preserve_os): machine_selector = component_value.machine model_with_defaults = select_first(docs, lambda x: x.kind == 'infrastructure/virtual-machine' and x.name == machine_selector) @@ -238,4 +240,12 @@ def get_virtual_machine(component_value, cluster_model, docs): model_with_defaults = merge_with_defaults(cluster_model.provider, 'infrastructure/virtual-machine', machine_selector, docs) + if manifest_docs and preserve_os: + manifest_vm_config = select_first(manifest_docs, lambda x: x.name == machine_selector and x.kind == 'infrastructure/virtual-machine') + manifest_first_config = select_first(manifest_docs, lambda x: x.kind == 'infrastructure/virtual-machine') + if manifest_vm_config is not None: + model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_vm_config.specification.storage_image_reference)) + else: + model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_first_config.specification.storage_image_reference)) + return model_with_defaults diff --git a/core/src/epicli/cli/helpers/build_saver.py b/core/src/epicli/cli/helpers/build_saver.py index 3f61587135..e8874a4148 100644 --- a/core/src/epicli/cli/helpers/build_saver.py +++ b/core/src/epicli/cli/helpers/build_saver.py @@ -85,6 +85,10 @@ def get_inventory_path(cluster_name): return os.path.join(get_build_path(cluster_name), INVENTORY_FILE_NAME) +def get_manifest_path(cluster_name): + return os.path.join(get_build_path(cluster_name), MANIFEST_FILE_NAME) + + def get_inventory_path_for_build(build_directory): build_version = check_build_output_version(build_directory) inventory = os.path.join(build_directory, INVENTORY_FILE_NAME) diff --git a/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py b/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py index 3b307956bb..8671ff596a 100644 --- a/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py +++ b/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py @@ -68,7 +68,7 @@ def test_get_public_ip_should_set_proper_values_to_model(): component_value = dict_to_objdict({ 'machine': 'kubernetes-master-machine' }) - vm_config = builder.get_virtual_machine(component_value, cluster_model, []) + vm_config = builder.get_virtual_machine(component_value, cluster_model, [], [], False) actual = builder.get_public_ip('kubernetes_master', component_value, vm_config, 1) @@ -84,7 +84,7 @@ def test_get_network_interface_should_set_proper_values_to_model(): component_value = dict_to_objdict({ 'machine': 'kubernetes-master-machine' }) - vm_config = builder.get_virtual_machine(component_value, cluster_model, []) + vm_config = builder.get_virtual_machine(component_value, cluster_model, [], [], False) actual = builder.get_network_interface( 'kubernetes_master', From 4dc5b828157ef2a9e49ed60ccc4ddf73a1821441 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Tue, 18 May 2021 21:36:17 +0200 Subject: [PATCH 02/23] Minor updates for AWS. --- core/src/epicli/cli/engine/ApplyEngine.py | 7 +++---- .../cli/engine/providers/aws/InfrastructureBuilder.py | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/epicli/cli/engine/ApplyEngine.py b/core/src/epicli/cli/engine/ApplyEngine.py index 89ea827980..e5758873c9 100644 --- a/core/src/epicli/cli/engine/ApplyEngine.py +++ b/core/src/epicli/cli/engine/ApplyEngine.py @@ -101,10 +101,9 @@ def load_manifest_docs(self): # We ask here if we want to preserve the OS base image to avoid Terraform issues with the re-apply if self.manifest_docs: manifest_cluster_model = select_single(self.manifest_docs, lambda x: x.kind == 'epiphany-cluster') - if manifest_cluster_model.version != VERSION and manifest_cluster_model.provider != 'any': - self.preserve_os = query_yes_no("""You are about to re-apply a configuration with a different version of Epiphany then the cluster was originally created with. -This version might try and apply different OS images for your virtual machines which might cause issues and/or data loss. -Do you want to preserve the OS images used during the first cluster creation?""" ) + if manifest_cluster_model.provider != 'any': + self.preserve_os = query_yes_no("""You are about to re-apply a configuration. This action might try to apply a different OS image to your virtual machines which might result data loss and/or other issues. +Do you want to preserve the original OS image used during the clusters creation?""") def assert_no_master_downscale(self): components = self.cluster_model.specification.components diff --git a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py index cad421c0d6..9a5aa79e1e 100644 --- a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py @@ -290,9 +290,9 @@ def get_virtual_machine(component_value, cluster_model, docs, manifest_docs, pre manifest_vm_config = select_first(manifest_docs, lambda x: x.name == machine_selector and x.kind == 'infrastructure/virtual-machine') manifest_first_config = select_first(manifest_docs, lambda x: x.kind == 'infrastructure/virtual-machine') if manifest_vm_config is not None: - model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_vm_config.specification.storage_image_reference)) + model_with_defaults.specification.os_full_name = manifest_vm_config.specification.os_full_name else: - model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_first_config.specification.storage_image_reference)) + model_with_defaults.specification.os_full_name = manifest_first_config.specification.os_full_name return model_with_defaults From 361eae1547907bd457c341f495821ebd758c36ea Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Wed, 19 May 2021 17:56:30 +0200 Subject: [PATCH 03/23] Adding addition logic for preserving images. --- core/src/epicli/cli/engine/ApplyEngine.py | 12 +--- .../providers/any/InfrastructureBuilder.py | 3 +- .../providers/aws/InfrastructureBuilder.py | 53 +++++++++------- .../providers/azure/InfrastructureBuilder.py | 61 ++++++++++++------- core/src/epicli/cli/epicli.py | 20 ------ 5 files changed, 72 insertions(+), 77 deletions(-) diff --git a/core/src/epicli/cli/engine/ApplyEngine.py b/core/src/epicli/cli/engine/ApplyEngine.py index e5758873c9..3e56cb48e2 100644 --- a/core/src/epicli/cli/engine/ApplyEngine.py +++ b/core/src/epicli/cli/engine/ApplyEngine.py @@ -18,7 +18,6 @@ from cli.engine.terraform.TerraformFileCopier import TerraformFileCopier from cli.engine.terraform.TerraformRunner import TerraformRunner from cli.engine.ansible.AnsibleRunner import AnsibleRunner -from cli.helpers.query_yes_no import query_yes_no from cli.version import VERSION @@ -35,7 +34,6 @@ def __init__(self, input_data): self.configuration_docs = [] self.infrastructure_docs = [] self.manifest_docs = [] - self.preserve_os = False def __enter__(self): return self @@ -71,7 +69,7 @@ def process_infrastructure_docs(self): # Build the infrastructure docs with provider_class_loader(self.cluster_model.provider, 'InfrastructureBuilder')( - self.input_docs, self.manifest_docs, self.preserve_os) as infrastructure_builder: + self.input_docs, self.manifest_docs) as infrastructure_builder: self.infrastructure_docs = infrastructure_builder.run() # Validate infrastructure documents @@ -97,14 +95,6 @@ def load_manifest_docs(self): if os.path.isfile(path_to_manifest): self.manifest_docs = load_manifest_docs(get_build_path(self.cluster_model.specification.name)) - # If we can load manifest docs it means we are re-applying the config. - # We ask here if we want to preserve the OS base image to avoid Terraform issues with the re-apply - if self.manifest_docs: - manifest_cluster_model = select_single(self.manifest_docs, lambda x: x.kind == 'epiphany-cluster') - if manifest_cluster_model.provider != 'any': - self.preserve_os = query_yes_no("""You are about to re-apply a configuration. This action might try to apply a different OS image to your virtual machines which might result data loss and/or other issues. -Do you want to preserve the original OS image used during the clusters creation?""") - def assert_no_master_downscale(self): components = self.cluster_model.specification.components diff --git a/core/src/epicli/cli/engine/providers/any/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/any/InfrastructureBuilder.py index 59df11e0d1..3894c8e7e8 100644 --- a/core/src/epicli/cli/engine/providers/any/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/any/InfrastructureBuilder.py @@ -3,12 +3,11 @@ from cli.version import VERSION class InfrastructureBuilder(Step): - def __init__(self, docs, manifest_docs=[], preserve_os=False): + def __init__(self, docs, manifest_docs=[]): super().__init__(__name__) self.cluster_model = select_single(docs, lambda x: x.kind == 'epiphany-cluster') self.docs = docs self.manifest_docs = manifest_docs - self.preserve_os = preserve_os def run(self): infrastructure_docs = select_all(self.docs, lambda x: x.kind.startswith('infrastructure/')) diff --git a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py index 9a5aa79e1e..fd7cec4c60 100644 --- a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py @@ -13,10 +13,11 @@ from cli.helpers.naming_helpers import resource_name from cli.helpers.objdict_helpers import objdict_to_dict, dict_to_objdict from cli.version import VERSION +from cli.helpers.query_yes_no import query_yes_no class InfrastructureBuilder(Step): - def __init__(self, docs, manifest_docs=[], preserve_os=False): + def __init__(self, docs, manifest_docs=[]): super().__init__(__name__) self.cluster_model = select_single(docs, lambda x: x.kind == 'epiphany-cluster') self.cluster_name = self.cluster_model.specification.name.lower() @@ -24,7 +25,6 @@ def __init__(self, docs, manifest_docs=[], preserve_os=False): self.use_network_security_groups = self.cluster_model.specification.cloud.network.use_network_security_groups self.docs = docs self.manifest_docs = manifest_docs - self.preserve_os = preserve_os def run(self): infrastructure = [] @@ -138,7 +138,7 @@ def get_efs_config(self): return efs_config def get_autoscaling_group(self, component_key, component_value, subnets_to_create, index): - autoscaling_group = dict_to_objdict(deepcopy(self.get_virtual_machine(component_value, self.cluster_model, self.docs, self.manifest_docs, self.preserve_os))) + autoscaling_group = dict_to_objdict(deepcopy(self.get_virtual_machine(component_value, self.cluster_model, self.docs, self.manifest_docs, False))) autoscaling_group.specification.cluster_name = self.cluster_name autoscaling_group.specification.name = resource_name(self.cluster_prefix, self.cluster_name, 'asg' + '-' + str(index), component_key) autoscaling_group.specification.count = component_value.count @@ -247,6 +247,34 @@ def add_security_rules_inbound_efs(self, infrastructure, security_group): rules.append(objdict_to_dict(rule)) security_group.specification.rules = rules + def get_virtual_machine(self, component_value): + machine_selector = component_value.machine + model_with_defaults = select_first(self.docs, lambda x: x.kind == 'infrastructure/virtual-machine' and + x.name == machine_selector) + if model_with_defaults is None: + model_with_defaults = merge_with_defaults(self.cluster_model.provider, 'infrastructure/virtual-machine', + machine_selector, self.docs) + + if self.manifest_docs: + manifest_vm_config = select_first(self.manifest_docs, lambda x: x.name == machine_selector and x.kind == 'infrastructure/virtual-machine') + manifest_firstvm_config = select_first(self.manifest_docs, lambda x: x.kind == 'infrastructure/virtual-machine') + + if manifest_vm_config is not None and model_with_defaults.specification.os_full_name == manifest_vm_config.specification.os_full_name: + return model_with_defaults + + if model_with_defaults.specification.os_full_name == manifest_firstvm_config.specification.os_full_name: + return model_with_defaults + + self.logger.warning(f"Currently we don`t support changing of OS images with AWS autoscaling groups. Preserving the existing OS image used for VM definition '{machine_selector}'") + + if manifest_vm_config is not None: + model_with_defaults.specification.os_full_name = manifest_vm_config.specification.os_full_name + else: + model_with_defaults.specification.os_full_name = manifest_firstvm_config.specification.os_full_name + + return model_with_defaults + + @staticmethod def efs_add_mount_target_config(efs_config, subnet): target = select_first(efs_config.specification.mount_targets, @@ -277,25 +305,6 @@ def get_config_or_default(docs, kind): config['version'] = VERSION return config - @staticmethod - def get_virtual_machine(component_value, cluster_model, docs, manifest_docs, preserve_os): - machine_selector = component_value.machine - model_with_defaults = select_first(docs, lambda x: x.kind == 'infrastructure/virtual-machine' and - x.name == machine_selector) - if model_with_defaults is None: - model_with_defaults = merge_with_defaults(cluster_model.provider, 'infrastructure/virtual-machine', - machine_selector, docs) - - if manifest_docs and preserve_os: - manifest_vm_config = select_first(manifest_docs, lambda x: x.name == machine_selector and x.kind == 'infrastructure/virtual-machine') - manifest_first_config = select_first(manifest_docs, lambda x: x.kind == 'infrastructure/virtual-machine') - if manifest_vm_config is not None: - model_with_defaults.specification.os_full_name = manifest_vm_config.specification.os_full_name - else: - model_with_defaults.specification.os_full_name = manifest_first_config.specification.os_full_name - - return model_with_defaults - @staticmethod def rule_exists_in_list(rule_list, rule_to_check): for rule in rule_list: diff --git a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py index 97340df31b..fd069bb954 100644 --- a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py @@ -10,9 +10,10 @@ from cli.helpers.objdict_helpers import objdict_to_dict, dict_to_objdict from cli.helpers.os_images import get_os_distro_normalized from cli.version import VERSION +from cli.helpers.query_yes_no import query_yes_no class InfrastructureBuilder(Step): - def __init__(self, docs, manifest_docs=[], preserve_os=False): + def __init__(self, docs, manifest_docs=[]): super().__init__(__name__) self.cluster_model = select_single(docs, lambda x: x.kind == 'epiphany-cluster') self.cluster_name = self.cluster_model.specification.name.lower() @@ -23,7 +24,7 @@ def __init__(self, docs, manifest_docs=[], preserve_os=False): self.use_public_ips = self.cluster_model.specification.cloud.use_public_ips self.docs = docs self.manifest_docs = manifest_docs - self.preserve_os = preserve_os + self.preserve_os_images = False def run(self): infrastructure = [] @@ -46,7 +47,7 @@ def run(self): # The vm config also contains some other stuff we use for network and security config. # So get it here and pass it allong. - vm_config = self.get_virtual_machine(component_value, self.cluster_model, self.docs, self.manifest_docs, self.preserve_os) + vm_config = self.get_virtual_machine(component_value) # Set property that controls cloud-init. vm_config.specification['use_cloud_init_custom_data'] = cloud_init_custom_data.specification.enabled @@ -223,6 +224,41 @@ def get_cloud_init_custom_data(self): cloud_init_custom_data.specification.file_name = 'cloud-config.yml' return cloud_init_custom_data + def get_virtual_machine(self, component_value): + machine_selector = component_value.machine + model_with_defaults = select_first(self.docs, lambda x: x.kind == 'infrastructure/virtual-machine' and + x.name == machine_selector) + if model_with_defaults is None: + model_with_defaults = merge_with_defaults(self.cluster_model.provider, 'infrastructure/virtual-machine', + machine_selector, self.docs) + + if self.manifest_docs: + manifest_vm_config = select_first(self.manifest_docs, lambda x: x.name == machine_selector and x.kind == 'infrastructure/virtual-machine') + manifest_firstvm_config = select_first(self.manifest_docs, lambda x: x.kind == 'infrastructure/virtual-machine') + + if manifest_vm_config is not None and model_with_defaults.specification.storage_image_reference == manifest_vm_config.specification.storage_image_reference: + return model_with_defaults + + if model_with_defaults.specification.storage_image_reference == manifest_firstvm_config.specification.storage_image_reference: + return model_with_defaults + + preserve_os_image = False + if not self.preserve_os_images: + preserve_os_image = query_yes_no(f"""You are about to apply a different OS image for the '{machine_selector}' VM definition. This might lead to data loss and/or other issues. +Do you want to preserve the original OS image for VM definition '{machine_selector}'?""") + print("") + if preserve_os_image: + self.preserve_os_images = query_yes_no("""Do you want to preserve the OS images for all other VM definitions in your cluster?""") + print("") + + if preserve_os_image or self.preserve_os_images: + if manifest_vm_config is not None: + model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_vm_config.specification.storage_image_reference)) + else: + model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_firstvm_config.specification.storage_image_reference)) + + return model_with_defaults + @staticmethod def get_config_or_default(docs, kind): config = select_first(docs, lambda x: x.kind == kind) @@ -230,22 +266,3 @@ def get_config_or_default(docs, kind): config = load_yaml_obj(types.DEFAULT, 'azure', kind) config['version'] = VERSION return config - - @staticmethod - def get_virtual_machine(component_value, cluster_model, docs, manifest_docs, preserve_os): - machine_selector = component_value.machine - model_with_defaults = select_first(docs, lambda x: x.kind == 'infrastructure/virtual-machine' and - x.name == machine_selector) - if model_with_defaults is None: - model_with_defaults = merge_with_defaults(cluster_model.provider, 'infrastructure/virtual-machine', - machine_selector, docs) - - if manifest_docs and preserve_os: - manifest_vm_config = select_first(manifest_docs, lambda x: x.name == machine_selector and x.kind == 'infrastructure/virtual-machine') - manifest_first_config = select_first(manifest_docs, lambda x: x.kind == 'infrastructure/virtual-machine') - if manifest_vm_config is not None: - model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_vm_config.specification.storage_image_reference)) - else: - model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_first_config.specification.storage_image_reference)) - - return model_with_defaults diff --git a/core/src/epicli/cli/epicli.py b/core/src/epicli/cli/epicli.py index 8abdbe641e..b298ccbf7b 100644 --- a/core/src/epicli/cli/epicli.py +++ b/core/src/epicli/cli/epicli.py @@ -93,9 +93,6 @@ def debug_level(x): upgrade_parser(subparsers) delete_parser(subparsers) test_parser(subparsers) - ''' - validate_parser(subparsers) - ''' backup_parser(subparsers) recovery_parser(subparsers) @@ -318,23 +315,6 @@ def run_test(args): sub_parser.set_defaults(func=run_test) -''' -def validate_parser(subparsers): - sub_parser = subparsers.add_parser('verify', description='Validates the configuration from file by executing a dry ' - 'run without changing the physical ' - 'infrastructure/configuration') - sub_parser.add_argument('-f', '--file', dest='file', type=str, - help='File with infrastructure/configuration definitions to use.') - - def run_validate(args): - adjust_paths_from_file(args) - with ApplyEngine(args) as engine: - return engine.validate() - - sub_parser.set_defaults(func=run_validate) -''' - - def backup_parser(subparsers): """Configure and execute backup of cluster components.""" From c5cfcb9adb6fc1fa6796131ef3e1c7183088ce94 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Wed, 19 May 2021 18:26:36 +0200 Subject: [PATCH 04/23] Fix minor typo. --- .../epicli/cli/engine/providers/azure/InfrastructureBuilder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py index fd069bb954..d746cb3489 100644 --- a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py @@ -244,7 +244,7 @@ def get_virtual_machine(self, component_value): preserve_os_image = False if not self.preserve_os_images: - preserve_os_image = query_yes_no(f"""You are about to apply a different OS image for the '{machine_selector}' VM definition. This might lead to data loss and/or other issues. + preserve_os_image = query_yes_no(f"""You are about to re-apply a different OS image for the '{machine_selector}' VM definition. This might lead to data loss and/or other issues. Do you want to preserve the original OS image for VM definition '{machine_selector}'?""") print("") if preserve_os_image: From 273d91a84a213ab70bad10f31f2e1fb12c069240 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Wed, 19 May 2021 22:09:04 +0200 Subject: [PATCH 05/23] Minor fix for AWS --- .../epicli/cli/engine/providers/aws/InfrastructureBuilder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py index fd7cec4c60..3cd850ca4f 100644 --- a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py @@ -138,7 +138,7 @@ def get_efs_config(self): return efs_config def get_autoscaling_group(self, component_key, component_value, subnets_to_create, index): - autoscaling_group = dict_to_objdict(deepcopy(self.get_virtual_machine(component_value, self.cluster_model, self.docs, self.manifest_docs, False))) + autoscaling_group = dict_to_objdict(deepcopy(self.get_virtual_machine(component_value))) autoscaling_group.specification.cluster_name = self.cluster_name autoscaling_group.specification.name = resource_name(self.cluster_prefix, self.cluster_name, 'asg' + '-' + str(index), component_key) autoscaling_group.specification.count = component_value.count From d52a98875bdeb766050bbd517f55abdfa991b5e6 Mon Sep 17 00:00:00 2001 From: Seriva Date: Thu, 20 May 2021 12:43:00 +0200 Subject: [PATCH 06/23] Fixing tests. --- .../tests/engine/providers/azure/test_AzureConfigBuilder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py b/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py index 8671ff596a..4c33f711f2 100644 --- a/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py +++ b/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py @@ -68,7 +68,7 @@ def test_get_public_ip_should_set_proper_values_to_model(): component_value = dict_to_objdict({ 'machine': 'kubernetes-master-machine' }) - vm_config = builder.get_virtual_machine(component_value, cluster_model, [], [], False) + vm_config = builder.get_virtual_machine(component_value) actual = builder.get_public_ip('kubernetes_master', component_value, vm_config, 1) @@ -84,7 +84,7 @@ def test_get_network_interface_should_set_proper_values_to_model(): component_value = dict_to_objdict({ 'machine': 'kubernetes-master-machine' }) - vm_config = builder.get_virtual_machine(component_value, cluster_model, [], [], False) + vm_config = builder.get_virtual_machine(component_value) actual = builder.get_network_interface( 'kubernetes_master', @@ -119,6 +119,7 @@ def get_cluster_model(address_pool='10.22.0.0/22', cluster_name='EpiphanyTestClu cluster_model = dict_to_objdict({ 'kind': 'epiphany-cluster', 'provider': 'azure', + 'name': 'default', 'specification': { 'name': cluster_name, 'prefix': 'prefix', From a762eb45ba1fdc037eaf5bf8f7c87e8c8a10109f Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 21 May 2021 16:52:27 +0200 Subject: [PATCH 07/23] - Implemented a mechanism to use the current OS images for every OS and not only the default we have defined for Ubuntu. --- .../providers/aws/InfrastructureBuilder.py | 11 +++++++++++ .../providers/azure/InfrastructureBuilder.py | 12 ++++++++++++ .../configuration/minimal-cluster-config.yml | 1 + .../cloud-os-image-defaults.yml | 8 ++++++++ .../configuration/minimal-cluster-config.yml | 1 + .../cloud-os-image-defaults.yml | 19 +++++++++++++++++++ .../data/common/defaults/epiphany-cluster.yml | 1 + .../common/validation/epiphany-cluster.yml | 11 +++++++++++ docs/home/howto/CLUSTER.md | 13 ++++++++++++- 9 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml create mode 100644 core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml diff --git a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py index 3cd850ca4f..cda8e679b9 100644 --- a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py @@ -251,10 +251,21 @@ def get_virtual_machine(self, component_value): machine_selector = component_value.machine model_with_defaults = select_first(self.docs, lambda x: x.kind == 'infrastructure/virtual-machine' and x.name == machine_selector) + + # Merge with defaults if model_with_defaults is None: model_with_defaults = merge_with_defaults(self.cluster_model.provider, 'infrastructure/virtual-machine', machine_selector, self.docs) + # Check if we have a cluster-config OS image defined that we want to apply cluster wide. + cloud_os_image_defaults = self.get_config_or_default(self.docs, 'Infrastructure/cloud-os-image-defaults') + cloud_image = self.cluster_model.specification.cloud.os_image + if cloud_image != 'default': + if not hasattr(cloud_os_image_defaults.specification, cloud_image): + raise NotImplementedError(f'"{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') + model_with_defaults.specification.os_full_name = cloud_os_image_defaults.specification[cloud_image] + + # finally check if we are trying to re-apply a configuration. if self.manifest_docs: manifest_vm_config = select_first(self.manifest_docs, lambda x: x.name == machine_selector and x.kind == 'infrastructure/virtual-machine') manifest_firstvm_config = select_first(self.manifest_docs, lambda x: x.kind == 'infrastructure/virtual-machine') diff --git a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py index d746cb3489..7244adf75f 100644 --- a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py @@ -228,10 +228,21 @@ def get_virtual_machine(self, component_value): machine_selector = component_value.machine model_with_defaults = select_first(self.docs, lambda x: x.kind == 'infrastructure/virtual-machine' and x.name == machine_selector) + + # Merge with defaults if model_with_defaults is None: model_with_defaults = merge_with_defaults(self.cluster_model.provider, 'infrastructure/virtual-machine', machine_selector, self.docs) + # Check if we have a cluster-config OS image defined that we want to apply cluster wide. + cloud_os_image_defaults = self.get_config_or_default(self.docs, 'Infrastructure/cloud-os-image-defaults') + cloud_image = self.cluster_model.specification.cloud.os_image + if cloud_image != 'default': + if not hasattr(cloud_os_image_defaults.specification, cloud_image): + raise NotImplementedError(f'"{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') + model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(cloud_os_image_defaults.specification[cloud_image])) + + # finally check if we are trying to re-apply a configuration. if self.manifest_docs: manifest_vm_config = select_first(self.manifest_docs, lambda x: x.name == machine_selector and x.kind == 'infrastructure/virtual-machine') manifest_firstvm_config = select_first(self.manifest_docs, lambda x: x.kind == 'infrastructure/virtual-machine') @@ -245,6 +256,7 @@ def get_virtual_machine(self, component_value): preserve_os_image = False if not self.preserve_os_images: preserve_os_image = query_yes_no(f"""You are about to re-apply a different OS image for the '{machine_selector}' VM definition. This might lead to data loss and/or other issues. +More information about possible issues of re-applying an OS image can be found here: https://github.com/epiphany-platform/epiphany/blob/develop/docs/home/howto/UPGRADE.md#run-apply-after-upgrade Do you want to preserve the original OS image for VM definition '{machine_selector}'?""") print("") if preserve_os_image: diff --git a/core/src/epicli/data/aws/defaults/configuration/minimal-cluster-config.yml b/core/src/epicli/data/aws/defaults/configuration/minimal-cluster-config.yml index 9005e443ab..15f1d9a93b 100644 --- a/core/src/epicli/data/aws/defaults/configuration/minimal-cluster-config.yml +++ b/core/src/epicli/data/aws/defaults/configuration/minimal-cluster-config.yml @@ -14,6 +14,7 @@ specification: credentials: key: XXXX-XXXX-XXXX secret: XXXXXXXXXXXXXXXX + os_image: default components: repository: count: 1 diff --git a/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml b/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml new file mode 100644 index 0000000000..ee9d63c27a --- /dev/null +++ b/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml @@ -0,0 +1,8 @@ +kind: Infrastructure/cloud-os-image-defaults +title: "Cloud OS Image Defaults" +name: default +specification: + ubuntu-18.04-x86_64: ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20210323 + redhat-7-x86_64: RHEL-7.9_HVM-20210208-x86_64-0-Hourly2-GP2 + centos-7-x86_64: CentOS 7.9.2009 x86_64 + centos-7-arm64: CentOS 7.9.2009 aarch64 \ No newline at end of file diff --git a/core/src/epicli/data/azure/defaults/configuration/minimal-cluster-config.yml b/core/src/epicli/data/azure/defaults/configuration/minimal-cluster-config.yml index 41af4a2155..8f2507d706 100644 --- a/core/src/epicli/data/azure/defaults/configuration/minimal-cluster-config.yml +++ b/core/src/epicli/data/azure/defaults/configuration/minimal-cluster-config.yml @@ -11,6 +11,7 @@ specification: cloud: k8s_as_cloud_service: False use_public_ips: False # When not using public IPs you have to provide connectivity via private IPs (VPN) + os_image: default components: repository: count: 1 diff --git a/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml b/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml new file mode 100644 index 0000000000..853c4af408 --- /dev/null +++ b/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml @@ -0,0 +1,19 @@ +kind: Infrastructure/cloud-os-image-defaults +title: "Cloud OS Image Defaults" +name: default +specification: + ubuntu-18.04-x86_64: + publisher: Canonical + offer: UbuntuServer + sku: 18.04-LTS + version: "18.04.202103151" + redhat-7-x86_64: + publisher: RedHat + offer: RHEL + sku: 7-LVM + version: "7.9.2020111202" + centos-7-x86_64: + publisher: OpenLogic + offer: CentOS + sku: "7_9" + version: "7.9.2021020400" \ No newline at end of file diff --git a/core/src/epicli/data/common/defaults/epiphany-cluster.yml b/core/src/epicli/data/common/defaults/epiphany-cluster.yml index 27ed2a581c..09e4e3fdad 100644 --- a/core/src/epicli/data/common/defaults/epiphany-cluster.yml +++ b/core/src/epicli/data/common/defaults/epiphany-cluster.yml @@ -20,6 +20,7 @@ specification: secret: DADFAFHCJHCAUYEAk network: use_network_security_groups: True + os_image: default components: kubernetes_master: count: 1 diff --git a/core/src/epicli/data/common/validation/epiphany-cluster.yml b/core/src/epicli/data/common/validation/epiphany-cluster.yml index 914516dee2..a9d3a0fef2 100644 --- a/core/src/epicli/data/common/validation/epiphany-cluster.yml +++ b/core/src/epicli/data/common/validation/epiphany-cluster.yml @@ -104,6 +104,17 @@ properties: default: false examples: - true + os_image: + type: string + title: Set the latest cloud OS image verified for use by the Epiphany team for this Epiphany version. + default: 'default' + examples: + - default + - ubuntu-18.04-x86_64 + - redhat-7-x86_64 + - centos-7-x86_64 + - centos-7-arm64 + pattern: ^(default|ubuntu-18.04-x86_64|redhat-7-x86_64|centos-7-x86_64|centos-7-arm64)$ components: "$id": "#/properties/components" type: object diff --git a/docs/home/howto/CLUSTER.md b/docs/home/howto/CLUSTER.md index 9c1baa468d..9a066811fe 100644 --- a/docs/home/howto/CLUSTER.md +++ b/docs/home/howto/CLUSTER.md @@ -427,6 +427,7 @@ To setup the cluster do the following steps from the provisioning machine: key: aws_key secret: aws_secret use_public_ips: false + os_image: default ``` The [region](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html) lets you chose the most optimal place to deploy your cluster. The `key` and `secret` are needed by Terraform and can be generated in the AWS console. More information about that [here](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) @@ -439,6 +440,7 @@ To setup the cluster do the following steps from the provisioning machine: subscription_name: Subscribtion_name use_service_principal: false use_public_ips: false + os_image: default ``` The [region](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html) lets you chose the most optimal place to deploy your cluster. The `subscription_name` is the Azure subscribtion under which you want to deploy the cluster. @@ -464,7 +466,16 @@ To setup the cluster do the following steps from the provisioning machine: Epicli will read this file and automaticly use it for authentication for resource creation and management. - For both `aws`and `azure` there is a `use_public_ips` tag. When this is true the VM's will also have a direct inferface to the internet. While this is easy for setting up a cluster for testing it should not be used in production. A VPN setup should be used which we will document in a different section (TODO). + For both `aws`and `azure`here the following cloud attributes overlap: + - `use_public_ips`: When this is true the VM's will also have a direct inferface to the internet. While this is easy for setting up a cluster for testing it should not be used in production. A VPN setup should be used which we will document in a different section (TODO). + - `os_image`: This attribute lets you more easily select Epiphany team validated and tested OS images. When one is selected it will be applied to **every** `infrastructure/virtual-machine` document in the cluster regardless of user defined ones. + The following values are accepted: + - `default`: The default value when generating a new configuration which will result in the use of user defined `infrastructure/virtual-machine` documents. + - `ubuntu-18.04-x86_64`: Applies the latest validated and tested Ubuntu 18.04 image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. + - `redhat-7-x86_64`: Applies the latest validated and tested RedHat 7.x image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. + - `centos-7-x86_64`: Applies the latest validated and tested CentOS 7.x image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. + - `centos-7-arm64`: Applies the latest validated and tested CentOS 7.x image to all `infrastructure/virtual-machine` documents on `arm64` on AWS. Azure currently does support `arm64`. + The images which will be used for these values will be updated and tested on regular basis. 4. Define the components you want to install: From f04b47957213f5638db9f28d3b71e5a653763573 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 21 May 2021 17:14:55 +0200 Subject: [PATCH 08/23] Fixed Infrastructure/cloud-os-image-defaults to infrastructure/cloud-os-image-defaults --- .../epicli/cli/engine/providers/aws/InfrastructureBuilder.py | 2 +- .../epicli/cli/engine/providers/azure/InfrastructureBuilder.py | 2 +- .../aws/defaults/infrastructure/cloud-os-image-defaults.yml | 2 +- .../azure/defaults/infrastructure/cloud-os-image-defaults.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py index cda8e679b9..6cdf00ba02 100644 --- a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py @@ -258,7 +258,7 @@ def get_virtual_machine(self, component_value): machine_selector, self.docs) # Check if we have a cluster-config OS image defined that we want to apply cluster wide. - cloud_os_image_defaults = self.get_config_or_default(self.docs, 'Infrastructure/cloud-os-image-defaults') + cloud_os_image_defaults = self.get_config_or_default(self.docs, 'infrastructure/cloud-os-image-defaults') cloud_image = self.cluster_model.specification.cloud.os_image if cloud_image != 'default': if not hasattr(cloud_os_image_defaults.specification, cloud_image): diff --git a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py index 7244adf75f..f9322041c9 100644 --- a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py @@ -235,7 +235,7 @@ def get_virtual_machine(self, component_value): machine_selector, self.docs) # Check if we have a cluster-config OS image defined that we want to apply cluster wide. - cloud_os_image_defaults = self.get_config_or_default(self.docs, 'Infrastructure/cloud-os-image-defaults') + cloud_os_image_defaults = self.get_config_or_default(self.docs, 'infrastructure/cloud-os-image-defaults') cloud_image = self.cluster_model.specification.cloud.os_image if cloud_image != 'default': if not hasattr(cloud_os_image_defaults.specification, cloud_image): diff --git a/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml b/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml index ee9d63c27a..4e1a4422b0 100644 --- a/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml +++ b/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml @@ -1,4 +1,4 @@ -kind: Infrastructure/cloud-os-image-defaults +kind: infrastructure/cloud-os-image-defaults title: "Cloud OS Image Defaults" name: default specification: diff --git a/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml b/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml index 853c4af408..c708a4848f 100644 --- a/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml +++ b/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml @@ -1,4 +1,4 @@ -kind: Infrastructure/cloud-os-image-defaults +kind: infrastructure/cloud-os-image-defaults title: "Cloud OS Image Defaults" name: default specification: From 855b255d1428f51181c9b6c7a4a79ebdcefe2298 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 21 May 2021 20:01:46 +0200 Subject: [PATCH 09/23] Update docs/home/howto/CLUSTER.md Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- docs/home/howto/CLUSTER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/home/howto/CLUSTER.md b/docs/home/howto/CLUSTER.md index 9a066811fe..9c7f47a45e 100644 --- a/docs/home/howto/CLUSTER.md +++ b/docs/home/howto/CLUSTER.md @@ -474,7 +474,7 @@ To setup the cluster do the following steps from the provisioning machine: - `ubuntu-18.04-x86_64`: Applies the latest validated and tested Ubuntu 18.04 image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. - `redhat-7-x86_64`: Applies the latest validated and tested RedHat 7.x image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. - `centos-7-x86_64`: Applies the latest validated and tested CentOS 7.x image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. - - `centos-7-arm64`: Applies the latest validated and tested CentOS 7.x image to all `infrastructure/virtual-machine` documents on `arm64` on AWS. Azure currently does support `arm64`. + - `centos-7-arm64`: Applies the latest validated and tested CentOS 7.x image to all `infrastructure/virtual-machine` documents on `arm64` on AWS. Azure currently doesn't support `arm64`. The images which will be used for these values will be updated and tested on regular basis. 4. Define the components you want to install: From d8a08e1b307b098317783242d4741622afb2c42c Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 21 May 2021 20:02:32 +0200 Subject: [PATCH 10/23] Update docs/home/howto/CLUSTER.md Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- docs/home/howto/CLUSTER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/home/howto/CLUSTER.md b/docs/home/howto/CLUSTER.md index 9c7f47a45e..eb95490baa 100644 --- a/docs/home/howto/CLUSTER.md +++ b/docs/home/howto/CLUSTER.md @@ -470,7 +470,7 @@ To setup the cluster do the following steps from the provisioning machine: - `use_public_ips`: When this is true the VM's will also have a direct inferface to the internet. While this is easy for setting up a cluster for testing it should not be used in production. A VPN setup should be used which we will document in a different section (TODO). - `os_image`: This attribute lets you more easily select Epiphany team validated and tested OS images. When one is selected it will be applied to **every** `infrastructure/virtual-machine` document in the cluster regardless of user defined ones. The following values are accepted: - - `default`: The default value when generating a new configuration which will result in the use of user defined `infrastructure/virtual-machine` documents. + - `default`: Applies user defined `infrastructure/virtual-machine` documents when generating a new configuration. - `ubuntu-18.04-x86_64`: Applies the latest validated and tested Ubuntu 18.04 image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. - `redhat-7-x86_64`: Applies the latest validated and tested RedHat 7.x image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. - `centos-7-x86_64`: Applies the latest validated and tested CentOS 7.x image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. From 601ad805e5967415061a8a8eb34a5a454374b72e Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 21 May 2021 20:02:54 +0200 Subject: [PATCH 11/23] Update docs/home/howto/CLUSTER.md Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- docs/home/howto/CLUSTER.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/home/howto/CLUSTER.md b/docs/home/howto/CLUSTER.md index eb95490baa..6788b1b01c 100644 --- a/docs/home/howto/CLUSTER.md +++ b/docs/home/howto/CLUSTER.md @@ -467,8 +467,8 @@ To setup the cluster do the following steps from the provisioning machine: Epicli will read this file and automaticly use it for authentication for resource creation and management. For both `aws`and `azure`here the following cloud attributes overlap: - - `use_public_ips`: When this is true the VM's will also have a direct inferface to the internet. While this is easy for setting up a cluster for testing it should not be used in production. A VPN setup should be used which we will document in a different section (TODO). - - `os_image`: This attribute lets you more easily select Epiphany team validated and tested OS images. When one is selected it will be applied to **every** `infrastructure/virtual-machine` document in the cluster regardless of user defined ones. + - `use_public_ips`: When `true`, the VMs will also have a direct interface to the internet. While this is easy for setting up a cluster for testing it should not be used in production. A VPN setup should be used which we will document in a different section (TODO). + - `os_image`: Lets you more easily select Epiphany team validated and tested OS images. When one is selected, it will be applied to **every** `infrastructure/virtual-machine` document in the cluster regardless of user defined ones. The following values are accepted: - `default`: Applies user defined `infrastructure/virtual-machine` documents when generating a new configuration. - `ubuntu-18.04-x86_64`: Applies the latest validated and tested Ubuntu 18.04 image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS. From fd6aeb25de46c7ac43d622b11b2eef13157100f5 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 21 May 2021 20:03:09 +0200 Subject: [PATCH 12/23] Update docs/home/howto/CLUSTER.md Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- docs/home/howto/CLUSTER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/home/howto/CLUSTER.md b/docs/home/howto/CLUSTER.md index 6788b1b01c..b4c2fb7c57 100644 --- a/docs/home/howto/CLUSTER.md +++ b/docs/home/howto/CLUSTER.md @@ -466,7 +466,7 @@ To setup the cluster do the following steps from the provisioning machine: Epicli will read this file and automaticly use it for authentication for resource creation and management. - For both `aws`and `azure`here the following cloud attributes overlap: + For both `aws`and `azure` the following cloud attributes overlap: - `use_public_ips`: When `true`, the VMs will also have a direct interface to the internet. While this is easy for setting up a cluster for testing it should not be used in production. A VPN setup should be used which we will document in a different section (TODO). - `os_image`: Lets you more easily select Epiphany team validated and tested OS images. When one is selected, it will be applied to **every** `infrastructure/virtual-machine` document in the cluster regardless of user defined ones. The following values are accepted: From 978e201f25b9525a60bcf6e5a3a81706ce76b74d Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 21 May 2021 20:03:18 +0200 Subject: [PATCH 13/23] Update core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- .../azure/defaults/infrastructure/cloud-os-image-defaults.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml b/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml index c708a4848f..432f1affca 100644 --- a/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml +++ b/core/src/epicli/data/azure/defaults/infrastructure/cloud-os-image-defaults.yml @@ -16,4 +16,4 @@ specification: publisher: OpenLogic offer: CentOS sku: "7_9" - version: "7.9.2021020400" \ No newline at end of file + version: "7.9.2021020400" From d5faa247a740c17e90ef9920cf5a1cb622057bba Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 21 May 2021 20:03:23 +0200 Subject: [PATCH 14/23] Update core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- .../aws/defaults/infrastructure/cloud-os-image-defaults.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml b/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml index 4e1a4422b0..7d85f23776 100644 --- a/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml +++ b/core/src/epicli/data/aws/defaults/infrastructure/cloud-os-image-defaults.yml @@ -5,4 +5,5 @@ specification: ubuntu-18.04-x86_64: ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20210323 redhat-7-x86_64: RHEL-7.9_HVM-20210208-x86_64-0-Hourly2-GP2 centos-7-x86_64: CentOS 7.9.2009 x86_64 - centos-7-arm64: CentOS 7.9.2009 aarch64 \ No newline at end of file + centos-7-arm64: CentOS 7.9.2009 aarch64 + From 5103067cd930d42283dea19913ddba641f338c97 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 21 May 2021 20:07:28 +0200 Subject: [PATCH 15/23] - Fixed unit tests again --- .../tests/engine/providers/azure/test_AzureConfigBuilder.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py b/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py index 4c33f711f2..a5b7c0791d 100644 --- a/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py +++ b/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py @@ -127,6 +127,7 @@ def get_cluster_model(address_pool='10.22.0.0/22', cluster_name='EpiphanyTestClu 'region': 'West Europe', 'vnet_address_pool': address_pool, 'use_public_ips': True, + 'os_image': 'default', 'network': { 'use_network_security_groups': True } From 7a19eee0c2fd4328569c43c5151e0cdf3e1582e1 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Thu, 27 May 2021 15:33:14 +0200 Subject: [PATCH 16/23] - Removed questions for Azure. --- .../providers/aws/InfrastructureBuilder.py | 2 +- .../providers/azure/InfrastructureBuilder.py | 22 +++++-------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py index 6cdf00ba02..b877f68d41 100644 --- a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py @@ -276,7 +276,7 @@ def get_virtual_machine(self, component_value): if model_with_defaults.specification.os_full_name == manifest_firstvm_config.specification.os_full_name: return model_with_defaults - self.logger.warning(f"Currently we don`t support changing of OS images with AWS autoscaling groups. Preserving the existing OS image used for VM definition '{machine_selector}'") + self.logger.warning(f"Re-applying a different OS image might lead to data loss and/or other issues. Preserving the existing OS image used for VM definition '{machine_selector}'.") if manifest_vm_config is not None: model_with_defaults.specification.os_full_name = manifest_vm_config.specification.os_full_name diff --git a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py index f9322041c9..4e69d7957e 100644 --- a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py @@ -24,7 +24,6 @@ def __init__(self, docs, manifest_docs=[]): self.use_public_ips = self.cluster_model.specification.cloud.use_public_ips self.docs = docs self.manifest_docs = manifest_docs - self.preserve_os_images = False def run(self): infrastructure = [] @@ -253,21 +252,12 @@ def get_virtual_machine(self, component_value): if model_with_defaults.specification.storage_image_reference == manifest_firstvm_config.specification.storage_image_reference: return model_with_defaults - preserve_os_image = False - if not self.preserve_os_images: - preserve_os_image = query_yes_no(f"""You are about to re-apply a different OS image for the '{machine_selector}' VM definition. This might lead to data loss and/or other issues. -More information about possible issues of re-applying an OS image can be found here: https://github.com/epiphany-platform/epiphany/blob/develop/docs/home/howto/UPGRADE.md#run-apply-after-upgrade -Do you want to preserve the original OS image for VM definition '{machine_selector}'?""") - print("") - if preserve_os_image: - self.preserve_os_images = query_yes_no("""Do you want to preserve the OS images for all other VM definitions in your cluster?""") - print("") - - if preserve_os_image or self.preserve_os_images: - if manifest_vm_config is not None: - model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_vm_config.specification.storage_image_reference)) - else: - model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_firstvm_config.specification.storage_image_reference)) + self.logger.warning(f"Re-applying a different OS image might lead to data loss and/or other issues. Preserving the existing OS image used for VM definition '{machine_selector}'.") + + if manifest_vm_config is not None: + model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_vm_config.specification.storage_image_reference)) + else: + model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(manifest_firstvm_config.specification.storage_image_reference)) return model_with_defaults From e98c60e3d7b1f08b75f95ed1acb3673968a6f941 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Thu, 27 May 2021 15:45:55 +0200 Subject: [PATCH 17/23] - Added documentation. --- docs/home/howto/UPGRADE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/home/howto/UPGRADE.md b/docs/home/howto/UPGRADE.md index a6fa9833d4..cb1ca81b7d 100644 --- a/docs/home/howto/UPGRADE.md +++ b/docs/home/howto/UPGRADE.md @@ -124,6 +124,7 @@ The `epicli upgrade` command has additional flags: ### Run *apply* after *upgrade* Currently Epiphany does not fully support apply after upgrade. There is a possibility to re-apply configuration from newer version of Epicli but this needs some manual work from Administrator. Re-apply on already upgraded cluster needs to be called with `--no-infra` option to skip Terraform part of configuration. +If apply after upgrade is run with `--no-infra` the used system images from the older Epiphany version are preserved to prevent the destruction of the VM`s. If you plan modify any infrastructure unit (eg. add Kubernetes Node) you need to create machine by yourself and attach it into configuration yaml. While running `epicli apply...` on already upgraded cluster you should use config yamls generated in newer version of Epiphany and apply changes you had in older one. If the cluster is upgraded to version 0.8 or newer you need also add additional feature mapping for repository role as shown on example below: From db8e4ce7851276d740ddbc1a98803182de253454 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 28 May 2021 11:51:55 +0200 Subject: [PATCH 18/23] Update docs/home/howto/UPGRADE.md Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- docs/home/howto/UPGRADE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/home/howto/UPGRADE.md b/docs/home/howto/UPGRADE.md index cb1ca81b7d..c6da3134e1 100644 --- a/docs/home/howto/UPGRADE.md +++ b/docs/home/howto/UPGRADE.md @@ -124,7 +124,7 @@ The `epicli upgrade` command has additional flags: ### Run *apply* after *upgrade* Currently Epiphany does not fully support apply after upgrade. There is a possibility to re-apply configuration from newer version of Epicli but this needs some manual work from Administrator. Re-apply on already upgraded cluster needs to be called with `--no-infra` option to skip Terraform part of configuration. -If apply after upgrade is run with `--no-infra` the used system images from the older Epiphany version are preserved to prevent the destruction of the VM`s. +If `apply` after `upgrade` is run with `--no-infra`, the used system images from the older Epiphany version are preserved to prevent the destruction of the VMs. If you plan modify any infrastructure unit (eg. add Kubernetes Node) you need to create machine by yourself and attach it into configuration yaml. While running `epicli apply...` on already upgraded cluster you should use config yamls generated in newer version of Epiphany and apply changes you had in older one. If the cluster is upgraded to version 0.8 or newer you need also add additional feature mapping for repository role as shown on example below: From 1074dd8b1cb9c01c6dc8aca97b8195658d6ae9fe Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 28 May 2021 11:52:19 +0200 Subject: [PATCH 19/23] Update core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- .../epicli/cli/engine/providers/aws/InfrastructureBuilder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py index b877f68d41..62a876720c 100644 --- a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py @@ -262,7 +262,7 @@ def get_virtual_machine(self, component_value): cloud_image = self.cluster_model.specification.cloud.os_image if cloud_image != 'default': if not hasattr(cloud_os_image_defaults.specification, cloud_image): - raise NotImplementedError(f'"{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') + raise NotImplementedError(f'os_image "{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') model_with_defaults.specification.os_full_name = cloud_os_image_defaults.specification[cloud_image] # finally check if we are trying to re-apply a configuration. From d310ec2c294f36d0a05908b5a5d7eff745d9f936 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 28 May 2021 11:52:35 +0200 Subject: [PATCH 20/23] Update core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- .../epicli/cli/engine/providers/azure/InfrastructureBuilder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py index 4e69d7957e..635357eea9 100644 --- a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py @@ -238,7 +238,7 @@ def get_virtual_machine(self, component_value): cloud_image = self.cluster_model.specification.cloud.os_image if cloud_image != 'default': if not hasattr(cloud_os_image_defaults.specification, cloud_image): - raise NotImplementedError(f'"{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') + raise NotImplementedError(f'os_image "{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(cloud_os_image_defaults.specification[cloud_image])) # finally check if we are trying to re-apply a configuration. From e698e31fde9f761c105c06b2010bb11e5bb33a4f Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 28 May 2021 11:52:54 +0200 Subject: [PATCH 21/23] Update docs/home/howto/CLUSTER.md Co-authored-by: to-bar <46519524+to-bar@users.noreply.github.com> --- docs/home/howto/CLUSTER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/home/howto/CLUSTER.md b/docs/home/howto/CLUSTER.md index b4c2fb7c57..2794034d27 100644 --- a/docs/home/howto/CLUSTER.md +++ b/docs/home/howto/CLUSTER.md @@ -467,7 +467,7 @@ To setup the cluster do the following steps from the provisioning machine: Epicli will read this file and automaticly use it for authentication for resource creation and management. For both `aws`and `azure` the following cloud attributes overlap: - - `use_public_ips`: When `true`, the VMs will also have a direct interface to the internet. While this is easy for setting up a cluster for testing it should not be used in production. A VPN setup should be used which we will document in a different section (TODO). + - `use_public_ips`: When `true`, the VMs will also have a direct interface to the internet. While this is easy for setting up a cluster for testing, it should not be used in production. A VPN setup should be used which we will document in a different section (TODO). - `os_image`: Lets you more easily select Epiphany team validated and tested OS images. When one is selected, it will be applied to **every** `infrastructure/virtual-machine` document in the cluster regardless of user defined ones. The following values are accepted: - `default`: Applies user defined `infrastructure/virtual-machine` documents when generating a new configuration. From 9e3e31809e1abb675ac997afb6c97e95b36cf5b7 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 28 May 2021 12:21:36 +0200 Subject: [PATCH 22/23] Renamed os_image to default_os_image --- .../epicli/cli/engine/providers/aws/InfrastructureBuilder.py | 4 ++-- .../cli/engine/providers/azure/InfrastructureBuilder.py | 4 ++-- .../aws/defaults/configuration/minimal-cluster-config.yml | 2 +- .../azure/defaults/configuration/minimal-cluster-config.yml | 2 +- core/src/epicli/data/common/defaults/epiphany-cluster.yml | 2 +- core/src/epicli/data/common/validation/epiphany-cluster.yml | 2 +- .../tests/engine/providers/azure/test_AzureConfigBuilder.py | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py index 62a876720c..7978ac5d82 100644 --- a/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/aws/InfrastructureBuilder.py @@ -259,10 +259,10 @@ def get_virtual_machine(self, component_value): # Check if we have a cluster-config OS image defined that we want to apply cluster wide. cloud_os_image_defaults = self.get_config_or_default(self.docs, 'infrastructure/cloud-os-image-defaults') - cloud_image = self.cluster_model.specification.cloud.os_image + cloud_image = self.cluster_model.specification.cloud.default_os_image if cloud_image != 'default': if not hasattr(cloud_os_image_defaults.specification, cloud_image): - raise NotImplementedError(f'os_image "{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') + raise NotImplementedError(f'default_os_image "{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') model_with_defaults.specification.os_full_name = cloud_os_image_defaults.specification[cloud_image] # finally check if we are trying to re-apply a configuration. diff --git a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py index 635357eea9..6e84e30df5 100644 --- a/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py +++ b/core/src/epicli/cli/engine/providers/azure/InfrastructureBuilder.py @@ -235,10 +235,10 @@ def get_virtual_machine(self, component_value): # Check if we have a cluster-config OS image defined that we want to apply cluster wide. cloud_os_image_defaults = self.get_config_or_default(self.docs, 'infrastructure/cloud-os-image-defaults') - cloud_image = self.cluster_model.specification.cloud.os_image + cloud_image = self.cluster_model.specification.cloud.default_os_image if cloud_image != 'default': if not hasattr(cloud_os_image_defaults.specification, cloud_image): - raise NotImplementedError(f'os_image "{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') + raise NotImplementedError(f'default_os_image "{cloud_image}" is unsupported for "{self.cluster_model.provider}" provider.') model_with_defaults.specification.storage_image_reference = dict_to_objdict(deepcopy(cloud_os_image_defaults.specification[cloud_image])) # finally check if we are trying to re-apply a configuration. diff --git a/core/src/epicli/data/aws/defaults/configuration/minimal-cluster-config.yml b/core/src/epicli/data/aws/defaults/configuration/minimal-cluster-config.yml index 15f1d9a93b..049c019715 100644 --- a/core/src/epicli/data/aws/defaults/configuration/minimal-cluster-config.yml +++ b/core/src/epicli/data/aws/defaults/configuration/minimal-cluster-config.yml @@ -14,7 +14,7 @@ specification: credentials: key: XXXX-XXXX-XXXX secret: XXXXXXXXXXXXXXXX - os_image: default + default_os_image: default components: repository: count: 1 diff --git a/core/src/epicli/data/azure/defaults/configuration/minimal-cluster-config.yml b/core/src/epicli/data/azure/defaults/configuration/minimal-cluster-config.yml index 8f2507d706..050e2bf5b8 100644 --- a/core/src/epicli/data/azure/defaults/configuration/minimal-cluster-config.yml +++ b/core/src/epicli/data/azure/defaults/configuration/minimal-cluster-config.yml @@ -11,7 +11,7 @@ specification: cloud: k8s_as_cloud_service: False use_public_ips: False # When not using public IPs you have to provide connectivity via private IPs (VPN) - os_image: default + default_os_image: default components: repository: count: 1 diff --git a/core/src/epicli/data/common/defaults/epiphany-cluster.yml b/core/src/epicli/data/common/defaults/epiphany-cluster.yml index 09e4e3fdad..2f7ba91bd4 100644 --- a/core/src/epicli/data/common/defaults/epiphany-cluster.yml +++ b/core/src/epicli/data/common/defaults/epiphany-cluster.yml @@ -20,7 +20,7 @@ specification: secret: DADFAFHCJHCAUYEAk network: use_network_security_groups: True - os_image: default + default_os_image: default components: kubernetes_master: count: 1 diff --git a/core/src/epicli/data/common/validation/epiphany-cluster.yml b/core/src/epicli/data/common/validation/epiphany-cluster.yml index a9d3a0fef2..0451c69c4f 100644 --- a/core/src/epicli/data/common/validation/epiphany-cluster.yml +++ b/core/src/epicli/data/common/validation/epiphany-cluster.yml @@ -104,7 +104,7 @@ properties: default: false examples: - true - os_image: + default_os_image: type: string title: Set the latest cloud OS image verified for use by the Epiphany team for this Epiphany version. default: 'default' diff --git a/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py b/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py index a5b7c0791d..e24a15acf1 100644 --- a/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py +++ b/core/src/epicli/tests/engine/providers/azure/test_AzureConfigBuilder.py @@ -127,7 +127,7 @@ def get_cluster_model(address_pool='10.22.0.0/22', cluster_name='EpiphanyTestClu 'region': 'West Europe', 'vnet_address_pool': address_pool, 'use_public_ips': True, - 'os_image': 'default', + 'default_os_image': 'default', 'network': { 'use_network_security_groups': True } From 7e0c865d4e335f9c91177afcc7888491a292a9d3 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Fri, 28 May 2021 13:22:08 +0200 Subject: [PATCH 23/23] Fixed documentation. --- docs/home/howto/CLUSTER.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/home/howto/CLUSTER.md b/docs/home/howto/CLUSTER.md index 2794034d27..4aa3e4f8a1 100644 --- a/docs/home/howto/CLUSTER.md +++ b/docs/home/howto/CLUSTER.md @@ -427,7 +427,7 @@ To setup the cluster do the following steps from the provisioning machine: key: aws_key secret: aws_secret use_public_ips: false - os_image: default + default_os_image: default ``` The [region](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html) lets you chose the most optimal place to deploy your cluster. The `key` and `secret` are needed by Terraform and can be generated in the AWS console. More information about that [here](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) @@ -440,7 +440,7 @@ To setup the cluster do the following steps from the provisioning machine: subscription_name: Subscribtion_name use_service_principal: false use_public_ips: false - os_image: default + default_os_image: default ``` The [region](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html) lets you chose the most optimal place to deploy your cluster. The `subscription_name` is the Azure subscribtion under which you want to deploy the cluster. @@ -468,7 +468,7 @@ To setup the cluster do the following steps from the provisioning machine: For both `aws`and `azure` the following cloud attributes overlap: - `use_public_ips`: When `true`, the VMs will also have a direct interface to the internet. While this is easy for setting up a cluster for testing, it should not be used in production. A VPN setup should be used which we will document in a different section (TODO). - - `os_image`: Lets you more easily select Epiphany team validated and tested OS images. When one is selected, it will be applied to **every** `infrastructure/virtual-machine` document in the cluster regardless of user defined ones. + - `default_os_image`: Lets you more easily select Epiphany team validated and tested OS images. When one is selected, it will be applied to **every** `infrastructure/virtual-machine` document in the cluster regardless of user defined ones. The following values are accepted: - `default`: Applies user defined `infrastructure/virtual-machine` documents when generating a new configuration. - `ubuntu-18.04-x86_64`: Applies the latest validated and tested Ubuntu 18.04 image to all `infrastructure/virtual-machine` documents on `x86_64` on Azure and AWS.