Deploy ActiveGate in Kubernetes as a StatefulSet

Dynatrace Operator manages the lifecycle of several Dynatrace components, including ActiveGate. If you can't use Dynatrace Operator, you can deploy ActiveGate directly as a StatefulSet. See below for instructions.

Deploy ActiveGate

  1. Create a dedicated namespace.
kubectl create namespace dynatrace
  1. Create a secret holding the environment URL and login credentials for this registry.

Example command:

kubectl create secret docker-registry dynatrace-docker-registry --docker-server=<YOUR_ENVIRONMENT_URL> --docker-username=<YOUR_ENVIRONMENT_ID> --docker-password=<YOUR_PAAS_TOKEN> -n dynatrace

where you need to replace

  • <YOUR_ENVIRONMENT_URL> with your environment URL (without 'http'). Example:
  • <YOUR_ENVIRONMENT_ID> with the Docker account username (same as the ID in your environment URL above)
  • <YOUR_PAAS_TOKEN> with the PaaS token you created in Prerequisites
  1. Create a file named ag-monitoring.yaml with the following content, making sure to replace
  • <YOUR_ENVIRONMENT_URL> and <YOUR_ENVIRONMENT_ID>with your own values as described above
  • <ANY_UNIQUE_ID> with any unique value. This ID will be used by the ActiveGate to generate a unique name in the UI.
  1. Deploy ActiveGate.
kubectl apply -f ag-monitoring.yaml
  1. Set up routing. optional

To set up OneAgent routing inside Kubernetes using ActiveGate as a StatefulSet, create a file named, for example, ag-routing.yaml with the content as in the following example, where

  • <YOUR_ENVIRONMENT_URL> is as described in step 2.
  • <ANY_UNIQUE_ID> is the value you set in step 3.
  1. Save your configuration.
kubectl apply -f ag-routing.yaml

Connect your Kubernetes clusters to Dynatrace

To get native Kubernetes metrics, you need to connect the Kubernetes API to Dynatrace.

To connect the Kubernetes API to Dynatrace

  1. Create a service account and cluster role.

Create a service account and cluster role for accessing the Kubernetes API. This creates the bearer token necessary to authenticate in the Kubernetes API. Use the following snippet.

kubectl apply -f
  1. Get the Kubernetes API URL.
$ kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'
  1. Get the bearer token.
$ kubectl get secret $(kubectl get sa dynatrace-monitoring -o jsonpath='{.secrets[0].name}' -n dynatrace) -o jsonpath='{.data.token}' -n dynatrace | base64 --decode

Special instructions for Rancher distributions

  1. In the Dynatrace menu, go to Settings > Cloud and virtualization > Kubernetes, and select Connect new cluster.
  2. Provide a Name, Kubernetes API URL, and the Bearer token for the Kubernetes cluster.

Note: For Rancher distributions, you need the bearer token that was created in Rancher web UI, as described in Special instructions for Rancher distributions above.

If you haven't installed a trusted certificate to your ActiveGate, make sure to clear the Require valid certificates for communication with the API server (recommended) checkbox.

Once you connect your Kubernetes clusters to Dynatrace, you can get native Kubernetes metrics, like request limits, and differences in pods requested vs. running pods.

ActiveGate update behavior

ActiveGate is updated automatically on pod restart whenever there is a new version available, unless the image already specifies a certain version.