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
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
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
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))
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)
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()
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()
def check_for_docker(self): if not self.docker.check(): raise PolyaxonDeploymentConfigError( 'Docker is required to run this command.') return True