diff --git a/src/mas/devops/ocp.py b/src/mas/devops/ocp.py index a6f264b4..e61cccef 100644 --- a/src/mas/devops/ocp.py +++ b/src/mas/devops/ocp.py @@ -6,7 +6,7 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # -# ***************************************************************************** +# ****************************************************************************** import logging import os diff --git a/src/mas/devops/tekton.py b/src/mas/devops/tekton.py index 95b20d41..d8486568 100644 --- a/src/mas/devops/tekton.py +++ b/src/mas/devops/tekton.py @@ -6,7 +6,7 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # -# ***************************************************************************** +# ****************************************************************************** import logging import re @@ -1244,6 +1244,30 @@ def launchUpdatePipeline(dynClient: DynamicClient, params: dict) -> str: return pipelineURL +def launchDb2MigrationPipeline(dynClient: DynamicClient, params: dict) -> str: + """ + Create a PipelineRun to migrate Db2uCluster to Db2uInstance. + + Parameters: + dynClient (DynamicClient): OpenShift Dynamic Client + params (dict): Migration parameters including: + - db2_migration_namespace: Target namespace + - db2_migration_cluster_name: Cluster to migrate + - db2_migration_backup_enabled: Whether to backup + + Returns: + str: URL to the PipelineRun in the OpenShift console + + Raises: + NotFoundError: If resources cannot be created + """ + namespace = "mas-pipelines" + timestamp = launchPipelineRun(dynClient, namespace, "pipelinerun-db2-migration", params) + + pipelineURL = f"{getConsoleURL(dynClient)}/k8s/ns/mas-pipelines/tekton.dev~v1beta1~PipelineRun/db2-migration-{timestamp}" + return pipelineURL + + def launchBackupPipeline(dynClient: DynamicClient, params: dict) -> str: """ Create a PipelineRun to backup a MAS instance. diff --git a/src/mas/devops/templates/pipelinerun-db2-migration.yml.j2 b/src/mas/devops/templates/pipelinerun-db2-migration.yml.j2 new file mode 100644 index 00000000..b06ae8eb --- /dev/null +++ b/src/mas/devops/templates/pipelinerun-db2-migration.yml.j2 @@ -0,0 +1,51 @@ +--- +apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +metadata: + name: "db2-migration-{{ timestamp }}" + labels: + tekton.dev/pipeline: mas-devops-db2-migration +spec: + pipelineRef: + name: mas-devops-db2-migration + + serviceAccountName: "{{ service_account_name | default('pipeline', True) }}" + timeouts: + pipeline: "0" + + params: +{%- if image_pull_policy is defined and image_pull_policy != "" %} + # Image Pull Policy + # ------------------------------------------------------------------------- + - name: image_pull_policy + value: "{{ image_pull_policy }}" +{%- endif %} + + # DB2 Migration Parameters + # ------------------------------------------------------------------------- + - name: db2_action + value: "migrate" + + - name: db2_migration_namespace + value: "{{ db2_migration_namespace }}" + + - name: db2_migration_cluster_name + value: "{{ db2_migration_cluster_name }}" + + - name: db2_migration_backup_enabled + value: "{{ db2_migration_backup_enabled }}" + +{%- if db2_migration_cleanup_old_cluster is defined and db2_migration_cleanup_old_cluster != "" %} + - name: db2_migration_cleanup_old_cluster + value: "{{ db2_migration_cleanup_old_cluster }}" +{%- endif %} + +{%- if ibm_entitlement_key is defined and ibm_entitlement_key != "" %} + - name: ibm_entitlement_key + value: "{{ ibm_entitlement_key }}" +{%- endif %} + + workspaces: + # Shared workspace for configs + - name: shared-configs + emptyDir: {}