Exemple #1
0
def ingress_controller(cli_arguments, kube_apis, ingress_controller_prerequisites, request) -> str:
    """
    Create Ingress Controller according to the context.

    :param cli_arguments: context
    :param kube_apis: client apis
    :param ingress_controller_prerequisites
    :param request: pytest fixture
    :return: IC name
    """
    namespace = ingress_controller_prerequisites.namespace
    name = "nginx-ingress"
    print("------------------------- Create IC without CRDs -----------------------------------")
    try:
        extra_args = request.param.get('extra_args', None)
        extra_args.append("-enable-custom-resources=false")
    except AttributeError:
        print("IC will start with CRDs disabled and without any additional cli-arguments")
        extra_args = ["-enable-custom-resources=false"]
    try:
        name = create_ingress_controller(kube_apis.v1, kube_apis.apps_v1_api, cli_arguments, namespace, extra_args)
    except ApiException as ex:
        # Finalizer doesn't start if fixture creation was incomplete, ensure clean up here
        print(f"Failed to complete IC fixture: {ex}\nClean up the cluster as much as possible.")
        delete_ingress_controller(kube_apis.apps_v1_api, name, cli_arguments['deployment-type'], namespace)

    def fin():
        print("Delete IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name, cli_arguments['deployment-type'], namespace)

    request.addfinalizer(fin)

    return name
Exemple #2
0
 def fin():
     print("--------------Cleanup----------------")
     delete_crd(
         kube_apis.api_extensions_v1_beta1,
         ap_pol_crd_name,
     )
     delete_crd(
         kube_apis.api_extensions_v1_beta1,
         ap_log_crd_name,
     )
     delete_crd(
         kube_apis.api_extensions_v1_beta1,
         ap_uds_crd_name,
     )
     delete_crd(
         kube_apis.api_extensions_v1_beta1,
         vs_crd_name,
     )
     delete_crd(
         kube_apis.api_extensions_v1_beta1,
         vsr_crd_name,
     )
     delete_crd(
         kube_apis.api_extensions_v1_beta1,
         pol_crd_name,
     )
     delete_crd(
         kube_apis.api_extensions_v1_beta1,
         ts_crd_name,
     )
     print("Remove ap-rbac")
     cleanup_rbac(kube_apis.rbac_v1, rbac)
     print("Remove the IC:")
     delete_ingress_controller(kube_apis.apps_v1_api, name,
                               cli_arguments["deployment-type"], namespace)
Exemple #3
0
 def fin():
     delete_crd(kube_apis.api_extensions_v1_beta1, vs_crd_name)
     delete_crd(kube_apis.api_extensions_v1_beta1, vsr_crd_name)
     print("Restore the ClusterRole:")
     patch_rbac(kube_apis.rbac_v1_beta1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
     print("Remove the IC:")
     delete_ingress_controller(kube_apis.apps_v1_api, name, cli_arguments['deployment-type'], namespace)
def crd_ingress_controller(cli_arguments, kube_apis,
                           ingress_controller_prerequisites,
                           ingress_controller_endpoint, request, crds) -> None:
    """
    Create an Ingress Controller with CRD enabled.

    :param crds: the common ingress controller crds.
    :param cli_arguments: pytest context
    :param kube_apis: client apis
    :param ingress_controller_prerequisites
    :param ingress_controller_endpoint:
    :param request: pytest fixture to parametrize this method
        {type: complete|rbac-without-vs, extra_args: }
        'type' type of test pre-configuration
        'extra_args' list of IC cli arguments
    :return:
    """
    namespace = ingress_controller_prerequisites.namespace
    name = "nginx-ingress"

    try:
        print(
            "------------------------- Update ClusterRole -----------------------------------"
        )
        if request.param["type"] == "rbac-without-vs":
            patch_rbac(kube_apis.rbac_v1,
                       f"{TEST_DATA}/virtual-server/rbac-without-vs.yaml")
        print(
            "------------------------- Create IC -----------------------------------"
        )
        name = create_ingress_controller(
            kube_apis.v1,
            kube_apis.apps_v1_api,
            cli_arguments,
            namespace,
            request.param.get("extra_args", None),
        )
        ensure_connection_to_public_endpoint(
            ingress_controller_endpoint.public_ip,
            ingress_controller_endpoint.port,
            ingress_controller_endpoint.port_ssl,
        )
    except ApiException as ex:
        # Finalizer method doesn't start if fixture creation was incomplete, ensure clean up here
        print("Restore the ClusterRole:")
        patch_rbac(kube_apis.rbac_v1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name,
                                  cli_arguments["deployment-type"], namespace)
        pytest.fail("IC setup failed")

    def fin():
        print("Restore the ClusterRole:")
        patch_rbac(kube_apis.rbac_v1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name,
                                  cli_arguments["deployment-type"], namespace)

    request.addfinalizer(fin)
 def fin():
     delete_crds_from_yaml(
         kube_apis.api_extensions_v1_beta1,
         f"{DEPLOYMENTS}/common/custom-resource-definitions.yaml")
     print("Restore the ClusterRole:")
     patch_rbac(kube_apis.rbac_v1_beta1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
     print("Remove the IC:")
     delete_ingress_controller(kube_apis.apps_v1_api, name,
                               cli_arguments['deployment-type'], namespace)
Exemple #6
0
def crd_ingress_controller(cli_arguments, kube_apis, ingress_controller_prerequisites,
                           ingress_controller_endpoint,
                           request) -> None:
    """
    Create an Ingress Controller with CRD enabled.

    :param cli_arguments: pytest context
    :param kube_apis: client apis
    :param ingress_controller_prerequisites
    :param ingress_controller_endpoint:
    :param request: pytest fixture to parametrize this method
        {type: complete|rbac-without-vs, extra_args: }
        'type' type of test pre-configuration
        'extra_args' list of IC cli arguments
    :return:
    """
    namespace = ingress_controller_prerequisites.namespace
    name = "nginx-ingress"
    vs_crd_name = get_name_from_yaml(f"{DEPLOYMENTS}/common/vs-definition.yaml")
    vsr_crd_name = get_name_from_yaml(f"{DEPLOYMENTS}/common/vsr-definition.yaml")

    try:
        print("------------------------- Update ClusterRole -----------------------------------")
        if request.param['type'] == 'rbac-without-vs':
            patch_rbac(kube_apis.rbac_v1_beta1, f"{TEST_DATA}/virtual-server/rbac-without-vs.yaml")
        print("------------------------- Register CRDs -----------------------------------")
        create_crd_from_yaml(kube_apis.api_extensions_v1_beta1, vs_crd_name,
                             f"{DEPLOYMENTS}/common/vs-definition.yaml")
        create_crd_from_yaml(kube_apis.api_extensions_v1_beta1, vsr_crd_name,
                             f"{DEPLOYMENTS}/common/vsr-definition.yaml")
        print("------------------------- Create IC -----------------------------------")
        name = create_ingress_controller(kube_apis.v1, kube_apis.apps_v1_api, cli_arguments, namespace,
                                         request.param.get('extra_args', None))
        ensure_connection_to_public_endpoint(ingress_controller_endpoint.public_ip,
                                             ingress_controller_endpoint.port,
                                             ingress_controller_endpoint.port_ssl)
    except ApiException as ex:
        # Finalizer method doesn't start if fixture creation was incomplete, ensure clean up here
        print(f"Failed to complete CRD IC fixture: {ex}\nClean up the cluster as much as possible.")
        delete_crd(kube_apis.api_extensions_v1_beta1, vs_crd_name)
        delete_crd(kube_apis.api_extensions_v1_beta1, vsr_crd_name)
        print("Restore the ClusterRole:")
        patch_rbac(kube_apis.rbac_v1_beta1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name, cli_arguments['deployment-type'], namespace)

    def fin():
        delete_crd(kube_apis.api_extensions_v1_beta1, vs_crd_name)
        delete_crd(kube_apis.api_extensions_v1_beta1, vsr_crd_name)
        print("Restore the ClusterRole:")
        patch_rbac(kube_apis.rbac_v1_beta1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name, cli_arguments['deployment-type'], namespace)

    request.addfinalizer(fin)
 def fin():
     print("Restore the ClusterRole:")
     patch_rbac(kube_apis.rbac_v1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
     print("Remove the DNSEndpoint CRD:")
     delete_crd(
         kube_apis.api_extensions_v1,
         external_dns_crd_name,
     )
     print("Remove the IC:")
     delete_ingress_controller(kube_apis.apps_v1_api, name,
                               cli_arguments["deployment-type"], namespace)
     replace_configmap_from_yaml(
         kube_apis.v1,
         ingress_controller_prerequisites.config_map["metadata"]["name"],
         ingress_controller_prerequisites.namespace,
         f"{DEPLOYMENTS}/common/nginx-config.yaml",
     )
 def fin():
     print("--------------Cleanup----------------")
     delete_crd(
         kube_apis.api_extensions_v1,
         dos_pol_crd_name,
     )
     delete_crd(
         kube_apis.api_extensions_v1,
         dos_log_crd_name,
     )
     delete_crd(
         kube_apis.api_extensions_v1,
         dos_protected_crd_name,
     )
     print("Remove ap-rbac")
     cleanup_rbac(kube_apis.rbac_v1, rbac)
     print("Remove dos arbitrator:")
     delete_dos_arbitrator(kube_apis.v1, kube_apis.apps_v1_api,
                           dos_arbitrator_name, namespace)
     print("Remove the IC:")
     delete_ingress_controller(kube_apis.apps_v1_api, name,
                               cli_arguments["deployment-type"], namespace)
     print("Remove the syslog svc:")
     delete_items_from_yaml(kube_apis, src_syslog_yaml, namespace)
Exemple #9
0
 def fin():
     print("Delete IC:")
     delete_ingress_controller(extensions_v1_beta1, name, request.param, namespace)
Exemple #10
0
 def fin():
     print("Delete IC:")
     delete_ingress_controller(kube_apis.apps_v1_api, name, cli_arguments['deployment-type'], namespace)
Exemple #11
0
 def fin():
     print("Restore the ClusterRole:")
     patch_rbac(kube_apis.rbac_v1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
     print("Remove the IC:")
     delete_ingress_controller(kube_apis.apps_v1_api, name,
                               cli_arguments["deployment-type"], namespace)
Exemple #12
0
def crd_ingress_controller_with_dos(cli_arguments, kube_apis,
                                    ingress_controller_prerequisites,
                                    ingress_controller_endpoint, request,
                                    crds) -> None:
    """
    Create an Ingress Controller with DOS CRDs enabled.
    :param crds: the common IC crds.
    :param cli_arguments: pytest context
    :param kube_apis: client apis
    :param ingress_controller_prerequisites
    :param ingress_controller_endpoint:
    :param request: pytest fixture to parametrize this method
        {extra_args: }
        'extra_args' list of IC arguments
    :return:
    """
    namespace = ingress_controller_prerequisites.namespace
    name = "nginx-ingress"

    try:
        print(
            "--------------------Create roles and bindings for AppProtect------------------------"
        )
        rbac = configure_rbac_with_dos(kube_apis.rbac_v1)

        print(
            "------------------------- Register AP CRD -----------------------------------"
        )
        dos_pol_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds/appprotectdos.f5.com_apdospolicy.yaml")
        dos_log_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds/appprotectdos.f5.com_apdoslogconfs.yaml"
        )
        dos_protected_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds/appprotectdos.f5.com_dosprotectedresources.yaml"
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1,
            dos_pol_crd_name,
            f"{DEPLOYMENTS}/common/crds/appprotectdos.f5.com_apdospolicy.yaml",
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1,
            dos_log_crd_name,
            f"{DEPLOYMENTS}/common/crds/appprotectdos.f5.com_apdoslogconfs.yaml",
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1,
            dos_protected_crd_name,
            f"{DEPLOYMENTS}/common/crds/appprotectdos.f5.com_dosprotectedresources.yaml",
        )

        print(
            "------------------------- Create syslog svc -----------------------"
        )
        src_syslog_yaml = f"{TEST_DATA}/dos/dos-syslog.yaml"
        log_loc = f"/var/log/messages"
        create_items_from_yaml(kube_apis, src_syslog_yaml, namespace)
        before = time.time()
        wait_until_all_pods_are_ready(kube_apis.v1, namespace)
        after = time.time()
        print(f"All pods came up in {int(after-before)} seconds")
        print(f"syslog svc was created")

        print(
            "------------------------- Create dos arbitrator -----------------------"
        )
        dos_arbitrator_name = create_dos_arbitrator(
            kube_apis.v1,
            kube_apis.apps_v1_api,
            namespace,
        )

        print(
            "------------------------- Create IC -----------------------------------"
        )
        name = create_ingress_controller(
            kube_apis.v1,
            kube_apis.apps_v1_api,
            cli_arguments,
            namespace,
            request.param.get("extra_args", None),
        )
        ensure_connection_to_public_endpoint(
            ingress_controller_endpoint.public_ip,
            ingress_controller_endpoint.port,
            ingress_controller_endpoint.port_ssl,
        )
    except Exception as ex:
        print(
            f"Failed to complete CRD IC fixture: {ex}\nClean up the cluster as much as possible."
        )
        delete_crd(
            kube_apis.api_extensions_v1,
            dos_pol_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1,
            dos_log_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1,
            dos_protected_crd_name,
        )
        print("Remove ap-rbac")
        cleanup_rbac(kube_apis.rbac_v1, rbac)
        print("Remove dos arbitrator:")
        delete_dos_arbitrator(kube_apis.v1, kube_apis.apps_v1_api,
                              dos_arbitrator_name, namespace)
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name,
                                  cli_arguments["deployment-type"], namespace)
        pytest.fail("IC setup failed")

    def fin():
        print("--------------Cleanup----------------")
        delete_crd(
            kube_apis.api_extensions_v1,
            dos_pol_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1,
            dos_log_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1,
            dos_protected_crd_name,
        )
        print("Remove ap-rbac")
        cleanup_rbac(kube_apis.rbac_v1, rbac)
        print("Remove dos arbitrator:")
        delete_dos_arbitrator(kube_apis.v1, kube_apis.apps_v1_api,
                              dos_arbitrator_name, namespace)
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name,
                                  cli_arguments["deployment-type"], namespace)
        print("Remove the syslog svc:")
        delete_items_from_yaml(kube_apis, src_syslog_yaml, namespace)

    request.addfinalizer(fin)
Exemple #13
0
def crd_ingress_controller_with_ap(cli_arguments, kube_apis,
                                   ingress_controller_prerequisites,
                                   ingress_controller_endpoint,
                                   request) -> None:
    """
    Create an Ingress Controller with AppProtect CRD enabled.
    :param cli_arguments: pytest context
    :param kube_apis: client apis
    :param ingress_controller_prerequisites
    :param ingress_controller_endpoint:
    :param request: pytest fixture to parametrize this method
        {extra_args: }
        'extra_args' list of IC arguments
    :return:
    """
    namespace = ingress_controller_prerequisites.namespace
    name = "nginx-ingress"
    try:
        print(
            "--------------------Create roles and bindings for AppProtect------------------------"
        )
        rbac = configure_rbac_with_ap(kube_apis.rbac_v1)

        print(
            "------------------------- Register AP CRD -----------------------------------"
        )
        ap_pol_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds-v1beta1/appprotect.f5.com_appolicies.yaml"
        )
        ap_log_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds-v1beta1/appprotect.f5.com_aplogconfs.yaml"
        )
        ap_uds_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds-v1beta1/appprotect.f5.com_apusersigs.yaml"
        )
        vs_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds-v1beta1/k8s.nginx.org_virtualservers.yaml"
        )
        vsr_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds-v1beta1/k8s.nginx.org_virtualserverroutes.yaml"
        )
        pol_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds-v1beta1/k8s.nginx.org_policies.yaml")
        ts_crd_name = get_name_from_yaml(
            f"{DEPLOYMENTS}/common/crds-v1beta1/k8s.nginx.org_transportservers.yaml"
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1_beta1,
            ap_pol_crd_name,
            f"{DEPLOYMENTS}/common/crds-v1beta1/appprotect.f5.com_appolicies.yaml",
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1_beta1,
            ap_log_crd_name,
            f"{DEPLOYMENTS}/common/crds-v1beta1/appprotect.f5.com_aplogconfs.yaml",
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1_beta1,
            ap_uds_crd_name,
            f"{DEPLOYMENTS}/common/crds-v1beta1/appprotect.f5.com_apusersigs.yaml",
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1_beta1,
            vs_crd_name,
            f"{DEPLOYMENTS}/common/crds-v1beta1/k8s.nginx.org_virtualservers.yaml",
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1_beta1,
            vsr_crd_name,
            f"{DEPLOYMENTS}/common/crds-v1beta1/k8s.nginx.org_virtualserverroutes.yaml",
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1_beta1,
            pol_crd_name,
            f"{DEPLOYMENTS}/common/crds-v1beta1/k8s.nginx.org_policies.yaml",
        )
        create_crd_from_yaml(
            kube_apis.api_extensions_v1_beta1,
            ts_crd_name,
            f"{DEPLOYMENTS}/common/crds-v1beta1/k8s.nginx.org_transportservers.yaml",
        )

        print(
            "------------------------- Create IC -----------------------------------"
        )
        name = create_ingress_controller(
            kube_apis.v1,
            kube_apis.apps_v1_api,
            cli_arguments,
            namespace,
            request.param.get("extra_args", None),
        )
        ensure_connection_to_public_endpoint(
            ingress_controller_endpoint.public_ip,
            ingress_controller_endpoint.port,
            ingress_controller_endpoint.port_ssl,
        )
    except Exception as ex:
        print(
            f"Failed to complete CRD IC fixture: {ex}\nClean up the cluster as much as possible."
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            ap_pol_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            ap_log_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            ap_uds_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            vs_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            vsr_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            pol_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            ts_crd_name,
        )
        print("Remove ap-rbac")
        cleanup_rbac(kube_apis.rbac_v1, rbac)
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name,
                                  cli_arguments["deployment-type"], namespace)

    def fin():
        print("--------------Cleanup----------------")
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            ap_pol_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            ap_log_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            ap_uds_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            vs_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            vsr_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            pol_crd_name,
        )
        delete_crd(
            kube_apis.api_extensions_v1_beta1,
            ts_crd_name,
        )
        print("Remove ap-rbac")
        cleanup_rbac(kube_apis.rbac_v1, rbac)
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name,
                                  cli_arguments["deployment-type"], namespace)

    request.addfinalizer(fin)
 def fin():
     print("Remove IC and wildcard secret:")
     delete_ingress_controller(kube_apis.extensions_v1_beta1, name,
                               request.param, namespace)
     if is_secret_present(kube_apis.v1, secret_name, namespace):
         delete_secret(kube_apis.v1, secret_name, namespace)
 def fin():
     print("Remove IC and wildcard secret:")
     delete_ingress_controller(kube_apis.extensions_v1_beta1, name, cli_arguments['deployment-type'], namespace)
     if is_secret_present(kube_apis.v1, secret_name, namespace):
         delete_secret(kube_apis.v1, secret_name, namespace)
