def main():
    deploy_options = deployment_options.load_deployment_options()
    utils.verify_build_directory(deploy_options.namespace)

    src_file = os.path.join(os.getcwd(), 'deploy/mariadb/mariadb-configmap.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace, 'mariadb-configmap.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE', f'"{deploy_options.namespace}"')
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        file=dst_file
    )

    src_file = os.path.join(os.getcwd(), 'deploy/mariadb/mariadb-deployment.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace, 'mariadb-deployment.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE', f'"{deploy_options.namespace}"')
            print("Deploying {}".format(dst_file))
            dst.write(data)
    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        file=dst_file
    )

    src_file = os.path.join(os.getcwd(), 'deploy/mariadb/mariadb-storage.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace, 'mariadb-storage.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE', f'"{deploy_options.namespace}"')
            try:
                kubectl_cmd = utils.get_kubectl_command(
                    target=deploy_options.target,
                    namespace=deploy_options.namespace
                )
                size = utils.check_output(
                    f'{kubectl_cmd} get persistentvolumeclaims mariadb-pv-claim ' +
                    '-o=jsonpath="{.status.capacity.storage}"')
                print("Using existing disk size", size)
            except:
                size = "10Gi"
                print("Using default size", size)
            data = data.replace("REPLACE_STORAGE", size)
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        file=dst_file
    )
Esempio n. 2
0
def main():
    utils.verify_build_directory(deploy_options.namespace)

    ocm_secret = deploy_options.secret
    if ocm_secret == "":
        ocm_secret = '""'
    ocm_id = deploy_options.id
    if ocm_id == "":
        ocm_id = '""'

    src_file = os.path.join(os.getcwd(), 'deploy/assisted-installer-sso.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                            'assisted-installer-sso.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            data = data.replace('REPLACE_OCM_SECRET', ocm_secret)
            data = data.replace('REPLACE_OCM_ID', ocm_id)
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=dst_file)
Esempio n. 3
0
def main():
    deploy_options = deployment_options.load_deployment_options()

    utils.verify_build_directory(deploy_options.namespace)

    dst_dir = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                           'rbac')
    if os.path.exists(dst_dir):
        shutil.rmtree(dst_dir)
    shutil.copytree('config/rbac', dst_dir)

    if deploy_options.target == deployment_options.OCP_TARGET:
        dst_file = os.path.join(dst_dir, 'ocp/kustomization.yaml')
    else:
        dst_file = os.path.join(dst_dir, 'base/kustomization.yaml')

    if deploy_options.enable_kube_api:
        dst_file = os.path.join(dst_dir, 'kustomization.yaml')

    with open(dst_file, "a") as dst:
        log.info(f"Deploying {dst_file}")
        dst.write("namespace: " + deploy_options.namespace + '\n')

    if deploy_options.apply_manifest:
        utils.apply_kustomize(
            target=deploy_options.target,
            namespace=deploy_options.namespace,
            file=os.path.dirname(dst_file),
        )
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--delete-namespace", type=lambda x: (str(x).lower() == 'true'), default=True)
    parser.add_argument("--delete-pvc", type=lambda x: (str(x).lower() == 'true'), default=False)
    deploy_options = deployment_options.load_deployment_options(parser)

    utils.verify_build_directory(deploy_options.namespace)

    kubectl_cmd = utils.get_kubectl_command(
        target=deploy_options.target,
        profile=deploy_options.profile
    )
    print(utils.check_output(f'{kubectl_cmd} delete all --all -n {deploy_options.namespace} --force --grace-period=0 1> /dev/null ; true'))
    # configmaps are not deleted with `delete all`
    print(utils.check_output(f"{kubectl_cmd} get configmap -o name -n {deploy_options.namespace} | " +
                             f"xargs -r {kubectl_cmd} delete -n {deploy_options.namespace} --force --grace-period=0 1> /dev/null ; true"))
    # ingress is not deleted with `delete all`
    print(utils.check_output(f"{kubectl_cmd} get ingress -o name -n {deploy_options.namespace} | " +
                             f"xargs -r {kubectl_cmd} delete -n {deploy_options.namespace} --force --grace-period=0 1> /dev/null ; true"))

    if deploy_options.delete_pvc:
        print(utils.check_output(f"{kubectl_cmd} delete pvc --all -n {deploy_options.namespace} --force --grace-period=0 1> /dev/null ; true"))

    if deploy_options.delete_namespace is True:
        print(utils.check_output(f"{kubectl_cmd} delete namespace {deploy_options.namespace} --force --grace-period=0 1> /dev/null ; true"))
