Skip to content

Commit

Permalink
feat: Allow user to customize ASM install with different directories …
Browse files Browse the repository at this point in the history
…and versions (#620)
  • Loading branch information
bharathkkb committed Aug 5, 2020
1 parent 114e3cf commit d542c5c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions modules/asm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion modules/asm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
11 changes: 6 additions & 5 deletions modules/asm/scripts/install_asm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

set -e

if [ "$#" -lt 3 ]; then
if [ "$#" -lt 5 ]; then
>&2 echo "Not all expected arguments set."
exit 1
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.
Expand All @@ -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}
Expand Down
12 changes: 12 additions & 0 deletions modules/asm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit d542c5c

Please sign in to comment.