MEDIUM
Source
Trivy
ID
AVD-GCP-0056

Network Policy should be enabled on GKE clusters

Enabling a network policy allows the segregation of network traffic by namespace

Impact

Follow the appropriate remediation steps below to resolve the issue.

Enable network policy

1
2
3
4
5
6
7
resource "google_container_cluster" "good_example" {
  name     = "my-gke-cluster"
  location = "us-central1"
  network_policy {
    enabled = true
  }
}
1
2
3
4
5
resource "google_container_cluster" "good_example" {
  name             = "my-gke-cluster"
  location         = "us-central1"
  enable_autopilot = true
}
1
2
3
4
5
resource "google_container_cluster" "good_example" {
  name              = "my-gke-cluster"
  location          = "us-central1"
  datapath_provider = "ADVANCED_DATAPATH"
}