Skip to content

Commit 1173518

Browse files
authored
feat(TPG>=4.32.0)!: Support enabling Policy Controller mutations (#1665)
1 parent 36c02c8 commit 1173518

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

modules/acm/README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This module installs [Anthos Config Management](https://cloud.google.com/anthos-config-management/docs/) (ACM) in a Kubernetes cluster.
44

55
Specifically, this module automates the following steps for [installing ACM](https://cloud.google.com/anthos-config-management/docs/how-to/installing):
6+
67
1. Enabling the ACM feature on the fleet
78
2. Registering the cluster to the fleet
89
3. Optionally, generating an SSH key for accessing Git and providing it to the Operator
@@ -11,6 +12,7 @@ Specifically, this module automates the following steps for [installing ACM](htt
1112
6. Optionally, create and configure a Google Cloud Service Account for writing ACM metrics to Cloud Monitoring
1213

1314
## Fleet feature
15+
1416
Only the first cluster in a fleet should activate the ACM fleet feature.
1517

1618
Other clusters should disable feature activation by setting `enable_fleet_feature = false`.
@@ -46,9 +48,10 @@ module "acm" {
4648
```
4749

4850
To deploy this config:
51+
4952
1. Configure the [Kubernetes Provider](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs) for the target cluster, for example:
5053

51-
```
54+
```tf
5255
provider "kubernetes" {
5356
host = "https://${module.gke.endpoint}"
5457
token = data.google_client_config.default.access_token
@@ -58,13 +61,13 @@ provider "kubernetes" {
5861
data "google_client_config" "default" {}
5962
```
6063

61-
2. Run `terraform apply`
62-
3. Inspect the `git_creds_public` [output](#outputs) to retrieve the public key used for accessing Git. Whitelist this key for access to your Git repo. Instructions for some popular Git hosting providers are included for convenience:
64+
1. Run `terraform apply`
65+
1. Inspect the `git_creds_public` [output](#outputs) to retrieve the public key used for accessing Git. Whitelist this key for access to your Git repo. Instructions for some popular Git hosting providers are included for convenience:
6366

64-
* [Cloud Souce Repositories](https://cloud.google.com/source-repositories/docs/authentication#ssh)
65-
* [Bitbucket](https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html)
66-
* [GitHub](https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/)
67-
* [Gitlab](https://docs.gitlab.com/ee/ssh/)
67+
* [Cloud Souce Repositories](https://cloud.google.com/source-repositories/docs/authentication#ssh)
68+
* [Bitbucket](https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html)
69+
* [GitHub](https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/)
70+
* [Gitlab](https://docs.gitlab.com/ee/ssh/)
6871

6972
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
7073
## Inputs
@@ -80,14 +83,15 @@ data "google_client_config" "default" {}
8083
| enable\_fleet\_feature | Whether to enable the ACM feature on the fleet. | `bool` | `true` | no |
8184
| enable\_fleet\_registration | Whether to create a new membership. | `bool` | `true` | no |
8285
| enable\_log\_denies | Whether to enable logging of all denies and dryrun failures for ACM Policy Controller. | `bool` | `false` | no |
86+
| enable\_mutation | Whether to enable mutations for ACM Policy Controller. | `bool` | `false` | no |
8387
| enable\_policy\_controller | Whether to enable the ACM Policy Controller on the cluster | `bool` | `true` | no |
8488
| enable\_referential\_rules | Enables referential constraints which reference another object in it definition and are therefore eventually consistent. | `bool` | `true` | no |
8589
| hierarchy\_controller | Configurations for Hierarchy Controller. See [Hierarchy Controller docs](https://cloud.google.com/anthos-config-management/docs/how-to/installing-hierarchy-controller) for more details | `map(any)` | `null` | no |
8690
| https\_proxy | URL for the HTTPS proxy to be used when communicating with the Git repo. | `string` | `null` | no |
8791
| install\_template\_library | Whether to install the default Policy Controller template library | `bool` | `true` | no |
8892
| location | GCP location used to reach cluster. | `string` | n/a | yes |
8993
| metrics\_gcp\_sa\_name | The name of the Google service account for ACM metrics writing | `string` | `"acm-metrics-writer"` | no |
90-
| policy\_bundles | A list of Policy Controller policy bundles git urls (example: https://github.com/GoogleCloudPlatform/acm-policy-controller-library.git/bundles/policy-essentials-v2022) to install on the cluster. | `list(string)` | `[]` | no |
94+
| policy\_bundles | A list of Policy Controller policy bundles git urls (example: <https://github.com/GoogleCloudPlatform/acm-policy-controller-library.git/bundles/policy-essentials-v2022>) to install on the cluster. | `list(string)` | `[]` | no |
9195
| policy\_dir | Subfolder containing configs in ACM Git repo. If un-set, uses Config Management default. | `string` | `""` | no |
9296
| project\_id | GCP project\_id used to reach cluster. | `string` | n/a | yes |
9397
| secret\_type | git authentication secret type, is passed through to ConfigManagement spec.git.secretType. Overriden to value 'ssh' if `create_ssh_key` is true | `string` | `"ssh"` | no |

modules/acm/feature.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ resource "google_gke_hub_feature_membership" "main" {
6060

6161
content {
6262
enabled = true
63+
mutation_enabled = var.enable_mutation
6364
referential_rules_enabled = var.enable_referential_rules
6465
template_library_installed = var.install_template_library
6566
log_denies_enabled = var.enable_log_denies

modules/acm/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ variable "enable_log_denies" {
134134
default = false
135135
}
136136

137+
variable "enable_mutation" {
138+
description = "Whether to enable mutations for ACM Policy Controller."
139+
type = bool
140+
default = false
141+
}
142+
137143
# Hierarchy Controller config
138144
variable "hierarchy_controller" {
139145
description = "Configurations for Hierarchy Controller. See [Hierarchy Controller docs](https://cloud.google.com/anthos-config-management/docs/how-to/installing-hierarchy-controller) for more details"

modules/acm/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ terraform {
2929
required_providers {
3030
google = {
3131
source = "hashicorp/google"
32-
version = ">= 4.19.0, < 5.0"
32+
version = ">= 4.32.0, < 5.0"
3333
}
3434
google-beta = {
3535
source = "hashicorp/google-beta"
36-
version = ">= 4.19.0, < 5.0"
36+
version = ">= 4.32.0, < 5.0"
3737
}
3838
kubernetes = {
3939
source = "hashicorp/kubernetes"

0 commit comments

Comments
 (0)