-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.sh
executable file
·61 lines (51 loc) · 1.16 KB
/
init.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
#!/bin/bash
#
# Bootstrap the Kubernetes cluster and AWS resources.
# See README.
#
is_env_set="yes"
function echo_message () {
if [[ $is_env_set == "yes" ]]
then
echo 'Success!!!!'
else
echo 'Failed!!!!'
fi
}
if [ -z "$AWS_PROFILE" ]; then
is_env_set="no"
echo "Please export AWS_PROFILE and ENVIRONMENT env variable and run following command"
echo ' source envs/${ENVIRONMENT}/variables.sh'
echo_message
exit 1
fi
if [ -z "$KOPS_CLUSTER_NAME" ]; then
is_env_set="no"
echo "Run the following command before running $0"
echo ' source envs/${ENVIRONMENT}/variables.sh'
echo_message
exit 1
fi
set -e
set -o pipefail
set -x
cd "$(dirname "$0")"
# Show versions
kops version
terraform version
helm version -c
helmfile -v
# Initialize kubecontext
kops export kubecfg
kops validate cluster
# Remove terraform.tfstate
if [ -d ./.terraform ]; then
if [ ! -f ./.terraform/terraform.tfstate ]; then
rm -r ./.terraform/terraform.tfstate
fi
fi
# Initialize Terraform
terraform init -backend-config="bucket=$TF_VAR_state_store_bucket_name" -backend-config="region=$TF_VAR_aws_default_region"
# Initialize Helm
helm init --client-only
echo_message