Uninstall OneAgent from Kubernetes

Find out below how to uninstall OneAgent according to your particular deployment strategy. For a clear view of all the deployment alternatives, see Understanding deployment strategies.

Uninstall OneAgent Operator with Helm

Remove OneAgent custom resources and clean-up all remaining OneAgent Operator specific objects:

$ helm uninstall dynatrace-oneagent-operator -n dynatrace

Uninstall OneAgent Operator via kubectl

In order to uninstall OneAgent Operator for Kubernetes 1.9 or higher, follow the steps below.

Remove OneAgent custom resources and clean-up all remaining OneAgent Operator specific objects.

$ kubectl delete -n dynatrace oneagent --all
$ kubectl delete -f https://raw.githubusercontent.com/Dynatrace/\
dynatrace-oneagent-operator/master/deploy/kubernetes.yaml

Optional After deleting OneAgent Operator, the OneAgent binary remains on the node in an inactive state. To uninstall it completely, execute the uninstall.sh script and delete logs and configuration files.
See Linux related information.

Uninstall OneAgent DaemonSet

To uninstall OneAgent DaemonSet from Kubernetes version 1.8 or lower

Delete the dynatrace-oneagent DaemonSet.

$ kubectl delete ds/dynatrace-oneagent

Optional After deleting the dynatrace-oneagent DaemonSet, the OneAgent binary remains on the node in an inactive state. To uninstall it completely, execute the uninstall.sh script and delete logs and configuration files.
See Linux related information.

Uninstall OneAgent for application-only monitoring

To uninstall Kubernetes from application-only monitoring, simply remove references from your application or Docker image and redeploy the application.

Build time

  1. Remove the two lines of code from the application image.
COPY --from=<ACTIVEGATE-ADDRESS>/linux/oneagent-codemodules:<TECHNOLOGY> / /
ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so
  1. Rebuild the application image.
$ docker build -t yourapp .

Runtime

Remove the install-oneagent YAML from your deployment template.

k8s-app-only-run-time.yaml
Download
# your application containers
      containers:
      - name: customer-app
        image: tomcat
        env:
        - name: LD_PRELOAD
          value: /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so
        volumeMounts:
        - mountPath: /opt/dynatrace/oneagent
          name: oneagent

# initContainer to download OneAgent
      initContainers:
      - name: install-oneagent
        image: alpine:3.8
        command:
        - /bin/sh
        args:
        - -c
        - ARCHIVE=$(mktemp) && wget -O $ARCHIVE "$DT_API_URL/v1/deployment/installer/agent/unix/paas/latest?Api-Token=$DT_PAAS_TOKEN&$DT_ONEAGENT_OPTIONS" && unzip -o -d /opt/dynatrace/oneagent $ARCHIVE && rm -f $ARCHIVE
        env:
        - name: DT_API_URL
          value: https://<Your-environment-ID>.live.dynatrace.com/api
        - name: DT_PAAS_TOKEN
          value: <paastoken>
        - name: DT_ONEAGENT_OPTIONS
          value: flavor=<FLAVOR>&include=<TECHNOLOGY>
        volumeMounts:
        - mountPath: /opt/dynatrace/oneagent
          name: oneagent

# Make OneAgent available as a volume
      volumes:
      - name: oneagent
        emptyDir: {}