This is a sample application to showcase Harness Continuous Verification use cases. It has an internal web server with automatic load on 4 transactions, and will log errors on a set frequency. It can be configured to integrate with multiple APM tools & log aggregators. It also has 4 different run modes that can be set via an environment variable.
Finally, there is an example Harness Application stored as Config as Code in the Setup
directory. This includes a kubernetes service, environment mapping, and a Workflow.
The current Docker image can be found at https://hub.docker.com/r/ldhertert/harness-cv-testapp
Prerequisites: Existing Harness account with connectors in place for docker registry, kubernetes cluster, and a working delegate.
-
Fork this repository
-
Clone your fork to your local machine
-
Optional - Publish docker image to your own repository
-
Modify
package.json
and put your repo/image information in the following section"config": { "imageRepo": "ldhertert/harness-cv-testapp" }
-
Ensure you have permissions to push to the target repo via
docker push
, and then runnpm install # These are just helper shortcuts. Normal docker build/push commands work as well. npm run docker:build npm run docker:publish
-
-
In Harness, create a new Git connector that points to your forked repository
-
Create a new Harness application called
harness-cv-testapp
and configure it with Git sync using your new git connector. -
Harness does not currently import preexisting config as code when a new application is created, so we need to revert a commit that was automatically made. On your local machine, within the cloned git repo, run the following
git pull git revert HEAD --no-edit git push origin master
-
You will probably get a notification in the Harness UI that Harness was unable to process some changes from Git. We just need to tweak one thing. Click the link from the notification, find the error for
Applications/harness-cv-testapp/Environments/Dev/Service Infrastructure/k8s-dev.yaml
(you can ignore any other errors), click Fix This and edit the value ofcomputeProviderName
to the name of your Kubernetes cloud provider in Harness. This should match the name displayed on theSetup -> Cloud Providers
page. -
Now that your YAML is imported, we need to customize a few things:
- In the Service editor, add the docker image as an artifact and set the values for your New Relic API Key, New Relic Application Name, Splunk URL, and Splunk Token.
- In the Environments, modify the infra mapping if needed to specify namespace
- In the Workflow, click into the Canary phase. In the verification steps, update New Relic Server, New Relic App Name, and Splunk Server.
-
You're ready to start deploying. Execute the workflow, and select
Normal
for theTestMode
parameter. This will perform an initial deployment with normal expected performance. -
Execute additional deployments with different
TestMode
values to prove out different failure use cases. Verification should fail, and Harness should automatically roll back to theNormal
artifact.
To enable New Relic, set the following environment variables
NEW_RELIC_LICENSE_KEY=xxxxxxxxxx
NEW_RELIC_APP_NAME=YourNewRelicApp
To enable AppDynamics, set the following environment variables
APPD_CONTROLLER_URL=https://myinstance.saas.appdynamics.com
APPD_ACCESS_KEY=xxxx
#Optional config settings, will be inferred if excluded
APPD_APPLICATION_NAME (default harness-cv-testapp)
APPD_ACCOUNT_NAME (inferred from URL if SaaS, customer1 if non-SaaS url)
To enable Splunk, set the following environment variables
SPLUNK_TOKEN=xxxxxxxxxx
SPLUNK_URL=https://input-prd-p-XXXXXXXX.cloud.splunk.com:8088/services/collector
There are 4 different modes to showcase different Harness CV use cases. You can enable different modes with the following environment variable values
HARNESS_MODE=NORMAL
HARNESS_MODE=UNKNOWN_EVENT
HARNESS_MODE=UNEXPECTED_FREQUENCY
HARNESS_MODE=APM_REGRESSION
To publish to Docker Hub, run the following:
npm run docker:build && npm run docker:publish
- 1.0.3 - Jan 16, 2020 - Improve console error logging
- 1.0.2 - July 2, 2019 - Fix docker CMD
- 1.0.1 - July 1, 2019 - Added support for AppDynamics APM
- 1.0.0 - June 30, 2019 - Initial release. Support for New Relic & Splunk on Kubernetes.
- ELK - In progress
- Datadog APM - In progress, see datadog branch
- Datadog Logs - In progress, see datadog branch
- Logz.io - Implemented, not fully tested
- AppDynamics - TBD
- Dynatrace - TBD
- Support for non-kubernetes deployments - TBD
- Configure cloudwatch logs for AMI (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/QuickStartEC2Instance.html)
- Allow configuration of load generator to point to external load balancer
- PCF Support (status - PCF working properly, just need to put into config as code and add documentation)