Description
Calico on GKE Standard needs both the control-plane add-on and enforcement on the nodes. Autopilot and Dataplane V2 have built-in enforcement.
Potential impact
Without a NetworkPolicy that selects the target Pods, other workloads may reach ports they do not need.
Remediation
For Calico, set addons_config.network_policy_config.disabled = false, network_policy.enabled = true and provider = "CALICO". Deploy a NetworkPolicy for the required traffic. A maintenance window can delay node recreation on an existing cluster. Once the nodes are ready, test one connection that should succeed and one that should be blocked.
Examples
Both examples enable the add-on. The second also enables node enforcement and specifies VPC_NATIVE. An existing routes-based cluster must migrate to a separate cluster to change its network mode.
Before
resource "google_container_cluster" "cluster" {
name = "marcellus-wallace"
location = "us-central1-a"
initial_node_count = 3
network_policy {
enabled = false
}
addons_config {
network_policy_config {
disabled = false
}
}
timeouts {
create = "30m"
update = "40m"
}
}
After
resource "google_container_cluster" "cluster" {
name = "marcellus-wallace"
location = "us-central1-a"
initial_node_count = 3
networking_mode = "VPC_NATIVE"
network_policy {
enabled = true
provider = "CALICO"
}
addons_config {
network_policy_config {
disabled = false
}
}
timeouts {
create = "30m"
update = "40m"
}
}