How do I deploy Dynatrace OneAgent in GKE-based clusters?

Google Container Engine (GKE) is a management and orchestration system for Docker containers and container clusters that run within Google's public cloud services. Google Container Engine is based on Kubernetes, Google's open source container management system.

To deploy OneAgent in GKE-based clusters, follow the instructions below.

What you'll need

  1. Install Google Cloud SDK (there's no need to run gcloud init). Following installation, open your terminal. Using the gcloud tool, install kubectl using the following command:
    gcloud components install kubectl

  2. Set the environmental variable KUBECONFIG to %USERPROFILE%\.kube\config (for Windows) or /home/username/.kube/config (for Linux).

  3. Create a new directory %USERPROFILE%\.kube (for Windows) or /home/username/.kube/ (for Linux) with an empty file config inside.

Create your Google Cloud project

  1. Click the arrow button next to the Google Cloud logo.

  2. Click the plus sign button to open a New Project window.

  3. Type a new project name and select Create.

  4. Select your project and click Open.

Note: There's no need to run this procedure more than once; projects can be reused.

Create your Container Engine cluster

  1. Select Container Engine from the sidebar menu.

  2. Click Create a container cluster.

  3. Enter the desired settings. The most important are Size (number of nodes), Node image (cos image deploys OS with read-only file system, Ubuntu is an ordinary OS with a r/w file system), Cluster version (version of Kubernetes) and Machine type (keep these settings as low as you can to reduce your monitoring costs).

  4. Click Create. Cluster spawning takes some time. After completion, a green tick mark appears next to the cluster name.

Connect to the deployed Kubernetes cluster

  1. Click Connect.

  2. In your terminal, invoke the commands shown in the image below. The second command will prepare a dashboard hosted on your local machine, which will be accessible through the URL appearing at the bottom of the popup window.

Deploy Dynatrace OneAgent in Kubernetes

Note:
The GKE cluster must be deployed using the Ubuntu image. Container-Optimised OS isn't supported.

Connect to the cluster and open the Kubernetes UI dashboard.

Select Workloads > Deployments from the sidebar menu.

Click CREATE in the upper-right corner of the page.

Select Upload a YAML or JSON file and use the system dialog to upload the YAML file required for the deployment of Dynatrace OneAgent in Kubernetes.

Get the YAML file

Click Upload and wait for the page to reload. You will be shown a view of the deployed daemon sets and pods. You can look up the deployment event log by clicking the dynatrace-oneagent-… entry beneath the Pods section.

Once the icon preceding the pod name in the Workloads dashboard changes to a green tick, your OneAgent deployment is completed and OneAgent will be running.

You can view logs of the running container by clicking View logs in your pod dashboard.

Your app will proceed its deployment. You can see your applications on the Daemon Sets page. Virtual hosts are listed on the Pods page.

To connect to a pod, you'll need the pod name. You can look up the name on your Kubernetes dashboard or by invoking kubectl get pods in the command line. Open your terminal and type:

kubectl exec <pod name> -it -- <command>

For example:

kubectl exec pod1-hlbz3 -it -- /bin/sh

This command executes a shell on the selected pod.

To remove a pod, go to the Pods page, open the actions menu (...) of the selected pod and select Delete.

To remove an entire daemon set (app), go to the Daemon Sets page and follow the same steps as for pod removal.

Add collaborators to your Google Cloud project

To grant other users access to your Google Cloud project

  1. Open the IAM page from the Google Cloud dashboard.
  2. Go to IAM subpage and click Add.
  3. Enter the new user’s email address and set an applicable role (for example, Owner). After a while, the new user will be able to access your project.

More information can be found on the following pages: https://cloud.google.com/compute/docs/access/
https://cloud.google.com/compute/docs/access/add-remove-change-permissions-for-team-members