Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added supported stages + video demo + started harness prerequisites. #120

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "spinnaker-migration",
"label": "Spinnaker Migration",
"collapsed": false,
"position": 11,
"link": {
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/spinnaker-migration/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<iframe width="560" height="315" src="https://www.youtube.com/embed/gkWK3BGpDEU?si=ExGLw9B5Q7h2VMdn" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
27 changes: 26 additions & 1 deletion docs/docs/spinnaker-migration/intro.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
title: Introduction
description: Introduction to the Spinnaker Migration tool. Includes supported Spinnaker stages.
sidebar_position: 1
---

Expand All @@ -10,5 +12,28 @@ 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 | 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 | 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 | |
94 changes: 89 additions & 5 deletions docs/docs/spinnaker-migration/prerequisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,97 @@ 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)

#### 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.

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 = '<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>';
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);
});
};
```
Loading