Skip to content

Commit

Permalink
feat: Make creation of istio-system namespace optional (terraform-goo…
Browse files Browse the repository at this point in the history
…gle-modules#1439)

Use try function for configmap namespace
  • Loading branch information
pib authored Nov 1, 2022
1 parent 1530c87 commit 335c62a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/asm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ To deploy this config:
| channel | The channel to use for this ASM installation. | `string` | `""` | no |
| cluster\_location | The cluster location for this ASM installation. | `string` | n/a | yes |
| cluster\_name | The unique name to identify the cluster in ASM. | `string` | n/a | yes |
| create\_system\_namespace | Determines whether the module creates the istio-system namespace. | `bool` | `true` | no |
| enable\_cni | Determines whether to enable CNI for this ASM installation. Required to use Managed Data Plane (MDP). | `bool` | `false` | no |
| enable\_fleet\_registration | Determines whether the module registers the cluster to the fleet. | `bool` | `false` | no |
| enable\_mesh\_feature | Determines whether the module enables the mesh feature on the fleet. | `bool` | `false` | no |
Expand Down
4 changes: 3 additions & 1 deletion modules/asm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ data "google_container_cluster" "asm" {
}

resource "kubernetes_namespace" "system" {
count = var.create_system_namespace ? 1 : 0

metadata {
name = "istio-system"
}
Expand All @@ -42,7 +44,7 @@ resource "kubernetes_namespace" "system" {
resource "kubernetes_config_map" "asm_options" {
metadata {
name = "asm-options"
namespace = kubernetes_namespace.system.metadata[0].name
namespace = try(kubernetes_namespace.system[0].metadata[0].name, "istio-system")
}

data = {
Expand Down
6 changes: 6 additions & 0 deletions modules/asm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,9 @@ variable "module_depends_on" {
type = list(any)
default = []
}

variable "create_system_namespace" {
description = "Determines whether the module creates the istio-system namespace."
type = bool
default = true
}

0 comments on commit 335c62a

Please sign in to comment.