Skip to content

Commit

Permalink
Upstream GKE scopes description (hashicorp#4101)
Browse files Browse the repository at this point in the history
* GKE documentation recommends default oauth scope

The `oauth_scopes` section of `google_container_cluster` has generated a lot of confusion since GCP [no longer uses access scopes](https://cloud.google.com/kubernetes-engine/docs/how-to/access-scopes). The [best practice](https://cloud.google.com/compute/docs/access/create-enable-service-accounts-for-instances#best_practices) is to use the `https://www.googleapis.com/auth/cloud-platform` scope and constrain permissions at the service account level. As currently documented, the examples guide the developer down the path of using legacy access scopes. This PR updates the documentation with the recommended configuration.

Related: hashicorp/terraform-provider-google#1962, hashicorp/terraform-provider-google#1817, hashicorp/terraform-provider-google#7391

* Add note to node_config.oauth_scopes pointing to official docs

Co-authored-by: tshak <[email protected]>
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician and tshak committed Oct 14, 2020
1 parent eda2a67 commit fe7540d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .changelog/4101.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
24 changes: 7 additions & 17 deletions website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ resource "google_container_node_pool" "primary_preemptible_nodes" {
}
oauth_scopes = [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/cloud-platform"
]
}
}
Expand All @@ -87,8 +86,7 @@ resource "google_container_cluster" "primary" {
node_config {
oauth_scopes = [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/cloud-platform"
]
metadata = {
Expand Down Expand Up @@ -440,7 +438,7 @@ Minimum CPU platform to be used for NAP created node pools. The instance may be
specified or newer CPU platform. Applicable values are the friendly names of CPU platforms, such
as "Intel Haswell" or "Intel Sandy Bridge".

* `oauth_scopes` - (Optional) Scopes that are used by NAP when creating node pools.
* `oauth_scopes` - (Optional) Scopes that are used by NAP when creating node pools. Use the "https://www.googleapis.com/auth/cloud-platform" scope to grant access to all APIs. It is recommended that you set `service_account` to a non-default service account and grant IAM roles to that service account for only the resources that it needs.

-> `monitoring.write` is always enabled regardless of user input. `monitoring` and `logging.write` may also be enabled depending on the values for `monitoring_service` and `logging_service`.

Expand Down Expand Up @@ -596,18 +594,10 @@ The `node_config` block supports:
for more information.

* `oauth_scopes` - (Optional) The set of Google API scopes to be made available
on all of the node VMs under the "default" service account. These can be
either FQDNs, or scope aliases. The following scopes are necessary to ensure
the correct functioning of the cluster:

* `storage-ro` (`https://www.googleapis.com/auth/devstorage.read_only`),
if the cluster must read private images from GCR.
Note this will grant read access to ALL GCS content unless you also
specify a custom role. See https://cloud.google.com/kubernetes-engine/docs/how-to/access-scopes
* `logging-write` (`https://www.googleapis.com/auth/logging.write`),
if `logging_service` is not `none`.
* `monitoring` (`https://www.googleapis.com/auth/monitoring`),
if `monitoring_service` is not `none`.
on all of the node VMs under the "default" service account.
Use the "https://www.googleapis.com/auth/cloud-platform" scope to grant access to all APIs. It is recommended that you set `service_account` to a non-default service account and grant IAM roles to that service account for only the resources that it needs.

See the [official documentation](https://cloud.google.com/kubernetes-engine/docs/how-to/access-scopes) for information on migrating off of legacy access scopes.

* `preemptible` - (Optional) A boolean that represents whether or not the underlying node VMs
are preemptible. See the [official documentation](https://cloud.google.com/container-engine/docs/preemptible-vm)
Expand Down

0 comments on commit fe7540d

Please sign in to comment.