@@ -462,3 +462,35 @@ def launchAiServiceInstallPipeline(dynClient: DynamicClient, params: dict) -> st
462462
463463 pipelineURL = f"{ getConsoleURL (dynClient )} /k8s/ns/aiservice-{ instanceId } -pipelines/tekton.dev~v1beta1~PipelineRun/{ instanceId } -install-{ timestamp } "
464464 return pipelineURL
465+
466+
467+ def launchAiServiceUpgradePipeline (dynClient : DynamicClient ,
468+ aiserviceInstanceId : str ,
469+ skipPreCheck : bool = False ,
470+ masChannel : str = "" ,
471+ params : dict = {}) -> str :
472+ """
473+ Create a PipelineRun to upgrade the chosen AI Service instance
474+ """
475+ pipelineRunsAPI = dynClient .resources .get (api_version = "tekton.dev/v1beta1" , kind = "PipelineRun" )
476+ namespace = f"aiservice-{ aiserviceInstanceId } -pipelines"
477+ timestamp = datetime .now ().strftime ("%y%m%d-%H%M" )
478+ # Create the PipelineRun
479+ templateDir = path .join (path .abspath (path .dirname (__file__ )), "templates" )
480+ env = Environment (
481+ loader = FileSystemLoader (searchpath = templateDir )
482+ )
483+ template = env .get_template ("pipelinerun-upgrade.yml.j2" )
484+ renderedTemplate = template .render (
485+ timestamp = timestamp ,
486+ mas_instance_id = aiserviceInstanceId ,
487+ skip_pre_check = skipPreCheck ,
488+ mas_channel = masChannel ,
489+ ** params
490+ )
491+ logger .debug (renderedTemplate )
492+ pipelineRun = yaml .safe_load (renderedTemplate )
493+ pipelineRunsAPI .apply (body = pipelineRun , namespace = namespace )
494+
495+ pipelineURL = f"{ getConsoleURL (dynClient )} /k8s/ns/aiservice-{ aiserviceInstanceId } -pipelines/tekton.dev~v1beta1~PipelineRun/{ aiserviceInstanceId } -upgrade-{ timestamp } "
496+ return pipelineURL
0 commit comments