Optimize your usage of GKE with insights and recommendations


With Google Kubernetes Engine (GKE), you can receive prescriptive guidance for how to optimize your clusters.

GKE monitors your clusters and if there are potential optimizations, guidance is delivered through Recommender, a Google Cloud service that generates insights and recommendations for using resources on Google Cloud. For GKE, Recommenders deliver two types of information:

  • An insight explains that GKE detected your cluster usage can be optimized in some way.
  • A recommendation explains how to optimize your cluster usage.

GKE delivers this information in the Google Cloud console and you can also find it with the Google Cloud CLI and the Recommender API. GKE provides Recommenders for topics including:

Before you begin

Before you start, make sure you have performed the following tasks:

  • Enable the Google Kubernetes Engine API.
  • Enable Google Kubernetes Engine API
  • If you want to use the Google Cloud CLI for this task, install and then initialize the gcloud CLI. If you previously installed the gcloud CLI, get the latest version by running gcloud components update.

Required roles

Ensure that you have the necessary permissions for Kubernetes insights and recommendations, either with the following basic roles or predefined roles:

View insights and recommendations

You can view insights and recommendations with the Google Cloud CLI, in the Google Cloud console, or with the Recommender API.

Console

  1. Go to the Google Kubernetes Engine page in the Google Cloud console:

    Go to Google Kubernetes Engine

  2. Check the Notifications column for specific clusters to find insights.

  3. Click on the insight to reveal more information. In the revealed sidebar panel, you can see details about this insight, including any associated recommendation.

gcloud

An insight typically has a corresponding recommendation. Insights are fetched with gcloud recommender insights and recommendations are fetched with gcloud recommender recommendations.

  1. View the list of insights for the clusters of a specific zone (for zonal clusters) or a specific region (for regional clusters):

    gcloud recommender insights list \
        --insight-type=google.container.DiagnosisInsight \
        --location=LOCATION \
        --project=PROJECT_ID \
        --format=FORMAT \
        --filter="insightSubtype:SUBTYPE"
    

    Replace the following:

    • PROJECT_ID: the Google Cloud project ID for the project where the cluster(s) are located.
    • LOCATION: the exact region or zone of the cluster. For zonal clusters, you must provide the exact zone (e.g. us-central1-c). For regional clusters, you must provide the exact region (e.g. us-central1).
    • FORMAT: change the output format to YAML. This flag is optional.
    • SUBTYPE: an insight subtype, for example, DEPRECATION_K8S_1_23_CERTIFICATE. This limits the output to insights of a specified subtype. This flag is optional.

    Or, if you already have an insight ID, you can see details about the insight by running the following command:

    gcloud recommender insights describe INSIGHT \
        --insight-type=google.container.DiagnosisInsight \
        --location=LOCATION \
        --project=PROJECT_ID \
        --format=FORMAT
    

    Replace the INSIGHT with the value of insight ID, specified at the end of the URL from the name field for the insight.

    The output includes additional details about what behavior GKE has detected with your cluster.

  2. View the list of recommendations for the clusters of a specific zone (for zonal clusters) or a specific region (for regional clusters):

    gcloud recommender recommendations list \
        --recommender=google.container.DiagnosisRecommender \
        --location=LOCATION \
        --project=PROJECT_ID \
        --format=FORMAT \
        --filter="recommenderSubtype:SUBTYPE"
    

    Replace SUBTYPE with a recommender subtype, for example, DEPRECATION_K8S_1_23_CERTIFICATE. This limits the output to recommendations of a specified subtype. This flag is optional.

    Or, if you already have a recommendation ID, you can view the recommendation by running the following command:

    gcloud recommender recommendations describe RECOMMENDATION_ID \
        --recommender=google.container.DiagnosisRecommender \
        --location=LOCATION \
        --project=PROJECT_ID \
        --format=FORMAT
    

    Replace the RECOMMENDATION_ID with the saved value of associatedRecommendations.recommendation from the command output in Step 1.

    The output provides guidance on what action you might need to take to optimize your cluster's usage of GKE.

