Skip to content

Commit 7fc3b48

Browse files
authored
feat: Update fields for ACM and Config Sync to bring them to feature parity (#635)
1 parent 19a9e9c commit 7fc3b48

File tree

12 files changed

+103
-42
lines changed

12 files changed

+103
-42
lines changed

examples/simple_zonal_with_acm/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ module "gke" {
3535
ip_range_pods = var.ip_range_pods
3636
ip_range_services = var.ip_range_services
3737
service_account = "create"
38+
node_pools = [
39+
{
40+
name = "acm-node-pool"
41+
autoscaling = false
42+
auto_upgrade = true
43+
# Trying larger node pool for ACM to prevent against test flakiness
44+
node_count = 4
45+
machine_type = "e2-standard-4"
46+
},
47+
]
3848
}
3949

4050
data "google_client_config" "default" {

modules/acm/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ By default, this module will attempt to download the ACM operator from Google di
4747
| cluster\_endpoint | Kubernetes cluster endpoint. | string | n/a | yes |
4848
| cluster\_name | GCP cluster Name used to reach cluster and which becomes the cluster name in the Config Sync kubernetes custom resource. | string | n/a | yes |
4949
| create\_ssh\_key | Controls whether a key will be generated for Git authentication | bool | `"true"` | no |
50+
| enable\_log\_denies | Whether to enable logging of all denies and dryrun failures for ACM Policy Controller. | bool | `"false"` | no |
5051
| enable\_policy\_controller | Whether to enable the ACM Policy Controller on the cluster | bool | `"true"` | no |
52+
| 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 | `"null"` | no |
5153
| install\_template\_library | Whether to install the default Policy Controller template library | bool | `"true"` | no |
5254
| location | GCP location used to reach cluster. | string | n/a | yes |
5355
| operator\_path | Path to the operator yaml config. If unset, will download from GCS releases. | string | `"null"` | no |
5456
| policy\_dir | Subfolder containing configs in ACM Git repo. If un-set, uses Config Management default. | string | `""` | no |
5557
| project\_id | GCP project_id used to reach cluster. | string | n/a | yes |
5658
| 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 |
5759
| skip\_gcloud\_download | Whether to skip downloading gcloud (assumes gcloud and kubectl already available outside the module) | bool | `"true"` | no |
60+
| source\_format | Configures a non-hierarchical repo if set to 'unstructured'. Uses [ACM defaults](https://cloud.google.com/anthos-config-management/docs/how-to/installing#configuring-config-management-operator) when unset. | string | `""` | no |
5861
| ssh\_auth\_key | Key for Git authentication. Overrides 'create_ssh_key' variable. Can be set using 'file(path/to/file)'-function. | string | `"null"` | no |
5962
| sync\_branch | ACM repo Git branch. If un-set, uses Config Management default. | string | `""` | no |
6063
| sync\_repo | ACM Git repo address | string | n/a | yes |

modules/acm/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ module "acm_operator" {
3232
enable_policy_controller = var.enable_policy_controller
3333
install_template_library = var.install_template_library
3434
skip_gcloud_download = var.skip_gcloud_download
35+
source_format = var.source_format
36+
hierarchy_controller = var.hierarchy_controller
37+
enable_log_denies = var.enable_log_denies
3538

3639
operator_latest_manifest_url = "gs://config-management-release/released/latest/config-management-operator.yaml"
3740
operator_cr_template_path = "${path.module}/templates/acm-config.yml.tpl"

modules/acm/templates/acm-config.yml.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ spec:
88
policyController:
99
enabled: ${enable_policy_controller}
1010
templateLibraryInstalled: ${install_template_library}
11+
logDeniesEnabled: ${enable_log_denies}
1112
git:
1213
syncRepo: ${sync_repo}
1314
secretType: ${secret_type}
1415
${policy_dir_node}
1516
${sync_branch_node}
17+
${source_format_node}
18+
${hierarchy_controller_map_node}

modules/acm/variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,21 @@ variable "skip_gcloud_download" {
9292
type = bool
9393
default = true
9494
}
95+
96+
variable "source_format" {
97+
description = "Configures a non-hierarchical repo if set to 'unstructured'. Uses [ACM defaults](https://cloud.google.com/anthos-config-management/docs/how-to/installing#configuring-config-management-operator) when unset."
98+
type = string
99+
default = ""
100+
}
101+
102+
variable "hierarchy_controller" {
103+
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"
104+
type = map
105+
default = null
106+
}
107+
108+
variable "enable_log_denies" {
109+
description = "Whether to enable logging of all denies and dryrun failures for ACM Policy Controller."
110+
type = bool
111+
default = false
112+
}

modules/config-sync/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ To deploy this config:
5050
| cluster\_endpoint | Kubernetes cluster endpoint. | string | n/a | yes |
5151
| cluster\_name | GCP cluster name used to reach cluster and which becomes the cluster name in the Config Sync kubernetes custom resource. | string | n/a | yes |
5252
| create\_ssh\_key | Controls whether a key will be generated for Git authentication | bool | `"true"` | no |
53+
| hierarchy\_controller | Configurations for Hierarchy Controller. See [Hierarchy Controller docs](https://cloud.google.com/kubernetes-engine/docs/add-on/config-sync/how-to/installing-hierarchy-controller) for more details. | map | `"null"` | no |
5354
| location | GCP location used to reach cluster. | string | n/a | yes |
5455
| operator\_path | Path to the operator yaml config. If unset, will download from GCS releases. | string | `"null"` | no |
5556
| policy\_dir | Subfolder containing configs in ACM Git repo. If un-set, uses Config Management default. | string | `""` | no |
5657
| project\_id | GCP project_id used to reach cluster. | string | n/a | yes |
5758
| secret\_type | credential secret type, passed through to ConfigManagement spec.git.secretType. Overriden to value 'ssh' if `create_ssh_key` is true | string | n/a | yes |
5859
| skip\_gcloud\_download | Whether to skip downloading gcloud (assumes gcloud and kubectl already available outside the module) | bool | `"true"` | no |
60+
| source\_format | Configures a non-hierarchical repo if set to 'unstructured'. Uses [Config Sync defaults](https://cloud.google.com/kubernetes-engine/docs/add-on/config-sync/how-to/installing#configuring-config-management-operator) when unset. | string | `""` | no |
5961
| ssh\_auth\_key | Key for Git authentication. Overrides 'create_ssh_key' variable. Can be set using 'file(path/to/file)'-function. | string | `"null"` | no |
6062
| sync\_branch | ACM repo Git branch. If un-set, uses Config Management default. | string | `""` | no |
6163
| sync\_repo | ACM Git repo address | string | n/a | yes |

modules/config-sync/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ module "configsync_operator" {
3030
secret_type = var.secret_type
3131
ssh_auth_key = var.ssh_auth_key
3232
skip_gcloud_download = var.skip_gcloud_download
33+
source_format = var.source_format
34+
hierarchy_controller = var.hierarchy_controller
3335

3436
operator_latest_manifest_url = "gs://config-management-release/released/latest/config-sync-operator.yaml"
3537
operator_cr_template_path = "${path.module}/templates/config-sync-config.yml.tpl"

modules/config-sync/templates/config-sync-config.yml.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ spec:
1010
secretType: ${secret_type}
1111
${sync_branch_node}
1212
${policy_dir_node}
13+
${source_format_node}
14+
${hierarchy_controller_map_node}

modules/config-sync/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,15 @@ variable "skip_gcloud_download" {
7979
type = bool
8080
default = true
8181
}
82+
83+
variable "source_format" {
84+
description = "Configures a non-hierarchical repo if set to 'unstructured'. Uses [Config Sync defaults](https://cloud.google.com/kubernetes-engine/docs/add-on/config-sync/how-to/installing#configuring-config-management-operator) when unset."
85+
type = string
86+
default = ""
87+
}
88+
89+
variable "hierarchy_controller" {
90+
description = "Configurations for Hierarchy Controller. See [Hierarchy Controller docs](https://cloud.google.com/kubernetes-engine/docs/add-on/config-sync/how-to/installing-hierarchy-controller) for more details."
91+
type = map
92+
default = null
93+
}

modules/k8s-operator-crd-support/main.tf

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
*/
1616

1717
locals {
18-
cluster_endpoint = "https://${var.cluster_endpoint}"
19-
private_key = var.create_ssh_key && var.ssh_auth_key == null ? tls_private_key.k8sop_creds[0].private_key_pem : var.ssh_auth_key
20-
k8sop_creds_secret_key = var.secret_type == "cookiefile" ? "cookie_file" : var.secret_type
21-
should_download_manifest = var.operator_path == null ? true : false
22-
manifest_path = local.should_download_manifest ? "${path.root}/.terraform/tmp/config-management-operator.yaml" : var.operator_path
23-
sync_branch_node = var.sync_branch != "" ? format("syncBranch: %s", var.sync_branch) : ""
24-
policy_dir_node = var.policy_dir != "" ? format("policyDir: %s", var.policy_dir) : ""
18+
cluster_endpoint = "https://${var.cluster_endpoint}"
19+
private_key = var.create_ssh_key && var.ssh_auth_key == null ? tls_private_key.k8sop_creds[0].private_key_pem : var.ssh_auth_key
20+
k8sop_creds_secret_key = var.secret_type == "cookiefile" ? "cookie_file" : var.secret_type
21+
should_download_manifest = var.operator_path == null ? true : false
22+
manifest_path = local.should_download_manifest ? "${path.root}/.terraform/tmp/config-management-operator.yaml" : var.operator_path
23+
sync_branch_node = var.sync_branch != "" ? format("syncBranch: %s", var.sync_branch) : ""
24+
policy_dir_node = var.policy_dir != "" ? format("policyDir: %s", var.policy_dir) : ""
25+
hierarchy_controller_map_node = var.hierarchy_controller == null ? "" : format("hierarchy_controller:\n %s", yamlencode(var.hierarchy_controller))
26+
source_format_node = var.source_format != "" ? format("sourceFormat: %s", var.source_format) : ""
2527
}
2628

2729
module "k8sop_manifest" {
@@ -75,13 +77,16 @@ data "template_file" "k8sop_config" {
7577

7678
template = file(var.operator_cr_template_path)
7779
vars = {
78-
cluster_name = var.cluster_name
79-
sync_repo = var.sync_repo
80-
sync_branch_node = local.sync_branch_node
81-
policy_dir_node = local.policy_dir_node
82-
secret_type = var.create_ssh_key ? "ssh" : var.secret_type
83-
enable_policy_controller = var.enable_policy_controller ? "true" : "false"
84-
install_template_library = var.install_template_library ? "true" : "false"
80+
cluster_name = var.cluster_name
81+
sync_repo = var.sync_repo
82+
sync_branch_node = local.sync_branch_node
83+
policy_dir_node = local.policy_dir_node
84+
secret_type = var.create_ssh_key ? "ssh" : var.secret_type
85+
enable_policy_controller = var.enable_policy_controller ? "true" : "false"
86+
install_template_library = var.install_template_library ? "true" : "false"
87+
source_format_node = local.source_format_node
88+
hierarchy_controller_map_node = local.hierarchy_controller_map_node
89+
enable_log_denies = var.enable_log_denies
8590
}
8691
}
8792

0 commit comments

Comments
 (0)