Init コンテナを使用したアプリケーションのインストゥルメント化

このページでは、展開時に init コンテナオプションを使用してエージェントファイルを Kubernetes® アプリケーションコンテナにコピーする方法について説明します。®

注: クラスタエージェントがクラスタにインストールされている場合、Splunk AppDynamics ではクラスタエージェントの自動インストルメンテーションが推奨されます。「クラスタエージェントを使用したアプリケーションの自動インストルメンテーション」を参照してください。

init コンテナオプションは、アプリケーションの初期化に役立つ追加のコンテナを起動時に実行するために使用され、Kubernetes 環境で使用できます。init コンテナは初期化タスクを完了すると終了しますが、アプリケーションコンテナは実行されたままになります。アプリケーション サーバ エージェントのインストールでは、init コンテナは、展開時にエージェントファイルをアプリケーションコンテナにコピーする配信メカニズムとして使用されます。「Kubernetes の Init コンテナオプション」を参照してください。

(構築時ではなく)展開時にエージェントファイルをコピーすることには、エージェントファイルと依存関係をアプリケーションイメージに明示的にコピーするよりも優れている点があります。init コンテナオプションを使用すると、次の理由でイメージの構築プロセスが簡素化されます。

  • エージェントファイルをコピーするために各アプリケーションの Dockerfile を更新する必要がありません。
  • アプリケーションのアップグレードのためにアプリケーションイメージを再構築する必要はありません。

init コンテナの使用方法については、次の言語固有のコンテナインストールページを参照してください。

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

Dockerfile Example

In this example for a Java application, the Java Agent files in the AppServerAgent folder are copied to the application image and the application JAR file. The agent environment variables are set before the start script runs.

FROM openjdk:8-jre-slim

COPY myapp.jar /app
COPY AppServerAgent/ /opt/appdynamics

ENV APPDYNAMICS_AGENT_APPLICATION_NAME=<value>
ENV APPDYNAMICS_AGENT_TIER_NAME=<value>
ENV APPDYNAMICS_AGENT_ACCOUNT_NAME=<value>
ENV APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY=<value>
ENV APPDYNAMICS_CONTROLLER_HOST_NAME=<value>
ENV APPDYNAMICS_CONTROLLER_PORT=<value>
ENV APPDYNAMICS_CONTROLLER_SSL_ENABLED=<value>
ENV APPDYNAMICS_JAVA_AGENT_REUSE_NODE_NAME=true
ENV APPDYNAMICS_JAVA_AGENT_REUSE_NODE_NAME_PREFIX=<value>

COPY ./startup.sh /startup.sh
RUN chmod +x /startup.sh
ENTRYPOINT ["/bin/bash", "/startup.sh"]
注: Kubernetes® is a trademark of The Linux Foundation®.