def install_release(self, chart, dry_run, name, namespace, prefix, values=None, wait=False, timeout=None): ''' Create a Helm Release ''' LOG.debug("wait: %s", wait) LOG.debug("timeout: %s", timeout) if values is None: values = Config(raw='') else: values = Config(raw=values) # build release install request stub = ReleaseServiceStub(self.channel) release_request = InstallReleaseRequest(chart=chart, dry_run=dry_run, values=values, name="{}-{}".format( prefix, name), namespace=namespace, wait=wait, timeout=timeout) return stub.InstallRelease(release_request, self.timeout, metadata=self.metadata)
def install_release(self, chart, namespace, dry_run=False, name=None, values=None, wait=False, disable_hooks=False, reuse_name=False, disable_crd_hook=False, description=""): """ Create a Helm Release """ values = Config(raw=yaml.safe_dump(values or {})) stub = ReleaseServiceStub(self._channel) release_request = InstallReleaseRequest( chart=chart, dry_run=dry_run, values=values, name=name or '', namespace=namespace, wait=wait, disable_hooks=disable_hooks, reuse_name=reuse_name, disable_crd_hook=disable_crd_hook, description=description) return stub.InstallRelease(release_request, self._timeout, metadata=self.metadata)
def install_release(self, chart, release, namespace, dry_run=False, values=None, wait=False, timeout=None): ''' Create a Helm Release ''' LOG.info("Wait: %s, Timeout: %s", wait, timeout) if values is None: values = Config(raw='') else: values = Config(raw=values) # build release install request try: stub = ReleaseServiceStub(self.channel) release_request = InstallReleaseRequest( chart=chart, dry_run=dry_run, values=values, name=release, namespace=namespace, wait=wait, timeout=timeout) return stub.InstallRelease( release_request, self.timeout, metadata=self.metadata) except Exception: status = self.get_release_status(release) raise ex.ReleaseException(release, status, 'Install')
def install_release(self, chart, release, namespace, values=None, wait=False, timeout=None): ''' Create a Helm Release ''' timeout = self._check_timeout(wait, timeout) LOG.info('Helm install release%s: wait=%s, timeout=%s', (' (dry run)' if self.dry_run else ''), wait, timeout) if values is None: values = Config(raw='') else: values = Config(raw=values) # build release install request try: stub = ReleaseServiceStub(self.channel) release_request = InstallReleaseRequest( chart=chart, dry_run=self.dry_run, values=values, name=release, namespace=namespace, wait=wait, timeout=timeout) install_msg = stub.InstallRelease( release_request, timeout + GRPC_EPSILON, metadata=self.metadata) tiller_result = TillerResult( install_msg.release.name, install_msg.release.namespace, install_msg.release.info.status.Code.Name( install_msg.release.info.status.code), install_msg.release.info.Description, install_msg.release.version) return tiller_result except Exception: LOG.exception('Error while installing release %s', release) status = self.get_release_status(release) raise ex.ReleaseException(release, status, 'Install')
def install_release(self, chart, dry_run, name, namespace, values=None): ''' Create a Helm Release ''' if values is None: values = Config(raw='') else: values = Config(raw=values) # build release install request stub = ReleaseServiceStub(self.channel) release_request = InstallReleaseRequest( chart=chart, dry_run=dry_run, values=values, name=name, namespace=namespace) return stub.InstallRelease(release_request, self.timeout, metadata=self.metadata)
def install_release(self, chart, namespace, dry_run=False, name=None, values=None): """ Create a Helm Release """ values = Config(raw=yaml.safe_dump(values or {})) # build release install request stub = ReleaseServiceStub(self.channel) release_request = InstallReleaseRequest( chart=chart, dry_run=dry_run, values=values, name=name or '', namespace=namespace) return stub.InstallRelease(release_request, self.timeout, metadata=self.metadata)
def install_release(self, chart, namespace, disable_hooks=False, reuse_name=False, disable_crd_hook=False, timeout=REQUEST_TIMEOUT, dry_run=False, name=None, values=None): """安装release Args: :params - chart - chart 元数据,由函数生成 :params - name - release name,为空时随机生成 :params - namespace - kubernetes namespace :params - dry_run - simulate an install :params - values - 额外的values,用来进行value值替换 :params - disable_hooks - prevent hooks from running during install(bool) :params - disable_crd_hook - prevent CRD hooks from running, but run other hooks(bool) :params - reuse_name - re-use the given name, even if that name is already used. This is unsafe in production(bool) :params - timeout - time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks) (default 300) Returns: 返回安装release的grpc响应对象 """ #values = Config(raw=yaml.safe_dump(values or {})) # build release install request stub = ReleaseServiceStub(self.channel) release_request = InstallReleaseRequest( chart=chart, disable_hooks=disable_hooks, reuse_name=reuse_name, disable_crd_hook=disable_crd_hook, dry_run=dry_run, timeout=timeout, values=values, name=name or '', namespace=namespace) return stub.InstallRelease(release_request, self.timeout, metadata=self.metadata)
def install_release( self, chart, namespace, dry_run=False, name=None, values=None, wait=False, disable_hooks=False, reuse_name=False, disable_crd_hook=False, description="", ): """ Create a Helm Release """ if values: f = io.StringIO() yaml.dump(values, f) f.seek(0) raw = f.read() else: raw = "" values = Config(raw=raw) stub = ReleaseServiceStub(self._channel) release_request = InstallReleaseRequest( chart=chart, dry_run=dry_run, values=values, name=name or "", namespace=namespace, wait=wait, disable_hooks=disable_hooks, reuse_name=reuse_name, disable_crd_hook=disable_crd_hook, description=description, ) return stub.InstallRelease(release_request, self._timeout, metadata=self.metadata)
def get_chart_templates(self, template_name, name, release_name, namespace, chart, disable_hooks, values): # returns some info LOG.info("Template( %s ) : %s ", template_name, name) stub = ReleaseServiceStub(self.channel) release_request = InstallReleaseRequest(chart=chart, dry_run=True, values=values, name=name, namespace=namespace, wait=False) templates = stub.InstallRelease(release_request, self.timeout, metadata=self.metadata) for template in yaml.load_all( getattr(templates.release, 'manifest', [])): if template_name == template.get('metadata', None).get('name', None): LOG.info(template_name) return template
def install_release(self, chart, release, namespace, dry_run=False, values=None, wait=False, timeout=None): ''' Create a Helm Release ''' LOG.debug("wait: %s", wait) LOG.debug("timeout: %s", timeout) if values is None: values = Config(raw='') else: values = Config(raw=values) # build release install request try: stub = ReleaseServiceStub(self.channel) release_request = InstallReleaseRequest(chart=chart, dry_run=dry_run, values=values, name=release, namespace=namespace, wait=wait, timeout=timeout) return stub.InstallRelease(release_request, self.timeout, metadata=self.metadata) except Exception: raise tiller_exceptions.ReleaseInstallException(release, namespace)
def install_release(self, chart, namespace, dry_run=False, name=None, values=None, wait=False, disable_hooks=False, reuse_name=False, disable_crd_hook=False, overrides=[], description="", chartbuilder=None): """ Prepare overrides, note it only supports one file at the moment """ standard_values = {} if overrides is not None and chartbuilder is not None: standard_values = yaml.safe_load(chartbuilder.get_values().raw) for file in overrides: standard_values.update(yaml.safe_load(file.value)) """ Create a Helm Release """ # now this is where it gets tricky # since the overrides are appended 'left to right' # the later mappings override the standard values in `values.yaml` # the standard helm client does something similar but this 'works' (and is a kludge) values = Config(raw=yaml.safe_dump(standard_values)) stub = ReleaseServiceStub(self._channel) release_request = InstallReleaseRequest( chart=chart, dry_run=dry_run, values=values, name=name or '', namespace=namespace, wait=wait, disable_hooks=disable_hooks, reuse_name=reuse_name, disable_crd_hook=disable_crd_hook, description=description) return stub.InstallRelease(release_request, self._timeout, metadata=self.metadata)