From f687b90c88502d34ef4c961fd7a8b25546759265 Mon Sep 17 00:00:00 2001 From: Sushrut Athavale Date: Wed, 15 May 2024 13:57:00 -0700 Subject: [PATCH 1/4] Added supported stages + video demo + started harness prerequisites. --- .../{_category_ copy.json => _category_.json} | 2 +- docs/docs/spinnaker-migration/instructions.md | 4 ++ docs/docs/spinnaker-migration/intro.md | 23 ++++++- .../docs/spinnaker-migration/prerequisites.md | 64 +++++++++++++++++-- 4 files changed, 86 insertions(+), 7 deletions(-) rename docs/docs/spinnaker-migration/{_category_ copy.json => _category_.json} (72%) diff --git a/docs/docs/spinnaker-migration/_category_ copy.json b/docs/docs/spinnaker-migration/_category_.json similarity index 72% rename from docs/docs/spinnaker-migration/_category_ copy.json rename to docs/docs/spinnaker-migration/_category_.json index e9188ef..9dd69e1 100644 --- a/docs/docs/spinnaker-migration/_category_ copy.json +++ b/docs/docs/spinnaker-migration/_category_.json @@ -1,5 +1,5 @@ { - "label": "spinnaker-migration", + "label": "Spinnaker Migration", "collapsed": false, "position": 11, "link": { diff --git a/docs/docs/spinnaker-migration/instructions.md b/docs/docs/spinnaker-migration/instructions.md index 56c6fff..d018e99 100644 --- a/docs/docs/spinnaker-migration/instructions.md +++ b/docs/docs/spinnaker-migration/instructions.md @@ -51,3 +51,7 @@ Migration details: ? Do you want to proceed? Yes INFO[2024-03-04T15:50:41-08:00] Spinnaker migration completed ``` + +## Video Demo + + \ No newline at end of file diff --git a/docs/docs/spinnaker-migration/intro.md b/docs/docs/spinnaker-migration/intro.md index a7ae817..a632352 100644 --- a/docs/docs/spinnaker-migration/intro.md +++ b/docs/docs/spinnaker-migration/intro.md @@ -1,4 +1,6 @@ --- +title: Introduction +description: Introduction to the Spinnaker Migration tool. Includes supported Spinnaker stages. sidebar_position: 1 --- @@ -10,5 +12,24 @@ This tool was developed by Harness to assist in the migration process from Spinn This tool is designed for customers, CSMs, and developers who are currently using Spinnaker and wish to migrate their accounts to Harness CD Next Gen. -### Key Components that can be migrated +### Spinnaker stages that can be migrated The following key components can be migrated using this tool: + +| | Stages | Harness | Can we Migrate? | Comments | +| -- | ------------------------- | ----------------- | --------------- | ------------------------------------------------------ | +| 1 | pipeline | Pipeline Chaining | Yes | Can only chain up to 2 pipelines | +| 2 | manualJudgment | Approval | Yes | | +| 3 | checkPreconditions | Shell Script | Yes | Supports Expressions, and Multiple Check preconditions | +| 4 | deleteManifest | Delete | Yes | | +| 5 | evaluateVariables | JEXL Expression | Yes | | +| 6 | wait | Wait | Yes | | +| 7 | deployManifest | Deploy | Yes | | +| 8 | webhook | Custom Webhook | Yes | | +| 9 | findImageFromTags | | Yes | | +| 10 | bake | Bake Plugin | Yes | AMI Baking | +| 11 | jenkins | Jenkins Step | Yes | | +| 12 | findArtifactsFromResource | Shell Script | Yes | | +| 13 | Find Image From Tags | Plugin | Yes | | +| 14 | AWS: invokeLambda | Plugin | Yes | | +| 15 | ShrinkCluster | Plugin | Yes | | +| 16 | ScaleDownCluster | Plugin | Yes | \ No newline at end of file diff --git a/docs/docs/spinnaker-migration/prerequisites.md b/docs/docs/spinnaker-migration/prerequisites.md index 0a879a5..5169b7b 100644 --- a/docs/docs/spinnaker-migration/prerequisites.md +++ b/docs/docs/spinnaker-migration/prerequisites.md @@ -7,13 +7,67 @@ sidebar_position: 2 Before using the Spinnaker to CD Next Gen migration tool, you must have the following prerequisites: - Armory Account - Armory Platform | Spinnaker - - Harness Account - AccountID - - Harness Org - default if not provided - - Harness Project - Project_Name - - API Key - Follow instructions at Manage API keys | [Harness Developer Hub](https://developer.harness.io/docs/platform/automation/api/add-and-manage-api-keys/#create-personal-api-keys-and-tokens) - - Environment - Prod, Prod1, or Prod3 + +## Cloud Providers + +Cloud providers can have their own specific prerequisites for migration. Here they are: + +### AWS + +If you are using the **spinnaker-aws-drone-plugin** for any stages (i.e. Shrinkcluster, Scaledowncluster, Invokelambda) then ensure that there is an AWS secret created at the project level within Harness with the following names: + +``` +AWS_ACCESS_KEY_ID +AWS_SECRET_ACCESS_KEY +``` + +For information on how to create secrets with Harness, go to [AWS Secrets Manager](https://developer.harness.io/docs/platform/secrets/secrets-management/add-an-aws-secret-manager) + +### GCP + +Regrettably, Harness lacks native support for triggering pipelines directly via incoming Pub/Sub messages. However, we can work around this limitation by using a custom webhook trigger. + +For detailed information about custom webhook triggers, go to [Using Custom Triggers](https://developer.harness.io/docs/platform/triggers/trigger-deployments-using-custom-triggers/) + +In this approach, you would need to provision a new GCP Cloud Function that triggers from Pub/Sub topic messages and invokes the custom webhook URL. Below is an example of such a function in Node.js. + +```jsx +const fetch = require('node-fetch'); + +exports.pubsubListener = (event, context) => { + const pubsubMessage = event.data; + const message = Buffer.from(pubsubMessage, 'base64').toString(); + + console.log(`Received message: ${message}`); + + // Define the webhook URL and payload + const webhookUrl = ''; + const payload = { + sample_key: 'sample_value' + }; + + // Make a POST request to the webhook URL + fetch(webhookUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(payload) + }) + .then(response => { + if (!response.ok) { + throw new Error('Failed to trigger webhook'); + } + console.log('Webhook triggered successfully'); + return response.json(); + }) + .catch(error => { + console.error('Error triggering webhook:', error); + }); +}; +``` From 4cb9e9fdc7ea731d9b169278960fe1db96617bbf Mon Sep 17 00:00:00 2001 From: Sushrut Athavale Date: Wed, 22 May 2024 17:45:39 -0700 Subject: [PATCH 2/4] Jenkins trigger prerequisite --- .../docs/spinnaker-migration/prerequisites.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/docs/spinnaker-migration/prerequisites.md b/docs/docs/spinnaker-migration/prerequisites.md index 5169b7b..3ee307f 100644 --- a/docs/docs/spinnaker-migration/prerequisites.md +++ b/docs/docs/spinnaker-migration/prerequisites.md @@ -28,6 +28,36 @@ AWS_SECRET_ACCESS_KEY For information on how to create secrets with Harness, go to [AWS Secrets Manager](https://developer.harness.io/docs/platform/secrets/secrets-management/add-an-aws-secret-manager) +#### Jenkins Trigger + +Unfortunately, Harness does not natively support passing payloads for Jenkins Trigger. Consequently, you cannot use Spinnaker expressions such as `${trigger["properties"]["hash"]}` or `${trigger["properties"]["branch"]}`. + +One possible workaround we suggest is using a custom webhook trigger. For more information about this, go to [Using Custom Triggers](https://developer.harness.io/docs/platform/triggers/trigger-deployments-using-custom-triggers/) + +With this approach, you would need to add a new step to your Jenkins Job, similar to the example below. + +``` +pipeline { + agent any + + stages { + // YOUR STAGES HERE... + + stage('Trigger Harness Pipeline') { + steps { + script { + sh ''' + curl -X POST -H 'Content-Type: application/json' \ + --url 'https://app.harness.io/gateway/pipeline/api/webhook/custom/Wlke4SU6TAeKwDERALcptQ/v3?accountIdentifier=YOUR_ACCOUNT_ID&orgIdentifier=YOUR_ORG_ID&projectIdentifier=YOUR_PROJECT_ID&pipelineIdentifier=YOUR_PIPELINE_ID&triggerIdentifier=webhook_trigger' \ + -d '{"properties": {"hash": "hash_value", "branch": "branch_value"}}' + ''' + } + } + } + } +} +``` + ### GCP Regrettably, Harness lacks native support for triggering pipelines directly via incoming Pub/Sub messages. However, we can work around this limitation by using a custom webhook trigger. From e04ad1c3dd6fa64a856801055c7fffd59853a34b Mon Sep 17 00:00:00 2001 From: Sushrut Athavale Date: Thu, 23 May 2024 12:36:33 -0700 Subject: [PATCH 3/4] Updated supported stages for new stages. Added clarification for bake step. --- docs/docs/spinnaker-migration/intro.md | 41 +++++++++++++++----------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/docs/docs/spinnaker-migration/intro.md b/docs/docs/spinnaker-migration/intro.md index a632352..9c4053d 100644 --- a/docs/docs/spinnaker-migration/intro.md +++ b/docs/docs/spinnaker-migration/intro.md @@ -15,21 +15,26 @@ This tool is designed for customers, CSMs, and developers who are currently usin ### Spinnaker stages that can be migrated The following key components can be migrated using this tool: -| | Stages | Harness | Can we Migrate? | Comments | -| -- | ------------------------- | ----------------- | --------------- | ------------------------------------------------------ | -| 1 | pipeline | Pipeline Chaining | Yes | Can only chain up to 2 pipelines | -| 2 | manualJudgment | Approval | Yes | | -| 3 | checkPreconditions | Shell Script | Yes | Supports Expressions, and Multiple Check preconditions | -| 4 | deleteManifest | Delete | Yes | | -| 5 | evaluateVariables | JEXL Expression | Yes | | -| 6 | wait | Wait | Yes | | -| 7 | deployManifest | Deploy | Yes | | -| 8 | webhook | Custom Webhook | Yes | | -| 9 | findImageFromTags | | Yes | | -| 10 | bake | Bake Plugin | Yes | AMI Baking | -| 11 | jenkins | Jenkins Step | Yes | | -| 12 | findArtifactsFromResource | Shell Script | Yes | | -| 13 | Find Image From Tags | Plugin | Yes | | -| 14 | AWS: invokeLambda | Plugin | Yes | | -| 15 | ShrinkCluster | Plugin | Yes | | -| 16 | ScaleDownCluster | Plugin | Yes | \ No newline at end of file +| | Stages | Harness | Can we Migrate? | Comments | +|----|-------------------------------|-------------------|-----------------|--------------------------------------------------------| +| 1 | pipeline | Pipeline Chaining | Yes | Can only chain up to 2 pipelines | +| 2 | manualJudgment | Approval | Yes | | +| 3 | checkPreconditions | Shell Script | Yes | Supports Expressions, and Multiple Check preconditions | +| 4 | deleteManifest | Delete | Yes | | +| 5 | evaluateVariables | JEXL Expression | Yes | | +| 6 | wait | Wait | Yes | | +| 7 | deployManifest | Deploy | Yes | | +| 8 | webhook | HTTP Step | Yes | | +| 9 | findImageFromTags | Shell Script | Yes | | +| 10 | bake | Bake Plugin | Yes | Only supports AWS cloud provider currently | +| 11 | jenkins | Jenkins Step | Yes | | +| 12 | findArtifactsFromResource | Shell Script | Yes | | +| 13 | Find Image From Tags | Plugin | Yes | | +| 14 | AWS: invokeLambda | Plugin | Yes | | +| 15 | ShrinkCluster | Plugin | Yes | | +| 16 | ScaleDownCluster | Plugin | Yes | | +| 17 | ResizeServerGroup | Plugin | Yes | | +| 18 | DisableCluster | Plugin | Yes | | +| 19 | ArtifactoryPromote | HTTP Step | Yes | | +| 20 | DestroyServerGroup | Plugin | Yes | | +| 21 | Deploy AMI Backed with Packer | Plugin | Yes | | From ad9f84b89bd9f8d664efe70f368475a6abfa9f0e Mon Sep 17 00:00:00 2001 From: Sushrut Athavale Date: Thu, 23 May 2024 13:21:03 -0700 Subject: [PATCH 4/4] removed repeated stage --- docs/docs/spinnaker-migration/intro.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/docs/spinnaker-migration/intro.md b/docs/docs/spinnaker-migration/intro.md index 9c4053d..c249011 100644 --- a/docs/docs/spinnaker-migration/intro.md +++ b/docs/docs/spinnaker-migration/intro.md @@ -29,12 +29,11 @@ The following key components can be migrated using this tool: | 10 | bake | Bake Plugin | Yes | Only supports AWS cloud provider currently | | 11 | jenkins | Jenkins Step | Yes | | | 12 | findArtifactsFromResource | Shell Script | Yes | | -| 13 | Find Image From Tags | Plugin | Yes | | -| 14 | AWS: invokeLambda | Plugin | Yes | | -| 15 | ShrinkCluster | Plugin | Yes | | -| 16 | ScaleDownCluster | Plugin | Yes | | -| 17 | ResizeServerGroup | Plugin | Yes | | -| 18 | DisableCluster | Plugin | Yes | | -| 19 | ArtifactoryPromote | HTTP Step | Yes | | -| 20 | DestroyServerGroup | Plugin | Yes | | -| 21 | Deploy AMI Backed with Packer | Plugin | Yes | | +| 13 | AWS: invokeLambda | Plugin | Yes | | +| 14 | ShrinkCluster | Plugin | Yes | | +| 15 | ScaleDownCluster | Plugin | Yes | | +| 16 | ResizeServerGroup | Plugin | Yes | | +| 17 | DisableCluster | Plugin | Yes | | +| 18 | ArtifactoryPromote | HTTP Step | Yes | | +| 19 | DestroyServerGroup | Plugin | Yes | | +| 20 | Deploy AMI Backed with Packer | Plugin | Yes | |