Review GKE network policy support

Configure both Pod traffic policies and the network capability that enforces them.

Description

Kubernetes NetworkPolicy uses Pod and namespace labels to select which connections are allowed. Autopilot and Dataplane V2 have built-in enforcement. For Calico on Standard, also check the add-on and node settings.

Potential impact

Without a policy selecting sensitive Pods, other workloads in the cluster may reach services they do not need.

Remediation

For Calico, set addons_config.network_policy_config.disabled = false, network_policy.enabled = true and provider = "CALICO". Allow required traffic before introducing default-deny policies in stages. Test from both an allowed Pod and a blocked Pod. On an existing cluster, wait for GKE to finish recreating the nodes before testing.

Examples

The examples show only the change to node enforcement. Configure the omitted add-on, deploy the actual NetworkPolicy, and supply the project, network and node count.

Before

hcl
resource "google_container_cluster" "example" {
  name     = "example-cluster"
  location = "asia-northeast3"

  network_policy {
    enabled = false
  }
}

After

hcl
resource "google_container_cluster" "example" {
  name     = "example-cluster"
  location = "asia-northeast3"

  network_policy {
    enabled  = true
    provider = "CALICO"
  }
}

References