Giter Club home page Giter Club logo

Comments (3)

andrewazores avatar andrewazores commented on June 26, 2024

As seen done by another project recently, the Agent JAR could be built into a simple JAR-carrier container image, ex:

FROM scratch
COPY ./target/cryostat-agent.jar /cryostat/

This would be an easy way for application images to consume the Agent JAR - rather than manually downloading the JAR to the build machine and copying it into the container build, they could use a multi-stage container build like:

FROM cryostat/agent-carrier:latest as cryostat-agent
RUN echo '' # no-op, can this be removed?

FROM base-image
COPY --from=cryostat-agent /cryostat/cryostat-agent.jar /app/deployment/lib
... copy application artifacts in

Alternatively, this JAR-carrier image can be used as an init container in the application's Deployment to achieve the same result dynamically, if there is a volume shared between the init container and the application container:

        initContainers:
        - name: download-agent
          image: agent-carrier:latest
          imagePullPolicy: Always
          command: [ 'cp', '/cryostat/cryostat-agent.jar','/etc/agent/ ]
          volumeMounts: # this must also be defined on the container that runs the host JVM which the Agent should attach to, so that the JAR is available on its filesystem as well
            - name: shared
              mountPath: /etc/agent/

from cryostat-agent.

andrewazores avatar andrewazores commented on June 26, 2024

https://github.com/open-telemetry/opentelemetry-operator/blob/16e11344ae27db6f2bfb0a8953d908827c7b9019/pkg/instrumentation/javaagent.go#L28

This is a good reference for the same/similar technique, which also includes the technique of modifying the target container's JAVA_TOOL_OPTIONS environment variable to include -javaagent to launch the agent via static attach. This would necessitate a target container restart for agent instrumentation to begin.

Discussion on dynamic attach mechanisms over here: cryostatio/cryostat-operator#784

from cryostat-agent.

andrewazores avatar andrewazores commented on June 26, 2024

Since the init container needs at least cp in order to copy the carried JAR into the shared volume, FROM scratch alone won't be quite enough. It could be a FROM scratch that also has a standalone cp binary copied into it, or else a very minimal base image with some coreutils in it instead:

FROM docker.io/library/busybox:latest
COPY ./target/cryostat-agent.jar /cryostat/

from cryostat-agent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.