Installing Cloud Operations for GKE support

Google Kubernetes Engine (GKE) includes integration with Cloud Monitoring and Cloud Logging. This integration lets you monitor your running GKE clusters, manage your system and debug logs, and analyze your system's performance using advanced profiling and tracing capabilities.

This page describes how to do the following:

  • Create a new cluster and configure Cloud Operations for GKE or Legacy Logging and Monitoring.

  • Select whether to collect application logs or not.

  • Disable Cloud Monitoring and Cloud Logging for a cluster.

Cloud Operations for GKE provides a single option that enables improved support for both Cloud Monitoring and Cloud Logging in your clusters. With Legacy Logging and Monitoring, you could enable Monitoring without Logging, but this option is not supported in Cloud Operations for GKE.

Before you begin

  • Determine which monitoring and logging integration option you want to use.

  • Determine whether application logs should be collected.

  • Ensure you are an Owner of the project containing your cluster. Your project must be associated with a Workspace.

Controlling the collection of application logs

By default, GKE collects logs for workloads deployed to the cluster. This is a powerful tool for instrumenting your application; however, this automated collection may not be preferred. Beginning with GKE version 1.15.7, you can configure Cloud Operations for GKE to only capture system logs and not collect application logs.

When the system-only option is selected, the following logs are collected:

  • All Pods running in namespaces kube-system, istio-system, knative-serving,gke-system, and config-management-system.

  • Key services that are not containerized including docker/containerd runtime, kubelet, kubelet-monitor, node-problem-detector, and kube-container-runtime-monitor.

  • The node's serial ports output, if the VM instance metadata serial-port-logging-enable is set to true.

Configuring monitoring and logging support for a new cluster

When you create a new GKE cluster, Cloud Operations for GKE dashboard is enabled by default. If you are using version 1.14 or 1.15, then you can select Legacy Logging and Monitoring integration. For all cluster configurations, you can disable Google Cloud's operations suite all together.

The cluster-creation instructions in this section only cover the options relevant to Cloud Operations for GKE. For complete instructions on creating a GKE cluster, see Creating a cluster.

CONSOLE

  1. Go to the GKE Clusters page for your project. The following button takes you there:

    Go to Kubernetes clusters

  2. Click Create Cluster.

  3. Select a Master version for your cluster. The version you select changes the Cloud Monitoring and Cloud Logging options available to you.

  4. From the navigation pane, under Cluster, click Features.

  5. Under Operations, select the logging and monitoring support for your cluster:

    • For new clusters, Cloud Operations for GKE is selected by default.

      • If your Master version is 1.15.7 or later, you can select one of the following options from the drop-down list:

        • System and workload logging and monitoring
        • System logging and monitoring only (beta)
      • If your Master version is 1.14 or 1.15, you can enable Legacy Logging and Monitoring support:

        1. From the drop-down list, select Legacy Logging and Monitoring.
        2. Select Enable Legacy Monitoring service or Enable Legacy Logging service, or both options.

          Legacy Monitoring and Legacy Logging can be enabled or disabled separately.

    • To disable Cloud Operations for GKE, clear the Enable Cloud Operations for GKE checkbox.

  6. Configure the cluster as you want.

  7. Click Create to create the cluster.

GCLOUD

Use gcloud to create your cluster:

  1. Open a terminal window with Cloud SDK and gcloud installed. One way to do this is to use Cloud Shell.

  2. In the Cloud Console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Cloud Console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Cloud SDK already installed, including the gcloud command-line tool, and with values already set for your current project. It can take a few seconds for the session to initialize.

  3. To create your cluster, run the following command. For new clusters, Cloud Operations for GKE is enabled by default:

    gcloud container clusters create [CLUSTER_NAME] \
      --zone=[ZONE] \
      --project=[PROJECT_ID] \
      --cluster-version=[CLUSTER_VERSION]
    

    In the previous expression, [CLUSTER_NAME] is your clusters' name, [ZONE] is the compute zone for the cluster, and [PROJECT_ID] is the Google Cloud project ID, not the project name.

    [CLUSTER_VERSION] is the GKE version to install on the cluster. You can enter the specific patch release to install, for example 1.16.13-gke.401. Otherwise, you can enter the minor version to install, for example, 1.16, and your cluster is created with the latest patch version. For more information on GKE versioning, see Versioning and upgrades.

  4. Alternatively, to select Legacy Logging and Monitoring for your GKE clusters with version 1.14 or 1.15, create your cluster and include the --enable-cloud-logging and/or --enable-cloud-monitoring options in the create command. For example, a simple cluster creation might look like the following:

        gcloud container clusters create [CLUSTER_NAME] \
          --zone=[ZONE] \
          --project=[PROJECT_ID] \
          --cluster-version=[CLUSTER_VERSION] \
          --enable-cloud-logging \
          --enable-cloud-monitoring
    
    
    
    1. Alternatively, you can create your cluster without enabling Cloud Operations for GKE by adding the --no-enable-stackdriver-kubernetes flag to the create command. For example:

      gcloud container clusters create [CLUSTER_NAME] \
        --zone=[ZONE] \
        --project=[PROJECT_ID] \
        --cluster-version=[CLUSTER_VERSION] \
        --no-enable-stackdriver-kubernetes
      

