-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·93 lines (81 loc) · 2.52 KB
/
setup.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
set -e
export $(grep -v '^#' .env | xargs)
export $(grep -v '^#' .env.local | xargs)
sed -i '' "s/ACCOUNT_ID/${ACCOUNT_ID//\//\\/}/" ./flux/releases/api.yaml
sed -i '' "s/REGION/${REGION//\//\\/}/" ./flux/releases/api.yaml
sed -i '' "s/ACCOUNT_ID/${ACCOUNT_ID//\//\\/}/" ./flux/releases/backend.yaml
sed -i '' "s/REGION/${REGION//\//\\/}/" ./flux/releases/backend.yaml
sed -i '' "s/REGION/${REGION//\//\\/}/" ./flux/releases/ingress-gateway.yaml
git checkout -b gitops
git commit -a -m "Set app repo."
git push --set-upstream origin gitops --force
# CDK
cd cdk
npm run build
# npx cdk@1.54.0 bootstrap
npx cdk@1.54.0 deploy --require-approval never
cd ..
# Docker Image
sh ./build_and_push_docker_images.sh
# EKS
if ! which aws-iam-authenticator > /dev/null; then
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install aws-iam-authenticator
else
echo "aws-iam-authenticator should be installed"
exit 1
fi
fi
if ! which jq > /dev/null; then
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install jq
else
echo "jq should be installed"
exit 1
fi
fi
aws eks --region ${REGION} update-kubeconfig --name AppMeshFluxFlagger --role-arn arn:aws:iam::${ACCOUNT_ID}:role/app-mesh-flux-flagger-masters-role
# Helm
echo 'Installing Helm...'
if ! which helm > /dev/null; then
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install kubernetes-helm
else
echo "helm should be installed"
exit 1
fi
fi
echo " Done!!!\n"
# Flux
echo 'Installing Flux...'
if ! which fluxctl > /dev/null; then
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install fluxctl
else
echo "fluxctl should be installed"
exit 1
fi
fi
kubectl apply -f ./flux/namespaces/flux-namespace.yaml
helm repo add fluxcd https://charts.fluxcd.io
helm upgrade --install --values ./k8s-values/flux-values.yaml \
--namespace flux flux fluxcd/flux
while [[ $(kubectl -n flux get pod -l app=flux -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do echo "waiting for Flux pod" && sleep 1; done
fluxctl identity --k8s-fwd-ns flux
helm upgrade --install --values ./k8s-values/helm-operator-values.yaml \
--namespace flux helm-operator fluxcd/helm-operator
echo ' Optionally, add "export FLUX_FORWARD_NAMESPACE=flux" to the profile file.'
echo " Done!!!\n"
kubectl apply -f ./flux/namespaces/appmesh-system-namespace.yaml
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: flagger
namespace: appmesh-system
data:
values.yaml: |
slack:
url: ${FLAGGER_SLACK_WEBHOOK_URL}
EOF