def k8s_bootup(self, args): cluster_object_model_instance = cluster_object_model(args.config_path) com = cluster_object_model_instance.run() logger.info("Begin to initialize PAI k8s cluster.") cluster_util.maintain_cluster_k8s(com, option_name="deploy", clean=True) logger.info("Finish initializing PAI k8s cluster.")
def k8s_set_environment(self, args): if args.config_path != None: args.config_path = os.path.expanduser(args.config_path) cluster_object_model_instance = cluster_object_model(args.config_path) com = cluster_object_model_instance.run() else: com = None kubectl_install_worker = kubectl_install.kubectl_install(com) kubectl_install_worker.run()
def process_args(self, args): cluster_object_model_instance = cluster_object_model(args.config_path) com = cluster_object_model_instance.run() node_list = file_handler.load_yaml_config(args.node_list) if not kubectl_env_checking(com): raise RuntimeError("failed to do kubectl checking") for host in node_list["machine-list"]: if "nodename" not in host: host["nodename"] = host["hostip"] return com, node_list
def k8s_clean(self, args): # just use 'k8s-clean' for testing temporarily. cluster_object_model_instance = cluster_object_model(args.config_path) com = cluster_object_model_instance.run() logger.warning("--------------------------------------------------------") logger.warning("--------------------------------------------------------") logger.warning("---------- Dangerous Operation!!! ---------------") logger.warning("------ Your k8s Cluster will be destroyed -------") logger.warning("------ PAI service on k8s will be stopped -------") logger.warning("--------------------------------------------------------") if args.force: logger.warning("--------------------------------------------------------") logger.warning("---------- ETCD data will be cleaned. ------------") logger.warning("----- If you wanna keep pai's user data. ---------") logger.warning("----- Please backup etcd data. ---------") logger.warning("----- And restore it after k8s-bootup ---------") logger.warning("--- And restore it before deploy pai service ----") logger.warning("--------------------------------------------------------") logger.warning("--------------------------------------------------------") logger.warning("---- Please ensure you wanna do this operator, ------") logger.warning("------- after knowing all risk above. -------") logger.warning("--------------------------------------------------------") logger.warning("--------------------------------------------------------") count_input = 0 while True: user_input = raw_input("Do you want to continue this operation? (Y/N) ") if user_input == "N": return elif user_input == "Y": break else: print(" Please type Y or N.") count_input = count_input + 1 if count_input == 3: logger.warning("3 Times......... Sorry, we will force stopping your operation.") return logger.info("Begin to clean up whole cluster.") cluster_util.maintain_cluster_k8s(com, option_name="clean", force=args.force, clean=True) logger.info("Clean up job finished")
def get_machine_list(self, config_path): objectModelFactoryHandler = cluster_object_model(configuration_path=config_path) return objectModelFactoryHandler.run()["machine"]["machine-list"]