-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
install_asm.sh
executable file
·66 lines (63 loc) · 2.72 KB
/
install_asm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
if [ "$#" -lt 3 ]; then
>&2 echo "Not all expected arguments set."
exit 1
fi
PROJECT_ID=$1
CLUSTER_NAME=$2
CLUSTER_LOCATION=$3
ASM_RESOURCES="asm-dir"
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.
if [[ -z $(command -v kustomize) ]]; then
echo "kustomize is unavailable. Skipping ASM installation. Please install kustomize, add to PATH and rerun terraform apply."
exit 1
fi
# # check docker which is optionally used for validating asm yaml using gcr.io/kustomize-functions/validate-asm:v0.1.0
# if [[ $(command -v docker) ]]; then
# echo "Docker is available. ASM yaml validation will be performed."
# else
# echo "ASM yaml validation will be skipped as Docker is unavailable"
# SKIP_ASM_VALIDATION=true
# fi
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 .
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}
kpt cfg set asm-patch/ gcloud.core.project "${PROJECT_ID}"
kpt cfg set asm-patch/ gcloud.container.cluster "${CLUSTER_NAME}"
kpt cfg set asm-patch/ gcloud.compute.location "${CLUSTER_LOCATION}"
kpt cfg list-setters asm-patch/
pushd ${BASE_DIR} && kustomize create --autodetect --namespace "${PROJECT_ID}" && popd
pushd asm-patch && kustomize build -o ../${BASE_DIR}/all.yaml && popd
# # skip validate as we should investigate if we can check this without having to resort to dind
# if [[ ${SKIP_ASM_VALIDATION} ]]; then
# echo "Skipping ASM validation..."
# else
# echo "Running ASM validation..."
# kpt fn source ${BASE_DIR} | kpt fn run --image gcr.io/kustomize-functions/validate-asm:v0.1.0
# fi
gcloud beta anthos apply ${BASE_DIR}
kubectl wait --for=condition=available --timeout=600s deployment --all -n istio-system