def main(): parser = argparse.ArgumentParser() parser.add_argument("--target") parser.add_argument("--domain") parser.add_argument("--subsystem-test", help='deploy in subsystem mode', action='store_true') deploy_options = deployment_options.load_deployment_options(parser) dst_file = os.path.join(os.getcwd(), "build/deploy_ui.yaml") image_fqdn = deployment_options.get_image_override(deploy_options, "ocp-metal-ui", "UI_IMAGE") runtime_cmd = utils.get_runtime_command() utils.check_output(f'{runtime_cmd} pull {image_fqdn}') cmd = f'{runtime_cmd} run {image_fqdn} /deploy/deploy_config.sh -i {image_fqdn} -n {deploy_options.namespace}' cmd += ' > {}'.format(dst_file) utils.check_output(cmd) print("Deploying {}".format(dst_file)) utils.apply(dst_file) # in case of openshift deploy ingress as well if deploy_options.target == "oc-ingress": src_file = os.path.join(os.getcwd(), "deploy/ui/ui_ingress.yaml") dst_file = os.path.join(os.getcwd(), "build/ui_ingress.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) data = data.replace("REPLACE_HOSTNAME", utils.get_service_host("assisted-installer-ui", deploy_options.target, deploy_options.domain, deploy_options.namespace)) print("Deploying {}".format(dst_file)) dst.write(data) utils.apply(dst_file)
def main(): deploy_options = handle_arguments() # TODO: delete once rename everything to assisted-installer if deploy_options.target == "oc-ingress": service_host = "assisted-installer.{}".format( utils.get_domain(deploy_options.domain)) service_port = "80" else: service_host = utils.get_service_host( SERVICE, deploy_options.target, namespace=deploy_options.namespace) service_port = utils.get_service_port( SERVICE, deploy_options.target, namespace=deploy_options.namespace) with open(SRC_FILE, "r") as src: with open(DST_FILE, "w+") as dst: data = src.read() data = data.replace("REPLACE_URL", '"{}"'.format(service_host)) data = data.replace("REPLACE_PORT", '"{}"'.format(service_port)) data = data.replace("REPLACE_DOMAINS", '"{}"'.format(deploy_options.base_dns_domains)) data = data.replace('REPLACE_NAMESPACE', deploy_options.namespace) print("Deploying {}".format(DST_FILE)) versions = { "IMAGE_BUILDER": "installer-image-build", "AGENT_DOCKER_IMAGE": "agent", "KUBECONFIG_GENERATE_IMAGE": "ignition-manifests-and-kubeconfig-generate", "INSTALLER_IMAGE": "assisted-installer", "CONTROLLER_IMAGE": "assisted-installer-controller", "CONNECTIVITY_CHECK_IMAGE": "connectivity_check", "INVENTORY_IMAGE": "inventory" } for env_var_name, image_short_name in versions.items(): image_fqdn = deployment_options.get_image_override( deploy_options, image_short_name, env_var_name) versions[env_var_name] = image_fqdn # 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) data = yaml.dump(y) dst.write(data) utils.apply(DST_FILE)
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)
def main(): scality_url = utils.get_service_url(SERVICE) scality_host = utils.get_service_host(SERVICE) with open(SRC_FILE, "r") as src: with open(DST_FILE, "w+") as dst: data = src.read() data = data.replace('REPLACE_URL', scality_url) data = data.replace('REPLACE_HOST_NAME', scality_host) print("Deploying {}:\n{}".format(DST_FILE, data)) dst.write(data) utils.apply(DST_FILE)
def main(): service_host = utils.get_service_host(SERVICE) service_port = utils.get_service_port(SERVICE) with open(SRC_FILE, "r") as src: with open(DST_FILE, "w+") as dst: data = src.read() data = data.replace("REPLACE_URL", '"{}"'.format(service_host)) data = data.replace("REPLACE_PORT", '"{}"'.format(service_port)) print("Deploying {}:\n{}".format(DST_FILE, data)) dst.write(data) utils.apply(DST_FILE)
def main(): parser = argparse.ArgumentParser() parser.add_argument("--subsystem-test", help="deploy in subsystem mode", action="store_true") deploy_options = deployment_options.load_deployment_options(parser) utils.set_profile(deploy_options.target, deploy_options.profile) dst_file = os.path.join(os.getcwd(), "build/deploy_ui.yaml") image_fqdn = deployment_options.get_image_override(deploy_options, "ocp-metal-ui", "UI_IMAGE") tag = deployment_options.get_tag(image_fqdn) clone_directory = os.path.join(os.getcwd(), "build/assisted-installer-ui") if not os.path.exists(clone_directory): utils.check_output(f"git clone --branch master {UI_REPOSITORY} {clone_directory}") cmd = f"cd {clone_directory} && git pull" if tag == "latest": log.warning("No hash specified. Will run the deployment generation script from the top of master branch") else: cmd += f" && git reset --hard {tag}" cmd += f" && deploy/deploy_config.sh -t {clone_directory}/deploy/ocp-metal-ui-template.yaml " \ f"-i {image_fqdn} -n {deploy_options.namespace} > {dst_file}" utils.check_output(cmd) log.info("Deploying %s", dst_file) utils.apply(dst_file) # in case of openshift deploy ingress as well if deploy_options.target == "oc-ingress": src_file = os.path.join(os.getcwd(), "deploy/ui/ui_ingress.yaml") dst_file = os.path.join(os.getcwd(), "build/ui_ingress.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) data = data.replace('REPLACE_HOSTNAME', utils.get_service_host( 'assisted-installer-ui', deploy_options.target, deploy_options.domain, deploy_options.namespace, deploy_options.profile )) log.info("Deploying ingress from %s", dst_file) dst.write(data) utils.apply(dst_file)
def main(): parser = argparse.ArgumentParser() deploy_options = deployment_options.load_deployment_options(parser) utils.set_profile(deploy_options.target, deploy_options.profile) src_file = os.path.join(os.getcwd(), "deploy/assisted-service-service.yaml") dst_file = os.path.join(os.getcwd(), "build/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(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(): # TODO: delete once rename everything to assisted-installer if args.target == "oc-ingress": service_host = "assisted-installer.{}".format( utils.get_domain(args.domain)) service_port = "80" else: service_host = utils.get_service_host(SERVICE, args.target) service_port = utils.get_service_port(SERVICE, args.target) with open(SRC_FILE, "r") as src: with open(DST_FILE, "w+") as dst: data = src.read() data = data.replace("REPLACE_URL", '"{}"'.format(service_host)) data = data.replace("REPLACE_PORT", '"{}"'.format(service_port)) print("Deploying {}".format(DST_FILE)) if args.deploy_tag is not "": versions = { "IMAGE_BUILDER": "quay.io/ocpmetal/installer-image-build:", "AGENT_DOCKER_IMAGE": "quay.io/ocpmetal/agent:", "KUBECONFIG_GENERATE_IMAGE": "quay.io/ocpmetal/ignition-manifests-and-kubeconfig-generate:", "INSTALLER_IMAGE": "quay.io/ocpmetal/assisted-installer:", "CONNECTIVITY_CHECK_IMAGE": "quay.io/ocpmetal/connectivity_check:", "INVENTORY_IMAGE": "quay.io/ocpmetal/inventory:", "HARDWARE_INFO_IMAGE": "quay.io/ocpmetal/hardware_info:", "SELF_VERSION": "quay.io/ocpmetal/installer-image-build:" } versions = { k: v + args.deploy_tag for k, v in versions.items() } y = yaml.load(data) y['data'].update(versions) data = yaml.dump(y) else: y = yaml.load(data) y['data'].update({"SELF_VERSION": os.environ.get("SERVICE")}) data = yaml.dump(y) dst.write(data) utils.apply(DST_FILE)
def main(): dst_file = os.path.join(os.getcwd(), "build/deploy_ui.yaml") cmd = 'docker run quay.io/ocpmetal/ocp-metal-ui:latest /deploy/deploy_config.sh > {}'.format( dst_file) utils.check_output(cmd) print("Deploying {}".format(dst_file)) utils.apply(dst_file) # in case of openshift deploy ingress as well if args.target == "oc-ingress": src_file = os.path.join(os.getcwd(), "deploy/ui/ui_ingress.yaml") dst_file = os.path.join(os.getcwd(), "build/ui_ingress.yaml") with open(src_file, "r") as src: with open(dst_file, "w+") as dst: data = src.read() data = data.replace( "REPLACE_HOSTNAME", utils.get_service_host("assisted-installer-ui", args.target, args.domain)) print("Deploying {}".format(dst_file)) dst.write(data) utils.apply(dst_file)
def main(): src_file = os.path.join(os.getcwd(), "deploy/bm-inventory-service.yaml") dst_file = os.path.join(os.getcwd(), "build/bm-inventory-service.yaml") with open(src_file, "r") as src: with open(dst_file, "w+") as dst: data = src.read() print("Deploying {}".format(dst_file)) dst.write(data) utils.apply(dst_file) # in case of openshift deploy ingress as well if args.target == "oc-ingress": src_file = os.path.join(os.getcwd(), "deploy/assisted-installer-ingress.yaml") dst_file = os.path.join(os.getcwd(), "build/assisted-installer-ingress.yaml") with open(src_file, "r") as src: with open(dst_file, "w+") as dst: data = src.read() data = data.replace("REPLACE_HOSTNAME", utils.get_service_host("assisted-installer", args.target, args.domain)) print("Deploying {}".format(dst_file)) dst.write(data) utils.apply(dst_file)