def main():
    utils.verify_build_directory(deploy_options.namespace)

    with open(SRC_FILE, "r") as src:
        log.info(
            f"Loading source template file for assisted-image-service: {SRC_FILE}"
        )
        raw_data = src.read()
        raw_data = raw_data.replace('REPLACE_NAMESPACE',
                                    f'"{deploy_options.namespace}"')
        raw_data = raw_data.replace('REPLACE_IMAGE_SERVICE_IMAGE',
                                    os.environ.get("IMAGE_SERVICE"))
        data = yaml.safe_load(raw_data)
        log.info(data)

    with open(DST_FILE, "w+") as dst:
        yaml.dump(data, dst, default_flow_style=False)

    if not deploy_options.apply_manifest:
        return

    log.info(f"Deploying {DST_FILE}")
    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                file=DST_FILE)
Esempio n. 6
0
def main():
    deploy_options = deployment_options.load_deployment_options()

    utils.verify_build_directory(deploy_options.namespace)

    if deploy_options.target == 'ocp':
        src_file = os.path.join(os.getcwd(), 'deploy/roles/ocp_role.yaml')
        dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                                'ocp_role.yaml')
    else:
        src_file = os.path.join(os.getcwd(), 'deploy/roles/default_role.yaml')
        dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                                'default_role.yaml')

    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=dst_file)
Esempio n. 7
0
def main():
    utils.verify_build_directory(deploy_options.namespace)

    ## Main OLM Manifest for K8s
    if deploy_options.target != "oc-ingress":
        # K8s
        deployed = utils.check_if_exists(k8s_object='namespace',
                                         k8s_object_name='olm',
                                         target=deploy_options.target,
                                         namespace='olm',
                                         profile=deploy_options.profile)
        if not deployed:
            olm_manifests = [
                "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/0.15.1/crds.yaml",
                "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/0.15.1/olm.yaml"
            ]
            for manifest_url in olm_manifests:
                dst_file = os.path.join(
                    os.getcwd(), 'build', deploy_options.namespace,
                    os.path.basename(urlparse(manifest_url).path))
                print("Deploying {}".format(dst_file))
                urlretrieve(manifest_url, dst_file)
                utils.apply(target=deploy_options.target,
                            namespace=None,
                            profile=deploy_options.profile,
                            file=dst_file)

            check_deployment()

    else:
        # OCP
        print("OLM Deployment not necessary")
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--deploy-namespace",
                        type=lambda x: (str(x).lower() == 'true'),
                        default=True)
    deploy_options = deployment_options.load_deployment_options(parser)

    utils.verify_build_directory(deploy_options.namespace)

    if deploy_options.deploy_namespace is False:
        print("Not deploying namespace")
        return
    src_file = os.path.join(os.getcwd(), 'deploy/namespace/namespace.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                            'namespace.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                file=dst_file)
Esempio n. 9
0
def main():
    deploy_options = deployment_options.load_deployment_options()

    utils.verify_build_directory(deploy_options.namespace)

    if deploy_options.target == 'ocp':
        src_file = os.path.join(os.getcwd(), 'deploy/roles/ocp_role.yaml')
        dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                                'ocp_role.yaml')
    else:
        src_file = os.path.join(os.getcwd(), 'deploy/roles/default_role.yaml')
        dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                                'default_role.yaml')

    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=dst_file)

    if deploy_options.enable_kube_api:
        controller_roles_path = 'internal/controller/config/rbac'
        src_file = os.path.join(os.getcwd(), controller_roles_path,
                                'kube_api_roles.yaml')
        dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                                'kube_api_roles.yaml')
        with open(src_file, "r") as src:
            with open(dst_file, "w+") as dst:
                data = src.read()
                data = data.replace('REPLACE_NAMESPACE',
                                    f'"{deploy_options.namespace}"')
                dst.write(data)

        print("Deploying {}".format(dst_file))
        utils.apply(target=deploy_options.target,
                    namespace=deploy_options.namespace,
                    profile=deploy_options.profile,
                    file=dst_file)

        src_file = os.path.join(os.getcwd(), controller_roles_path,
                                'role.yaml')
        dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                                'controller_roles.yaml')
        shutil.copy(src_file, dst_file)
        print("Deploying {}".format(dst_file))
        utils.apply(
            target=deploy_options.target,
            namespace=deploy_options.namespace,
            profile=deploy_options.profile,
            file=dst_file,
        )
