Update/Uninstall Dynatrace Operator
This page provides detailed instructions on how to update and uninstall the Dynatrace Operator in Kubernetes and OpenShift environments.
Dynatrace Operator manages the deployment and lifecycle of all Dynatrace components in your Kubernetes clusters (for example, OneAgent, ActiveGate, and code modules). This includes, depending on the configuration, automatic updates for these components. Dynatrace Operator itself needs to be updated either by applying new manifests or by using helm charts.
We recommend using an up-to-date Operator version (at least version n-2) and always using the latest patch version of that Operator version (for example, 0.10.4 instead of 0.10.0).
Update Dynatrace Operator
To update Dynatrace Operator, select one of the following options, depending on your deployment approach:
Manifest
Helm
Manifest
For classicFullStack
, applicationMonitoring
, or hostMonitoring
, execute the following command.
kubectl apply -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes.yaml
oc apply -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/openshift.yaml
If you're using the CSI driver, there's an additional prerequisite command:
kubectl apply -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes-csi.yaml
oc apply -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/openshift-csi.yaml
Helm
To update Dynatrace Operator, you need to upgrade the Helm chart. Run the command below.
helm upgrade dynatrace-operator dynatrace/dynatrace-operator -f values.yaml --atomic -n dynatrace
The values.yaml
file may have changed in newer versions. If existing values are no longer valid, they will be silently ignored as there's no validation for this.
Update OneAgent if automatic updates are disabled
By default, Dynatrace Operator handles OneAgent updates automatically. If you choose to disable automatic updates, and haven't set any standard OneAgent version in Dynatrace, you can manually update OneAgent by running the command below.
kubectl -n dynatrace rollout restart daemonset/<DYNAKUBE>-oneagent
oc -n dynatrace rollout restart daemonset/<DYNAKUBE>-oneagent
Update Access tokens
If you need to update your Dynatrace access tokens, follow the steps below.
Find current tokens
Delete your secret
Create new tokens
Create a new secret with updated tokens
Delete the old tokens
Find current access tokens
Find and save your currently used tokens.
After generating new tokens, you'll need to delete the old ones.
kubectl -n dynatrace get secrets <dynakube-name> -o yaml | yq '.data.apiToken' | base64 -d
oc -n dynatrace get secrets <dynakube-name> -o yaml | yq '.data.apiToken' | base64 -d
Delete your secret
To delete the secret, run one of the commands below.
In Kubernetes, used tokens are stored in a secret named dynakube
by default. If the DynaKube custom resource has a different name, or the tokens
field in DynaKube is set, make sure that the new secret has the same name as defined there.
kubectl -n dynatrace delete secret dynakube
oc -n dynatrace delete secret dynakube
Create new access tokens
For instructions on how to create the tokens, see Access tokens and permissions.
Create a new secret with updated access tokens
To create a new secret with the updated tokens, run one of the commands below, making sure to replace the placeholders with the new tokens.
- For
apiToken
:kubectl -n dynatrace create secret generic dynakube --from-literal="apiToken=<API-TOKEN>"
- For
apiToken
anddataIngestToken
:kubectl -n dynatrace create secret generic dynakube --from-literal="apiToken=<API-TOKEN>" --from-literal="dataIngestToken=<INGEST-TOKEN>"
- For
apiToken
:oc -n dynatrace create secret generic dynakube --from-literal="apiToken=<API-TOKEN>"
- For
apiToken
anddataIngestToken
:oc -n dynatrace create secret generic dynakube --from-literal="apiToken=<API-TOKEN>" --from-literal="dataIngestToken=<INGEST-TOKEN>"
Dynatrace Operator picks up the updated secrets in approximately five minutes. Removing DynaKube and reapplying it forces an instant reconciliation.
Delete the old access token
After the new tokens are in place, delete the old ones.
- In Dynatrace, go to Access tokens and look for the old token.
- Select Delete.
Migrate from classicFullStack
to cloudNativeFullStack
with CRI-O runtime
If you're using CRI-O as your cluster's container runtime and you want to transition from classicFullStack
to cloudNativeFullStack
, follow the steps outlined below.
The migration process is distinct for clusters using CRI-O due to the method the classic OneAgent employs for injection on CRI-O. Before transitioning to cloudNativeFullStack
, remove the CRI-O hooks used by the classic OneAgent. For more information about CRI-O hooks, see this Red Hat blog post.
-
Delete the DynaKube that is set up with
classicFullStack
. -
Wait for the OneAgent pods to terminate.
-
Execute the
uninstall.sh
script on each node that previously hosted a classic OneAgent pod./opt/dynatrace/oneagent/agent/uninstall.sh
-
Apply the DynaKube that is set up with
cloudNativeFullStack
. -
Wait until OneAgent pods start up.
-
Reboot all monitored applications.
Uninstall Dynatrace Operator
To uninstall Dynatrace Operator, select one of the following options (Manifest or Helm), depending on your deployment approach.
Manifest
Helm
Manifest
Select one of the following options (with or without CSI driver) to uninstall Dynatrace Operator.
Without CSI driver
-
Delete Dynatrace Operator.
kubectl delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes.yaml
oc delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/openshift.yaml
-
Delete the namespace.
kubectl delete namespace dynatrace
oc delete namespace dynatrace
With CSI driver
-
Clean up DynaKube resources.
kubectl delete dynakube -n dynatrace --all
oc delete dynakube -n dynatrace --all
-
Wait until Dynatrace Operator components have been deleted.
kubectl -n dynatrace wait pod --for=delete -l app.kubernetes.io/managed-by=dynatrace-operator --timeout=300s
oc -n dynatrace wait pod --for=delete -l app.kubernetes.io/managed-by=dynatrace-operator --timeout=300s
-
Restart your monitored applications.
-
Clean up CSI driver resources.
kubectl delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes-csi.yaml
oc delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes-csi.yaml
-
Uninstall Dynatrace Operator.
kubectl delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes.yaml
oc delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes.yaml
-
Delete the namespace.
kubectl delete namespace dynatrace
oc delete namespace dynatrace
Helm
Select one of the following options (with or without CSI driver) to uninstall Dynatrace Operator.
Without CSI driver
-
Delete Dynatrace Operator.
helm uninstall dynatrace-operator -n dynatrace
-
Delete the namespace.
kubectl delete namespace dynatrace
oc delete namespace dynatrace
With CSI driver
-
Clean up DynaKube resources.
kubectl delete dynakube -n dynatrace --all
oc delete dynakube -n dynatrace --all
-
Wait until Dynatrace Operator components have been deleted.
kubectl -n dynatrace wait pod --for=delete -l app.kubernetes.io/managed-by=dynatrace-operator --timeout=300s
oc -n dynatrace wait pod --for=delete -l app.kubernetes.io/managed-by=dynatrace-operator --timeout=300s
-
Restart your monitored applications.
-
Uninstall Dynatrace Operator.
helm uninstall dynatrace-operator -n dynatrace
-
Delete the namespace.
kubectl delete namespace dynatrace
oc delete namespace dynatrace