Not a customer? Click the 'Start a free trial' link to begin a 30-day SaaS trial of our product and to join our community.
Existing Cisco AppDynamics customers should click the 'Sign In' button to authenticate to access the community
on 10-04-2024 02:36 PM - edited on 10-07-2024 11:04 AM by Ryan.Paredez
Currently, InfraViz doesn't let you deploy Custom extensions. If you wish to deploy custom extensions on Kubernetes using machine agents then this article is for you.
Now if you wish to use this method, which is modifying the Machine Agent image you need to take a step back and ask yourself:
In any case, the Dockerfile will look like below:
FROM ubuntu:latest
# Install curl and unzip
RUN apt-get update && apt-get install -y curl unzip procps
# Add and unzip the Machine Agent bundle
ADD machineagent-bundle-64bit-linux-23.7.0.3689.zip /tmp/machineagent.zip
RUN unzip /tmp/machineagent.zip -d /opt/appdynamics && rm /tmp/machineagent.zip
# Set environment variable for Machine Agent home
ENV MACHINE_AGENT_HOME /opt/appdynamics
# Add AWS API Gateway Monitor and start-appdynamics script
ADD create-open-file-extension-folder /opt/appdynamics/monitors
ADD start-appdynamics ${MACHINE_AGENT_HOME}
# Make start-appdynamics script executable
RUN chmod 744 ${MACHINE_AGENT_HOME}/start-appdynamics
# Set Java Home environment variable
ENV JAVA_HOME /opt/appdynamics/jre/bin/java
# Run AppDynamics Machine Agent
CMD ["/opt/appdynamics/start-appdynamics"]
NOTE: In the same directory as Dockerfile
MA_PROPERTIES="-Dappdynamics.controller.hostName=xxx.saas.appdynamics.com"
MA_PROPERTIES+=" -Dappdynamics.controller.port=443"
MA_PROPERTIES+=" -Dappdynamics.agent.accountName=xxxx"
MA_PROPERTIES+=" -Dappdynamics.agent.accountAccessKey=xx"
MA_PROPERTIES+=" -Dappdynamics.controller.ssl.enabled=true"
MA_PROPERTIES+=" -Dappdynamics.sim.enabled=true"
MA_PROPERTIES+=" -Dappdynamics.docker.enabled=false"
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
Great. Now all you need to do is build the Image and push it to your repository. Once done, in the InfraViz section, Update the Image section of InfraViz with this new Image
Now the second option is using deployment and InfraViz together.
I have created a infraviz-deployment.yaml file. This is a deployment that I am deploying on a specific node.
apiVersion: apps/v1
kind: Deployment
metadata:
name: machine-agent-extension
labels:
app: machine-agent-extension
spec:
replicas: 1
selector:
matchLabels:
app: machine-agent-extension
template:
metadata:
labels:
app: machine-agent-extension
spec:
initContainers:
- name: create-open-file-extension-folder
image: busybox
command: ['sh', '-c', 'mkdir -p /opt/appdynamics/monitors/open-file-extension && cp /tmp/config/* /opt/appdynamics/monitors/open-file-extension && chmod +x /opt/appdynamics/monitors/open-file-extension/script.sh']
volumeMounts:
- name: config-volume
mountPath: /tmp/config # Mount ConfigMap here temporarily
- name: open-file-extension
mountPath: /opt/appdynamics/monitors/open-file-extension # Target directory in emptyDir
containers:
- name: machine-agent-extension
image: appdynamics/machine-agent:latest
ports:
- containerPort: 9090
env:
- name: APPDYNAMICS_CONTROLLER_HOST_NAME
value: "xxxx.saas.appdynamics.com"
- name: APPDYNAMICS_CONTROLLER_PORT
value: "443"
- name: APPDYNAMICS_AGENT_ACCOUNT_NAME
value: "xxx"
- name: APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY
value: "xxx"
- name: APPDYNAMICS_SIM_ENABLED
value: "true"
- name: APPDYNAMICS_CONTROLLER_SSL_ENABLED
value: "true"
volumeMounts:
- name: open-file-extension
mountPath: /opt/appdynamics/monitors/open-file-extension
volumes:
- name: config-volume
configMap:
name: open-file-extension-config # ConfigMap holding script.sh and monitor.xml
- name: open-file-extension
emptyDir: {} # EmptyDir to allow read/write
nodeSelector:
kubernetes.io/hostname: "ip-222-222-222-222.us-west-2.compute.internal"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: open-file-extension-config
namespace: default
data:
script.sh: |
#!/bin/bash
# Get the current open files limit for the process
open_files_limit=$(ulimit -n)
##Commentlineforcheck
# Output the open files limit to stdout
echo "name=Custom Metrics|OpenFilesLimitMonitor|OpenFilesLimit,value=$open_files_limit"
monitor.xml: |
<monitor>
<name>OpenFile</name>
<type>managed</type>
<enabled>true</enabled>
<enable-override os-type="linux">true</enable-override>
<description>OpenFile</description>
<monitor-configuration></monitor-configuration>
<monitor-run-task>
<execution-style>periodic</execution-style>
<name>Run</name>
<type>executable</type>
<task-arguments></task-arguments>
<executable-task>
<type>file</type>
<file>script.sh</file>
</executable-task>
</monitor-run-task>
</monitor>
Right now I am only monitoring one node though, so we will use InfraViz to monitor other nodes now.
Please reach out to Support if you have any questions.
Thank you! Your submission has been received!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form