def main():
    utils.verify_build_directory(deploy_options.namespace)

    with open(SRC_FILE, "r") as src:
        raw_data = src.read()
        raw_data = raw_data.replace('REPLACE_NAMESPACE', f'"{deploy_options.namespace}"')
        raw_data = raw_data.replace('REPLACE_IMAGE_PULL_POLICY', f'"{deploy_options.image_pull_policy}"')
        data = yaml.safe_load(raw_data)

        image_fqdn = deployment_options.get_image_override(deploy_options, "assisted-service", "SERVICE")
        data["spec"]["replicas"] = deploy_options.replicas_count
        data["spec"]["template"]["spec"]["containers"][0]["image"] = image_fqdn
        if deploy_options.subsystem_test:
            if data["spec"]["template"]["spec"]["containers"][0].get("env", None) is None:
                data["spec"]["template"]["spec"]["containers"][0]["env"] = []
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'CLUSTER_MONITOR_INTERVAL', 'value': TEST_CLUSTER_MONITOR_INTERVAL})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'HOST_MONITOR_INTERVAL', 'value': TEST_HOST_MONITOR_INTERVAL})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name': 'JWKS_CERT', 'value': load_key()})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'SUBSYSTEM_RUN', 'value': 'True'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'DUMMY_IGNITION', 'value': 'True'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_BASE_URL', 'value': WIREMOCK_SERVICE})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_TOKEN_URL', 'value': WIREMOCK_SERVICE + '/token'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_SERVICE_CLIENT_ID', 'value': 'mock-ocm-client-id'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_SERVICE_CLIENT_SECRET', 'value': 'mock-ocm-client-secret'})

            if deploy_options.target == deployment_options.OPENSHIFT_TARGET:
                # Images built on infra cluster but needed on ephemeral cluster
                data["spec"]["template"]["spec"]["containers"][0]["imagePullPolicy"] = "IfNotPresent"
            else:
                data["spec"]["template"]["spec"]["containers"][0]["imagePullPolicy"] = "Never"

        if deploy_options.target == deployment_options.OCP_TARGET:
            data["spec"]["replicas"] = 1 # force single replica
            spec = data["spec"]["template"]["spec"]
            service_container = spec["containers"][0]
            service_container["env"].append({'name': 'DEPLOY_TARGET', 'value': "ocp"})
            service_container["env"].append({'name': 'STORAGE', 'value': "filesystem"})
            service_container["env"].append({'name': 'ISO_WORKSPACE_BASE_DIR', 'value': '/data'})
            service_container["env"].append({'name': 'ISO_CACHE_DIR', 'value': '/data/cache'})

        if deploy_options.port:
            for port_option in deploy_options.port:
                port = {"containerPort": int(port_option[0])}
                data["spec"]["template"]["spec"]["containers"][0]["ports"].append(port)

    with open(DST_FILE, "w+") as dst:
        yaml.dump(data, dst, default_flow_style=False)

    if not deploy_options.apply_manifest:
        return

    log.info(f"Deploying {DST_FILE}")
    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        file=DST_FILE
    )
