Skip to content

Commit ad65b49

Browse files
author
chrislovecnm
committed
Enabling two features in beta clusters
This allow pod security policies and binary authorization to be used by both beta private and beta public clusters. Previously these two features where limited to only private clusters, and this commit also removes that functionality from private clusters.
1 parent f34320d commit ad65b49

File tree

15 files changed

+33
-28
lines changed

15 files changed

+33
-28
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,6 @@ To more cleanly handle cases where desired functionality would require complex d
233233

234234
The root module is generated by running `make generate`. Changes to this repository should be made in the [`autogen`](/autogen) directory where appropriate.
235235

236-
Note: The correct sequence to update the repo using autogen functionality is the run `make generate && make generate_docs`. This
237-
will create the various Terraform files, and then generate the Terraform documentation using `terraform-docs`.
238-
239236
## Testing
240237

241238
### Requirements

autogen/cluster_regional.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ resource "google_container_cluster" "primary" {
4242
logging_service = "${var.logging_service}"
4343
monitoring_service = "${var.monitoring_service}"
4444

45-
{% if private_cluster %}
45+
{% if beta_cluster %}
4646
enable_binary_authorization = "${var.enable_binary_authorization}"
4747
pod_security_policy_config = "${var.pod_security_policy_config}"
48-
{% endif %}
48+
{% endif %}
4949
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]
5050

