Skip to content

Commit e0b850c

Browse files
authored
feat: add attached-install-mesh arguments (#718)
1 parent 3bde268 commit e0b850c

File tree

5 files changed

+121
-6
lines changed

5 files changed

+121
-6
lines changed

anthos-attached-clusters/kind/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Sandbox Example to Attach a [kind](https://kind.sigs.k8s.io/) Cluster using Terraform
1+
# Sandbox Example to Attach a [kind](https://kind.sigs.k8s.io/) Cluster and install Service Mesh using Terraform
22

33
## Prerequisites
44
The sample is meant just to provide a local example for experimentation. It assumes an environment where [`kind`](https://kind.sigs.k8s.io/) is available and could otherwise be run on the command line, e.g. `kind create cluster`.

anthos-attached-clusters/kind/main.tf

+6
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,19 @@ resource "google_container_attached_cluster" "primary" {
120120
]
121121
}
122122

123+
# Install Cloud Service Mesh
123124
module "install-mesh" {
124125
source = "../modules/attached-install-mesh"
125126

126127
kubeconfig = kind_cluster.cluster.kubeconfig_path
127128
context = local.cluster_context
128129
fleet_id = data.google_project.project.project_id
129130

131+
asmcli_enable_cluster_roles = true
132+
asmcli_enable_cluster_labels = true
133+
asmcli_enable_gcp_components = true
134+
asmcli_enable_namespace_creation = true
135+
130136
depends_on = [
131137
google_container_attached_cluster.primary
132138
]

anthos-attached-clusters/modules/attached-install-mesh/README.md

+21-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ Sample module to install [Google Cloud Service Mesh](https://cloud.google.com/pr
66

77
```
88
module "install-mesh" {
9-
source = "./attached-install-mesh"
9+
source = "github.com/GoogleCloudPlatform/anthos-samples.git//anthos-attached-clusters/modules/attached-install-mesh?ref=3bde26802919539d27ae9295a8b936d7aa827eb3" #TODO: Use ref= release tag e.g. v0.15.4
1010
11-
kubeconfig = kind_cluster.cluster.kubeconfig_path
12-
context = local.cluster_context
13-
fleet_id = data.google_project.project.project_id
11+
kubeconfig = "PATH TO CLUSTER CONTEXT FILE"
12+
context = "CLUSTER CONTEXT"
13+
fleet_id = "FLEET PROJECT ID"
14+
15+
asmcli_enable_cluster_roles = true
16+
asmcli_enable_cluster_labels = true
17+
asmcli_enable_gcp_components = true
18+
asmcli_enable_namespace_creation = true
1419
}
1520
```
1621

@@ -20,7 +25,19 @@ module "install-mesh" {
2025
| Name | Description | Type | Default | Required |
2126
|------|-------------|------|---------|:--------:|
2227
| activate\_service\_account | Set to false to skip running `gcloud auth activate-service-account`. Optional. | `bool` | `true` | no |
28+
| asmcli\_additional\_arguments | asmcli: additional arguments | `string` | `null` | no |
29+
| asmcli\_ca | asmcli: certificate authority | `string` | `"mesh_ca"` | no |
2330
| asmcli\_download\_url | Custom asmcli download url. Optional. | `string` | `null` | no |
31+
| asmcli\_enable\_all | asmcli: enable all | `bool` | `false` | no |
32+
| asmcli\_enable\_cluster\_labels | asmcli: enable cluster labels | `bool` | `false` | no |
33+
| asmcli\_enable\_cluster\_roles | asmcli: enable cluster roles | `bool` | `false` | no |
34+
| asmcli\_enable\_gcp\_apis | asmcli: enable gcp apis | `bool` | `false` | no |
35+
| asmcli\_enable\_gcp\_components | asmcli: enable gcp components | `bool` | `false` | no |
36+
| asmcli\_enable\_gcp\_iam\_roles | asmcli: enable gcp iam roles | `bool` | `false` | no |
37+
| asmcli\_enable\_meshconfig\_init | asmcli: enable meshconfig init | `bool` | `false` | no |
38+
| asmcli\_enable\_namespace\_creation | asmcli: enable namespace creation | `bool` | `false` | no |
39+
| asmcli\_enable\_registration | asmcli: enable registration | `bool` | `false` | no |
40+
| asmcli\_verbose | asmcli: verbose | `bool` | `false` | no |
2441
| asmcli\_version | The asmcli version to download. Optional. | `string` | `"1.22"` | no |
2542
| context | The cluster contex. | `string` | n/a | yes |
2643
| fleet\_id | The fleet\_id. | `string` | n/a | yes |

anthos-attached-clusters/modules/attached-install-mesh/main.tf

+16-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,23 @@ locals {
2727
jq_download_url = var.jq_download_url != null ? var.jq_download_url : "https://github.com/stedolan/jq/releases/download/jq-${var.jq_version}/jq-${local.jq_platform}64"
2828
asmcli_download_url = var.asmcli_download_url != null ? var.asmcli_download_url : "https://storage.googleapis.com/csm-artifacts/asm/asmcli_${var.asmcli_version}"
2929

30+
asmcli_options = join("", [
31+
" --ca ${var.asmcli_ca}",
32+
var.asmcli_enable_all ? " --enable_all" : "",
33+
var.asmcli_enable_cluster_roles ? " --enable_cluster_roles" : "",
34+
var.asmcli_enable_cluster_labels ? " --enable_cluster_labels" : "",
35+
var.asmcli_enable_gcp_components ? " --enable_gcp_components" : "",
36+
var.asmcli_enable_gcp_apis ? " --enable_gcp_apis" : "",
37+
var.asmcli_enable_gcp_iam_roles ? " --enable_gcp_iam_roles" : "",
38+
var.asmcli_enable_meshconfig_init ? " --enable_meshconfig_init" : "",
39+
var.asmcli_enable_namespace_creation ? " --enable_namespace_creation" : "",
40+
var.asmcli_enable_registration ? " --enable_registration" : "",
41+
var.asmcli_verbose ? " --verbose" : "",
42+
var.asmcli_additional_arguments != null ? " ${var.asmcli_additional_arguments}" : ""
43+
])
44+
3045
cmd_entrypoint = "${local.gcloud_bin_path}/asmcli"
31-
create_cmd_body = "install --kubeconfig ${var.kubeconfig} --context ${var.context} --fleet_id ${var.fleet_id} --platform multicloud --enable_cluster_labels --enable_namespace_creation --enable_gcp_components --enable_cluster_roles --ca mesh_ca --option attached-cluster"
46+
create_cmd_body = "install --kubeconfig ${var.kubeconfig} --context ${var.context} --fleet_id ${var.fleet_id} --platform multicloud --option attached-cluster${local.asmcli_options}"
3247

3348
wait = length(null_resource.additional_components[*].triggers) + length(
3449
null_resource.gcloud_auth_service_account_key_file[*].triggers,

anthos-attached-clusters/modules/attached-install-mesh/variables.tf

+77
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,80 @@ variable "asmcli_download_url" {
8888
type = string
8989
default = null
9090
}
91+
92+
variable "asmcli_enable_all" {
93+
description = "asmcli: enable all"
94+
type = bool
95+
default = false
96+
}
97+
98+
variable "asmcli_enable_cluster_roles" {
99+
description = "asmcli: enable cluster roles"
100+
type = bool
101+
default = false
102+
}
103+
104+
variable "asmcli_enable_cluster_labels" {
105+
description = "asmcli: enable cluster labels"
106+
type = bool
107+
default = false
108+
}
109+
110+
variable "asmcli_enable_gcp_components" {
111+
description = "asmcli: enable gcp components"
112+
type = bool
113+
default = false
114+
}
115+
116+
variable "asmcli_enable_gcp_apis" {
117+
description = "asmcli: enable gcp apis"
118+
type = bool
119+
default = false
120+
}
121+
122+
variable "asmcli_enable_gcp_iam_roles" {
123+
description = "asmcli: enable gcp iam roles"
124+
type = bool
125+
default = false
126+
}
127+
128+
variable "asmcli_enable_meshconfig_init" {
129+
description = "asmcli: enable meshconfig init"
130+
type = bool
131+
default = false
132+
}
133+
134+
variable "asmcli_enable_namespace_creation" {
135+
description = "asmcli: enable namespace creation"
136+
type = bool
137+
default = false
138+
}
139+
140+
variable "asmcli_enable_registration" {
141+
description = "asmcli: enable registration "
142+
type = bool
143+
default = false
144+
}
145+
146+
variable "asmcli_ca" {
147+
description = "asmcli: certificate authority"
148+
type = string
149+
default = "mesh_ca"
150+
151+
validation {
152+
condition = contains(["mesh_ca", "gcp_cas", "citadel"], var.asmcli_ca)
153+
error_message = "The asmcli_ca value must be one of: mesh_ca, gcp_cas, citadel."
154+
}
155+
}
156+
157+
variable "asmcli_verbose" {
158+
description = "asmcli: verbose"
159+
type = bool
160+
default = false
161+
}
162+
163+
variable "asmcli_additional_arguments" {
164+
description = "asmcli: additional arguments"
165+
type = string
166+
default = null
167+
}

0 commit comments

Comments
 (0)