-
Notifications
You must be signed in to change notification settings - Fork 460
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
Java Instrumentation with runAsNonRoot #1058
Comments
@Yamakaky thanks for reporting the issue.
I am not sure if I understand. The auto-instrumentation uses init-container to copy the auto-instrumentation binaries into the app container. the |
Hum, I'm not completely sure how securityContext works with sidecars. I think the issue is that the init container doesn't define a user id to run as, so the pod configuration Here is how |
Actually the security context is defined in pod level but as well on container level
The container level overrides the pod level. Could you please share your pod spec where the instrumentation was injected? |
https://gist.github.com/Yamakaky/43580abf273d2214feaa17d6a4d21057 I removed some unrelated parts like like resource limits. Note that the docker image is defined with a fixed user id, otherwise I would have to configure |
The security context is defined on the pod level https://gist.github.com/Yamakaky/43580abf273d2214feaa17d6a4d21057#file-deployment-yml-L67 therefore I would say all containers would inherit from it. |
Yes, but the init container will still try to run as root since a userid is not defined. |
@Yamakaky , anyways to run opentelemetry auto instrumentor init container as nonroot user ? as since we want the main container to run with nonroot user. |
I also need a configuration for the security context of the init-container (kind: instrumentation) because I want to add labels to the namespace to fullfil the restricted mode of the PSA (https://kubernetes.io/docs/concepts/security/pod-security-admission/). For this I need to add at least this:
It is already possible for the OpenTelemetryCollector:
|
I also need to set the securityContext on the init container. Did you ever figure this out? |
I added
instrumentation.opentelemetry.io/inject-java: "my-instrumentation"
to a pod withrunAsNonRoot
enabled. I get this error:Error: container has runAsNonRoot and image will run as root (pod: "mypod-58f5d96bbc-tq77x_ns(2eb77116-d336-41ec-a064-eea6b6be10c0)", container: opentelemetry-auto-instrumentation)
. RemovingrunAsNonRoot
fixes the issue, but that's not a proper fix. I guess the injected container should copy thesecurityContext
from the main parent?The text was updated successfully, but these errors were encountered: