-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
125 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,46 @@ 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" { | ||
source = "./fabric/modules/gke-nodepool" | ||
project_id = "myproject" | ||
cluster_name = "cluster-1" | ||
location = "europe-west1-b" | ||
name = "nodepool-1" | ||
} | ||
# 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 = "[email protected]" | ||
} | ||
} | ||
# 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" { | ||
|
@@ -30,7 +69,11 @@ module "cluster-1-nodepool-1" { | |
cluster_name = "cluster-1" | ||
location = "europe-west1-b" | ||
name = "nodepool-1" | ||
service_account = {} | ||
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,9 @@ def test_defaults(plan_runner): | |
|
||
|
||
def test_service_account(plan_runner): | ||
_, resources = plan_runner(service_account='{email="[email protected]"}') | ||
_, 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] | ||
|
||
|