Esempio n. 11
0
def main():
    utils.verify_build_directory(deploy_options.namespace)

    src_file = os.path.join(os.getcwd(),
                            'deploy/assisted-service-service.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                            'assisted-service-service.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            raw_data = src.read()
            raw_data = raw_data.replace('REPLACE_NAMESPACE',
                                        f'"{deploy_options.namespace}"')
            data = yaml.safe_load(raw_data)

            if deploy_options.port:
                for port_number_str, port_name in deploy_options.port:
                    port = {
                        "name": port_name,
                        "port": int(port_number_str),
                        "protocol": "TCP",
                        "targetPort": int(port_number_str)
                    }
                    data["spec"]["ports"].append(port)

            print("Deploying {}".format(dst_file))
            dst.write(yaml.dump(data))

    if deploy_options.apply_manifest:
        utils.apply(target=deploy_options.target,
                    namespace=deploy_options.namespace,
                    file=dst_file)
    # in case of OpenShift deploy ingress as well
    if deploy_options.target == "oc-ingress":
        hostname = utils.get_service_host('assisted-installer',
                                          deploy_options.target,
                                          deploy_options.domain,
                                          deploy_options.namespace)

        if deploy_options.disable_tls:
            template = "assisted-installer-ingress.yaml"
        else:
            print(
                "WARNING: On OpenShift, in order to change TLS redirection behavior update "
                "spec/tls/insecureEdgeTerminationPolicy (None|Allow|Redirect) "
                "in the corresponding OpenShift route")
            deploy_tls_secret.generate_secret(
                output_dir=os.path.join(os.getcwd(), "build"),
                service="assisted-service",
                san=hostname,
                namespace=deploy_options.namespace)
            template = "assisted-installer-ingress-tls.yaml"

        deploy_ingress(hostname=hostname,
                       namespace=deploy_options.namespace,
                       template_file=template)
Esempio n. 12
0
def main():
    deploy_options = deployment_options.load_deployment_options()

    log.info('Starting scality deployment')

    utils.verify_build_directory(deploy_options.namespace)

    deploy_scality(deploy_options)
    deploy_scality_storage(deploy_options)

    log.info('Completed to scality deployment')
def main():
    deploy_options = deployment_options.load_deployment_options()

    log.info('Starting postgres deployment')

    utils.verify_build_directory(deploy_options.namespace)

    deploy_postgres_secret(deploy_options)
    deploy_postgres(deploy_options)
    deploy_postgres_storage(deploy_options)

    log.info('Completed postgres deployment')
Esempio n. 14
0
def main():
    deploy_options = deployment_options.load_deployment_options()

    if deploy_options.storage == 'filesystem':
        return

    log.info('Starting object store deployment')

    utils.verify_build_directory(deploy_options.namespace)

    deploy_object_store_deployment(deploy_options)
    deploy_object_store_pvc(deploy_options)

    log.info('Completed to object store deployment')
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--inventory-url")
    parser.add_argument("--cluster-id")
    parser.add_argument("--controller-image")
    parser.add_argument("--namespace")
    parser.add_argument("--target")
    parser.add_argument("--profile")
    deploy_options = parser.parse_args()

    log.info('Starting assisted-installer-controller deployment')
    utils.verify_build_directory(deploy_options.namespace)
    deploy_controller(deploy_options)
    log.info('Completed assisted-installer-controller deployment')
Esempio n. 16
0
def main():
    deploy_options = deployment_options.load_deployment_options()

    utils.verify_build_directory(deploy_options.namespace)

    if deploy_options.enable_kube_api:
        file_path = os.path.join(os.getcwd(), 'build',
                                 deploy_options.namespace, 'resources.yaml')

        if not deploy_options.apply_manifest:
            return

        utils.apply(target=deploy_options.target,
                    namespace=deploy_options.namespace,
                    profile=deploy_options.profile,
                    file=file_path)
def main():
    utils.verify_build_directory(deploy_options.namespace)

    with open(SRC_FILE, "r") as src:
        raw_data = src.read()
        raw_data = raw_data.replace('REPLACE_NAMESPACE',
                                    f'"{deploy_options.namespace}"')
        data = yaml.safe_load(raw_data)

    with open(DST_FILE, "w+") as dst:
        yaml.dump(data, dst, default_flow_style=False)

    if not deploy_options.apply_manifest:
        return

    log.info(f"Deploying {DST_FILE}")
    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                file=DST_FILE)
Esempio n. 18
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--service")
    parser.add_argument("--tls-san")
    parser.add_argument("--tls-expiration",
                        help="Server certificate expiration (days)",
                        type=int,
                        default=120)
    deploy_options = deployment_options.load_deployment_options(parser)

    utils.verify_build_directory(deploy_options.namespace)

    output_dir = os.path.join(os.getcwd(), 'build', deploy_options.namespace)
    generate_secret(output_dir=output_dir,
                    service=deploy_options.service,
                    san=deploy_options.tls_san,
                    namespace=deploy_options.namespace,
                    expiration=deploy_options.tls_expiration,
                    keep_files=False)
