-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-k8s-config.sh
165 lines (132 loc) · 4.02 KB
/
init-k8s-config.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
# init weagle
echo -e "\033[0;62m\033[0;49;35m"
set -a && source .env.k8s.private && set +a
set -a && source .env.common.private && set +a
root_dir="$(pwd)"
log () {
echo -e "\033[0;49;35m"
# warning
if [[ "$2" == "2" ]]; then
echo -e "\033[35;43m$1\033[0m"
fi
# error
if [[ "$2" == "1" ]]; then
echo -e "\033[35;41m\033[33m$1\033[0m"
fi
# success
if [[ "$2" == "0" ]]; then
echo -e "\033[35;42m$1\033[0m"
fi
# normal
if [[ "$2" == "" ]]; then
echo -e "\033[35;46m$1\033[0m"
fi
}
prompt () {
log "$1" 2
read answer
echo "$answer"
}
gosu () {
if [ $( id -u ) -ne 0 ]; then
log "dp::(auth)::this command needs sudo, please add password for %p: " 2
sudo -v
# exit $?
fi
}
take () {
log "dp::(idle)::let's wait ($1 * $HERMES_COOLDOWN_POINTER) seconds for $2." 2
while true; do echo -n .; sleep 1; done | pv -s $1 * $HERMES_COOLDOWN_POINTER -S -F '%t %p' > /dev/null
}
_deploy () {
kubectl apply -f . -n hermes
}
_kompose () {
kompose convert --out data/charts/
}
log "dp::hermes::${HERMES_ENV}::k8s::(busy)::Initiating Kubernetes: ${HERMES_ENV} env."
# # install kompose
# # Linux
# curl -L https://github.com/kubernetes/kompose/releases/download/v1.34.0/kompose-linux-amd64 -o kompose
# # # macOS
# # curl -L https://github.com/kubernetes/kompose/releases/download/v1.34.0/kompose-darwin-amd64 -o kompose
# # # Windows
# # curl -L https://github.com/kubernetes/kompose/releases/download/v1.34.0/kompose-windows-amd64.exe -o kompose.exe
# chmod +x kompose
# sudo mv ./kompose /usr/local/bin/kompose
# # install docker
# # Add Docker's official GPG key:
# sudo apt-get update
# sudo apt-get install ca-certificates curl
# sudo install -m 0755 -d /etc/apt/keyrings
# sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
# sudo chmod a+r /etc/apt/keyrings/docker.asc
# # Add the repository to Apt sources:
# echo \
# "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
# $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
# sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# sudo apt-get update
# docker setup
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Cleaning up previous deployment." 2
./init0.sh
kubectl delete --all deployments --namespace hermes
# docker setup
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Configuring networks." 2
./init-networks.sh
# prepare
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Initiating Kubernetes: creating namespaces."
kubectl create namespace hermes
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Creating Charts: Weagle (Ingress)." 2
./init-weagle.sh
cd ingress
_kompose
cd $root_dir
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Creating Charts: Daegis: (Databases)."
./init-model.sh
cd model
_kompose
cd $root_dir
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Creating Charts: Drew: (Auth)."
./init-auth.sh
cd auth
_kompose
cd $root_dir
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Creating Charts: Aemilia: (Mail)."
./init-mail.sh
cd mail
_kompose
cd $root_dir
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Creating Charts: Claudia: (Storage, Calendar, MWC)."
./init-cloud.sh
cd cloud
_kompose
cd $root_dir
# deploy
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Deploying: Applying Charts for Weagle (Ingress)." 2
cd ingress
cd data/charts
_deploy
cd $root_dir
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Deploying: Applying Charts for Daegis: (Databases)."
cd model
cd data/charts
_deploy
cd $root_dir
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Deploying: Applying Charts for Drew: (Auth)."
cd auth
cd data/charts
_deploy
cd $root_dir
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Deploying: Applying Charts for Aemilia: (Mail)."
cd mail
cd data/charts
_deploy
cd $root_dir
log "dp::hermes::${HERMES_ENV}::k8s::(busy):: Deploying: Applying Charts for Claudia: (Storage, Calendar, MWC)."
cd cloud
cd data/charts
_deploy
cd $root_dir
log "dp::hermes::${HERMES_ENV}::k8s::(idle)::all good." 0