How do I run Dynatrace OneAgent with Kubernetes?

To monitor applications running in Kubernetes clusters, first deploy Dynatrace OneAgent on all Kubernetes nodes (previously known as "minions") by means of a DaemonSet. Subsequently, install Dynatrace OneAgent on the Kubernetes worker nodes, as described on this page.

Before you begin

What you'll need:

  • kubectl CLI

Locate your Dynatrace environment credentials

The first step is to get your Dynatrace environment ID and token. This information is presented to you during Dynatrace OneAgent installation.

To get your Dynatrace environment ID and token

  1. Select Deploy Dynatrace from the navigation menu.
  2. Click Start installation and select Linux.
  3. Locate your environment ID and token, as shown below.

Install Dynatrace OneAgent

Deploy Dynatrace OneAgent on Kubernetes nodes.

$ cat <<- EOF > dynatrace-oneagent.yaml
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: dynatrace-oneagent
spec:
  template:
    metadata:
      labels:
        run: dynatrace-oneagent
    spec:
      hostPID: true
      hostIPC: true
      hostNetwork: true
      volumes:
      - name: host-root
        hostPath:
          path: /
      containers:
      - name: dynatrace-oneagent
        image: dynatrace/oneagent
        args:
        - "TENANT=REPLACE_WITH_YOUR_ENVIRONMENT_ID"
        - "TENANT_TOKEN=REPLACE_WITH_YOUR_TOKEN"
        - "SERVER=REPLACE_WITH_YOUR_CONNECTION_ENDPOINT"
        volumeMounts:
        - mountPath: /mnt/root
          name: host-root
        securityContext:
          privileged: true
EOF

Be sure to replace all REPLACE_WITH placeholders in the dynatrace-oneagent.yaml file with the respective credential information explained above. The connection endpoint in REPLACE_WITH_YOUR_CONNECTION_ENDPOINT is https://REPLACE_WITH_YOUR_ENVIRONMENT_ID.live.dynatrace.com.
If you're using Dynatrace Managed, the connection endpoint for your Managed cluster is https://<YourManagedServerURL>/e/REPLACE_WITH_ENVIRONMENT_ID.

Deploy the DaemonSet

$ kubectl create -f dynatrace-oneagent.yaml

The command above runs Dynatrace OneAgent on all Kubernetes worker nodes. You may also want to run Dynatrace OneAgent on the master nodes. Please use the default Linux installer for this.