I have a requirement to pass cluster, namespace and pod name to AppDynamics agent from my container deployed in Kubernetes cluster.
I tried something as below, but that does not work.
containers:
- env:
- name: JAVA_OPTS
value: -Dappdynamics.agent.nodeName=$HOST-$spec.nodeName-spec.PodName
and
- name: appdynamics.agent.nodeName
value= $HOST-$spec.nodeName-spec.PodName
Could anyone please help me here how to collect the detail and pass to AppD. Thanks in advance.
You can get
POD_NAMEandPOD_NAMESPACEpassing them as environment variables viafieldRef.EDIT: Added example env
REFERENCE_EXAMPLEto show how to reference variables. Thanks to this answer for pointing out the$()interpolation.You can reference
supports metadata.name, metadata.namespace, metadata.labels, metadata.annotations, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIPas mentioned in the documentation here.However,
CLUSTERNAMEis not a standard property available. According to this PR #22043, theCLUSTERNAMEshould be injected to the.metadatafield if using GCE.Otherwise, you'll have to specific the
CLUSTERNAMEmanually in the.metadatafield and then usefieldRefto inject it as an environment variable.