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 Kubernetes deployment strategies.
Uninstall OneAgent Operator with kubectl
In order to uninstall OneAgent Operator for Kubernetes version 1.9+, 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://github.com/Dynatrace/dynatrace-oneagent-operator/releases/latest/download/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 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 DaemonSet
To uninstall OneAgent DaemonSet from Kubernetes versions 1.8 and earlier
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 OneAgent from application-only monitoring, simply remove references from your application or Docker image and redeploy the application.
Container build-time injection
- 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
- Rebuild the application image.
$ docker build -t yourapp .
- Remove the following commands from your Dockerfile.
ARG DT_API_URL="https://<environmentID>.live.dynatrace.com/api"
ARG DT_API_TOKEN="<token>"
ARG DT_ONEAGENT_OPTIONS="flavor=default&include=<technology1>&include=<technology2>"
ENV DT_HOME="/opt/dynatrace/oneagent"
RUN mkdir -p "$DT_HOME" && \
wget -O "$DT_HOME/oneagent.zip" "$DT_API_URL/v1/deployment/installer/agent/unix/paas/latest?Api-Token=$DT_API_TOKEN&$DT_ONEAGENT_OPTIONS" && \
unzip -d "$DT_HOME" "$DT_HOME/oneagent.zip" && \
rm "$DT_HOME/oneagent.zip"
ENTRYPOINT [ "/opt/dynatrace/oneagent/dynatrace-agent64.sh" ]
CMD [ "executable", "param1", "param2" ] # the command of your application, for example, Java
- Rebuild the application image.
$ docker build -t yourapp .
Pod run-time injection
Remove the install-oneagent YAML from your deployment template.
k8s-app-only-run-time.yaml
# 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: {}
Automated application-only injection
- Remove the label from the namespace.
- Redeploy your application.