GKE cluster labels are not configured

Without labels, GKE clusters can be harder to classify, allocate costs for and manage through automation.

Description

Set resource labels on google_container_cluster for the details you use in inventory, such as environment and service.

Potential impact

A cluster without labels can be missed in billing reports and label-based automation.

Remediation

Put your standard keys and values in resource_labels and check required labels at creation. Include an owner label if you need to track the responsible team.

Examples

The example adds environment and service to the cluster. Configure Kubernetes pod labels and IAM permissions separately.

Before

hcl
resource "google_container_cluster" "example" {
  name               = "marcellus-wallace"
  location           = "us-central1-a"
  initial_node_count = 3
}

After

hcl
resource "google_container_cluster" "example" {
  name               = "marcellus-wallace"
  location           = "us-central1-a"
  initial_node_count = 3

  resource_labels = {
    environment = "prod"
    service     = "payments"
  }
}

References