Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes attachment #2622

Closed
2 tasks done
felixbarny opened this issue Mar 24, 2022 · 9 comments
Closed
2 tasks done

Kubernetes attachment #2622

felixbarny opened this issue Mar 24, 2022 · 9 comments
Assignees
Labels
agent-nodejs Make available for APM Agents project planning.
Milestone

Comments

@felixbarny
Copy link
Member

felixbarny commented Mar 24, 2022

@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Mar 24, 2022
@trentm
Copy link
Member

trentm commented Mar 24, 2022

I think we should consider starting a package-lock.json file for the Node.js APM agent for this and for the AWS Lambda layers that we are publishing for releases now, so that we have repeatable builds. Fits in with SLSA as well.

(Or we could go deeper and consider using a npm-shrinkwrap.json that would get published so that those using elastic-apm-node as a library would also get locked-down/stable transitive dep versions ... even though the npm docs discourage that. https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json#package-lockjson-vs-npm-shrinkwrapjson)

@trentm trentm added this to the 8.3 milestone Mar 28, 2022
@trentm trentm assigned trentm and astorm and unassigned trentm May 9, 2022
@astorm
Copy link
Contributor

astorm commented May 9, 2022

Spent a bit of last week learning enough to define some concrete deliverable for this. Specifically --

  • We need to build a docker container that contains all the source files needed for the Node Agent agent, similar to what we do when building the lambda layer. The end deliverable here is a Dockerfile that can build a an image with the source files located in a /usr/agent/node_modules folder on the container

  • Once we have the ability to build this Docker container, we need to automatically build and publish it whenever a new version of the agent is built. This build and publish should include a latest tag

  • Finally, we need to extend the mutating web hook such that

    • The default configuration includes a section that ensures the above published docker container is mounted when a user has the mutating webhook deployed into their system
    • The command that copies the agent from the above container to the shared mounted volume can copy a folder (right now it's setup to copy a single file only -- hopefully as simple as adding a -r option)
    • User containers have a NODE_OPTIONS=-r elastic-apm-agent/start env. var set to that ensure the agent is started automatically
    • If necessary -- user containers have a NODE_PATH env var set that points to the mounted volume path such that the copied agent is available for requiring from user code.

@AlexanderWert
Copy link
Member

Note: This can also be reused to support Elastic APM with container-based AWS Lambda functions.

@trentm
Copy link
Member

trentm commented May 24, 2022

For comparison, my (very naive) read of the "OTel Operator" is that it sets (or appends to) NODE_OPTIONS=" --require /otel-auto-instrumentation/autoinstrumentation.js"
https://github.com/open-telemetry/opentelemetry-operator/blob/main/pkg/instrumentation/nodejs.go#L24-L27

@astorm
Copy link
Contributor

astorm commented May 26, 2022

Request made to productivity team for a published Dockerfile: https://github.com/elastic/observability-robots/issues/1229

I'm proceeding to making the adjustments to the mutating webhook to enable attachment.

@trentm
Copy link
Member

trentm commented May 31, 2022

see #2742

@estolfo estolfo modified the milestones: 8.3, 8.4 Jun 1, 2022
trentm pushed a commit that referenced this issue Jun 1, 2022
This will build and publish a Docker image of the APM agent as
part of the release process
    docker.elastic.co/observability/apm-agent-nodejs:VERSION
    docker.elastic.co/observability/apm-agent-nodejs:latest (if this is the latest version)

This image can be used for k8s attachment and Docker container-based
lambda functions.

Refs: #2622
Refs: elastic/apm-aws-lambda#107
@astorm
Copy link
Contributor

astorm commented Jun 8, 2022

Completed the minor changes needed to the mutating webhook, see elastic/apm-k8s-attacher#31. @trentm per last week's planning I decided to go absolute NODE_OPTIONS path and left out NODE_PATH for now.

@astorm
Copy link
Contributor

astorm commented Jun 8, 2022

Final task to finish this will be fore the Node.js Docker image to be listed as a public docker image. Right now it appears to require some sort of elastic auth to fetch. See: https://github.com/elastic/sre/issues/194

@trentm
Copy link
Member

trentm commented Jun 21, 2022

@astorm This can be closed now, right?

@astorm astorm closed this as completed Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning.
Projects
None yet
Development

No branches or pull requests

5 participants