diff --git a/modules/asm/README.md b/modules/asm/README.md index fbe2311e8..f62e1cf47 100644 --- a/modules/asm/README.md +++ b/modules/asm/README.md @@ -40,6 +40,8 @@ To deploy this config: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| +| asm\_dir | Name of directory to keep ASM resource config files. | string | `"asm-dir"` | no | +| asm\_version | ASM version to deploy. Available versions are documented in https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages | string | `"release-1.6-asm"` | no | | cluster\_endpoint | The GKE cluster endpoint. | string | n/a | yes | | cluster\_name | The unique name to identify the cluster in ASM. | string | n/a | yes | | enable\_gke\_hub\_registration | Enables GKE Hub Registration when set to true | bool | `"true"` | no | diff --git a/modules/asm/main.tf b/modules/asm/main.tf index 27d0c2045..22b8bbc2a 100644 --- a/modules/asm/main.tf +++ b/modules/asm/main.tf @@ -32,7 +32,7 @@ module "asm_install" { project_id = var.project_id - kubectl_create_command = "${path.module}/scripts/install_asm.sh ${var.project_id} ${var.cluster_name} ${var.location}" + kubectl_create_command = "${path.module}/scripts/install_asm.sh ${var.project_id} ${var.cluster_name} ${var.location} ${var.asm_dir} ${var.asm_version}" kubectl_destroy_command = "kubectl delete ns istio-system" } diff --git a/modules/asm/scripts/install_asm.sh b/modules/asm/scripts/install_asm.sh index a71c45f3d..707cd7f9d 100755 --- a/modules/asm/scripts/install_asm.sh +++ b/modules/asm/scripts/install_asm.sh @@ -15,7 +15,7 @@ set -e -if [ "$#" -lt 3 ]; then +if [ "$#" -lt 5 ]; then >&2 echo "Not all expected arguments set." exit 1 fi @@ -23,7 +23,8 @@ fi PROJECT_ID=$1 CLUSTER_NAME=$2 CLUSTER_LOCATION=$3 -ASM_RESOURCES="asm-dir" +ASM_RESOURCES=$4 +ASM_VERSION=$5 BASE_DIR="asm-base-dir" # check for needed binaries # kustomize is a requirement for installing ASM and is not available via gcloud. Safely exit if not available. @@ -38,14 +39,14 @@ fi # echo "ASM yaml validation will be skipped as Docker is unavailable" # SKIP_ASM_VALIDATION=true # fi -mkdir -p $ASM_RESOURCES -pushd $ASM_RESOURCES +mkdir -p "${ASM_RESOURCES}" +pushd "${ASM_RESOURCES}" gcloud config set project "${PROJECT_ID}" if [[ -d ./asm-patch ]]; then echo "ASM patch directory exists. Skipping download..." else echo "Downloading ASM patch" - kpt pkg get https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages.git/asm-patch@release-1.6-asm . + kpt pkg get https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages.git/asm-patch@"${ASM_VERSION}" . fi gcloud beta anthos export "${CLUSTER_NAME}" --output-directory ${BASE_DIR} --project "${PROJECT_ID}" --location "${CLUSTER_LOCATION}" kpt cfg set asm-patch/ base-dir ../${BASE_DIR} diff --git a/modules/asm/variables.tf b/modules/asm/variables.tf index 5b22774f1..1096a2be2 100644 --- a/modules/asm/variables.tf +++ b/modules/asm/variables.tf @@ -69,3 +69,15 @@ variable "internal_ip" { type = bool default = false } + +variable "asm_dir" { + description = "Name of directory to keep ASM resource config files." + type = string + default = "asm-dir" +} + +variable "asm_version" { + description = "ASM version to deploy. Available versions are documented in https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages" + type = string + default = "release-1.6-asm" +}