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 09-09-2024 05:15 PM
AppDynamics Cluster Agent allows you to auto-instrument your Applications running on Kubernetes. The auto-instrumentation injects APM agents on runtime, modifying your deployment spec with an init-container of AppDynamics APM agent.
You can use different strategies to target Kubernetes deployments, StatefulSet, or DeploymentConfigs.
In this article, we will cover instrumenting one deployment by using a label defined on the Deployment level (it will be the same for DeploymentConfig and StatefulSet)
Let's take this forward with two sample deployments running in namespace abhi-java-apps-second.
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-app-abhi
labels:
app: tomcat-app-abhi-second
namespace: abhi-java-apps-second
spec:
replicas: 1
selector:
matchLabels:
app: tomcat-app-abhi
template:
metadata:
labels:
app: tomcat-app-abhi
spec:
containers:
- name: tomcat-app-abhi
#image: docker.io/abhimanyubajaj98/java-tomcat-sample-app-buildx:latest
image: docker.io/abhimanyubajaj98/java-application:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
env:
- name: JAVA_TOOL_OPTIONS
value: -Xmx512m
#- name: APPDYNAMICS_AGENT_UNIQUE_HOST_ID
# value: $(cat /proc/self/cgroup | head -1 | awk -F '/' '{print $NF}' | cut -c 16-27)
---
apiVersion: v1
kind: Service
metadata:
name: tomcat-app-service
labels:
app: tomcat-app-abhi
namespace: abhi-java-apps-second
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: tomcat-app-abhi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-app-abhi-labelmatch
labels:
app: tomcat-app-abhi-second-labelmatch
namespace: abhi-java-apps-second
spec:
replicas: 1
selector:
matchLabels:
app: tomcat-app-abhi-labelmatch
template:
metadata:
labels:
app: tomcat-app-abhi-labelmatch
spec:
containers:
- name: tomcat-app-abhi
#image: docker.io/abhimanyubajaj98/java-tomcat-sample-app-buildx:latest
image: docker.io/abhimanyubajaj98/java-application:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
env:
- name: JAVA_TOOL_OPTIONS
value: -Xmx512m
#- name: APPDYNAMICS_AGENT_UNIQUE_HOST_ID
# value: $(cat /proc/self/cgroup | head -1 | awk -F '/' '{print $NF}' | cut -c 16-27)
---
apiVersion: v1
kind: Service
metadata:
name: tomcat-app-service-labelmatch
labels:
app: tomcat-app-abhi-labelmatch
namespace: abhi-java-apps-second
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: tomcat-app-abhi-labelmatch
Now, my use case is only for instrument deployment tomcat-app-abhi-labelmatch. To do this, I would need to edit my cluster-agent.yaml and add the below specs:
instrumentationRules:
- namespaceRegex: abhi-java-apps-second
labelMatch:
- app: tomcat-app-abhi-second-labelmatch
tierName: abhiapps
language: java
imageInfo:
image: "docker.io/appdynamics/java-agent:latest"
agentMountPath: /opt/appdynamics
imagePullPolicy: Always
Now, after the deployment is done, only the deployment tomcat-app-abhi-labelmatch will have AppDynamics Java Agent.
Thank you! Your submission has been received!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form