Skip to content

Commit 0fca886

Browse files
authored
Merge pull request #236 from paulpalamarchuk/add_storage_viewer_role_to_sa
Add 'grant_registry_access' variable to add 'storage.objectViewer'-role to SA
2 parents ca1788c + 7f9559c commit 0fca886

File tree

15 files changed

+76
-0
lines changed

15 files changed

+76
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Extending the adopted spec, each change should have a link to its corresponding
99
## [Unreleased]
1010
### Added
1111

12+
* Added `grant_registry_access` variable to grant Container Registry access to created SA [#236]
1213
* Support for Intranode Visbiility (IV) and Veritical Pod Autoscaling (VPA) beta features [#216]
1314
* Support for Workload Identity beta feature [#234]
1415
* Support for Google Groups based RBAC beta feature [#217]
@@ -169,6 +170,7 @@ Extending the adopted spec, each change should have a link to its corresponding
169170
[v0.3.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.2.0...v0.3.0
170171
[v0.2.0]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/compare/v0.1.0...v0.2.0
171172

173+
[#236]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/236
172174
[#217]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/217
173175
[#234]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/234
174176
[#216]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/216

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
137137
| create\_service\_account | Defines if service account specified to run nodes should be created. | bool | `"true"` | no |
138138
| description | The description of the cluster | string | `""` | no |
139139
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | bool | `"true"` | no |
140+
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
140141
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
141142
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |
142143
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | number | `"0"` | no |

autogen/sa.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
6161
role = "roles/monitoring.viewer"
6262
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
6363
}
64+
65+
resource "google_project_iam_member" "cluster_service_account-gcr" {
66+
count = var.create_service_account && var.grant_registry_access ? 1 : 0
67+
project = var.project_id
68+
role = "roles/storage.objectViewer"
69+
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
70+
}
71+

autogen/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ variable "create_service_account" {
261261
default = true
262262
}
263263

264+
variable "grant_registry_access" {
265+
type = bool
266+
description = "Grants created cluster-specific service account storage.objectViewer role."
267+
default = false
268+
}
269+
264270
variable "service_account" {
265271
type = string
266272
description = "The service account to run nodes as if not overridden in `node_pools`. The create_service_account variable default value (true) will cause a cluster-specific service account to be created."

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
154154
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | bool | `"false"` | no |
155155
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | bool | `"false"` | no |
156156
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool | `"false"` | no |
157+
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
157158
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
158159
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |
159160
| identity\_namespace | Workload Identity namespace | string | `""` | no |

modules/beta-private-cluster/sa.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
6161
role = "roles/monitoring.viewer"
6262
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
6363
}
64+
65+
resource "google_project_iam_member" "cluster_service_account-gcr" {
66+
count = var.create_service_account && var.grant_registry_access ? 1 : 0
67+
project = var.project_id
68+
role = "roles/storage.objectViewer"
69+
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
70+
}
71+

modules/beta-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ variable "create_service_account" {
261261
default = true
262262
}
263263

264+
variable "grant_registry_access" {
265+
type = bool
266+
description = "Grants created cluster-specific service account storage.objectViewer role."
267+
default = false
268+
}
269+
264270
variable "service_account" {
265271
type = string
266272
description = "The service account to run nodes as if not overridden in `node_pools`. The create_service_account variable default value (true) will cause a cluster-specific service account to be created."

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
146146
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
147147
| enable\_intranode\_visibility | Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network | bool | `"false"` | no |
148148
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool | `"false"` | no |
149+
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
149150
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
150151
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |
151152
| identity\_namespace | Workload Identity namespace | string | `""` | no |

modules/beta-public-cluster/sa.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ resource "google_project_iam_member" "cluster_service_account-monitoring_viewer"
6161
role = "roles/monitoring.viewer"
6262
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
6363
}
64+
65+
resource "google_project_iam_member" "cluster_service_account-gcr" {
66+
count = var.create_service_account && var.grant_registry_access ? 1 : 0
67+
project = var.project_id
68+
role = "roles/storage.objectViewer"
69+
member = "serviceAccount:${google_service_account.cluster_service_account[0].email}"
70+
}
71+

modules/beta-public-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ variable "create_service_account" {
261261
default = true
262262
}
263263

264+
variable "grant_registry_access" {
265+
type = bool
266+
description = "Grants created cluster-specific service account storage.objectViewer role."
267+
default = false
268+
}
269+
264270
variable "service_account" {
265271
type = string
266272
description = "The service account to run nodes as if not overridden in `node_pools`. The create_service_account variable default value (true) will cause a cluster-specific service account to be created."

0 commit comments

Comments
 (0)