Receive cluster notifications

Stay organized with collections Save and categorize content based on your preferences.

This page shows you how to use Pub/Sub to receive notifications about your Google Kubernetes Engine (GKE) clusters.

Overview

When certain events occur that are relevant to your GKE clusters, such as important scheduled upgrades or available security bulletins, GKE publishes notifications about those events as messages to Pub/Sub topics that you configure. You can receive these notifications on a Pub/Sub subscription, integrate with third-party services, and filter for the notification types you want to receive.

To learn more about the benefits of cluster notifications, how notifications work, and why filtering is important, refer to Cluster notifications.

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.

Enable cluster notifications on a new cluster

You can enable GKE cluster notifications on a new cluster using the Google Cloud CLI or the Google Cloud console.

gcloud

To enable cluster notifications on a new cluster, run the following command:

gcloud container clusters create CLUSTER_NAME \
    --region=COMPUTE_REGION \
    --notification-config=pubsub=ENABLED,pubsub-topic=projects/PROJECT_ID/topics/TOPIC_NAME,filter=NOTIFICATION_TYPE

Replace the following:

  • CLUSTER_NAME: the name of your new cluster.
  • COMPUTE_REGION: the compute region for your new cluster. For zonal clusters, use --zone=COMPUTE_ZONE.
  • PROJECT_ID: your Google Cloud project ID.
  • TOPIC_NAME: the name of your Pub/Sub topic.
  • NOTIFICATION_TYPE: a pipe (|) delimited list of the notification types you want to receive. For example, filter="UpgradeEvent|SecurityBulletinEvent" only sends UpgradeEvent and SecurityBulletinEvent notifications, ignoring all other types.

Console

To enable cluster notifications on a new cluster, perform the following:

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

    Go to Google Kubernetes Engine

  2. Click Create.

  3. On the Create cluster dialog, next to GKE Standard, click Configure.

  4. In the navigation pane, in the Cluster section, click Automation.

  5. Select the Enable notifications checkbox.

  6. From the drop-down list, select the Pub/Sub topic you created.

  7. To filter notifications, select the Filter notification types checkbox, and then select the notification types you want to receive.

  8. Continue to configure the cluster as desired.

  9. Click Create.

After enabling notifications, create a Pub/Sub subscription for your topic.

Enable cluster notifications on an existing cluster

You can enable GKE cluster notifications on an existing cluster using the Google Cloud CLI or the Google Cloud console.

gcloud

To enable cluster notifications on an existing cluster, run the following command:

gcloud container clusters update CLUSTER_NAME \
    --region=COMPUTE_REGION \
    --notification-config=pubsub=ENABLED,pubsub-topic=projects/PROJECT_ID/topics/TOPIC_NAME,filter=NOTIFICATION_TYPE

Replace the following:

  • CLUSTER_NAME: the name of your cluster.
  • COMPUTE_REGION: the compute region for your new cluster. For zonal clusters, use --zone=COMPUTE_ZONE..
  • PROJECT_ID: your Google Cloud project ID.
  • TOPIC_NAME: the name of your Pub/Sub topic.
  • NOTIFICATION_TYPE: a pipe (|) delimited list of the notification types you want to receive. For example, filter="UpgradeEvent|SecurityBulletinEvent" only sends UpgradeEvent and SecurityBulletinEvent notifications, ignoring all other types.

Console

To enable cluster notifications on an existing cluster, perform the following:

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

    Go to Google Kubernetes Engine

  2. Click the name of the cluster you want to modify.

  3. In the Automation section, next to Notifications, click Edit notifications.

  4. In the Edit notifications dialog, select the Enable notifications checkbox.

  5. From the drop-down list, select the Pub/Sub topic you created.

  6. To filter notifications, select the Filter notification types checkbox, and then select the notification types you want to receive.

  7. Click Save changes.

After enabling notifications, create a Pub/Sub subscription for your topic.

Filter cluster notifications

You can filter notifications by notification type to ensure that you receive notifications that you want.

You can choose to filter notifications using the following methods:

  • GKE: Specify values for filter in the --notification-config flag, as shown in the previous examples for enabling cluster notifications.
  • Pub/Sub: Configure your Pub/Sub subscription to filter messages when you create a subscription.

Modify existing filters in GKE

To modify your existing GKE cluster notification filters, follow the instructions in Enable notifications on an existing cluster and specify the new notification types to filter in the gcloud command or select the new types in the Google Cloud console.

Disable filters in GKE

You can disable your GKE notification filters and receive all notification types applicable to your cluster using the gcloud CLI or the Google Cloud console.

gcloud

To disable filters using the gcloud CLI, run the following command:

gcloud container clusters update CLUSTER_NAME \
  --region=COMPUTE_REGION \
  --notification-config=pubsub=ENABLED,pubsub-topic=projects/PROJECT_ID/topics/TOPIC_NAME

Console

To disable filters using the Google Cloud console, perform the following:

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

    Go to Google Kubernetes Engine

  2. Click the name of the cluster you want to modify.

  3. In the Automation section, next to Notifications, click Edit notifications.

  4. In the Edit notifications dialog, clear the Filter notification types checkbox.

  5. Click Save changes.

Verify setup for cluster notifications

To verify that notifications are set up correctly for your cluster, you can initiate a node pool upgrade to see if an UpgradeEvent message is sent. You can only manually verify setup for the UpgradeEvent notification type. If your filters are configured to ignore this type, you won't see a message.

You can manually upgrade a specific node pool using the gcloud CLI or the Google Cloud console. For instructions, refer to Manually upgrading a cluster or node pool. If you don't want to change the GKE version on your nodes, you can upgrade to the same version currently on the nodes.

After initiating the upgrade, check your Pub/Sub subscription for a notification message.

Disable cluster notifications

You can disable cluster notifications using the gcloud CLI or the Google Cloud console.

gcloud

To disable notifications using the gcloud CLI, run the following command:

gcloud container clusters update CLUSTER_NAME \
  --region=COMPUTE_REGION \
  --notification-config=pubsub=DISABLED

Console

To disable notifications using the Google Cloud console, perform the following:

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

    Go to Google Kubernetes Engine

  2. Click the name of the cluster you want to modify.

  3. In the Automation section, next to Notifications, click Edit notifications.

  4. In the Edit notifications dialog, clear the Enable notifications checkbox.

  5. Click Save changes.

Optionally, delete the Pub/Sub topic you created for notifications.

What's next