forked from billimek/k8s-gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap-cluster.sh
executable file
·65 lines (52 loc) · 1.36 KB
/
bootstrap-cluster.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
#!/bin/bash
REPO_ROOT=$(git rev-parse --show-toplevel)
need() {
which "$1" &>/dev/null || die "Binary '$1' is missing but required"
}
need "kubectl"
need "helm"
need "flux"
need "op"
message() {
echo -e "\n######################################################################"
echo "# $1"
echo "######################################################################"
}
installFlux() {
op whoami > /dev/null 2>&1
OP_SIGNEDIN=$?
if [ $OP_SIGNEDIN != 0 ]; then
echo -e "1password (op CLI) is not signed-in, aborting!"
exit 1
fi
message "fetching secrets from 1Password vault"
GITHUB_TOKEN=$(op read "op://kubernetes/github PAT for flux/password")
message "installing flux"
flux check --pre > /dev/null
FLUX_PRE=$?
if [ $FLUX_PRE != 0 ]; then
echo -e "flux prereqs not met:\n"
flux check --pre
exit 1
fi
if [ -z "$GITHUB_TOKEN" ]; then
echo "GITHUB_TOKEN is not set! Check $REPO_ROOT/setup/.env or 1Password settings"
exit 1
fi
flux bootstrap github \
--owner=billimek \
--repository=k8s-gitops \
--branch master \
--private=false \
--personal \
--network-policy=false
FLUX_INSTALLED=$?
if [ $FLUX_INSTALLED != 0 ]; then
echo -e "flux did not install correctly, aborting!"
exit 1
fi
}
installFlux
"$REPO_ROOT"/setup/bootstrap-objects.sh
message "all done!"
kubectl get nodes -o=wide