Skip to content

Commit

Permalink
GKE L4 ILB Subsetting support (#4626) (#8798)
Browse files Browse the repository at this point in the history
* mark field as updatable

Co-authored-by: upodroid <[email protected]>

* add l4 subsetting support

Co-authored-by: upodroid <[email protected]>

* fix beta guarding

* fix change typo

* add more beta guards

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Mar 30, 2021
1 parent 758fe09 commit d126fb2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/4626.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
container: added `enable_l4_ilb_subsetting` (beta) and `private_ipv6_google_access` fields to `google_container_cluster`
```
42 changes: 42 additions & 0 deletions google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,12 @@ func resourceContainerCluster() *schema.Resource {
Optional: true,
Description: `Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network.`,
},
"private_ipv6_google_access": {
Type: schema.TypeString,
Optional: true,
Description: `The desired state of IPv6 connectivity to Google Services. By default, no private IPv6 access to or from Google Services (all access will be via IPv4).`,
Computed: true,
},

"resource_usage_export_config": {
Type: schema.TypeList,
Expand Down Expand Up @@ -1115,6 +1121,7 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
EnableIntraNodeVisibility: d.Get("enable_intranode_visibility").(bool),
DefaultSnatStatus: expandDefaultSnatStatus(d.Get("default_snat_status")),
DatapathProvider: d.Get("datapath_provider").(string),
PrivateIpv6GoogleAccess: d.Get("private_ipv6_google_access").(string),
},
MasterAuth: expandMasterAuth(d.Get("master_auth")),
ResourceLabels: expandStringMap(d, "resource_labels"),
Expand Down Expand Up @@ -1452,6 +1459,9 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
if err := d.Set("enable_intranode_visibility", cluster.NetworkConfig.EnableIntraNodeVisibility); err != nil {
return fmt.Errorf("Error setting enable_intranode_visibility: %s", err)
}
if err := d.Set("private_ipv6_google_access", cluster.NetworkConfig.PrivateIpv6GoogleAccess); err != nil {
return fmt.Errorf("Error setting private_ipv6_google_access: %s", err)
}
if err := d.Set("authenticator_groups_config", flattenAuthenticatorGroupsConfig(cluster.AuthenticatorGroupsConfig)); err != nil {
return err
}
Expand Down Expand Up @@ -1725,6 +1735,38 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
log.Printf("[INFO] GKE cluster %s Intra Node Visibility has been updated to %v", d.Id(), enabled)
}

if d.HasChange("private_ipv6_google_access") {
req := &containerBeta.UpdateClusterRequest{
Update: &containerBeta.ClusterUpdate{
DesiredPrivateIpv6GoogleAccess: d.Get("private_ipv6_google_access").(string),
},
}
updateF := func() error {
log.Println("[DEBUG] updating private_ipv6_google_access")
name := containerClusterFullName(project, location, clusterName)
clusterUpdateCall := config.NewContainerBetaClient(userAgent).Projects.Locations.Clusters.Update(name, req)
if config.UserProjectOverride {
clusterUpdateCall.Header().Add("X-Goog-User-Project", project)
}
op, err := clusterUpdateCall.Do()
if err != nil {
return err
}

// Wait until it's updated
err = containerOperationWait(config, op, project, location, "updating GKE Private IPv6 Google Access", userAgent, d.Timeout(schema.TimeoutUpdate))
log.Println("[DEBUG] done updating private_ipv6_google_access")
return err
}

// Call update serially.
if err := lockedCall(lockKey, updateF); err != nil {
return err
}

log.Printf("[INFO] GKE cluster %s Private IPv6 Google Access has been updated", d.Id())
}

if d.HasChange("default_snat_status") {
req := &containerBeta.UpdateClusterRequest{
Update: &containerBeta.ClusterUpdate{
Expand Down
3 changes: 2 additions & 1 deletion google/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ resource "google_container_cluster" "with_intranode_visibility" {
name = "%s"
location = "us-central1-a"
initial_node_count = 1
enable_intranode_visibility = true
enable_intranode_visibility = true
}
`, clusterName)
}
Expand All @@ -2284,6 +2284,7 @@ resource "google_container_cluster" "with_intranode_visibility" {
location = "us-central1-a"
initial_node_count = 1
enable_intranode_visibility = false
private_ipv6_google_access = "PRIVATE_IPV6_GOOGLE_ACCESS_BIDIRECTIONAL"
}
`, clusterName)
}
Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ subnetwork in which the cluster's instances are launched.
* `enable_intranode_visibility` - (Optional)
Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network.

* `enable_l4_ilb_subsetting` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
Whether L4ILB Subsetting is enabled for this cluster.

* `private_ipv6_google_access` - (Optional)
The desired state of IPv6 connectivity to Google Services. By default, no private IPv6 access to or from Google Services (all access will be via IPv4).

* `datapath_provider` - (Optional)
The desired datapath provider for this cluster. By default, uses the IPTables-based kube-proxy implementation.

Expand Down

0 comments on commit d126fb2

Please sign in to comment.