This is a Sandbox Keptn Services that enables calling the Dynatrace Monaco (Monitoring as Code) toolset for individual Keptn Events
For more information on Dynatrace Monaco, visit the git repository https://github.com/dynatrace-oss/dynatrace-monitoring-as-code
This implements a monaco-service for Keptn. If you want to learn more about Keptn visit us on keptn.sh
Please fill in your versions accordingly
| Authors | Keptn Version | monaco-service Docker Image | Comment |
|---|---|---|---|
| @kristofre | 0.7.3 | keptnsandbox/monaco-service:0.1.0 | Initial release |
The monaco-service can be installed as a part of Keptn's uniform.
To deploy the current version of the monaco-service in your Keptn Kubernetes cluster, apply the deploy/service.yaml file:
kubectl apply -f deploy/service.yamlThis should install the monaco-service together with a Keptn distributor into the keptn namespace, which you can verify using
kubectl -n keptn get deployment monaco-service -o wide
kubectl -n keptn get pods -l run=monaco-serviceAdapt and use the following command in case you want to up- or downgrade your installed version (specified by the $VERSION placeholder):
kubectl -n keptn set image deployment/monaco-service monaco-service=keptnsandbox/monaco-service:$VERSION --recordTo delete a deployed monaco-service, use the file deploy/*.yaml files from this repository and delete the Kubernetes resources:
kubectl delete -f deploy/service.yamlThe goal of the monaco-service is to allow the user to trigger Dynatrace Monaco as part of their keptn-driven releases. For more information about how Dynatrace Monaco works, please check the git repository README: https://github.com/dynatrace-oss/dynatrace-monitoring-as-code
It needs the following configured:
- A Kubernetes secret containing the values
DT_TENANTandDT_API_TOKENis needed. TheDT_API_TOKENshould have the permission to read and write configuration - The monaco-service looks by default for the following secrets:
dynatrace,dynatrace-credentialsanddynatrace-credentials-$PROJECT. If a different secret name can be configured by adding a resourcedynatrace\monaco.conf.yaml. In this file you can specificy in the variabledtCredsthe name of a secret containing the info.
Next, you need to upload a zip archive that contains the projects. The folder structure should be the following:
+-- projects // this folder name needs to be used
| +-- projectName (this can be customized)
| +-- configuration1 (check monaco documentation for the possible options)
| +- json and yaml files (check monaco documentation for the possible options)
| +-- projectN
| +-- json and yaml files
You can add the file to Keptn by using keptn add-resource --project=PROJECTNAME --service=SERVICENAME --stage=STAGENAME --resource=monaco.zip --resourceUri=dynatrace/monaco.zip.
stage and service are optional. The monaco-service will automatically look for this file first on the service level, then on stage level and last on project level.
If not specified, the monaco-service looks for a monaco project with the name of the keptn project. So if your keptn project name is sockshop, then you would need the following structure in the monaco.zip file:
+-- projects
| +-- sockshop
| +-- auto-tag (an example)
| +- json and yaml files
If you want to overwrite that behaviour, it is possible to specify that in the dynatrace\monaco.conf.yaml file by adding them as follows:
projects:
- monaco
- sockshop
- infrastructure
All the projects that you want to process can be added. So for the above, you would need the following structure:
+-- projects
| +-- infrastructure
| +-- synthetic-location
| +- json and yaml files
| +-- monaco
| +-- auto-tag
| +- json and yaml files
| +-- sockshop
| +-- management-zone
| +- json and yaml files
The monaco-service automatically maps the following Keptn information as environment variables:
- Keptn project name as env var
KEPTN_PROJECT - Keptn stage name as env var
KEPTN_STAGE - Keptn service name as env var
KEPTN_SERVICE
They can then be used inside monaco files as follows: {{ Env.KEPTN_PROJECT }}
For an example, please check tagging.json
This is an open source project, so I welcome any contributions to make it even better!
If you don't care about the details, your first entrypoint is eventhandlers.go. Within this file you can add implementation for pre-defined Keptn Cloud events.
To better understand Keptn CloudEvents, please look at the Keptn Spec.
If you want to get more insights, please look into main.go, deploy/service.yaml, consult the Keptn docs as well as existing Keptn Core and Keptn Contrib services.
- Build the binary:
go build -ldflags '-linkmode=external' -v -o monaco-service - Run tests:
go test -race -v ./... - Build the docker image:
docker build . -t keptnsandbox/monaco-service:dev(Note: Ensure that you use the correct DockerHub account/organization) - Run the docker image locally:
docker run --rm -it -p 8080:8080 keptnsandbox/monaco-service:dev - Push the docker image to DockerHub:
docker push keptnsandbox/monaco-service:dev(Note: Ensure that you use the correct DockerHub account/organization) - Deploy the service using
kubectl:kubectl apply -f deploy/ - Delete/undeploy the service using
kubectl:kubectl delete -f deploy/ - Watch the deployment using
kubectl:kubectl -n keptn get deployment monaco-service -o wide - Get logs using
kubectl:kubectl -n keptn logs deployment/monaco-service -f - Watch the deployed pods using
kubectl:kubectl -n keptn get pods -l run=monaco-service - Deploy the service using Skaffold:
skaffold run --default-repo=your-docker-registry --tail(Note: Replaceyour-docker-registrywith your DockerHub username; also make sure to adapt the image name in skaffold.yaml)
We have dummy cloud-events in the form of RFC 2616 requests in the test-events/ directory. These can be easily executed using third party plugins such as the Huachao Mao REST Client in VS Code.
Please find more information in the LICENSE file.