|
15 | 15 |
|
16 | 16 | set -e |
17 | 17 |
|
18 | | -if [ "$#" -lt 6 ]; then |
| 18 | +if [ "$#" -lt 4 ]; then |
19 | 19 | >&2 echo "Not all expected arguments set." |
20 | 20 | exit 1 |
21 | 21 | fi |
22 | 22 |
|
23 | 23 | PROJECT_ID=$1 |
24 | 24 | CLUSTER_NAME=$2 |
25 | 25 | CLUSTER_LOCATION=$3 |
26 | | -ASM_RESOURCES=$4 |
27 | | -ASM_VERSION=$5 |
28 | | -PROJECT_NUM=$6 |
29 | | -BASE_DIR="asm-base-dir" |
30 | | -# check for needed binaries |
31 | | -# kustomize is a requirement for installing ASM and is not available via gcloud. Safely exit if not available. |
32 | | -if [[ -z $(command -v kustomize) ]]; then |
33 | | - echo "kustomize is unavailable. Skipping ASM installation. Please install kustomize, add to PATH and rerun terraform apply." |
34 | | - exit 1 |
35 | | -fi |
36 | | -# # check docker which is optionally used for validating asm yaml using gcr.io/kustomize-functions/validate-asm:v0.1.0 |
37 | | -# if [[ $(command -v docker) ]]; then |
38 | | -# echo "Docker is available. ASM yaml validation will be performed." |
39 | | -# else |
40 | | -# echo "ASM yaml validation will be skipped as Docker is unavailable" |
41 | | -# SKIP_ASM_VALIDATION=true |
42 | | -# fi |
43 | | -mkdir -p "${ASM_RESOURCES}" |
44 | | -pushd "${ASM_RESOURCES}" |
45 | | -gcloud config set project "${PROJECT_ID}" |
46 | | -if [[ -d ./asm-patch ]]; then |
47 | | - echo "ASM patch directory exists. Skipping download..." |
48 | | -else |
49 | | - echo "Downloading ASM patch" |
50 | | - kpt pkg get https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages.git/asm-patch@"${ASM_VERSION}" . |
51 | | -fi |
52 | | -gcloud beta anthos export "${CLUSTER_NAME}" --output-directory ${BASE_DIR} --project "${PROJECT_ID}" --location "${CLUSTER_LOCATION}" |
53 | | -kpt cfg set asm-patch/ base-dir ../${BASE_DIR} |
54 | | -kpt cfg set asm-patch/ gcloud.core.project "${PROJECT_ID}" |
55 | | -kpt cfg set asm-patch/ gcloud.container.cluster "${CLUSTER_NAME}" |
56 | | -kpt cfg set asm-patch/ gcloud.compute.location "${CLUSTER_LOCATION}" |
57 | | -kpt cfg set asm-patch/ gcloud.project.environProjectNumber "${PROJECT_NUM}" |
58 | | -kpt cfg list-setters asm-patch/ |
59 | | -pushd ${BASE_DIR} |
60 | | -kustomize create --autodetect --namespace "${PROJECT_ID}" |
61 | | -popd |
62 | | -pushd asm-patch |
63 | | -kustomize build -o ../${BASE_DIR}/all.yaml |
64 | | -popd |
65 | | -# # skip validate as we should investigate if we can check this without having to resort to dind |
66 | | -# if [[ ${SKIP_ASM_VALIDATION} ]]; then |
67 | | -# echo "Skipping ASM validation..." |
68 | | -# else |
69 | | -# echo "Running ASM validation..." |
70 | | -# kpt fn source ${BASE_DIR} | kpt fn run --image gcr.io/kustomize-functions/validate-asm:v0.1.0 |
71 | | -# fi |
72 | | -gcloud beta anthos apply ${BASE_DIR} |
73 | | -kubectl wait --for=condition=available --timeout=600s deployment --all -n istio-system |
| 26 | +ASM_VERSION=$4 |
| 27 | +MODE="install" |
| 28 | + |
| 29 | +#download the correct version of the install_asm script |
| 30 | +curl https://storage.googleapis.com/csm-artifacts/asm/install_asm_"${ASM_VERSION}" > install_asm |
| 31 | +chmod u+x install_asm |
| 32 | + |
| 33 | +#run the script with appropriate flags |
| 34 | +./install_asm --verbose --project_id "${PROJECT_ID}" --cluster_name "${CLUSTER_NAME}" --cluster_location "${CLUSTER_LOCATION}" --mode "${MODE}" --enable_cluster_labels --enable_cluster_roles |
0 commit comments