-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·93 lines (72 loc) · 3.21 KB
/
start.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
93
#!/bin/bash
DEBUG=${DEBUG:-false}
if [ "${DEBUG}" = "true" ]; then
set -x
fi
set -e
COL='\033[92m'
RED='\033[91m'
COL_RES='\033[0m'
SCRIPT_DIR=$(dirname "$0")
# Check for input argument GH_TOKEN and echo message in case not provided
if [ -z "${GH_TOKEN}" ]; then
echo "Please set the 'GH_TOKEN' environment variable with a GitHub token that has 'read:packages' scope."
exit 1
else
ghToken=$GH_TOKEN
fi
ghUser=""
if [ -z "${GH_USER}" ]; then
if ! command -v gh &> /dev/null; then
echo "gh CLI could not be found. Either install the gh cli or set the GH_USER environment variable with our GitHub username."
exit 1
else
ghUser=$(gh api user --jq '.login')
fi
else
ghUser=$GH_USER
fi
# Check if kind cluster kind is already running, exit if yes
if [ $(kind get clusters | grep -c openmfp) -gt 0 ]; then
echo -e "${COL}[$(date '+%H:%M:%S')] Kind cluster already running, using existing ${COL_RES}"
kind export kubeconfig --name openmfp
else
echo -e "${COL}[$(date '+%H:%M:%S')] Creating kind cluster ${COL_RES}"
kind create cluster --config $SCRIPT_DIR/../kind/kind-config.yaml --name openmfp --image=kindest/node:v1.30.2
fi
echo -e "${COL}[$(date '+%H:%M:%S')] Installing flux ${COL_RES}"
helm upgrade -i -n flux-system --create-namespace flux oci://ghcr.io/fluxcd-community/charts/flux2 \
--set imageAutomationController.create=false \
--set imageReflectionController.create=false \
--set kustomizeController.create=false \
--set notificationController.create=false
echo -e "${COL}[$(date '+%H:%M:%S')] Starting deployments ${COL_RES}"
kubectl apply -k $SCRIPT_DIR/../kustomize/overlays/default
sleep 5
kubectl apply -f $SCRIPT_DIR/../kustomize/base/istio-operator
echo -e "${COL}[$(date '+%H:%M:%S')] Creating necessary secrets ${COL_RES}"
kubectl create secret docker-registry ghcr-credentials -n openmfp-system --docker-server=ghcr.io --docker-username=$ghUser --docker-password=$ghToken --dry-run=client -o yaml | kubectl apply -f -
kubectl create secret generic keycloak-admin -n openmfp-system --from-literal=secret=admin --dry-run=client -o yaml | kubectl apply -f -
echo -e "${COL}[$(date '+%H:%M:%S')] Waiting for istio to become ready ${COL_RES}"
kubectl wait --namespace istio-system \
--for=condition=Ready helmreleases \
--timeout=120s istio-base
kubectl wait --namespace istio-system \
--for=condition=Ready helmreleases \
--timeout=120s istio-istiod
kubectl wait --namespace istio-system \
--for=condition=Ready helmreleases \
--timeout=120s istio-gateway
echo -e "${COL}[$(date '+%H:%M:%S')] Waiting for OpenMFP CRDs to become ready ${COL_RES} (this may take a few minutes)"
kubectl wait --namespace openmfp-system \
--for=condition=Ready helmreleases \
--timeout=280s openmfp-crds
echo -e "$COL Waiting for OpenMFP to become ready $COL_RES (this may take a while)"
kubectl wait --namespace openmfp-system \
--for=condition=Ready helmreleases \
--timeout=480s openmfp
echo -e "${COL}-------------------------------------${COL_RES}"
echo -e "${COL}[$(date '+%H:%M:%S')] Installation Complete ${RED}♥${COL}!${COL_RES}"
echo -e "${COL}-------------------------------------${COL_RES}"
echo -e "${COL}You can access the portal at: http://localhost:8000${COL_RES}"
exit 0