Configuring monitoring and logging support for an existing cluster

The following section details how to modify the monitoring and logging integration for an existing GKE cluster.

Which monitoring and logging support does my cluster use?

To see which monitoring and logging support your cluster is using, complete the following steps:

  1. In the Google Cloud Console, click your cluster's name:

    Go to Kubernetes clusters

  2. In the Details panel for your cluster, see the status for Cloud Operations for GKE, Legacy Monitoring, and Legacy Logging.

    Cluster details screen.

Modifying your cluster

To change the monitoring and logging configuration for an existing cluster, follow the instructions below:

CONSOLE

  1. Go to the GKE Kubernetes clusters page for your project:

    Go to Kubernetes clusters

  2. Upgrade your cluster to version 1.12.7 or higher. For instructions, see Upgrading clusters. Allow the upgrade to complete.

  3. Click Edit for your cluster:

    Edit a GKE cluster.

  4. Select the appropriate integration option for your cluster.

    • To change to Cloud Operations for GKE, in the Cloud Operations for GKE drop-down box, select System and workload logging and monitoring.

      Choose Cloud Operations for GKE support.

    • To change to Cloud Operations for GKE with system logs only, in the Cloud Operations for GKE drop-down box, select System logging and monitoring only (beta).

      Choose Cloud Operations for GKE support.

    • To change to Legacy Logging and Monitoring support for GKE version 1.14 and below, do the following:

      1. In the Cloud Operations for GKE drop-down box, select Legacy Logging and Monitoring.

      2. In the Legacy Logging drop-down box, select Enabled.

      3. In the Legacy Monitoring drop-down box, select Enabled.

        Choose Legacy Logging and Monitoring supports.

    • To completely disable Google Cloud's operations suite integration, select Disabled in the Cloud Operations for GKE drop-down box.

  5. Click Save.

GCLOUD

The following gcloud instructions cover upgrading your cluster's monitoring and logging support using the gcloud container clusters update command. Notice that you use the update command, not the upgrade command, even though we sometimes refer to this process as "upgrading."

  1. Open a terminal window with Cloud SDK and gcloud installed. One way to do this is to use Cloud Shell.

  2. In the Cloud Console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Cloud Console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Cloud SDK already installed, including the gcloud command-line tool, and with values already set for your current project. It can take a few seconds for the session to initialize.

  3. If you have not done so, set up default values for your cluster in Cloud SDK:

    gcloud config set project [PROJECT_ID]
    
  4. To enable Cloud Operations for GKE, run the update command with the --enable-stackdriver-kubernetes flag.

    gcloud container clusters update [CLUSTER_NAME] \
      --zone=[ZONE]  \
      --enable-stackdriver-kubernetes
      
  5. To enable Legacy Logging and Monitoring, run the update command with the --logging-service logging.googleapis.com and\or the --monitoring-service monitoring.googleapis.com flags. The example shown here only shows the options needed for Google Cloud's operations suite:

    gcloud container clusters update [CLUSTER_NAME] \
      --zone=[ZONE]  \
      --logging-service logging.googleapis.com \
      --monitoring-service monitoring.googleapis.com
      

  6. Alternatively, to remove Cloud Operations for GKE or Legacy Logging and Monitoring, run the update command and set the --logging-service and --monitoring-service flags to none.

    gcloud container clusters update [CLUSTER_NAME] \
      --zone=[ZONE]  \
      --logging-service none \
      --monitoring-service none

What's next

  • Learn about the costs associated with Cloud Logging by reading the Pricing page.

  • Learn more about Using Prometheus, a monitoring tool often used with Kubernetes.

  • If you are using Legacy Logging and Monitoring, become familiar with the changes in Cloud Operations for GKE by reading Migrating to Cloud Operations for GKE.