예제 #1
0
    def check_for_kubernetes(self):
        # Deployment on k8s requires helm & kubectl to be installed
        command_exist = self.kubectl.execute(args=[], is_json=False)
        if not command_exist:
            raise PolyaxonDeploymentConfigError(
                'kubectl is required to run this command.')
        Printer.print_success('kubectl is installed', add_sign=True)

        command_exist = self.helm.execute(args=[])
        if not command_exist:
            raise PolyaxonDeploymentConfigError(
                'helm is required to run this command.')
        Printer.print_success('helm is installed', add_sign=True)

        # Check the version to ensure that there's a connection
        command_exist = self.kubectl.execute(args=['version'])
        if not command_exist:
            raise PolyaxonDeploymentConfigError(
                'kubectl has no kubernetes config.')

        command_exist = self.helm.execute(args=['version'])
        if not command_exist:
            raise PolyaxonDeploymentConfigError(
                'helm is not configured or kubernetes config is not found.')

        # Check that polyaxon/polyaxon is set and up-to date
        self.helm.execute(
            args=['repo', 'add', 'polyaxon', 'https://charts.polyaxon.com'])
        self.helm.execute(args=['repo', 'update'])
        return True
예제 #2
0
    def check_for_docker_compose(self):
        # Deployment on docker compose requires Docker & Docker Compose to be installed
        if not self.docker.check():
            raise PolyaxonDeploymentConfigError(
                'Docker is required to run this command.')
        Printer.print_success('Docker is installed')

        if not self.compose.check():
            raise PolyaxonDeploymentConfigError(
                'Docker Compose is required to run this command.')
        Printer.print_success('Docker Compose is installed')

        # Check that .polyaxon/.compose is set and up-to date
        if ComposeConfigManager.is_initialized():
            Printer.print_success('Docker Compose deployment is initialised.')
        return True
예제 #3
0
    def check_for_kubernetes(self):
        # Deployment on k8s requires helm & kubectl to be installed
        if not self.kubectl.check():
            raise PolyaxonDeploymentConfigError(
                'kubectl is required to run this command.')
        Printer.print_success('kubectl is installed')

        if not self.helm.check():
            raise PolyaxonDeploymentConfigError(
                'helm is required to run this command.')
        Printer.print_success('helm is installed')

        # Check that polyaxon/polyaxon is set and up-to date
        self.helm.execute(
            args=['repo', 'add', 'polyaxon', 'https://charts.polyaxon.com'])
        self.helm.execute(args=['repo', 'update'])
        return True
예제 #4
0
 def check(self):
     """Add platform specific checks"""
     if not self.is_valid:
         raise PolyaxonDeploymentConfigError(
             'Deployment type `{}` not supported'.format(
                 self.deployment_type))
     check = False
     if self.is_kubernetes:
         check = self.check_for_kubernetes()
     elif self.is_docker_compose:
         check = self.check_for_docker_compose()
     elif self.is_docker:
         check = self.check_for_docker()
     elif self.is_heroku:
         check = self.check_for_heroku()
     if not check:
         raise PolyaxonDeploymentConfigError(
             'Deployment `{}` is not valid'.format(self.deployment_type))
예제 #5
0
    def teardown(self, hooks=True):
        """Teardown Polyaxon."""
        if not self.is_valid:
            raise PolyaxonDeploymentConfigError(
                'Deployment type `{}` not supported'.format(
                    self.deployment_type))

        if self.is_kubernetes:
            self.teardown_on_kubernetes(hooks=hooks)
        elif self.is_docker_compose:
            self.teardown_on_docker_compose()
        elif self.is_docker:
            self.teardown_on_docker(hooks=hooks)
        elif self.is_heroku:
            self.teardown_on_heroku(hooks=hooks)
예제 #6
0
    def upgrade(self):
        """Upgrade deployment."""
        if not self.is_valid:
            raise PolyaxonDeploymentConfigError(
                'Deployment type `{}` not supported'.format(
                    self.deployment_type))

        if self.is_kubernetes:
            self.upgrade_on_kubernetes()
        elif self.is_docker_compose:
            self.upgrade_on_docker_compose()
        elif self.is_docker:
            self.upgrade_on_docker()
        elif self.is_heroku:
            self.upgrade_on_heroku()
예제 #7
0
    def install(self):
        """Install polyaxon using the current config to the correct platform."""
        if not self.is_valid:
            raise PolyaxonDeploymentConfigError(
                'Deployment type `{}` not supported'.format(
                    self.deployment_type))

        if self.is_kubernetes:
            self.install_on_kubernetes()
        elif self.is_docker_compose:
            self.install_on_docker_compose()
        elif self.is_docker:
            self.install_on_docker()
        elif self.is_heroku:
            self.install_on_heroku()
예제 #8
0
 def check_for_docker(self):
     if not self.docker.check():
         raise PolyaxonDeploymentConfigError(
             'Docker is required to run this command.')
     return True