This page describes how to use the init containers option to copy agent files into a Kubernetes application container at deploy time.

When the Cluster Agent is installed in a cluster, AppDynamics recommends Cluster Agent auto-instrumentation. See Auto-Instrument Applications with the Cluster Agent.

The init containers option is available in Kubernetes environments used to run additional containers at startup that helps initialize an application. Once the init containers have completed their initialization tasks, they terminate but leave the application container(s) running. For the App Server Agent installation, init containers are used as delivery mechanism to copy the agent files into the application container at deploy time. See Init Containers Option in Kubernetes.

Copying the agent files at deploy time (instead of at build time) provides advantages over explicitly copying the agent files and dependencies into the application image. The init containers option simplifies the image build process because:

  • You do not need to update each application's Dockerfile to copy the agent files.
  • You do not need to rebuild the application image for agent upgrades. 

See the language-specific container installation page for how to use an init container:

Kubernetes Init Container Deployment Spec Example

In the Kubernetes deployment spec example for a Java application, the init container is a second Docker image that contains the App Server Agent files. Because this Docker image is built separately from the application image, you do not need to rebuild the application image when you add or upgrade the App Server Agent.

kind: Deployment
spec: 
  containers: 
    - 
      image: "repo/java-app:v1"
      name: java-app
      volumeMounts: 
        - 
          mountPath: /opt/appdynamics
          name: appd-agent-repo
  initContainers: 
    - 
      command: 
        - cp
        - "-ra"
        - /opt/appdynamics/.
        - /opt/temp
      image: "docker.io/appdynamics/java-agent:20.6.0"
      n ame: appd-agent
      volumeMounts: 
        - 
          mountPath: /opt/temp
          name: appd-agent-repo
  volumes: 
    - 
      emptyDir: {}
      name: appd-agent-repo

YML