5151
master_auth {

autogen/cluster_zonal.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ resource "google_container_cluster" "zonal_primary" {
4242
logging_service = "${var.logging_service}"
4343
monitoring_service = "${var.monitoring_service}"
4444

45-
{% if private_cluster %}
45+
{% if beta_cluster %}
4646
enable_binary_authorization = "${var.enable_binary_authorization}"
4747
pod_security_policy_config = "${var.pod_security_policy_config}"
48-
{% endif %}
48+
{% endif %}
49+
4950
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]
5051

5152
master_auth {

autogen/variables.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ variable "master_authorized_networks_config" {
8686
default = []
8787
}
8888

89-
{% if private_cluster %}
89+
{% if beta_cluster %}
9090
variable "enable_binary_authorization" {
9191
description = "Enable BinAuthZ Admission controller"
9292
default = false
@@ -99,8 +99,9 @@ variable "pod_security_policy_config" {
9999
"enabled" = false
100100
}]
101101
}
102-
103102
{% endif %}
103+
104+
104105
variable "horizontal_pod_autoscaling" {
105106
description = "Enable horizontal pod autoscaling addon"
106107
default = true

cluster_zonal.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ resource "google_container_cluster" "zonal_primary" {
4242
logging_service = "${var.logging_service}"
4343
monitoring_service = "${var.monitoring_service}"
4444

45+
4546
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]
4647

4748
master_auth {

modules/beta-private-cluster/cluster_zonal.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ resource "google_container_cluster" "zonal_primary" {
4444

4545
enable_binary_authorization = "${var.enable_binary_authorization}"
4646
pod_security_policy_config = "${var.pod_security_policy_config}"
47+
4748
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]
4849

4950
master_auth {

modules/beta-public-cluster/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
122122
| database\_encryption | Application-layer Secrets Encryption settings. Example: database_encryption = [{ state = "ENCRYPTED", key_name = "projects/my-project/locations/global/keyRings/my-ring/cryptoKeys/my-key" }] | list | `<list>` | no |
123123
| description | The description of the cluster | string | `""` | no |
124124
| 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. | string | `"true"` | no |
125+
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
125126
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | string | `"true"` | no |
126127
| http\_load\_balancing | Enable httpload balancer addon | string | `"true"` | no |
127128
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | string | `"0"` | no |
@@ -150,6 +151,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
150151
| node\_pools\_taints | Map of lists containing node taints by node-pool name | map | `<map>` | no |
151152
| node\_version | The Kubernetes version of the node pools. Defaults kubernetes_version (master) variable and can be overridden for individual node pools by setting the `version` key on them. Must be empyty or set the same as master at cluster creation. | string | `""` | no |
152153
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list | `<list>` | no |
154+
| pod\_security\_policy\_config | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. | list | `<list>` | no |
153155
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
154156
| region | The region to host the cluster in (required) | string | n/a | yes |
155157
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | string | `"true"` | no |

modules/beta-public-cluster/cluster_regional.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ resource "google_container_cluster" "primary" {
4242
logging_service = "${var.logging_service}"
4343
monitoring_service = "${var.monitoring_service}"
4444

45+
enable_binary_authorization = "${var.enable_binary_authorization}"
46+
pod_security_policy_config = "${var.pod_security_policy_config}"
4547
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]
4648

4749
master_auth {

modules/beta-public-cluster/cluster_zonal.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ resource "google_container_cluster" "zonal_primary" {
4242
logging_service = "${var.logging_service}"
4343
monitoring_service = "${var.monitoring_service}"
4444

45+
enable_binary_authorization = "${var.enable_binary_authorization}"
46+
pod_security_policy_config = "${var.pod_security_policy_config}"
47+
4548
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]
4649

4750
master_auth {

modules/beta-public-cluster/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ variable "master_authorized_networks_config" {
8686
default = []
8787
}
8888

89+
variable "enable_binary_authorization" {
90+
description = "Enable BinAuthZ Admission controller"
91+
default = false
92+
}
93+
94+
variable "pod_security_policy_config" {
95+
description = "enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created."
96+
97+
default = [{
98+
"enabled" = false
99+
}]
100+
}
101+
89102
variable "horizontal_pod_autoscaling" {
90103
description = "Enable horizontal pod autoscaling addon"
91104
default = true

modules/private-cluster/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
124124
| deploy\_using\_private\_endpoint | (Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | string | `"false"` | no |
125125
| description | The description of the cluster | string | `""` | no |
126126
| 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. | string | `"true"` | no |
127-
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
128127
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | string | `"false"` | no |
129128
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | string | `"false"` | no |
130129
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | string | `"true"` | no |
@@ -155,7 +154,6 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
155154
| node\_pools\_taints | Map of lists containing node taints by node-pool name | map | `<map>` | no |
156155
| node\_version | The Kubernetes version of the node pools. Defaults kubernetes_version (master) variable and can be overridden for individual node pools by setting the `version` key on them. Must be empyty or set the same as master at cluster creation. | string | `""` | no |
157156
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list | `<list>` | no |
158-
| pod\_security\_policy\_config | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. | list | `<list>` | no |
159157
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
160158
| region | The region to host the cluster in (required) | string | n/a | yes |
161159
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | string | `"true"` | no |

modules/private-cluster/cluster_regional.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ resource "google_container_cluster" "primary" {
4242
logging_service = "${var.logging_service}"
4343
monitoring_service = "${var.monitoring_service}"
4444

45-
enable_binary_authorization = "${var.enable_binary_authorization}"
46-
pod_security_policy_config = "${var.pod_security_policy_config}"
4745
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]
4846

4947
master_auth {

modules/private-cluster/cluster_zonal.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ resource "google_container_cluster" "zonal_primary" {
4242
logging_service = "${var.logging_service}"
4343
monitoring_service = "${var.monitoring_service}"
4444

45-
enable_binary_authorization = "${var.enable_binary_authorization}"
46-
pod_security_policy_config = "${var.pod_security_policy_config}"
45+
4746
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]
4847

4948
master_auth {

modules/private-cluster/variables.tf

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,6 @@ variable "master_authorized_networks_config" {
8686
default = []
8787
}
8888

89-
variable "enable_binary_authorization" {
90-
description = "Enable BinAuthZ Admission controller"
91-
default = false
92-
}
93-
94-
variable "pod_security_policy_config" {
95-
description = "enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created."
96-
97-
default = [{
98-
"enabled" = false
99-
}]
100-
}
101-
10289
variable "horizontal_pod_autoscaling" {
10390
description = "Enable horizontal pod autoscaling addon"
10491
default = true

variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ variable "master_authorized_networks_config" {
8686
default = []
8787
}
8888

89+
90+
8991
variable "horizontal_pod_autoscaling" {
9092
description = "Enable horizontal pod autoscaling addon"
9193
default = true

0 commit comments

Comments
 (0)