Esempio n. 19
0
def main():
    utils.verify_build_directory(deploy_options.namespace)
    if not deploy_options.ca_file_path or not deploy_options.registries_file_path:
        print(
            "mirror registry CA file or registries file are not provided, skipping generation of assisted-service-configmap-registry-ca.yaml"
        )
        return

    ca_content = read_input_data_file(deploy_options.ca_file_path)
    registries_conf_content = read_input_data_file(
        deploy_options.registries_file_path)
    constuct_deployment_yaml(ca_content, registries_conf_content)

    if not deploy_options.apply_manifest:
        return

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                file=DST_FILE)
Esempio n. 20
0
def main():
    deploy_options = deployment_options.load_deployment_options()
    utils.verify_build_directory(deploy_options.namespace)

    # Render a file without values for the operator as we don't want every deployment to have the same values
    if not deploy_options.apply_manifest:
        render_file(deploy_options.namespace, "", "")
        return

    secret_name = 'assisted-installer-local-auth-key'
    exists = utils.check_if_exists("secret",
                                   secret_name,
                                   target=deploy_options.target,
                                   namespace=deploy_options.namespace,
                                   profile=deploy_options.profile)

    if exists:
        print(
            f'Secret {secret_name} already exists in namespace {deploy_options.namespace}'
        )
        return

    output_dir = tempfile.TemporaryDirectory()
    priv_path = os.path.join(output_dir.name, f'ec-private-key.pem')
    pub_path = os.path.join(output_dir.name, f'ec-public-key.pem')

    print(
        utils.check_output(
            f'openssl ecparam -name prime256v1 -genkey -noout -out {priv_path}'
        ))
    print(
        utils.check_output(
            f'openssl ec -in {priv_path} -pubout -out {pub_path}'))

    secret_file = render_file(deploy_options.namespace,
                              encoded_contents(priv_path),
                              encoded_contents(pub_path))

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=secret_file)
Esempio n. 21
0
def main():
    deploy_options = deployment_options.load_deployment_options()

    utils.verify_build_directory(deploy_options.namespace)

    src_file = os.path.join(os.getcwd(), 'deploy/s3/scality-secret.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                            'scality-secret.yaml')
    scality_url = "http://cloudserver-front:8000"
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE', deploy_options.namespace)
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=dst_file)
Esempio n. 22
0
def main():
    utils.verify_build_directory(deploy_options.namespace)

    src_file = os.path.join(os.getcwd(), 'deploy/assisted-service-service.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace, 'assisted-service-service.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE', deploy_options.namespace)
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        profile=deploy_options.profile,
        file=dst_file
    )
    # in case of OpenShift deploy ingress as well
    if deploy_options.target == "oc-ingress":
        hostname = utils.get_service_host(
            'assisted-installer',
            deploy_options.target,
            deploy_options.domain,
            deploy_options.namespace,
            deploy_options.profile
        )

        if deploy_options.disable_tls:
            template = "assisted-installer-ingress.yaml"
        else:
            print("WARNING: On OpenShift, in order to change TLS redirection behavior update "
                  "spec/tls/insecureEdgeTerminationPolicy (None|Allow|Redirect) "
                  "in the corresponding OpenShift route")
            deploy_tls_secret.generate_secret(output_dir=os.path.join(os.getcwd(), "build"),
                                              service="assisted-service", san=hostname,
                                              namespace=deploy_options.namespace)
            template = "assisted-installer-ingress-tls.yaml"

        deploy_ingress(hostname=hostname, namespace=deploy_options.namespace, template_file=template)
def main():
    deploy_options = deployment_options.load_deployment_options()

    utils.verify_build_directory(deploy_options.namespace)

    if deploy_options.enable_kube_api:
        file_path = os.path.join(os.getcwd(), 'build',
                                 deploy_options.namespace, 'resources.yaml')

        if not deploy_options.apply_manifest:
            return

        utils.apply(target=deploy_options.target,
                    namespace=deploy_options.namespace,
                    file=file_path)

        crds_dir = os.path.join(os.getcwd(), 'hack/crds/')
        for crd in os.listdir(crds_dir):
            file_path = f"{crds_dir}/{crd}"
            utils.apply(target=deploy_options.target,
                        namespace=deploy_options.namespace,
                        file=file_path)
Esempio n. 24
0
def deploy(src_file):
    deploy_options = deployment_options.load_deployment_options()

    utils.verify_build_directory(deploy_options.namespace)

    src_file = os.path.join(os.getcwd(), src_file)
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                            os.path.basename(src_file))
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            print("Deploying {}".format(dst_file))
            dst.write(data)

    if not deploy_options.apply_manifest:
        return

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                file=dst_file)
Esempio n. 25
0
def main():
    utils.verify_build_directory(deploy_options.namespace)

    with open(SRC_FILE, "r") as src:
        raw_data = src.read()
        raw_data = raw_data.replace('REPLACE_NAMESPACE', deploy_options.namespace)
        data = yaml.safe_load(raw_data)

        image_fqdn = deployment_options.get_image_override(deploy_options, "assisted-service", "SERVICE")
        data["spec"]["replicas"] = deploy_options.replicas_count
        data["spec"]["template"]["spec"]["containers"][0]["image"] = image_fqdn
        if deploy_options.subsystem_test:
            if data["spec"]["template"]["spec"]["containers"][0].get("env", None) is None:
                data["spec"]["template"]["spec"]["containers"][0]["env"] = []
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'CLUSTER_MONITOR_INTERVAL', 'value': TEST_CLUSTER_MONITOR_INTERVAL})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'HOST_MONITOR_INTERVAL', 'value': TEST_HOST_MONITOR_INTERVAL})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name': 'JWKS_CERT', 'value': load_key()})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'SUBSYSTEM_RUN', 'value': 'True'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_BASE_URL', 'value': 'http://wiremock.assisted-installer.svc.cluster.local:8080'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_TOKEN_URL', 'value': 'http://wiremock.assisted-installer.svc.cluster.local:8080/token'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_SERVICE_CLIENT_ID', 'value': 'mock-ocm-client-id'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_SERVICE_CLIENT_SECRET', 'value': 'mock-ocm-client-secret'})
            data["spec"]["template"]["spec"]["containers"][0]["imagePullPolicy"] = "Never"
        else:
            data["spec"]["template"]["spec"]["containers"][0]["imagePullPolicy"] = "Always"

    with open(DST_FILE, "w+") as dst:
        yaml.dump(data, dst, default_flow_style=False)
    print("Deploying {}".format(DST_FILE))

    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        profile=deploy_options.profile,
        file=DST_FILE
    )
