Skip to content

Commit 41a0c83

Browse files
feat: Use ADVANCED_DATAPATH (aka. Dataplane V2) for safer-cluster modules (#1085)
BREAKING CHANGE: safer-cluster modules now use ADVANCED_DATAPATH by default. Set `datapath_provider` to `DATAPATH_PROVIDER_UNSPECIFIED` to continue using Dataplane v1.
1 parent 5603718 commit 41a0c83

File tree

9 files changed

+58
-9
lines changed

9 files changed

+58
-9
lines changed

autogen/safer-cluster/main.tf.tmpl

+9-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ module "gke" {
6565
// NetworkPolicies need to be configured in every namespace. The network
6666
// policies should be under the control of a cental cluster management team,
6767
// rather than individual teams.
68-
network_policy = true
68+
//
69+
// NOTE: Dataplane-V2 conflicts with the Calico network policy add-on because
70+
// it provides redundant NetworkPolicy capabilities. If V2 is enabled, the
71+
// Calico add-on should be disabled.
72+
network_policy = var.datapath_provider == "ADVANCED_DATAPATH" ? false : true
73+
74+
// Default to the recommended Dataplane V2 which enables NetworkPolicies and
75+
// allows for network policy logging of allowed and denied requests to Pods.
76+
datapath_provider = var.datapath_provider
6977

7078
maintenance_start_time = var.maintenance_start_time
7179

autogen/safer-cluster/variables.tf.tmpl

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ variable "http_load_balancing" {
9595
default = true
9696
}
9797

98+
variable "datapath_provider" {
99+
type = string
100+
description = "The desired datapath provider for this cluster. By default, `ADVANCED_DATAPATH` enables Dataplane-V2 feature. `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation as a fallback since upgrading to V2 requires a cluster re-creation."
101+
default = "ADVANCED_DATAPATH"
102+
}
103+
98104
variable "maintenance_start_time" {
99105
type = string
100106
description = "Time window specified for daily maintenance operations in RFC3339 format"

modules/safer-cluster-update-variant/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ For simplicity, we suggest using `roles/container.admin` and
208208
| compute\_engine\_service\_account | Use the given service account for nodes rather than creating a new dedicated service account. | `string` | `""` | no |
209209
| config\_connector | (Beta) Whether ConfigConnector is enabled for this cluster. | `bool` | `false` | no |
210210
| database\_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key\_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key\_name is the name of a CloudKMS key. | `list(object({ state = string, key_name = string }))` | <pre>[<br> {<br> "key_name": "",<br> "state": "DECRYPTED"<br> }<br>]</pre> | no |
211+
| datapath\_provider | The desired datapath provider for this cluster. By default, `ADVANCED_DATAPATH` enables Dataplane-V2 feature. `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation as a fallback since upgrading to V2 requires a cluster re-creation. | `string` | `"ADVANCED_DATAPATH"` | no |
211212
| default\_max\_pods\_per\_node | The maximum number of pods to schedule per node | `number` | `110` | no |
212213
| description | The description of the cluster | `string` | `""` | no |
213214
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |

modules/safer-cluster-update-variant/main.tf

+9-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ module "gke" {
6161
// NetworkPolicies need to be configured in every namespace. The network
6262
// policies should be under the control of a cental cluster management team,
6363
// rather than individual teams.
64-
network_policy = true
64+
//
65+
// NOTE: Dataplane-V2 conflicts with the Calico network policy add-on because
66+
// it provides redundant NetworkPolicy capabilities. If V2 is enabled, the
67+
// Calico add-on should be disabled.
68+
network_policy = var.datapath_provider == "ADVANCED_DATAPATH" ? false : true
69+
70+
// Default to the recommended Dataplane V2 which enables NetworkPolicies and
71+
// allows for network policy logging of allowed and denied requests to Pods.
72+
datapath_provider = var.datapath_provider
6573

6674
maintenance_start_time = var.maintenance_start_time
6775

modules/safer-cluster-update-variant/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ variable "http_load_balancing" {
9595
default = true
9696
}
9797

98+
variable "datapath_provider" {
99+
type = string
100+
description = "The desired datapath provider for this cluster. By default, `ADVANCED_DATAPATH` enables Dataplane-V2 feature. `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation as a fallback since upgrading to V2 requires a cluster re-creation."
101+
default = "ADVANCED_DATAPATH"
102+
}
103+
98104
variable "maintenance_start_time" {
99105
type = string
100106
description = "Time window specified for daily maintenance operations in RFC3339 format"

modules/safer-cluster/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ For simplicity, we suggest using `roles/container.admin` and
208208
| compute\_engine\_service\_account | Use the given service account for nodes rather than creating a new dedicated service account. | `string` | `""` | no |
209209
| config\_connector | (Beta) Whether ConfigConnector is enabled for this cluster. | `bool` | `false` | no |
210210
| database\_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key\_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key\_name is the name of a CloudKMS key. | `list(object({ state = string, key_name = string }))` | <pre>[<br> {<br> "key_name": "",<br> "state": "DECRYPTED"<br> }<br>]</pre> | no |
211+
| datapath\_provider | The desired datapath provider for this cluster. By default, `ADVANCED_DATAPATH` enables Dataplane-V2 feature. `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation as a fallback since upgrading to V2 requires a cluster re-creation. | `string` | `"ADVANCED_DATAPATH"` | no |
211212
| default\_max\_pods\_per\_node | The maximum number of pods to schedule per node | `number` | `110` | no |
212213
| description | The description of the cluster | `string` | `""` | no |
213214
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |

modules/safer-cluster/main.tf

+9-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ module "gke" {
6161
// NetworkPolicies need to be configured in every namespace. The network
6262
// policies should be under the control of a cental cluster management team,
6363
// rather than individual teams.
64-
network_policy = true
64+
//
65+
// NOTE: Dataplane-V2 conflicts with the Calico network policy add-on because
66+
// it provides redundant NetworkPolicy capabilities. If V2 is enabled, the
67+
// Calico add-on should be disabled.
68+
network_policy = var.datapath_provider == "ADVANCED_DATAPATH" ? false : true
69+
70+
// Default to the recommended Dataplane V2 which enables NetworkPolicies and
71+
// allows for network policy logging of allowed and denied requests to Pods.
72+
datapath_provider = var.datapath_provider
6573

6674
maintenance_start_time = var.maintenance_start_time
6775

modules/safer-cluster/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ variable "http_load_balancing" {
9595
default = true
9696
}
9797

98+
variable "datapath_provider" {
99+
type = string
100+
description = "The desired datapath provider for this cluster. By default, `ADVANCED_DATAPATH` enables Dataplane-V2 feature. `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation as a fallback since upgrading to V2 requires a cluster re-creation."
101+
default = "ADVANCED_DATAPATH"
102+
}
103+
98104
variable "maintenance_start_time" {
99105
type = string
100106
description = "Time window specified for daily maintenance operations in RFC3339 format"

test/integration/safer_cluster/controls/gcloud.rb

+11-6
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,21 @@
5757
"kubernetesDashboard" => including(
5858
"disabled" => true,
5959
),
60-
"networkPolicyConfig" => {},
60+
"networkPolicyConfig" => including(
61+
"disabled" => true,
62+
),
6163
)
6264
end
6365
end
6466

65-
it "has network policy enabled" do
66-
expect(data['networkPolicy']).to eq({
67-
"enabled" => true,
68-
"provider" => "CALICO",
69-
})
67+
it "has network policy disabled" do
68+
expect(data['networkPolicy']).to be_nil
69+
end
70+
71+
it "has dataplane v2 enabled" do
72+
expect(data['networkConfig']).to include(
73+
"datapathProvider" => "ADVANCED_DATAPATH"
74+
)
7075
end
7176

7277
it "has binary authorization" do

0 commit comments

Comments
 (0)