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_NAME
andPOD_NAMESPACE
passing them as environment variables viafieldRef
.EDIT: Added example env
REFERENCE_EXAMPLE
to 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.podIP
as mentioned in the documentation here.However,
CLUSTERNAME
is not a standard property available. According to this PR #22043, theCLUSTERNAME
should be injected to the.metadata
field if using GCE.Otherwise, you'll have to specific the
CLUSTERNAME
manually in the.metadata
field and then usefieldRef
to inject it as an environment variable.