This page describes best practices to use when configuring App Server Agents in a Kubernetes environment and manually instrumenting applications using init containers or a Dockerfile.
You can configure App Server Agents in Kubernetes using environment variables. Depending on the use case, you have three options to set environment variables:
See the language-specific container installation page to implement these best practices:
To access AppDynamics, you need your login credentials and the URL from where you can access your organization's AppDynamics Controller(s). If you do not have this information, contact your AppDynamics administrator.
When instrumenting a container running in Kubernetes, each App Server Agent requires that you set environment variables to configure:
- Connection parameters
- Application metadata
- Agent behavior
You can use ConfigMaps to store an application's environment variables in a Kubernetes object within the scope of a namespace. ConfigMaps are an optimal twelve-factor method used to manage agent configuration shared across multiple Kubernetes applications within a namespace.
Controller credentials configuration is stored in a single ConfigMap, and shared with each application in the namespace that reports to that Controller. If you use multiple Controllers across different environments, such as development, test, and production, you can store different ConfigMaps in the namespaces associated with those environments.
The Controller access key is another configuration that you can pass to App Server Agents as an environment variable. Sensitive data is stored in a Kubernetes namespace using a Secret, rather than a ConfigMap. You can use Kubernetes Secrets to obfuscate values rather than manipulate them in plaintext.
The AppDynamics Controller application tier name identifies a service that reports under a particular AppDynamics application. An application tier name is an example of agent configuration that is different for each Kubernetes application but typically does not vary across environments and namespaces. Application-specific configuration, similar to the tier name, is easier to define in the Kubernetes deployment spec directly.
After you set the agent environment variables, you can verify that they were added to your application.
To verify the environment variables:
- Create a ConfigMap.
Create a Secret.
Create an environment variable in the deployment spec.
- Restart the application container.
Log in to the container using kubectl exec
:
kubectl -n ecommerce exec -it <pod name> /bin/sh
BASH
List the AppDynamics environment variables available in the container to confirm they are defined and have the correct values:
env | grep APPD
APPDYNAMICS_AGENT_APPLICATION_NAME=<value>
APPDYNAMICS_AGENT_ACCOUNT_NAME=<value>
APPDYNAMICS_CONTROLLER_HOST_NAME=<value>
...
BASH