Merge branch 'master' into kmucha555/f_apigee_env_deployment
This commit is contained in:
commit
798fd6cc54
|
@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
### BLUEPRINTS
|
||||
|
||||
- [[#924](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/924)] Fix formatting for gcloud dataflow job launch command ([aymanfarhat](https://github.com/aymanfarhat)) <!-- 2022-10-27 14:07:25+00:00 -->
|
||||
- [[#921](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/921)] Align documentation, move glb blueprint ([ludoo](https://github.com/ludoo)) <!-- 2022-10-26 12:31:04+00:00 -->
|
||||
- [[#915](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/915)] TFE OIDC with GCP WIF blueprint added ([averbuks](https://github.com/averbuks)) <!-- 2022-10-25 19:06:43+00:00 -->
|
||||
- [[#899](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/899)] Static routes monitoring metrics added to network dashboard BP ([maunope](https://github.com/maunope)) <!-- 2022-10-25 11:36:39+00:00 -->
|
||||
- [[#909](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/909)] GCS2BQ: Move images and templates in sub-folders ([lcaggio](https://github.com/lcaggio)) <!-- 2022-10-25 08:31:25+00:00 -->
|
||||
|
@ -41,6 +43,7 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
### DOCUMENTATION
|
||||
|
||||
- [[#921](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/921)] Align documentation, move glb blueprint ([ludoo](https://github.com/ludoo)) <!-- 2022-10-26 12:31:04+00:00 -->
|
||||
- [[#898](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/898)] Update FAST bootstrap README.md ([juliocc](https://github.com/juliocc)) <!-- 2022-10-19 15:15:36+00:00 -->
|
||||
- [[#878](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/878)] chore: update cft and fabric ([bharathkkb](https://github.com/bharathkkb)) <!-- 2022-10-12 15:38:06+00:00 -->
|
||||
- [[#863](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/863)] Fabric vs CFT doc ([ludoo](https://github.com/ludoo)) <!-- 2022-10-07 12:47:51+00:00 -->
|
||||
|
@ -68,6 +71,7 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
### MODULES
|
||||
|
||||
- [[#923](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/923)] Fix service account creation error in gke nodepool module ([ludoo](https://github.com/ludoo)) <!-- 2022-10-27 15:12:05+00:00 -->
|
||||
- [[#908](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/908)] GKE module: autopilot fixes ([ludoo](https://github.com/ludoo)) <!-- 2022-10-25 21:33:49+00:00 -->
|
||||
- [[#906](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/906)] GKE module: add managed_prometheus to features ([apichick](https://github.com/apichick)) <!-- 2022-10-25 21:18:50+00:00 -->
|
||||
- [[#916](https://github.com/GoogleCloudPlatform/cloud-foundation-fabric/pull/916)] Add support for DNS routing policies ([juliocc](https://github.com/juliocc)) <!-- 2022-10-25 14:20:53+00:00 -->
|
||||
|
|
|
@ -151,7 +151,7 @@ Run the following command to start the dataflow job:
|
|||
--region europe-west1 \
|
||||
--disable-public-ips \
|
||||
--subnetwork https://www.googleapis.com/compute/v1/projects/$SERVICE_PROJECT_ID/regions/europe-west1/subnetworks/subnet \
|
||||
--staging-location gs://$PREFIX-df-tmp\
|
||||
--staging-location gs://$PREFIX-df-tmp \
|
||||
--service-account-email df-loading@$SERVICE_PROJECT_ID.iam.gserviceaccount.com \
|
||||
--parameters \
|
||||
javascriptTextTransformFunctionName=transform,\
|
||||
|
|
|
@ -104,7 +104,9 @@ module "cluster_nodepool" {
|
|||
cluster_name = module.cluster.name
|
||||
location = var.zone
|
||||
name = "nodepool"
|
||||
service_account = {}
|
||||
service_account = {
|
||||
create = true
|
||||
}
|
||||
node_count = { initial = 3 }
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,9 @@ module "cluster_nodepools" {
|
|||
location = var.region
|
||||
name = "nodepool-${each.key}"
|
||||
node_count = { initial = 1 }
|
||||
service_account = {}
|
||||
service_account = {
|
||||
create = true
|
||||
}
|
||||
tags = ["${each.key}-node"]
|
||||
}
|
||||
|
||||
|
|
|
@ -225,5 +225,7 @@ module "cluster-1-nodepool-1" {
|
|||
project_id = module.project-svc-gke.project_id
|
||||
location = module.cluster-1.0.location
|
||||
cluster_name = module.cluster-1.0.name
|
||||
service_account = {}
|
||||
service_account = {
|
||||
create = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ module "cluster_1_nodepool" {
|
|||
location = "europe-west1"
|
||||
name = "nodepool"
|
||||
node_count = { initial = 1 }
|
||||
service_account = {}
|
||||
service_account = { create = true }
|
||||
tags = ["cluster-1-node"]
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ module "cluster_2_nodepool" {
|
|||
location = "europe-west4"
|
||||
name = "nodepool"
|
||||
node_count = { initial = 1 }
|
||||
service_account = {}
|
||||
service_account = { create = true }
|
||||
tags = ["cluster-2-node"]
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,13 @@ module "cluster-1-nodepool-1" {
|
|||
|
||||
### Internally managed service account
|
||||
|
||||
To have the module auto-create a service account for the nodes, define the `service_account` variable without setting its `email` attribute. You can then specify service account scopes, or use the default. The service account resource and email (in both plain and IAM formats) are then available in outputs to assign IAM roles from your own code.
|
||||
There are three different approaches to defining the nodes service account, all depending on the `service_account` variable where the `create` attribute controls creation of a new service account by this module, and the `email` attribute controls the actual service account to use.
|
||||
|
||||
If you create a new service account, its resource and email (in both plain and IAM formats) are then available in outputs to reference it in other modules or resources.
|
||||
|
||||
#### GCE default service account
|
||||
|
||||
To use the GCE default service account, you can ignore the variable which is equivalent to `{ create = null, email = null }`.
|
||||
|
||||
```hcl
|
||||
module "cluster-1-nodepool-1" {
|
||||
|
@ -30,7 +36,44 @@ module "cluster-1-nodepool-1" {
|
|||
cluster_name = "cluster-1"
|
||||
location = "europe-west1-b"
|
||||
name = "nodepool-1"
|
||||
service_account = {}
|
||||
}
|
||||
# tftest modules=1 resources=1
|
||||
```
|
||||
|
||||
#### Externally defined service account
|
||||
|
||||
To use an existing service account, pass in just the `email` attribute.
|
||||
|
||||
```hcl
|
||||
module "cluster-1-nodepool-1" {
|
||||
source = "./fabric/modules/gke-nodepool"
|
||||
project_id = "myproject"
|
||||
cluster_name = "cluster-1"
|
||||
location = "europe-west1-b"
|
||||
name = "nodepool-1"
|
||||
service_account = {
|
||||
email = "foo-bar@myproject.iam.gserviceaccount.com"
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=1
|
||||
```
|
||||
|
||||
#### Auto-created service account
|
||||
|
||||
To have the module create a service account, set the `create` attribute to `true` and optionally pass the desired account id in `email`.
|
||||
|
||||
```hcl
|
||||
module "cluster-1-nodepool-1" {
|
||||
source = "./fabric/modules/gke-nodepool"
|
||||
project_id = "myproject"
|
||||
cluster_name = "cluster-1"
|
||||
location = "europe-west1-b"
|
||||
name = "nodepool-1"
|
||||
service_account = {
|
||||
create = true
|
||||
# optional
|
||||
email = "spam-eggs"
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=2
|
||||
```
|
||||
|
@ -53,10 +96,10 @@ module "cluster-1-nodepool-1" {
|
|||
| [nodepool_config](variables.tf#L109) | Nodepool-level configuration. | <code title="object({ autoscaling = optional(object({ location_policy = optional(string) max_node_count = optional(number) min_node_count = optional(number) use_total_nodes = optional(bool, false) })) management = optional(object({ auto_repair = optional(bool) auto_upgrade = optional(bool) })) upgrade_settings = optional(object({ max_surge = number max_unavailable = number })) })">object({…})</code> | | <code>null</code> |
|
||||
| [pod_range](variables.tf#L131) | Pod secondary range configuration. | <code title="object({ secondary_pod_range = object({ cidr = optional(string) create = optional(bool) name = string }) })">object({…})</code> | | <code>null</code> |
|
||||
| [reservation_affinity](variables.tf#L148) | Configuration of the desired reservation which instances could take capacity from. | <code title="object({ consume_reservation_type = string key = optional(string) values = optional(list(string)) })">object({…})</code> | | <code>null</code> |
|
||||
| [service_account](variables.tf#L158) | Nodepool service account. If this variable is set to null, the default GCE service account will be used. If set and email is null, a service account will be created. If scopes are null a default will be used. | <code title="object({ email = optional(string) oauth_scopes = optional(list(string)) })">object({…})</code> | | <code>null</code> |
|
||||
| [sole_tenant_nodegroup](variables.tf#L167) | Sole tenant node group. | <code>string</code> | | <code>null</code> |
|
||||
| [tags](variables.tf#L173) | Network tags applied to nodes. | <code>list(string)</code> | | <code>null</code> |
|
||||
| [taints](variables.tf#L179) | Kubernetes taints applied to all nodes. | <code title="list(object({ key = string value = string effect = string }))">list(object({…}))</code> | | <code>null</code> |
|
||||
| [service_account](variables.tf#L158) | Nodepool service account. If this variable is set to null, the default GCE service account will be used. If set and email is null, a service account will be created. If scopes are null a default will be used. | <code title="object({ create = optional(bool, false) email = optional(string, null) oauth_scopes = optional(list(string), null) })">object({…})</code> | | <code>{}</code> |
|
||||
| [sole_tenant_nodegroup](variables.tf#L169) | Sole tenant node group. | <code>string</code> | | <code>null</code> |
|
||||
| [tags](variables.tf#L175) | Network tags applied to nodes. | <code>list(string)</code> | | <code>null</code> |
|
||||
| [taints](variables.tf#L181) | Kubernetes taints applied to all nodes. | <code title="list(object({ key = string value = string effect = string }))">list(object({…}))</code> | | <code>null</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
|
@ -31,17 +31,14 @@ locals {
|
|||
)
|
||||
# if no attributes passed for service account, use the GCE default
|
||||
# if no email specified, create service account
|
||||
service_account_create = (
|
||||
var.service_account != null && try(var.service_account.email, null) == null
|
||||
)
|
||||
service_account_email = (
|
||||
local.service_account_create
|
||||
var.service_account.create
|
||||
? google_service_account.service_account[0].email
|
||||
: try(var.service_account.email, null)
|
||||
: var.service_account.email
|
||||
)
|
||||
service_account_scopes = (
|
||||
try(var.service_account.scopes, null) != null
|
||||
? var.service_account.scopes
|
||||
var.service_account.oauth_scopes != null
|
||||
? var.service_account.oauth_scopes
|
||||
: [
|
||||
"https://www.googleapis.com/auth/devstorage.read_only",
|
||||
"https://www.googleapis.com/auth/logging.write",
|
||||
|
@ -60,9 +57,13 @@ locals {
|
|||
}
|
||||
|
||||
resource "google_service_account" "service_account" {
|
||||
count = local.service_account_create ? 1 : 0
|
||||
count = var.service_account.create ? 1 : 0
|
||||
project = var.project_id
|
||||
account_id = "tf-gke-${var.name}"
|
||||
account_id = (
|
||||
var.service_account.email != null
|
||||
? split("@", var.service_account.email)[0]
|
||||
: "tf-gke-${var.name}"
|
||||
)
|
||||
display_name = "Terraform GKE ${var.cluster_name} ${var.name}."
|
||||
}
|
||||
|
||||
|
|
|
@ -158,10 +158,12 @@ variable "reservation_affinity" {
|
|||
variable "service_account" {
|
||||
description = "Nodepool service account. If this variable is set to null, the default GCE service account will be used. If set and email is null, a service account will be created. If scopes are null a default will be used."
|
||||
type = object({
|
||||
email = optional(string)
|
||||
oauth_scopes = optional(list(string))
|
||||
create = optional(bool, false)
|
||||
email = optional(string, null)
|
||||
oauth_scopes = optional(list(string), null)
|
||||
})
|
||||
default = null
|
||||
default = {}
|
||||
nullable = false
|
||||
}
|
||||
|
||||
variable "sole_tenant_nodegroup" {
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
resource "google_service_account" "test" {
|
||||
project = "my-project"
|
||||
account_id = "gke-nodepool-test"
|
||||
display_name = "Test Service Account"
|
||||
}
|
||||
|
||||
module "test" {
|
||||
source = "../../../../modules/gke-nodepool"
|
||||
project_id = "my-project"
|
||||
|
@ -29,7 +35,10 @@ module "test" {
|
|||
nodepool_config = var.nodepool_config
|
||||
pod_range = var.pod_range
|
||||
reservation_affinity = var.reservation_affinity
|
||||
service_account = var.service_account
|
||||
service_account = {
|
||||
create = var.service_account_create
|
||||
email = google_service_account.test.email
|
||||
}
|
||||
sole_tenant_nodegroup = var.sole_tenant_nodegroup
|
||||
tags = var.tags
|
||||
taints = var.taints
|
||||
|
|
|
@ -65,9 +65,9 @@ variable "reservation_affinity" {
|
|||
default = null
|
||||
}
|
||||
|
||||
variable "service_account" {
|
||||
type = any
|
||||
default = null
|
||||
variable "service_account_create" {
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "sole_tenant_nodegroup" {
|
||||
|
|
|
@ -21,9 +21,9 @@ def test_defaults(plan_runner):
|
|||
|
||||
|
||||
def test_service_account(plan_runner):
|
||||
_, resources = plan_runner(service_account='{email="foo@example.org"}')
|
||||
_, resources = plan_runner()
|
||||
assert len(resources) == 1
|
||||
_, resources = plan_runner(service_account='{}')
|
||||
_, resources = plan_runner(service_account_create='true')
|
||||
assert len(resources) == 2
|
||||
assert 'google_service_account' in [r['type'] for r in resources]
|
||||
|
||||
|
|
Loading…
Reference in New Issue