Use Docker Visibility with Red Hat OpenShift
This page describes how to set up the Machine Agent with Docker Visibility enabled to run as a DaemonSet on an OpenShift cluster.
Docker Visibility supports OpenShift Version 3. With the Machine Agent, you can collect performance data from OpenShift clusters. By installing the agent as a DaemonSet on each host in the OpenShift cluster, the DaemonSet monitors each host on the OpenShift cluster and the corresponding containers that have an Splunk AppDynamics App Agent running. This process is similar to that of monitoring the Kubernetes cluster.
Using Docker Visibility to monitor OpenShift containers is no longer the preferred option and will eventually be deprecated. Use the Cluster Agent instead as described in Monitor Kubernetes with the Cluster Agent. The Cluster Agent supports OpenShift container visibility, as well as visibility into cluster health and capacity.
Before You Begin
- You must have an OpenShift user account with a cluster-admin role, such as system:admin.
- Install the OpenShift command line tool (oc)
-
We recommend that you use Docker CE/EE v17.03 or Docker Engine >= v1.13 with this product. Some data may be unavailable if you are using previous versions of Docker.
Set the Java Options
By default, the MaxMetaspaceSize is set to 100 MB in OpenShift. If your application operates within a small margin of its existing memory resource allocation, increase the allocation for the application. We recommend allocating additional Metaspace Size space to accommodate the machine agent. Directly configure the environment variable GC_MAX_METASPACE_SIZE to set the MaxMetaspaceSize parameter in the deployment through a config map.
Register the Container ID as the Host ID
Install an App Server Agent in each container in a Kubernetes pod to collect application metrics. If multiple App Server agents are running in the same pod (for example, in the RedHat OpenShift platform), you must register the container ID as the unique host ID on both the App Server Agent and the Machine Agent to collect container-specific metrics from the pod. Kubernetes pods can contain multiple containers and they share the same host ID. The Machine Agent cannot identify different containers running in a pod unless each container ID is registered as the host ID.
To register the container ID as the host ID:
プロジェクトおよびサービスアカウントの作成
OpenShift の用語では、プロジェクトはユーザとそのリソースのグループを分離するメカニズムです。管理者は、プロジェクトの作成や特定のプロジェクトの管理に関する権限を持つ個々のユーザまたはグループを指定できます。
マシンエージェントを他のプロジェクトから分離するために、マシン エージェント プロジェクトを作成します。
oc new-project machine-agent
マシンエージェントがメトリックを取得するために必要な権限を持つサービスアカウント を作成するには、次の手順を実行します。
マシンエージェントの保護
セキュリティを強化してマシンエージェントを展開できます。プロジェクトのセキュリティレベルを決定し、セキュリティ権限を活用してマシンエージェントを保護します。
cluster-reader ロールを持たないマシンエージェントの実行
cluster-reader ロールを持たない場合、マシンエージェントは OpenShift クラスタからポッドや ReplicaSet などの情報を読み取ることができません。ただし、エージェントはアプリケーション サーバ エージェント コンテナのタグを除き、他のメトリックを収集することもできます。
特権コンテナモードを使用しないマシンエージェントの実行
この権限を無効にするには、次のセクションを DaemonSet YAML ファイルから削除します。
securityContext:
privileged: true
特権コンテナモードでないと、マシンエージェントは や などのファイルを読み取ることができません。そのため、プロセスやネットワークなどのメトリックを収集できません。
この権限を無効にしても、アプリケーション サーバ エージェントのコンテナメトリックの収集には影響しません。
サービスアカウントのセキュリティ権限
サービスアカウントには、マシンエージェントが実行されているプロジェクトで最大の分離を提供するために、次のセキュリティ権限が必要です。
| 権限 | 説明 |
|---|---|
| cluster-reader ロール |
この cluster-reader ロールを使用すると、マシンエージェントは OpenShift クラスタからタグを読み取ることができます。 例:
|
| 特権 SCC |
特権 SCC を使用すると、マシンエージェントをルートユーザとして実行できます。 例:
|
| 特権コンテナとして実行 |
特権コンテナとして実行すると、マシンエージェントは からのファイルの読み取りや、 からのプロセス情報の読み取りができます。 この権限は、次のように DaemonSet YAML ファイルで設定されます。
|
Create a Docker Image of the Machine Agent
Copy the following files to a directory on a machine that can build the Docker image.
-
Machine Agent Bundle - 64-bit Linux (zip).
Download this bundleand rename it to
machine-agent.zip. -
Dockerfile
See the sample Docker file below.
-
start-appdynamics script
See thesample script below.
Build the image with your desired method and make it available in your image registry.
Deploy the Machine Agent as DaemonSet
- Modify the sample DaemonSet to point to your Controller:
- Create DaemonSet below:
Verify Machine Agent Status
If the Machine Agent does not appear in the UI, check the status as follows:
Sample Machine Agent Deployment Files
Below are sample DaemonSet, Dockerfile and Start Script that you can use as a reference for deploying the Machine Agent.
SampleDaemonSet
Modify the sample DaemonSet to suit your deployment scenario.
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: machine-agent-daemonset
namespace: machine-agent
spec:
selector:
matchLabels:
name: appdynamics-machine-agent
template:
metadata:
labels:
name: appdynamics-machine-agent
spec:
nodeSelector:
node-role.kubernetes.io/compute: "true"
containers:
- env:
- name: APPDYNAMICS_CONTROLLER_HOST_NAME
value: "<your-hostname>"
- name: APPDYNAMICS_CONTROLLER_PORT
value: "<your-port>"
- name: APPDYNAMICS_CONTROLLER_SSL_ENABLED
value: "true"
- name: APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY
value: "<your-access-key>"
- name: APPDYNAMICS_AGENT_ACCOUNT_NAME
value: "<your-account>"
- name: APPDYNAMICS_SIM_ENABLED
value: "true"
- name: APPDYNAMICS_DOCKER_ENABLED
value: "true"
image: <your-image>
name: machine-agent
securityContext:
privileged: true
volumeMounts:
- mountPath: /hostroot
name: hostroot
readOnly: true
- mountPath: /var/run/docker.sock
name: docker-sock
restartPolicy: Always
imagePullPolicy: Always
serviceAccount: ma
serviceAccountName: ma
volumes:
- name: hostroot
hostPath:
path: /
- name: docker-sock
hostPath:
path: /var/run/docker.sock
Sample Dockerfile
You can use this Dockerfile sample or the one in OpenShift Visibility Manifests.
# Sample Dockerfile for the Machine Agent
# This is provided for illustration purposes only
FROM ubuntu:16.04
# Install required packages
RUN apt-get update && \
apt-get install -y unzip && \
apt-get clean
# Install Machine Agent
ENV MACHINE_AGENT_HOME /opt/appdynamics/machine-agent/
ADD machine-agent.zip /tmp/machine-agent.zip
RUN mkdir -p ${MACHINE_AGENT_HOME}
# Include start script to configure and start MA at runtime
ADD start-appdynamics ${MACHINE_AGENT_HOME}
RUN chmod 774 ${MACHINE_AGENT_HOME}/start-appdynamics
# change files and directories to be owned by root so MA container user in root
group can access
RUN chgrp -R 0 /opt && \
chmod -R g=u /opt
RUN chgrp -R 0 /tmp/machine-agent.zip && \
chmod g=u /tmp/machine-agent.zip
# Changing directory to MACHINE AGENT HOME
WORKDIR ${MACHINE_AGENT_HOME}
# Configure and Run Machine Agent
CMD "./start-appdynamics"
Sample start Script
#!/bin/bash
unzip -oq /tmp/machine-agent.zip -d ${MACHINE_AGENT_HOME} && \
rm /tmp/machine-agent.zip
# Start Machine Agent
./bin/machine-agent -j jre/