DRAFT SPACE - APPDYNAMICS INTERNAL ONLY

On this page:

 

Your Rating:
Results:
PatheticBadOKGoodOutstanding!
50 rates

The following example shows how to build and run the Standalone Machine Agent in a Kubernetes environment to monitor the performance of your containerized applications.  You might want to modify this example to suit your requirements.  

  1. Update the Controller to 4.4.3 or higher if you have not already done so.
  2. Set up an App Server Agent in each pod on the node where you plan to install the Machine Agent.
  3. Create a clean directory with the following files:
    1. Dockerfile: Contains the instructions to build the Docker image of Machine Agent.
    2. machine-agent.zip:  Download the Standalone Machine Agent Bundle version 4.4.3 or higher from https://download.appdynamics.com/.  For this example, use the 64-bit Linux ZIP version of the installer. Rename the ZIP file to machine-agent.zip and extract the files.
    3. start-appdynamics.sh: Contains the instructions to start the Machine Agent in the container.

  4. Log in to the host where your Kubernetes master node is running.
  5. Build the Docker image for the Machine Agent and tag it:

    Build docker image
    docker build . --tag k8s-ma

    For more information and details on how to configure and run the Standalone Machine Agent using Docker, see Configuring Docker Visibility.

  6. Make this image available across your nodes.
  7. Prepare the YAML file to create the Daemonset to deploy the Standalone Machine Agent. Ensure that you include the following:
    • Controller Properties. See Connecting to the Controller.
    • Cluster Role and Cluster Role Binding to provide the Machine Agent with necessary permissions on the Kubernetes API Server.
    • Volume mounts to enable the Machine Agent running inside the container to monitor host metrics and containers.

    Machine agent does not report Memory Soft limit (also known as memory reservation value) for app agent containers in Kubernetes environment and it is displayed as 0 in the UI.

  8. Deploy Machine Agent across your nodes by running the following:

    kubectl create -f <name of the daemonset> 
  9. Register each container ID as the unique host ID if multiple containers are running in the pod. For more information, see Register Container ID as the Host ID

Connecting to the Controller

Specify the following properties in the DaemonSet, which enable the Machine Agent to connect to the Controller:

  • APPDYNAMICS_CONTROLLER_HOST_NAME: The hostname or the IP address of the AppDynamics Controller. This is the same host that you use to access the AppDynamics browser-based user interface.
  • APPDYNAMICS_CONTROLLER_PORT: The HTTP(S) port of the AppDynamics Controller. This is the same port that you use to access the AppDynamics browser-based user interface. AppDynamics SaaS Controller users should always set this property to 443.
  • APPDYNAMICS_CONTROLLER_SSL_ENABLED: Specifies whether the agent should use SSL (HTTPS) to connect to the Controller. If SSL is enabled, set the Controller Port property to the HTTPS port of the Controller. AppDynamics SaaS Controller users should always set this property to 443.
  • APPDYNAMICS_AGENT_ACCOUNT_NAME: The account name used to authenticate with the Controller. If you are using the AppDynamics SaaS Controller, the account name is provided in the Welcome email sent by AppDynamics.
  • APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY: The account access key used to authenticate with the Controller. This key is generated at installation time and can be found by viewing the license information in the Controller Settings.
  • APPDYNAMICS_SIM_ENABLED: Enable Server Visibility on the Standalone Machine Agent.
  • APPDYNAMICS_DOCKER_ENABLED: Enable Docker Visibility on the Machine Agent.

Sample Docker File 

Here is an example Docker file to build an image of Machine Agent:

# Sample Dockerfile for the AppDynamics Standalone Machine Agent
# This is provided for illustration purposes only


FROM ubuntu:14.04

# Install required packages

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y unzip && \
    apt-get clean

# Install AppDynamics Machine Agent
ENV MACHINE_AGENT_HOME /opt/appdynamics/machine-agent
ADD machine-agent.zip /tmp/ 
RUN mkdir -p ${MACHINE_AGENT_HOME} && \
    unzip -oq /tmp/machine-agent.zip -d ${MACHINE_AGENT_HOME} && \
    rm /tmp/machine-agent.zip

# Include start script to configure and start MA at runtime
ADD start-appdynamics.sh ${MACHINE_AGENT_HOME}
RUN chmod 744 ${MACHINE_AGENT_HOME}/start-appdynamics.sh

# Configure and Run AppDynamics Machine Agent
CMD "${MACHINE_AGENT_HOME}/start-appdynamics.sh"


Sample start-appdynamics

#!bin/bash

# Sample Docker start script for the AppDynamics Standalone Machine Agent
# This is provided for illustration purposes only
 
# Enable using container ID as host ID when the pod has more than one containers
# MA_PROPERTIES+=" -Dappdynamics.docker.container.containerIdAsHostId.enabled=true"
# Start Machine Agent
${MACHINE_AGENT_HOME}/jre/bin/java ${MA_PROPERTIES} -jar ${MACHINE_AGENT_HOME}/machineagent.jar


Sample Daemonset

Here is an example YAML file to run Machine Agent as Daemonset across your Kubernetes nodes:

---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: sim-k8s-agent
  namespace: default
spec:
  template:
    metadata:
      labels:
        name: appdynamics
    spec:
      containers:
      - env:
        - name: APPDYNAMICS_CONTROLLER_HOST_NAME
          value: "<controller-host-name>"
        - name: APPDYNAMICS_CONTROLLER_PORT
          value: "<controller-port>"
        - name: APPDYNAMICS_CONTROLLER_SSL_ENABLED
          value: "<true/false>"
        - name: APPDYNAMICS_AGENT_ACCOUNT_NAME
          value: "<account-name>"
        - name: APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY
          value: "<access-key>"
        - name: APPDYNAMICS_SIM_ENABLED
          value: "true"
        - name: APPDYNAMICS_DOCKER_ENABLED
          value: "true"
        image: <machine-agent-image>
        name: sim-k8s-agent
        volumeMounts:
        - mountPath: /hostroot
          name: hostroot
          readOnly: true
        - mountPath: /var/run/docker.sock
          name: docker-sock
      volumes:
      - name: hostroot
        hostPath:
          path: /
          type: Directory
      - name: docker-sock
        hostPath:
          path: /var/run/docker.sock
          type: Socket
      restartPolicy: Always
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: cluster-read-all
rules:
  -
    apiGroups:
      - ""
      - apps
      - autoscaling
      - batch
      - extensions
      - policy
      - rbac.authorization.k8s.io
    resources:
    # everything except secrets
      - componentstatuses
      - configmaps
      - daemonsets
      - deployments
      - events
      - endpoints
      - horizontalpodautoscalers
      - ingress
      - jobs
      - limitranges
      - namespaces
      - nodes
      - pods
      - persistentvolumes
      - persistentvolumeclaims
      - resourcequotas
      - replicasets
      - replicationcontrollers
      - serviceaccounts
      - services
    verbs:
      - get
      - watch
      - list
  - nonResourceURLs: ["*"]
    verbs:
      - get
      - watch
      - list 
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: k8s-agent-readall-role-binding
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-read-all
---
  • No labels