-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·61 lines (49 loc) · 1.4 KB
/
build.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
#!/usr/bin/env bash
set -e
VERSION=${1}
MAKESELF_VERSION=${MAKESELF_VERSION:-"2.4.3"}
MAKESELF_INSTALL_DIR=$(mktemp -d makeself.XXXXXX)
check_version(){
if [ -z "${VERSION}" ]; then
warn "kubernetes version not specified, use default version 1.21.2."
VERSION="1.21.2"
fi
IMAGE_LIST=$(kubeadm config images list --kubernetes-version v${VERSION})
}
check_makeself(){
if ! command -v makeself.sh >/dev/null 2>&1; then
wget -q https://github.com/megastep/makeself/releases/download/release-${MAKESELF_VERSION}/makeself-${MAKESELF_VERSION}.run
bash makeself-${MAKESELF_VERSION}.run --target ${MAKESELF_INSTALL_DIR}
export PATH=${MAKESELF_INSTALL_DIR}:${PATH}
fi
}
download(){
info "download kubernetes images..."
for i in ${IMAGE_LIST[@]}; do
info "download => [${i}]..."
ctr images pull ${i}
done
ctr images export pack/kubeadm_v${VERSION}.tar ${IMAGE_LIST}
}
build(){
info "building..."
makeself.sh pack kubeadm-config_v${VERSION}.run "kubeadm-config" ./helper.sh kubeadm-config_v${VERSION}.run
}
clean(){
info "clean files."
rm -rf pack/bin/* makeself* ${MAKESELF_INSTALL_DIR} pack/*.tar
}
function info(){
echo -e "\033[1;32mINFO: $@\033[0m"
}
function warn(){
echo -e "\033[1;33mWARN: $@\033[0m"
}
function err(){
echo -e "\033[1;31mERROR: $@\033[0m"
}
check_version
check_makeself
download
build
clean