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.

This page does not apply to applications that use the Cluster Agent auto-instrumentation to configure agents. See Auto-Instrument Applications with the Cluster Agent.

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:

Gather Login Credentials

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. 

Use ConfigMaps to Configure the App Server Agent

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.

Use Secrets for the Controller Access Key

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.

Set Application-Specific Configuration in the Deployment Spec

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.

Verify the Environment Variables

After you set the agent environment variables, you can verify that they were added to your application.

To verify the environment variables:

  1. Create a ConfigMap.
  2. Restart the application container.
  3. Log in to the container using kubectl exec:

    kubectl -n ecommerce exec -it <pod name> /bin/sh
    BASH
  4. 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