def _get_cmd_args_for_template(self, root_dir, app_name, namespace, cluster_id): if enable_helm_v3(cluster_id): return [settings.HELM3_BIN, "template", app_name, root_dir, "--namespace", namespace] return [ settings.HELM_BIN, "template", root_dir, "--name", app_name, "--namespace", namespace, ]
def get_history_releases(self): # 针对helm upgrade的操作,执行成功时,才会有revision,才允许回滚 releases = ChartRelease.objects.filter(app_id=self.id).exclude( id=self.release.id).order_by("-id") if enable_helm_v3(self.cluster_id): releases = releases.exclude(revision=0) releases = [ dict( id=item.id, short_name=item.short_name, version=item.chartVersionSnapshot.version, created_at=item.created_at, revision=item.revision, ) for item in releases ] return releases
def first_deploy_task(self, access_token, activity_log_id, deploy_options): log_client = get_log_client_by_activity_log_id(activity_log_id) try: app_deployer = AppDeployer(app=self, access_token=access_token, **deploy_options) # 启用helm功能,使用helm相关命令 if enable_helm_v3(self.cluster_id): # 针对install操作,标识为使用helm命令 self.enable_helm = True self.save(update_fields=["enable_helm"]) app_deployer.install_app_by_helm() else: app_deployer.install_app_by_kubectl() except Exception as e: logger.exception("first deploy app with unexpected error: %s", e) self.set_transitioning(False, "unexpected error: %s" % e) log_client.update_log(activity_status="failed") else: activity_status = "succeed" if self.transitioning_result else "failed" log_client.update_log(activity_status=activity_status)