Exemple #16
0
 def fin():
     print("Delete IC:")
     delete_ingress_controller(extensions_v1_beta1, name,
                               cli_arguments['deployment-type'], namespace)
Exemple #17
0
def crd_ingress_controller_with_ed(cli_arguments, kube_apis,
                                   ingress_controller_prerequisites,
                                   ingress_controller_endpoint, request,
                                   crds) -> None:
    """
    Create an Ingress Controller with CRD enabled.

    :param crds: the common ingress controller crds.
    :param cli_arguments: pytest context
    :param kube_apis: client apis
    :param ingress_controller_prerequisites
    :param ingress_controller_endpoint:
    :param request: pytest fixture to parametrize this method
        {type: complete|rbac-without-vs, extra_args: }
        'type' type of test pre-configuration
        'extra_args' list of IC cli arguments
    :return:
    """
    namespace = ingress_controller_prerequisites.namespace
    name = "nginx-ingress"

    print(
        "---------------------- Register DNSEndpoint CRD ------------------------------"
    )
    external_dns_crd_name = get_name_from_yaml(
        f"{DEPLOYMENTS}/common/crds/externaldns.nginx.org_dnsendpoints.yaml")
    create_crd_from_yaml(
        kube_apis.api_extensions_v1,
        external_dns_crd_name,
        f"{DEPLOYMENTS}/common/crds/externaldns.nginx.org_dnsendpoints.yaml",
    )

    try:
        print(
            "------------------------- Create IC -----------------------------------"
        )
        name = create_ingress_controller(
            kube_apis.v1,
            kube_apis.apps_v1_api,
            cli_arguments,
            namespace,
            request.param.get("extra_args", None),
        )
        ensure_connection_to_public_endpoint(
            ingress_controller_endpoint.public_ip,
            ingress_controller_endpoint.port,
            ingress_controller_endpoint.port_ssl,
        )
        print(
            "---------------- Replace ConfigMap with external-status-address --------------------"
        )
        cm_source = f"{TEST_DATA}/virtual-server-external-dns/nginx-config.yaml"
        replace_configmap_from_yaml(
            kube_apis.v1,
            ingress_controller_prerequisites.config_map['metadata']['name'],
            ingress_controller_prerequisites.namespace, cm_source)
    except ApiException as ex:
        # Finalizer method doesn't start if fixture creation was incomplete, ensure clean up here
        print("Restore the ClusterRole:")
        patch_rbac(kube_apis.rbac_v1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
        print("Remove the DNSEndpoint CRD:")
        delete_crd(
            kube_apis.api_extensions_v1,
            external_dns_crd_name,
        )
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name,
                                  cli_arguments["deployment-type"], namespace)
        replace_configmap_from_yaml(
            kube_apis.v1,
            ingress_controller_prerequisites.config_map["metadata"]["name"],
            ingress_controller_prerequisites.namespace,
            f"{DEPLOYMENTS}/common/nginx-config.yaml",
        )
        pytest.fail("IC setup failed")

    def fin():
        print("Restore the ClusterRole:")
        patch_rbac(kube_apis.rbac_v1, f"{DEPLOYMENTS}/rbac/rbac.yaml")
        print("Remove the DNSEndpoint CRD:")
        delete_crd(
            kube_apis.api_extensions_v1,
            external_dns_crd_name,
        )
        print("Remove the IC:")
        delete_ingress_controller(kube_apis.apps_v1_api, name,
                                  cli_arguments["deployment-type"], namespace)
        replace_configmap_from_yaml(
            kube_apis.v1,
            ingress_controller_prerequisites.config_map["metadata"]["name"],
            ingress_controller_prerequisites.namespace,
            f"{DEPLOYMENTS}/common/nginx-config.yaml",
        )

    request.addfinalizer(fin)
 def fin():
     print("Remove IC and wildcard secret:")
     delete_ingress_controller(kube_apis.apps_v1_api, name,
                               cli_arguments['deployment-type'], namespace)
     if is_secret_present(kube_apis.v1, secret_name, namespace):
         delete_secret(kube_apis.v1, secret_name, namespace)
 def fin():
     print("Delete IC:")
     delete_ingress_controller(extensions_v1_beta1, name, cli_arguments['deployment-type'], namespace)