Deploy ActiveGate in Kubernetes/OpenShift 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.
Prerequisites
- Create a PaaS token
Deploy ActiveGate
To deploy ActiveGate, follow the steps below.
- Depending on your platform, select one of the options below.
Create a dedicated namespace.
kubectl create namespace dynatrace
Create a dedicated namespace.
oc adm new-project --node-selector="" dynatrace
- 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
oc -n dynatrace 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:environment.live.dynatrace.com
<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
- Create a file named
ag-monitoring-and-routing.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.
- Deploy ActiveGate.
kubectl apply -f ag-monitoring-and-routing.yaml
oc apply -f ag-monitoring-and-routing.yaml
Connect your Kubernetes clusters to Dynatrace
To get native Kubernetes metrics, you need to connect your clusters to Dynatrace.
To connect your clusters and enable monitoring, you have two options:
- Connect the containerized ActiveGate to a local Kubernetes API endpoint
- Connect the containerized ActiveGate to the public Kubernetes API URL
See below for instructions for both options.
Connect to a local Kubernetes API endpoint
ActiveGate version 1.229+You can enable monitoring by connecting a containerized ActiveGate to a local Kubernetes API endpoint. For this you only need to provide the unique Kubernetes cluster ID (the uuid of the kube-system namespace) in Dynatrace web UI. The containerized ActiveGate then identifies the unique cluster ID and sends it over to Dynatrace.
To connect to a local Kubernetes API endpoint
1. Get the Kubernetes cluster ID
Run the command below and grab the UID from the output.
kubectl get namespace kube-system -o jsonpath='{.metadata.uid}'
oc get namespace kube-system -o jsonpath='{.metadata.uid}'
2. Provide the Kubernetes cluster ID in the Dynatrace web UI
- In the Dynatrace menu, go to Kubernetes.
- Select Connect manually.
- On the Kubernetes cluster monitoring settings page, provide a Name, and then turn on Connect containerized ActiveGate to local Kubernetes API endpoint.
- For Kubernetes cluster ID, enter the UID obtained earlier.
- Select Save changes to save your configuration. Note: You can save your configuration even if the ActiveGate isn't ready to connect, and finish the configuration later. To verify if it's ready, select Test configuration.
Change monitoring settings
You can change monitoring settings at any time from your Kubernetes cluster details page.
- In the Dynatrace menu, go to Kubernetes.
- Find your Kubernetes cluster, and then select Actions > Settings.
- Adjust your settings, and then select Save changes.
Delete configuration
To delete the connection to a local Kubernetes API endpoint
- In the Dynatrace menu, go to Kubernetes.
- Find your Kubernetes cluster, and then select Actions > Settings.
- Select Use defaults, and then select Save changes.
Connect to the public Kubernetes API
To connect the Kubernetes API to Dynatrace
- Create a service account and cluster role.
Create a kubernetes-monitoring-service-account.yaml
file with the following content.
- Apply the file.
kubectl apply -f kubernetes-monitoring-service-account.yaml
oc apply -f kubernetes-monitoring-service-account.yaml
- Get the Kubernetes API URL.
kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'
oc config view --minify -o jsonpath='{.clusters[0].cluster.server}'
- 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
oc get secret $(oc get sa dynatrace-monitoring -o jsonpath='{.secrets[0].name}' -n dynatrace) -o jsonpath='{.data.token}' -n dynatrace | base64 --decode
oc get secret $(oc get sa dynatrace-monitoring -o jsonpath='{.secrets[1].name}' -n dynatrace) -o jsonpath='{.data.token}' -n dynatrace | base64 --decode
Special instructions for Rancher distributions
-
In the Dynatrace menu, go to Settings > Cloud and virtualization > Kubernetes and select Connect new cluster.
-
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.