def main():
    utils.verify_build_directory(deploy_options.namespace)
    verify_ocp_versions(
        json.loads(json.loads('"{}"'.format(deploy_options.ocp_versions))))

    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            data = data.replace("REPLACE_DOMAINS",
                                '"{}"'.format(deploy_options.base_dns_domains))

            if deploy_options.apply_manifest:
                data = data.replace(
                    "REPLACE_BASE_URL",
                    utils.get_service_url(
                        service=SERVICE,
                        target=deploy_options.target,
                        domain=deploy_options.domain,
                        namespace=deploy_options.namespace,
                        disable_tls=deploy_options.disable_tls))

            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            data = data.replace('REPLACE_AUTH_TYPE_FLAG',
                                '"{}"'.format(deploy_options.auth_type))
            data = data.replace(
                'REPLACE_WITH_AMS_SUBSCRIPTIONS',
                '"{}"'.format(deploy_options.with_ams_subscriptions))
            data = data.replace('REPLACE_CHECK_CLUSTER_VERSION_FLAG',
                                '"{}"'.format(deploy_options.check_cvo))
            data = data.replace('REPLACE_JWKS_URL',
                                '"{}"'.format(deploy_options.jwks_url))
            data = data.replace('REPLACE_OCM_BASE_URL',
                                '"{}"'.format(deploy_options.ocm_url))
            data = data.replace('REPLACE_OPENSHIFT_VERSIONS',
                                '"{}"'.format(deploy_options.ocp_versions))
            data = data.replace(
                'REPLACE_PUBLIC_CONTAINER_REGISTRIES',
                '"{}"'.format(deploy_options.public_registries))
            data = data.replace('REPLACE_IPV6_SUPPORT',
                                '"{}"'.format(deploy_options.ipv6_support))
            data = data.replace('REPLACE_HW_VALIDATOR_REQUIREMENTS',
                                '"{}"'.format(deploy_options.hw_requirements))
            data = data.replace(
                'REPLACE_DISABLED_HOST_VALIDATIONS',
                '"{}"'.format(deploy_options.disabled_host_validations))

            versions = {
                "INSTALLER_IMAGE": "assisted-installer",
                "CONTROLLER_IMAGE": "assisted-installer-controller",
                "AGENT_DOCKER_IMAGE": "assisted-installer-agent"
            }
            for env_var_name, image_short_name in versions.items():
                versions[env_var_name] = deployment_options.get_image_override(
                    deploy_options, image_short_name, env_var_name)
                log.info(f"Logging {image_short_name} information")
                log_image_revision(versions[env_var_name])

            # Edge case for controller image override
            if os.environ.get("INSTALLER_IMAGE"
                              ) and not os.environ.get("CONTROLLER_IMAGE"):
                versions[
                    "CONTROLLER_IMAGE"] = deployment_options.IMAGE_FQDN_TEMPLATE.format(
                        "assisted-installer-controller",
                        deployment_options.get_tag(
                            versions["INSTALLER_IMAGE"]))

            versions["SELF_VERSION"] = deployment_options.get_image_override(
                deploy_options, "assisted-service", "SERVICE")
            log.info(f"Logging assisted-service information")
            log_image_revision(versions["SELF_VERSION"])
            deploy_tag = get_deployment_tag(deploy_options)
            if deploy_tag:
                versions["RELEASE_TAG"] = deploy_tag

            y = yaml.safe_load(data)
            y['data'].update(versions)

            y['data'][
                'ENABLE_SINGLE_NODE_DNSMASQ'] = deploy_options.enable_sno_dnsmasq
            y['data']['STORAGE'] = deploy_options.storage

            if deploy_options.installation_timeout:
                y['data']['INSTALLATION_TIMEOUT'] = str(
                    deploy_options.installation_timeout)

            admins = get_admin_users()
            if admins:
                y['data']['ADMIN_USERS'] = admins

            if deploy_options.img_expr_time:
                y['data'][
                    'IMAGE_EXPIRATION_TIME'] = deploy_options.img_expr_time

            if deploy_options.img_expr_time:
                y['data'][
                    'IMAGE_EXPIRATION_INTERVAL'] = deploy_options.img_expr_interval

            if deploy_options.enable_kube_api:
                y['data']['ENABLE_KUBE_API'] = 'true'

            if deploy_options.kubeapi_day2:
                y['data']['ENABLE_KUBE_API_DAY2'] = deploy_options.kubeapi_day2

            data = yaml.dump(y)
            dst.write(data)

    if deploy_options.apply_manifest:
        log.info("Deploying {}".format(DST_FILE))
        utils.apply(target=deploy_options.target,
                    namespace=deploy_options.namespace,
                    file=DST_FILE)
