Exemple #1
0
    def create_k8s_dashboard(self):

        self.logger.info(
            "Create kubernetes dashboard deployment for kuberentes cluster.")

        self.logger.info("Create dashboard service.")
        file_path = "k8sPaiLibrary/template/dashboard-service.yaml.template"
        template_data = common.read_template(file_path)
        dict_map = {"clusterconfig": self.cluster_config['clusterinfo']}
        generated_data = common.generate_from_template_dict(
            template_data, dict_map)

        common.write_generated_file(generated_data, "dashboard-service.yaml")
        common.execute_shell("kubectl create -f dashboard-service.yaml",
                             "Failed to create dashboard-service")

        os.remove("dashboard-service.yaml")

        self.logger.info("Create dashboard deployment.")
        file_path = "k8sPaiLibrary/template/dashboard-deployment.yaml.template"
        template_data = common.read_template(file_path)
        dict_map = {"clusterconfig": self.cluster_config['clusterinfo']}
        generated_data = common.generate_from_template_dict(
            template_data, dict_map)

        common.write_generated_file(generated_data,
                                    "dashboard-deployment.yaml")
        common.execute_shell("kubectl create -f dashboard-deployment.yaml",
                             "Failed to create dashboard-deployment")

        os.remove("dashboard-deployment.yaml")
Exemple #2
0
    def create_k8s_dashboard(self):
        com = self.cluster_object_model
        self.logger.info(
            "Create kubernetes dashboard deployment for kuberentes cluster.")

        self.logger.info("Create dashboard service.")
        file_path = "deployment/k8sPaiLibrary/template/dashboard-service.yaml.template"
        template_data = common.read_template(file_path)
        dict_map = {"cluster_cfg": com}
        generated_data = common.generate_from_template_dict(
            template_data, dict_map)

        common.write_generated_file(generated_data, "dashboard-service.yaml")

        retry_count = 5
        common.execute_shell_retry(
            "kubectl apply --overwrite=true -f dashboard-service.yaml",
            "Failed to create dashboard-service", retry_count)

        os.remove("dashboard-service.yaml")

        self.logger.info("Create dashboard deployment.")
        file_path = "deployment/k8sPaiLibrary/template/dashboard-deployment.yaml.template"
        template_data = common.read_template(file_path)
        dict_map = {"cluster_cfg": com}
        generated_data = common.generate_from_template_dict(
            template_data, dict_map)

        common.write_generated_file(generated_data,
                                    "dashboard-deployment.yaml")
        common.execute_shell(
            "kubectl apply --overwrite=true -f dashboard-deployment.yaml",
            "Failed to create dashboard-deployment")

        os.remove("dashboard-deployment.yaml")
    def kubectl_configuration_generate(self):

        com = self.cluster_config
        self.logger.info("Generate the configuation file of kubectl.")

        if com != None:
            self.logger.info("Cluster configuration is detected.")
            self.logger.info(
                "Generate the KUBECONIFG based on the cluster configuration.")
            dict_map = {"cluster_cfg": com}
        else:
            self.logger.warning("Unable to find the cluster configuration.")
            self.logger.warning(
                "Please enter the required infomation, when prompted.")
            user_input = raw_input(
                "Please input the api-server (or the api servers' load-balancer) address in your cluster: "
            )
            dict_map = {
                "cluster_cfg": {
                    "kubernetes": {
                        "api-servers-ip": user_input
                    }
                }
            }

        file_path = "deployment/k8sPaiLibrary/template/config.template"
        template_data = common.read_template(file_path)
        generated_data = common.generate_from_template_dict(
            template_data, dict_map)

        kube_config_path = os.path.expanduser("~/.kube")
        common.write_generated_file(generated_data,
                                    "{0}/config".format(kube_config_path))
        self.logger.info("Successfully configure kubeconfig in the dev-box.")
Exemple #4
0
    def kubectl_configuration_generate(self):

        self.logger.info("Generate the configuation file of kubectl.")

        file_path = "k8sPaiLibrary/template/config.template"
        template_data = common.read_template(file_path)
        dict_map = {
            "clusterconfig": self.cluster_config['clusterinfo'],
        }
        generated_data = common.generate_from_template_dict(template_data, dict_map)

        kube_config_path = os.path.expanduser("~/.kube")
        common.write_generated_file(generated_data, "{0}/config".format(kube_config_path))
Exemple #5
0
    def create_kube_proxy(self):

        self.logger.info("Create kube-proxy daemon for kuberentes cluster.")

        file_path = "k8sPaiLibrary/template/kube-proxy.yaml.template"
        template_data = common.read_template(file_path)
        dict_map = {"clusterconfig": self.cluster_config['clusterinfo']}
        generated_data = common.generate_from_template_dict(
            template_data, dict_map)

        common.write_generated_file(generated_data, "kube-proxy.yaml")
        common.execute_shell("kubectl create -f kube-proxy.yaml",
                             "Failed to create kube-proxy")

        os.remove("kube-proxy.yaml")
Exemple #6
0
    def create_kube_proxy(self):
        com = self.cluster_object_model
        self.logger.info("Create kube-proxy daemon for kuberentes cluster.")

        file_path = "deployment/k8sPaiLibrary/template/kube-proxy.yaml.template"
        template_data = common.read_template(file_path)
        dict_map = {"cluster_cfg": com}
        generated_data = common.generate_from_template_dict(
            template_data, dict_map)

        common.write_generated_file(generated_data, "kube-proxy.yaml")

        retry_count = 5
        common.execute_shell_retry(
            "kubectl apply --overwrite=true -f kube-proxy.yaml",
            "Failed to create kube-proxy", retry_count)

        os.remove("kube-proxy.yaml")