• Home
  • Deploy
  • Kubernetes
  • Guides
  • Operation
  • Update/Uninstall Dynatrace Operator

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.

bash
kubectl apply -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes.yaml
bash
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:

bash
kubectl apply -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes-csi.yaml
bash
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.

bash
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.

Upgrade from a Dynatrace Operator version < 0.8.0

Upgrade from old Dynatrace Operator versions with Helm

If you use a Dynatrace Operator version earlier than v0.8.0 in a Helm deployment, follow the steps below to migrate to the latest Dynatrace Operator version with Helm.

Upgrade the custom resource definition

According to your configuration of the values.yaml file, select one of the options below.

  • If installCRD is set to true, the custom resource definition will be automatically upgraded and managed by Helm.

  • If installCRD is set to false, you need to upgrade the custom resource definition manually before starting the Helm installation:

    bash
    kubectl apply -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/dynatrace-operator-crd.yaml
    bash
    oc apply -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/dynatrace-operator-crd.yaml

Upgrade the Helm chart

Delete the CRD section and the secrets from your existing values.yaml file or use and customize the values.yaml sample from GitHub. Upgrade the helm chart:

bash
helm upgrade dynatrace-operator dynatrace/dynatrace-operator -f values.yaml --atomic -n dynatrace

The above changes make your old values unusable, therefore setting the --reuse-values flag isn't possible for migration.

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.

bash
kubectl -n dynatrace rollout restart daemonset/<DYNAKUBE>-oneagent
bash
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.

bash
kubectl -n dynatrace get secrets <dynakube-name> -o yaml | yq '.data.apiToken' | base64 -d
bash
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.

bash
kubectl -n dynatrace delete secret dynakube
bash
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:
    bash
    kubectl -n dynatrace create secret generic dynakube --from-literal="apiToken=<API-TOKEN>"
  • For apiToken and dataIngestToken:
    bash
    kubectl -n dynatrace create secret generic dynakube --from-literal="apiToken=<API-TOKEN>" --from-literal="dataIngestToken=<INGEST-TOKEN>"
  • For apiToken:
    bash
    oc -n dynatrace create secret generic dynakube --from-literal="apiToken=<API-TOKEN>"
  • For apiToken and dataIngestToken:
    bash
    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.

  1. In Dynatrace, go to Access tokens and look for the old token.
  2. 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.

  1. Delete the DynaKube that is set up with classicFullStack.

  2. Wait for the OneAgent pods to terminate.

  3. Execute the uninstall.sh script on each node that previously hosted a classic OneAgent pod.

    bash
    /opt/dynatrace/oneagent/agent/uninstall.sh
  4. Apply the DynaKube that is set up with cloudNativeFullStack.

  5. Wait until OneAgent pods start up.

  6. 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

  1. Delete Dynatrace Operator.

    bash
    kubectl delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes.yaml
    bash
    oc delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/openshift.yaml
  2. Delete the namespace.

    bash
    kubectl delete namespace dynatrace
    bash
    oc delete namespace dynatrace

With CSI driver

  1. Clean up DynaKube resources.

    bash
    kubectl delete dynakube -n dynatrace --all
    bash
    oc delete dynakube -n dynatrace --all
  2. Wait until Dynatrace Operator components have been deleted.

    bash
    kubectl -n dynatrace wait pod --for=delete -l app.kubernetes.io/managed-by=dynatrace-operator --timeout=300s
    bash
    oc -n dynatrace wait pod --for=delete -l app.kubernetes.io/managed-by=dynatrace-operator --timeout=300s
  3. Restart your monitored applications.

  4. Clean up CSI driver resources.

    bash
    kubectl delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes-csi.yaml
    bash
    oc delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes-csi.yaml
  5. Uninstall Dynatrace Operator.

    bash
    kubectl delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes.yaml
    bash
    oc delete -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.13.0/kubernetes.yaml
  6. Delete the namespace.

    bash
    kubectl delete namespace dynatrace
    bash
    oc delete namespace dynatrace

Helm

Select one of the following options (with or without CSI driver) to uninstall Dynatrace Operator.

Without CSI driver

  1. Delete Dynatrace Operator.

    bash
    helm uninstall dynatrace-operator -n dynatrace
  2. Delete the namespace.

    bash
    kubectl delete namespace dynatrace
    bash
    oc delete namespace dynatrace

With CSI driver

  1. Clean up DynaKube resources.

    bash
    kubectl delete dynakube -n dynatrace --all
    bash
    oc delete dynakube -n dynatrace --all
  2. Wait until Dynatrace Operator components have been deleted.

    bash
    kubectl -n dynatrace wait pod --for=delete -l app.kubernetes.io/managed-by=dynatrace-operator --timeout=300s
    bash
    oc -n dynatrace wait pod --for=delete -l app.kubernetes.io/managed-by=dynatrace-operator --timeout=300s
  3. Restart your monitored applications.

  4. Uninstall Dynatrace Operator.

    bash
    helm uninstall dynatrace-operator -n dynatrace
  5. Delete the namespace.

    bash
    kubectl delete namespace dynatrace
    bash
    oc delete namespace dynatrace