From 69862a325b1ad9998c9b4c250564919e2d8d611e Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 28 Aug 2024 15:23:50 +0530 Subject: [PATCH 1/7] added harness-chaos cloud builder Signed-off-by: Saranya-jena --- harness-chaos/Dockerfile | 10 ++++++++++ harness-chaos/cloudbuild.yaml | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 harness-chaos/Dockerfile create mode 100644 harness-chaos/cloudbuild.yaml diff --git a/harness-chaos/Dockerfile b/harness-chaos/Dockerfile new file mode 100644 index 00000000..b42aaa71 --- /dev/null +++ b/harness-chaos/Dockerfile @@ -0,0 +1,10 @@ +FROM redhat/ubi8-minimal:8.8 +USER root +# For future reference, do a minimal update of microdnf to avoid extra dependencies, minimizing vulnerabilities +RUN microdnf update --refresh --best --noplugins --setopt=install_weak_deps=0 \ + && rm -rf /var/cache/yum \ + && microdnf clean all +RUN microdnf install jq curl +RUN curl -L https://app.harness.io/public/shared/tools/chaos/hce-cli/0.0.6/hce-cli-0.0.6-linux-amd64 --output /usr/local/bin/hce-cli && chmod +x /usr/local/bin/hce-cli +USER 65534 +ENTRYPOINT ["hce-cli"] \ No newline at end of file diff --git a/harness-chaos/cloudbuild.yaml b/harness-chaos/cloudbuild.yaml new file mode 100644 index 00000000..0aefddd7 --- /dev/null +++ b/harness-chaos/cloudbuild.yaml @@ -0,0 +1,9 @@ +steps: +- name: 'gcr.io/cloud-builders/docker' + args: ['build', '--tag=gcr.io/$PROJECT_ID/harness-chaos', '.'] + +# To ensure tool is installed correctly +- name: 'gcr.io/$PROJECT_ID/harness-chaos' + args: ['generate', '--help'] + +images: ['gcr.io/$PROJECT_ID/harness-chaos'] \ No newline at end of file From 6768d8c3c9b0908b5155cbd98622cf01dfc53ec2 Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 28 Aug 2024 15:31:55 +0530 Subject: [PATCH 2/7] added readme file Signed-off-by: Saranya-jena --- harness-chaos/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 harness-chaos/README.md diff --git a/harness-chaos/README.md b/harness-chaos/README.md new file mode 100644 index 00000000..4b034009 --- /dev/null +++ b/harness-chaos/README.md @@ -0,0 +1,28 @@ +# Harness Chaos + +The harness-chaos builder step is used to launch chaos experiments and test the resilience of the applications. + +Here’s an example demonstrating how to launch and validate a chaos experiment. You can pass the `--workflow-id` flag along with the `--expected-resilience-score` flag to ensure that the actual resilience score of the experiment run meets the expected threshold, along with other necessary flags. + +**Example:** +``` +steps: +- name: 'gcr.io/$PROJECT_ID/harness-chaos' + args: ['generate', '--api=run-and-monitor-experiment', '--account-id=${_ACCOUNT_ID}','--org-id=${_ORG_ID}','--project-id=${_PROJECT_ID}', '--workflow-id=${_EXPERIMENT_ID}', '--expected-resilience-score=${_EXPECTED_RES_SCORE}', '--api-key=${_X_API_KEY}' ] + + env: + - 'ACCOUNT_ID=${_ACCOUNT_ID}' + - 'ORG_ID=${_ORG_ID}' + - 'PROJECT_ID=${_PROJECT_ID}' + - 'WORKFLOW_ID=${_EXPERIMENT_ID}' + - 'EXPECTED_RES_SCORE=${_EXPECTED_RES_SCORE}' + - 'X_API_KEY=${_X_API_KEY}' + +substitutions: + _ACCOUNT_ID: '' + _ORG_ID: 'ORG_ID' + _PROJECT_ID: 'PROJECT_ID' + _EXPERIMENT_ID: 'EXPERIMENT_ID' + _EXPECTED_RES_SCORE: '100' + _X_API_KEY: 'X_API_KEY' // required for authorization +``` \ No newline at end of file From 3c48ce8c4f4ed20288e52559e8f26ba980ea1196 Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 28 Aug 2024 15:39:57 +0530 Subject: [PATCH 3/7] updated readme file Signed-off-by: Saranya-jena --- harness-chaos/README.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/harness-chaos/README.md b/harness-chaos/README.md index 4b034009..4f589efc 100644 --- a/harness-chaos/README.md +++ b/harness-chaos/README.md @@ -10,14 +10,6 @@ steps: - name: 'gcr.io/$PROJECT_ID/harness-chaos' args: ['generate', '--api=run-and-monitor-experiment', '--account-id=${_ACCOUNT_ID}','--org-id=${_ORG_ID}','--project-id=${_PROJECT_ID}', '--workflow-id=${_EXPERIMENT_ID}', '--expected-resilience-score=${_EXPECTED_RES_SCORE}', '--api-key=${_X_API_KEY}' ] - env: - - 'ACCOUNT_ID=${_ACCOUNT_ID}' - - 'ORG_ID=${_ORG_ID}' - - 'PROJECT_ID=${_PROJECT_ID}' - - 'WORKFLOW_ID=${_EXPERIMENT_ID}' - - 'EXPECTED_RES_SCORE=${_EXPECTED_RES_SCORE}' - - 'X_API_KEY=${_X_API_KEY}' - substitutions: _ACCOUNT_ID: '' _ORG_ID: 'ORG_ID' @@ -25,4 +17,6 @@ substitutions: _EXPERIMENT_ID: 'EXPERIMENT_ID' _EXPECTED_RES_SCORE: '100' _X_API_KEY: 'X_API_KEY' // required for authorization -``` \ No newline at end of file +``` + +To know more about Harness Chaos Engineering visit [here](https://developer.harness.io/docs/chaos-engineering). \ No newline at end of file From 602747b369e86fac679389aa56bd5b567ee0e52f Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 28 Aug 2024 15:41:10 +0530 Subject: [PATCH 4/7] updated Dockerfile Signed-off-by: Saranya-jena --- harness-chaos/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harness-chaos/Dockerfile b/harness-chaos/Dockerfile index b42aaa71..91757a5d 100644 --- a/harness-chaos/Dockerfile +++ b/harness-chaos/Dockerfile @@ -5,6 +5,6 @@ RUN microdnf update --refresh --best --noplugins --setopt=install_weak_deps=0 \ && rm -rf /var/cache/yum \ && microdnf clean all RUN microdnf install jq curl -RUN curl -L https://app.harness.io/public/shared/tools/chaos/hce-cli/0.0.6/hce-cli-0.0.6-linux-amd64 --output /usr/local/bin/hce-cli && chmod +x /usr/local/bin/hce-cli +RUN curl -L https://app.harness.io/public/shared/tools/chaos/hce-cli/latest/hce-cli-latest-linux-amd64 --output /usr/local/bin/hce-cli && chmod +x /usr/local/bin/hce-cli USER 65534 ENTRYPOINT ["hce-cli"] \ No newline at end of file From bcb560160ef97743f3c33c322f68339cdd05ef9a Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 28 Aug 2024 15:59:48 +0530 Subject: [PATCH 5/7] updated Dockerfile Signed-off-by: Saranya-jena --- harness-chaos/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/harness-chaos/Dockerfile b/harness-chaos/Dockerfile index 91757a5d..0000ac11 100644 --- a/harness-chaos/Dockerfile +++ b/harness-chaos/Dockerfile @@ -1,6 +1,5 @@ FROM redhat/ubi8-minimal:8.8 USER root -# For future reference, do a minimal update of microdnf to avoid extra dependencies, minimizing vulnerabilities RUN microdnf update --refresh --best --noplugins --setopt=install_weak_deps=0 \ && rm -rf /var/cache/yum \ && microdnf clean all From f50da75e1195e2d4ed26e66def8db05e75f83f3d Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 28 Aug 2024 17:14:28 +0530 Subject: [PATCH 6/7] updated Readme Signed-off-by: Saranya-jena --- harness-chaos/README.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/harness-chaos/README.md b/harness-chaos/README.md index 4f589efc..9512bd71 100644 --- a/harness-chaos/README.md +++ b/harness-chaos/README.md @@ -1,8 +1,26 @@ # Harness Chaos -The harness-chaos builder step is used to launch chaos experiments and test the resilience of the applications. +## Introduction +The harness-chaos builder step is used to launch chaos experiments and test the resilience of the applications. This tool helps users easily simulate various failure scenarios and uncover potential vulnerabilities and weaknesses in the system/applications.This can be integrated with the CD pipelines to test the resiliency of the application before doing the releases -Here’s an example demonstrating how to launch and validate a chaos experiment. You can pass the `--workflow-id` flag along with the `--expected-resilience-score` flag to ensure that the actual resilience score of the experiment run meets the expected threshold, along with other necessary flags. +## Prerequisites + +**Identifiers(Account ID, Organization ID, Project ID)** + +To perform any operation in Harness Chaos Engineering(HCE) platform, users need to get onboarded and have the identifiers. Here are the references to get started: +- [User Onboarding Guide](https://developer.harness.io/docs/platform/get-started/onboarding-guide) +- [Create organizations and projects](https://developer.harness.io/docs/platform/organizations-and-projects/create-an-organization) + +**Create API Key** +To run any operation, users will need an API Key to authorize the same. API Key needs to be created and passed as flag in the command demonstrated below. Here is the document to [create and manage API keys](https://developer.harness.io/docs/platform/automation/api/add-and-manage-api-keys/). + +**Create a Chaos Experiment** + +Next step is to create a chaos experiment and get the experiment ID to launch the chaos experiment using cloud builder. Once the onboarding is complete, users can go to the Chaos Engineering Module and follow the steps mentioned in documentation to [create a chaos experiment](https://developer.harness.io/docs/chaos-engineering/get-started/tutorials/chaos-experiment-from-blank-canvas). + +## How to run launch chaos experiment using cloud builder + +Once the chaos experiment is created and we have the values for the required flags, here’s an example demonstrating how to launch and validate a chaos experiment using cloud builder. Users can pass the `--workflow-id` flag(`workflow-id` is same as experiment ID) along with the `--expected-resilience-score` flag to ensure that the actual resilience score of the experiment run meets the expected threshold, along with other necessary flags. **Example:** ``` @@ -19,4 +37,15 @@ substitutions: _X_API_KEY: 'X_API_KEY' // required for authorization ``` +### Flags + +- `--api`: Set the name of the target API (mandatory). +- `--account-id`: Set the account ID (mandatory). +- `--org-id`: Set the organisation id (default "default") +- `--project-id`: Set the HCE project ID (mandatory). +- `--workflow-id`: Set the workflow ID (mandatory for some APIs; a default dummy value is provided). +- `--api-key`: Set the API key (mandatory). +- `--delay`: Set the delay provided for multiple iterations (a default value of 2s is provided for some APIs). +- `--timeout`: Set the timeout provided for multiple iterations (a default value of 180s is provided for some APIs). + To know more about Harness Chaos Engineering visit [here](https://developer.harness.io/docs/chaos-engineering). \ No newline at end of file From db856fe760798ed8d95f4ebb4042ba2f03c75928 Mon Sep 17 00:00:00 2001 From: Saranya-jena Date: Wed, 28 Aug 2024 17:17:22 +0530 Subject: [PATCH 7/7] updated Readme Signed-off-by: Saranya-jena --- harness-chaos/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/harness-chaos/README.md b/harness-chaos/README.md index 9512bd71..453b9e54 100644 --- a/harness-chaos/README.md +++ b/harness-chaos/README.md @@ -30,11 +30,11 @@ steps: substitutions: _ACCOUNT_ID: '' - _ORG_ID: 'ORG_ID' - _PROJECT_ID: 'PROJECT_ID' - _EXPERIMENT_ID: 'EXPERIMENT_ID' + _ORG_ID: '' + _PROJECT_ID: '' + _EXPERIMENT_ID: '' _EXPECTED_RES_SCORE: '100' - _X_API_KEY: 'X_API_KEY' // required for authorization + _X_API_KEY: '' // required for authorization ``` ### Flags