Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for max pods per node configuration to Composer (beta) #3376

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4873.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
composer: added field `max_pods_per_node` to resource `google_composer_environment` (beta)
```
14 changes: 14 additions & 0 deletions google-beta/resource_composer_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ func resourceComposerEnvironment() *schema.Resource {
DiffSuppressFunc: compareServiceAccountEmailToLink,
Description: `The Google Cloud Platform Service Account to be used by the node VMs. If a service account is not specified, the "default" Compute Engine service account is used. Cannot be updated. If given, note that the service account must have roles/composer.worker for any GCP resources created under the Cloud Composer Environment.`,
},

"max_pods_per_node": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
ForceNew: true,
Description: `The maximum pods per node in the GKE cluster allocated during environment creation. Lowering this value reduces IP address consumption by the Cloud Composer Kubernetes cluster. This value can only be set during environment creation, and only if the environment is VPC-Native. The range of possible values is 8-110, and the default is 32.`,
},
"tags": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -913,6 +921,8 @@ func flattenComposerEnvironmentConfigNodeConfig(nodeCfg *composer.NodeConfig) in
transformed["disk_size_gb"] = nodeCfg.DiskSizeGb
transformed["service_account"] = nodeCfg.ServiceAccount
transformed["oauth_scopes"] = flattenComposerEnvironmentConfigNodeConfigOauthScopes(nodeCfg.OauthScopes)

transformed["max_pods_per_node"] = nodeCfg.MaxPodsPerNode
transformed["tags"] = flattenComposerEnvironmentConfigNodeConfigTags(nodeCfg.Tags)
transformed["ip_allocation_policy"] = flattenComposerEnvironmentConfigNodeConfigIPAllocationPolicy(nodeCfg.IpAllocationPolicy)
return []interface{}{transformed}
Expand Down Expand Up @@ -1153,6 +1163,10 @@ func expandComposerEnvironmentConfigNodeConfig(v interface{}, d *schema.Resource
transformed.ServiceAccount = transformedServiceAccount
}

if transformedMaxPodsPerNode, ok := original["max_pods_per_node"]; ok {
transformed.MaxPodsPerNode = int64(transformedMaxPodsPerNode.(int))
}

var nodeConfigZone string
if v, ok := original["zone"]; ok {
transformedZone, err := expandComposerEnvironmentZone(v, d, config)
Expand Down
5 changes: 5 additions & 0 deletions google-beta/resource_composer_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,11 @@ resource "google_composer_environment" "test" {
zone = "us-central1-a"

service_account = google_service_account.test.name
max_pods_per_node = 33
ip_allocation_policy {
use_ip_aliases = true
cluster_ipv4_cidr_block = "10.0.0.0/16"
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion google-beta/resource_gke_hub_feature_membership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
gkehub "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub/beta"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/composer_environment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ The `node_config` block supports:
Structure is documented below.
Cannot be updated.

* `max_pods_per_node` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
The maximum pods per node in the GKE cluster allocated during environment
creation. Lowering this value reduces IP address consumption by the Cloud
Composer Kubernetes cluster. This value can only be set if the environment is VPC-Native.
The range of possible values is 8-110, and the default is 32.
Cannot be updated.

The `software_config` block supports:

* `airflow_config_overrides` -
Expand Down