API

Each insight has a corresponding recommendation. Insights are fetched with REST Resource: projects.locations.insightTypes.insights and recommendations are fetched with REST Resource: projects.locations.recommenders.recommendations.

  1. View the list of insights for the clusters of a specific zone (for zonal clusters) or a specific region (for regional clusters):

    GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/google.container.DiagnosisInsight/insights?filter=insightSubtype%20%3D%20SUBTYPE
    

    Replace the following:

    • PROJECT_ID: the Google Cloud project ID for the project where the cluster(s) are located.
    • LOCATION: the exact region or zone of the cluster. For zonal clusters, you must provide the exact zone (e.g. us-central1-c). For regional clusters, you must provide the exact region (e.g. us-central1).
    • SUBTYPE: an insight subtype, for example, DEPRECATION_K8S_1_23_CERTIFICATE. This limits the output to insights of a specified subtype. This flag is optional.

    Or, if you already have an insight ID, you can see details about the insight by making the following request:

    GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/google.container.DiagnosisInsight/insights/INSIGHT
    

    Replace the INSIGHT with the value of insight ID, specified at the end of the URL from the name field for the insight.

    The response body includes details about what behavior GKE has detected with your cluster.

  2. View the list of recommendations for the clusters of a specific zone (for zonal clusters) or a specific region (for regional clusters):

    GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/recommenders/google.container.DiagnosisRecommender/recommendations?filter=recommenderSubtype%20%3D%20SUBTYPE
    

    Replace SUBTYPEwith a recommender subtype, for example, DEPRECATION_K8S_1_23_CERTIFICATE. This limits the output to recommendations of a specified subtype. This flag is optional.

    Or, if you already have a recommendation ID, you can view the recommendation by making the following request:

    GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/recommenders/google.container.DiagnosisRecommender/recommendations/RECOMMENDATION_ID
    

    Replace the RECOMMENDATION_ID with the saved value of associatedRecommendations.recommendation from the response body in Step 1.

    The response body provides guidance on what action you might need to take to optimize your cluster's usage of GKE.

Export insights and recommendations to BigQuery

You can use BigQuery to export and analyze insights and recommendations for your entire organization. To learn more, see Export recommendations to BigQuery.

Resolve recommendations

If you have implemented a recommendation, you can mark the recommendation as resolved in the Google Cloud console. When you mark a recommendation as resolved, it no longer appears to any user in the console. After you resolve the recommendation, if GKE detects the same behavior for this cluster, the Recommender displays the recommendation again. When you resolve a recommendation, it remains discoverable with the Google Cloud CLI and the Recommender API.

You might want to mark a recommendation as resolved because, depending on how the Recommender works, you might continue to see the recommendation for some period of time after you have implemented the recommendation.

To mark a recommendation as resolved, follow the instructions for Viewing insights and recommendations in the Google Cloud console to open the sidebar panel, which has more details. In that panel, click the Mark as resolved button.

Dismiss or restore recommendations

If you don't want to see a recommendation for a cluster in the Google Cloud console anymore, dismiss it. You might do this, for example, if you have assessed the recommendation and you have decided not to implement it.

If you dismiss the recommendation, it doesn't appear for any user viewing the cluster in the console. After you dismiss the recommendation, it doesn't appear again even if GKE detects the same behavior.

When you dismiss a recommendation, you only hide it for all users in the console. The recommendation remains discoverable with the Google Cloud CLI and the Recommender API.

Dismiss a recommendation

To dismiss the recommendation, follow the instructions for Viewing insights and recommendations in the Google Cloud console to open the sidebar panel, which has more details. In that panel, click the Dismiss button.

Restore a dismissed recommendation

You can restore a dismissed recommendation by following the instructions for Restoring a recommendation.

What's next