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.
This can be done in 2 ways: ...
See more...
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.
This can be done in 2 ways:
Creating a new Machine Agent Image
Creating a new yaml file for Machine Agent
Creating a new Machine Agent Image
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:
Do you need the extension on all nodes? If not, then if you deploy InfraViz in default by just updating the Image with extension then on the node where it works, everything will be fine but on others, you will have logs filled with ERROR/WARN messages which can potentially lead to Machine agent collector script timing out.
Do you need a Machine Agent on all nodes? If not, then we are okay. We can use NodeSelector property of InfraViz and simply deploy this new Image using InfraViz on the specific node.
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
You need to have the appdynamics zip in your local. In my case, I have machineagent-bundle-64bit-linux-23.7.0.3689.zip in my local
create-open-file-extension-folder is the extension folder which I am moving to /opt/appdynamics/monitors, This has my script.sh and monitor.xml file Remember for extensions, the Machine agent looks for folders and files in monitors directory.
start-appdynamics.sh script. This is the content of start-appdynamics.sh script. You will need to edit it and add your Controller configuration.
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
Creating a new yaml file for Machine Agent
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.
Taint the nodes that I don't want InfraViz to run now which is going to be above one ^ kubectl taint node ip-222-222-222-222.us-west-2.compute.internal machine-agent=false:NoSchedule
Now, I can deploy InfraViz.yaml normally and it won't be deployed on ip-222 node.
Now you have MA running on all of your nodes, one with extension, and the rest normally
Please reach out to Support if you have any questions.