Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhengzheYang committed Aug 5, 2021
1 parent c9f75b3 commit 76fc426
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion modules/asm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ To deploy this config:
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| asm\_git\_tag | ASM git tag to deploy. This module supports versions `1.8`, `1.9` and `1.10`. You can get the exact `asm_git_tag` by running the command `install_asm --version`. The ASM git tab should be of the form `1.9.3-asm.2+config5`. You can also see all ASM git tags by running `curl https://storage.googleapis.com/csm-artifacts/asm/STABLE_VERSIONS`. You must provide the full and exact git tag. This variable is optional. Leaving it empty (default) will download the latest `install_asm` script for the version provided by the `asm_version` variable. | `string` | `""` | no |
| asm\_version | ASM version to deploy. This module supports versions `1.8`, `1.9` and `1.10`. Available versions are documented in https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages | `string` | `"1.9"` | no |
| asm\_version | ASM version to deploy. This module supports versions `1.8`, `1.9` and `1.10`. Available versions are documented in https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages | `string` | `"1.10"` | no |
| ca | Sets CA option. Possible values are `meshca` or `citadel`. Additional documentation on Citadel is available at https://cloud.google.com/service-mesh/docs/scripted-install/gke-install#installation_with_citadel_as_the_ca. | `string` | `"meshca"` | no |
| ca\_certs | Sets CA certificate file paths when `ca` is set to `citadel`. These values must be provided when using Citadel as CA. Additional documentation on Citadel is available at https://cloud.google.com/service-mesh/docs/scripted-install/gke-install#installation_with_citadel_as_the_ca. | `map(any)` | `{}` | no |
| cluster\_endpoint | The GKE cluster endpoint. | `string` | n/a | yes |
Expand Down
6 changes: 5 additions & 1 deletion modules/asm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ locals {
root_cert = lookup(var.ca_certs, "root_cert", "none")
cert_chain = lookup(var.ca_certs, "cert_chain", "none")
revision_name_string = (var.revision_name == "" ? "none" : var.revision_name)
asm_minor_version = tonumber(split(".", var.asm_version)[1])
# https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages/blob/1cf61b679cd369f42a0e735f8e201de1a6a6433b/scripts/asm-installer/install_asm#L1970
iam_roles = [
"roles/container.admin",
Expand All @@ -48,6 +49,8 @@ locals {
asm_iam_member = var.enable_gcp_iam_roles ? coalesce(var.impersonate_service_account, var.service_account, var.iam_member) : ""
# compute any additonal resources that ASM provisioner should depend on
additional_depends_on = concat(var.enable_gcp_apis ? [module.asm-services[0].project_id] : [], local.asm_iam_member != "" ? [for k, v in google_project_iam_member.asm_iam : v.etag] : [])
# base command template for ASM installation
kubectl_create_command_base = "${path.module}/scripts/install_asm.sh ${var.project_id} ${var.cluster_name} ${var.location} ${var.asm_version} ${var.mode} ${var.managed_control_plane} ${var.skip_validation} ${local.options_string} ${local.custom_overlays_string} ${var.enable_all} ${var.enable_cluster_roles} ${var.enable_cluster_labels} ${var.enable_gcp_components} ${var.enable_registration} ${var.outdir} ${var.ca} ${local.ca_cert} ${local.ca_key} ${local.root_cert} ${local.cert_chain} ${local.service_account_string} ${local.key_file_string} ${local.asm_git_tag_string} ${local.revision_name_string}"
}

resource "google_project_iam_member" "asm_iam" {
Expand Down Expand Up @@ -97,6 +100,7 @@ module "asm_install" {
service_account_key_file = var.service_account_key_file
impersonate_service_account = var.impersonate_service_account

kubectl_create_command = "${path.module}/scripts/install_asm.sh ${var.project_id} ${var.cluster_name} ${var.location} ${var.asm_version} ${var.mode} ${var.managed_control_plane} ${var.skip_validation} ${local.options_string} ${local.custom_overlays_string} ${var.enable_all} ${var.enable_cluster_roles} ${var.enable_cluster_labels} ${var.enable_gcp_components} ${var.enable_registration} ${var.enable_namespace_creation} ${var.outdir} ${var.ca} ${local.ca_cert} ${local.ca_key} ${local.root_cert} ${local.cert_chain} ${local.service_account_string} ${local.key_file_string} ${local.asm_git_tag_string} ${local.revision_name_string}"
# enable_namespace_creation flag is only available starting 1.10
kubectl_create_command = (local.asm_minor_version > 9 ? "${local.kubectl_create_command_base} ${var.enable_namespace_creation}" : local.kubectl_create_command_base)
kubectl_destroy_command = "${path.module}/scripts/destroy_asm.sh"
}
29 changes: 14 additions & 15 deletions modules/asm/scripts/install_asm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ ENABLE_CLUSTER_ROLES=${11}
ENABLE_CLUSTER_LABELS=${12}
ENABLE_GCP_COMPONENTS=${13}
ENABLE_REGISTRATION=${14}
ENABLE_NAMESPACE_CREATION=${15}
OUTDIR=${16}
CA=${17}
CA_CERT=${18}
CA_KEY=${19}
ROOT_CERT=${20}
CERT_CHAIN=${21}
SERVICE_ACCOUNT=${22}
KEY_FILE=${23}
ASM_GIT_TAG=${24}
REVISION_NAME=${25}
OUTDIR=${15}
CA=${16}
CA_CERT=${17}
CA_KEY=${18}
ROOT_CERT=${19}
CERT_CHAIN=${20}
SERVICE_ACCOUNT=${21}
KEY_FILE=${22}
ASM_GIT_TAG=${23}
REVISION_NAME=${24}
ENABLE_NAMESPACE_CREATION=${25}

# Set SKIP_VALIDATION variable
if [[ ${SKIP_VALIDATION} = "true" ]]; then
Expand Down Expand Up @@ -178,11 +178,10 @@ else
ENABLE_REGISTRATION_COMMAND_SNIPPET="--enable_registration"
fi

if [[ "${ENABLE_NAMESPACE_CREATION}" = false ]]; then
ENABLE_NAMESPACE_CREATION_COMMAND_SNIPPET=""
elif [[ "${ASM_VERSION#*\.}" -gt 9 ]]; then
# --enable_namespace_creation flag is only available starting ASM 1.10
if [[ "${ENABLE_NAMESPACE_CREATION}" = true ]]; then
ENABLE_NAMESPACE_CREATION_COMMAND_SNIPPET="--enable_namespace_creation"
else
ENABLE_NAMESPACE_CREATION_COMMAND_SNIPPET=""
fi

if [[ "${OUTDIR}" = "none" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion modules/asm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ variable "service_account_key_file" {
variable "asm_version" {
description = "ASM version to deploy. This module supports versions `1.8`, `1.9` and `1.10`. Available versions are documented in https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages"
type = string
default = "1.9"
default = "1.10"
}

variable "asm_git_tag" {
Expand Down

0 comments on commit 76fc426

Please sign in to comment.