项目作者: celonis

项目描述 :
Configuring Datadog APM using kustomize
高级语言:
项目地址: git://github.com/celonis/kustomize-datadog-apm-example.git
创建时间: 2020-08-06T16:31:01Z
项目社区:https://github.com/celonis/kustomize-datadog-apm-example

开源协议:

下载


Demo: Datadog APM configuration using kustomize

This repository contains sample code for using kustomize to configure Datadog APM. This was presented as Quick Bite at Dash 2020.

First, define a place to work:

  1. DEMO_HOME=$(mktemp -d)

Create a kustomize base containing a simple deployment:

  1. BASE=$DEMO_HOME
  2. mkdir -p $BASE
  3. cat <<EOF >$BASE/kustomization.yaml
  4. apiVersion: kustomize.config.k8s.io/v1beta1
  5. kind: Kustomization
  6. resources:
  7. - deployment.yaml
  8. EOF
  9. cat <<EOF >$BASE/deployment.yaml
  10. apiVersion: apps/v1
  11. kind: Deployment
  12. metadata:
  13. name: foo
  14. labels:
  15. app: foo
  16. spec:
  17. replicas: 1
  18. template:
  19. metadata:
  20. name: foo
  21. labels:
  22. app: foo
  23. spec:
  24. containers:
  25. - name: foo
  26. image: my-java-app
  27. env: []
  28. envFrom: []
  29. selector:
  30. matchLabels:
  31. app: foo
  32. EOF

If you now run kustomize build $DEMO_HOME you will see the deployment manifest rendered without any changes.

Now, “import” the remote transformers for applying the configuration changes:

  1. cat <<EOF >>$BASE/kustomization.yaml
  2. transformers:
  3. - github.com:celonis/kustomize-datadog-apm-example

If you run kustomize build $DEMO_HOME again, you will see the following changes have been applied to the deployment manifest:

  • An init container is added to your deployment, which uses curl to download the Datadog Java APM agent into an emptyDir volume shared between the init and application container
  • All environment variables from a config map named datadog-apm-env are mounted into the app container (this is not really required, but useful for adding some environment specific configuration)
  • The JDK_JAVA_OPTIONS environment variable is set in order to attach the APM agent at runtime
  • The DD_AGENT_HOST environment variable points to the host IP using the downward API
  • The DD_SERVICE_NAME contains the value of deployment’s app label

Advanced Usage

Here are some advanced patterns which are useful when productionizing this approach for your team.

Versioning

When importing the remote transformers, you can also target a specific revisions. For example, check out branch release-1.1 which adds some configuration for logs injection and service name mapping:

  1. transformers:
  2. - github.com:celonis/kustomize-datadog-apm-example?ref=release-1.1

Or, if you want to make sure you don’t run into any breaking changes in the configuration, stick to the initial v1.0.0 release:

  1. transformers:
  2. - github.com:celonis/kustomize-datadog-apm-example?ref=v1.0.0

Questions?

If anything is unclear and you need some help, feel free to create an issue.