elastic / apm-k8s-attacher

Elastic APM Attacher for Kubernetes
https://www.elastic.co/guide/en/apm/attacher/current/apm-attacher.html
Apache License 2.0
7 stars 12 forks source link

set ELASTIC_APM_ACTIVATION_METHOD in code rather than values.yaml so it works for custom `webhookConfig.agents.*` names #91

Closed trentm closed 10 months ago

trentm commented 10 months ago

Currently ELASTIC_APM_ACTIVATION_METHOD is set in webhookConfig.agents.{name} in the chart's values.yaml. E.g.:

webhookConfig:
  agents:
    java:
      image: docker.elastic.co/observability/apm-agent-java:latest
      artifact: "/usr/agent/elastic-apm-agent.jar"
      environment:
        JAVA_TOOL_OPTIONS: "-javaagent:/elastic/apm/agent/elastic-apm-agent.jar"
        ELASTIC_APM_ACTIVATION_METHOD: "K8S_ATTACH"

An issue with setting the envvar this was is that a custom webhookConfig.agents. name requires one to repeat that envvar. As noted at https://www.elastic.co/guide/en/apm/attacher/current/apm-webhook-add-pod-annotation.html

The only webhookConfig.agents values defined in values.yaml are java and nodejs. When using other values, you must explicitly specify image, artifact, and *OPTIONS values.

Instead, it would be more helpful to set that envvar always in the webhook code, then the config becomes simpler.

One requirement of doing this is that we need to use a common value for all APM agents. We decided to use the value currently being used by the Java agent: K8S_ATTACH. That means that new versions of the Node.js and .NET agents will be needed that support ELASTIC_APM_ACTIVATION_METHOD=K8S_ATTACH. I plan to change the Node.js APM agent to support both values so that the newer APM agent will work with current and newer versions of the Helm chart.

trentm commented 10 months ago

/cc @elastic/apm-agent-node-js @elastic/apm-agent-net