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 admission controller for APM agent attachment #7386

Closed
axw opened this issue Feb 23, 2022 · 2 comments
Closed

Kubernetes admission controller for APM agent attachment #7386

axw opened this issue Feb 23, 2022 · 2 comments
Assignees
Milestone

Comments

@axw
Copy link
Member

axw commented Feb 23, 2022

We would like to implement a mutating admission webhook that automatically instruments supported runtimes.

This will initially be experimental, potentially building off the POC done by @eyalkoren in https://github.com/eyalkoren/k8s-tracing-webhook

See elastic/apm#385 for more details.

@axw
Copy link
Member Author

axw commented Mar 31, 2022

I've started looking at how we can use Elastic Agent's Kubernetes Leadership Election provider, to avoid having multiple APM Servers (e.g. when running as a Daemonset or a Service) double up on modifying pods.

The basic build blocks are there in Elastic Agent, but not yet in Fleet. I think a more expedient approach would be to make the webhook idempotent, e.g. check for the existence of environment variables that we would add (JAVA_TOOL_OPTIONS, NODE_OPTIONS, ...) before adding them, or add our own annotation and check for that.

Moreover, https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#reinvocation-policy states:

Mutating webhooks must be idempotent, able to successfully process an object they have already admitted and potentially modified. This is true for all mutating admission webhooks, since any change they can make in an object could already exist in the user-provided object, but it is essential for webhooks that opt into reinvocation.

So we should make it idempotent anyway.

Long term we should still figure out how we can use Elastic Agent providers with Fleet, e.g. for #7161. Also, even if it's safe to have every APM Server register the same webhook, it's probably not desirable as it will add overhead to Kubernetes performance.

@simitt simitt added the blocked label Jun 1, 2022
@axw
Copy link
Member Author

axw commented Jun 16, 2022

See https://github.com/elastic/apm-mutating-webhook (technical preview)

@axw axw closed this as completed Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants