def update_release(self, chart, dry_run, namespace, name=None, pre_actions=None, post_actions=None, disable_hooks=False, values=None): ''' Update a Helm Release ''' values = Config(raw=yaml.safe_dump(values or {})) self._pre_update_actions(pre_actions, namespace) # build release install request stub = ReleaseServiceStub(self.channel) release_request = UpdateReleaseRequest(chart=chart, dry_run=dry_run, disable_hooks=disable_hooks, values=values, name=name or '') stub.UpdateRelease(release_request, self.timeout, metadata=self.metadata) self._post_update_actions(post_actions, namespace)
def update_release(self, chart, release, namespace, pre_actions=None, post_actions=None, disable_hooks=False, values=None, wait=False, timeout=None, force=False, recreate_pods=False): ''' Update a Helm Release ''' timeout = self._check_timeout(wait, timeout) LOG.info( 'Helm update release%s: wait=%s, timeout=%s, force=%s, ' 'recreate_pods=%s', (' (dry run)' if self.dry_run else ''), wait, timeout, force, recreate_pods) if values is None: values = Config(raw='') else: values = Config(raw=values) self._pre_update_actions(pre_actions, release, namespace, chart, disable_hooks, values, timeout) update_msg = None # build release install request try: stub = ReleaseServiceStub(self.channel) release_request = UpdateReleaseRequest(chart=chart, dry_run=self.dry_run, disable_hooks=disable_hooks, values=values, name=release, wait=wait, timeout=timeout, force=force, recreate=recreate_pods) update_msg = stub.UpdateRelease(release_request, timeout + GRPC_EPSILON, metadata=self.metadata) except Exception: LOG.exception('Error while updating release %s', release) status = self.get_release_status(release) raise ex.ReleaseException(release, status, 'Upgrade') tiller_result = TillerResult( update_msg.release.name, update_msg.release.namespace, update_msg.release.info.status.Code.Name( update_msg.release.info.status.code), update_msg.release.info.Description, update_msg.release.version) return tiller_result
def update_release(self, chart, namespace, dry_run=False, name=None, values=None, wait=False, disable_hooks=False, recreate=False, reset_values=False, reuse_values=False, force=False, description="", install=False): """ Update a Helm Release """ stub = ReleaseServiceStub(self._channel) if install: if not namespace: namespace = DEFAULT_NAMESPACE try: release_status = self.get_release_status(name) except grpc.RpcError as rpc_error_call: if not rpc_error_call.details( ) == "getting deployed release \"{}\": release: \"{}\" not found".format( name, name): raise rpc_error_call # The release doesn't exist - it's time to install self._logger.info( "Release %s does not exist. Installing it now.", name) return self.install_release(chart, namespace, dry_run, name, values, wait) if release_status.namespace != namespace: self._logger.warn( "Namespace %s doesn't match with previous. Release will be deployed to %s", release_status.namespace, namespace) values = Config(raw=yaml.safe_dump(values or {})) release_request = UpdateReleaseRequest(chart=chart, dry_run=dry_run, disable_hooks=disable_hooks, values=values, name=name or '', wait=wait, recreate=recreate, reset_values=reset_values, reuse_values=reuse_values, force=force, description=description) return stub.UpdateRelease(release_request, self._timeout, metadata=self.metadata)
def update_release(self, chart, dry_run, name, disable_hooks=False, values=None): ''' Update 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 = UpdateReleaseRequest(chart=chart, dry_run=dry_run, disable_hooks=disable_hooks, values=values, name=name) return stub.UpdateRelease(release_request, self.timeout, metadata=self.metadata)
def update_release(self, chart, dry_run, name, namespace, prefix, pre_actions=None, post_actions=None, disable_hooks=False, values=None): ''' Update a Helm Release ''' if values is None: values = Config(raw='') else: values = Config(raw=values) self._pre_update_actions(pre_actions, namespace) # build release install request stub = ReleaseServiceStub(self.channel) release_request = UpdateReleaseRequest( chart=chart, dry_run=dry_run, disable_hooks=disable_hooks, values=values, name="{}-{}".format(prefix, name)) stub.UpdateRelease(release_request, self.timeout, metadata=self.metadata) self._post_update_actions(post_actions, namespace)
def update_release(self, chart, release, namespace, dry_run=False, pre_actions=None, post_actions=None, disable_hooks=False, values=None, wait=False, timeout=None): ''' Update a Helm Release ''' rel_timeout = self.timeout if not timeout else timeout LOG.debug("wait: %s", wait) LOG.debug("timeout: %s", timeout) if values is None: values = Config(raw='') else: values = Config(raw=values) self._pre_update_actions(pre_actions, release, namespace, chart, disable_hooks, values) # build release install request try: stub = ReleaseServiceStub(self.channel) release_request = UpdateReleaseRequest(chart=chart, dry_run=dry_run, disable_hooks=disable_hooks, values=values, name=release, wait=wait, timeout=timeout) stub.UpdateRelease(release_request, rel_timeout + GRPC_EPSILON, metadata=self.metadata) except Exception: status = self.get_release_status(release) raise ex.ReleaseException(release, status, 'Upgrade') self._post_update_actions(post_actions, namespace)
def update_release(self, chart, name, dry_run=False, disable_hooks=False, values=None, recreate=False, reset_values=False, reuse_values=False, force=False, timeout=REQUEST_TIMEOUT): """升级release Args: :params - chart - chart 元数据,由函数生成 :params - name - release name :params - dry_run - simulate an upgrade :params - values - 额外的values,用来进行value值替换 :params - disable_hooks - prevent hooks from running during rollback(bool) :params - recreate - performs pods restart for the resource if applicable(bool) :params - reset_values - when upgrading, reset the values to the ones built into the chart(bool) :params - reuse_values - when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' is specified, this is ignored.(bool) :params - force - 是否强制升级(bool) Returns: 返回升级release的grpc响应对象 """ values = Config(raw=yaml.safe_dump(values or {})) # build update release request stub = ReleaseServiceStub(self.channel) release_request = UpdateReleaseRequest(chart=chart, dry_run=dry_run, recreate=recreate, reset_values=reset_values, reuse_values=reuse_values, force=force, disable_hooks=disable_hooks, values=values, timeout=timeout, name=name) return stub.UpdateRelease(release_request, self.timeout, metadata=self.metadata)
def update_release(self, chart, release, namespace, dry_run=False, pre_actions=None, post_actions=None, disable_hooks=False, values=None, wait=False, timeout=None): ''' Update 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) self._pre_update_actions(pre_actions, release, namespace, chart, disable_hooks, values) # build release install request try: stub = ReleaseServiceStub(self.channel) release_request = UpdateReleaseRequest(chart=chart, dry_run=dry_run, disable_hooks=disable_hooks, values=values, name=release, wait=wait, timeout=timeout) stub.UpdateRelease(release_request, self.timeout, metadata=self.metadata) except Exception: raise tiller_exceptions.ReleaseInstallException(release, namespace) self._post_update_actions(post_actions, namespace)