...
This method mounts a volume which that already contains the agent.jar and the agent.properties file directly.
There are several different types of volumes you can choose from to do this. The example below uses an NFS volume since it is not bound to any one type of cloud provider and does not require the ability access a cluster's host storage, as would be the case for hostPath
volumes, but you can use whichever any volume type that fits your needs.
...
With the initContainer
method, you need to introduce the agent properties as well as invoke the coverage agent. For the former, you can use a ConfigMap
with another shared volume to insert an agent.properties file, which can then be referenced, or you can set the desired properties directly as part of the javaagent
argument that invokes the agent. The example below uses the <JDK_JAVA_OPTIONS>
environment variable (for more details, see this page), though you can also use <JAVA_TOOL_OPTIONS>
(for more details, see this page) or direct modification of an invoking Java call, as discussed for the NFS volume-based approach.
...