Esempio n. 27
0
'''
This script deploy Grafana instance of it on K8s and OCP
n the OCP case, it will be integrated automatically with OCP oauth.
'''

import os
import sys
from time import sleep
import secrets
import utils
import deployment_options

deploy_options = deployment_options.load_deployment_options()
utils.verify_build_directory(deploy_options.namespace)

if deploy_options.target != "oc-ingress":
    CMD_BIN = utils.get_kubectl_command(target=deploy_options.target,
                                        profile=deploy_options.profile)
else:
    CMD_BIN = 'oc'


def deploy_oauth_reqs():
    '''oauth Integration in OCP'''
    # Token generation for session_secret
    session_secret = secrets.token_hex(43)
    secret_name = 'grafana-proxy'
    if not utils.check_if_exists(k8s_object='secret',
                                 k8s_object_name=secret_name,
                                 target=deploy_options.target,
                                 namespace=deploy_options.namespace,
Esempio n. 28
0
def main():
    deploy_secret()
    utils.verify_build_directory(deploy_options.namespace)
def main():
    utils.verify_build_directory(deploy_options.namespace)

    with open(SRC_FILE, "r") as src:
        raw_data = src.read()
        raw_data = raw_data.replace('REPLACE_NAMESPACE',
                                    f'"{deploy_options.namespace}"')
        data = yaml.safe_load(raw_data)

        image_fqdn = deployment_options.get_image_override(
            deploy_options, "assisted-service", "SERVICE")
        data["spec"]["replicas"] = deploy_options.replicas_count
        data["spec"]["template"]["spec"]["containers"][0]["image"] = image_fqdn
        if deploy_options.subsystem_test:
            if data["spec"]["template"]["spec"]["containers"][0].get(
                    "env", None) is None:
                data["spec"]["template"]["spec"]["containers"][0]["env"] = []
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({
                'name':
                'CLUSTER_MONITOR_INTERVAL',
                'value':
                TEST_CLUSTER_MONITOR_INTERVAL
            })
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({
                'name':
                'HOST_MONITOR_INTERVAL',
                'value':
                TEST_HOST_MONITOR_INTERVAL
            })
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({
                'name':
                'JWKS_CERT',
                'value':
                load_key()
            })
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({
                'name':
                'SUBSYSTEM_RUN',
                'value':
                'True'
            })
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({
                'name':
                'DUMMY_IGNITION',
                'value':
                'True'
            })
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({
                'name':
                'OCM_BASE_URL',
                'value':
                'http://wiremock.assisted-installer.svc.cluster.local:8080'
            })
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({
                'name':
                'OCM_TOKEN_URL',
                'value':
                'http://wiremock.assisted-installer.svc.cluster.local:8080/token'
            })
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({
                'name':
                'OCM_SERVICE_CLIENT_ID',
                'value':
                'mock-ocm-client-id'
            })
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({
                'name':
                'OCM_SERVICE_CLIENT_SECRET',
                'value':
                'mock-ocm-client-secret'
            })
            data["spec"]["template"]["spec"]["containers"][0][
                "imagePullPolicy"] = "Never"
        else:
            data["spec"]["template"]["spec"]["containers"][0][
                "imagePullPolicy"] = "Always"
        if deploy_options.target == utils.OCP_TARGET:
            spec = data["spec"]["template"]["spec"]
            service_container = spec["containers"][0]
            service_container["env"].append({
                'name': 'DEPLOY_TARGET',
                'value': "ocp"
            })

            # Copy livecd from 'assisted-iso-create' image
            service_container["volumeMounts"].append({
                'name': 'iso',
                'mountPath': "/data"
            })
            spec["volumes"].append({'name': 'iso', 'emptyDir': {}})
            spec["initContainers"] = [{
                "name":
                "assisted-iso-create",
                "image":
                "quay.io/ocpmetal/assisted-iso-create:latest",
                "command": ["bash", "-c"],
                "args": ["cp -r /data/* /iso-data"],
                "volumeMounts": [{
                    "mountPath": "/iso-data",
                    "name": "iso"
                }]
            }]

    with open(DST_FILE, "w+") as dst:
        yaml.dump(data, dst, default_flow_style=False)
    print("Deploying {}".format(DST_FILE))

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=DST_FILE)
def main():
    log = utils.get_logger('deploy-service-configmap')
    utils.verify_build_directory(deploy_options.namespace)
    verify_ocp_versions(json.loads(json.loads('"{}"'.format(deploy_options.ocp_versions))))

    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            data = data.replace("REPLACE_DOMAINS", '"{}"'.format(deploy_options.base_dns_domains))
            data = data.replace("REPLACE_BASE_URL", utils.get_service_url(service=SERVICE,
                                                                          target=deploy_options.target,
                                                                          domain=deploy_options.domain,
                                                                          namespace=deploy_options.namespace,
                                                                          profile=deploy_options.profile,
                                                                          disable_tls=deploy_options.disable_tls))

            data = data.replace('REPLACE_NAMESPACE', f'"{deploy_options.namespace}"')
            data = data.replace('REPLACE_AUTH_ENABLED_FLAG', '"{}"'.format(deploy_options.enable_auth))
            data = data.replace('REPLACE_CHECK_CLUSTER_VERSION_FLAG', '"{}"'.format(deploy_options.check_cvo))
            data = data.replace('REPLACE_JWKS_URL', '"{}"'.format(deploy_options.jwks_url))
            data = data.replace('REPLACE_OCM_BASE_URL', '"{}"'.format(deploy_options.ocm_url))
            data = data.replace('REPLACE_OPENSHIFT_VERSIONS', '"{}"'.format(deploy_options.ocp_versions))
            data = data.replace('REPLACE_OPENSHIFT_INSTALL_RELEASE_IMAGE', '"{}"'.format(deploy_options.ocp_override))
            data = data.replace('REPLACE_PUBLIC_CONTAINER_REGISTRIES', '"{}"'.format(deploy_options.public_registries))

            versions = {"INSTALLER_IMAGE": "assisted-installer",
                        "CONTROLLER_IMAGE": "assisted-installer-controller",
                        "AGENT_DOCKER_IMAGE": "assisted-installer-agent",
                        "CONNECTIVITY_CHECK_IMAGE": "assisted-installer-agent",
                        "INVENTORY_IMAGE": "assisted-installer-agent",
                        "FREE_ADDRESSES_IMAGE": "assisted-installer-agent",
                        "DHCP_LEASE_ALLOCATOR_IMAGE": "assisted-installer-agent",
                        "API_VIP_CONNECTIVITY_CHECK_IMAGE": "assisted-installer-agent",
                        "FIO_PERF_CHECK_IMAGE": "assisted-installer-agent",
                        "NTP_SYNCHRONIZER_IMAGE": "assisted-installer-agent"}
            for env_var_name, image_short_name in versions.items():
                versions[env_var_name] = deployment_options.get_image_override(deploy_options, image_short_name, env_var_name)

            # Edge case for controller image override
            if os.environ.get("INSTALLER_IMAGE") and not os.environ.get("CONTROLLER_IMAGE"):
                versions["CONTROLLER_IMAGE"] = deployment_options.IMAGE_FQDN_TEMPLATE.format("assisted-installer-controller",
                    deployment_options.get_tag(versions["INSTALLER_IMAGE"]))

            versions["SELF_VERSION"] = deployment_options.get_image_override(deploy_options, "assisted-service", "SERVICE")
            deploy_tag = get_deployment_tag(deploy_options)
            if deploy_tag:
                versions["RELEASE_TAG"] = deploy_tag

            y = yaml.load(data)
            y['data'].update(versions)

            if deploy_options.installation_timeout:
                y['data']['INSTALLATION_TIMEOUT'] = str(deploy_options.installation_timeout)

            admins = get_admin_users()
            if admins:
                y['data']['ADMIN_USERS'] = admins

            if deploy_options.img_expr_time:
                y['data']['IMAGE_EXPIRATION_TIME'] = deploy_options.img_expr_time

            if deploy_options.img_expr_time:
                y['data']['IMAGE_EXPIRATION_INTERVAL'] = deploy_options.img_expr_interval

            data = yaml.dump(y)
            dst.write(data)

    log.info("Deploying {}".format(DST_FILE))
    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        profile=deploy_options.profile,
        file=DST_FILE
    )