Ejemplo n.º 1
0
def deploy_app(deployment_config: dict, config_dir: str,
               tag_to_deploy: str) -> dict:
    """Deploy a new version of an application on kubernetes
    following the provided configuration."""
    templates_path = os.path.join(config_dir,
                                  K8sConfiguration.get_templates_dir())
    templates = builders.load_templates(templates_path)

    previous_status = get_deployment_status(deployment_config)

    if has_process(deployment_config, WEB_PROCESS_NAME):
        deploy_app_ingress(deployment_config, WEB_PROCESS_NAME, templates)

    deployment_yaml = builders.build_deployment_yaml(deployment_config,
                                                     templates, tag_to_deploy)
    write_and_deploy_configuration(deployment_config["cluster_name"],
                                   deployment_yaml)

    new_status = get_deployment_status(deployment_config)
    status_changes = get_deployment_statuses_diff(previous_status, new_status)

    return status_changes
Ejemplo n.º 2
0
 def test_get_templates_dir_configured(self):
     template_dir = K8sConfiguration.get_templates_dir()
     self.assertEqual(template_dir, "custom")
Ejemplo n.º 3
0
 def test_get_templates_dir_default(self):
     del os.environ["NESTOR_K8S_TEMPLATE_FOLDER"]
     template_dir = K8sConfiguration.get_templates_dir()
     self.assertEqual(template_dir, "templates")