modify tools/easzup

pull/951/head
gjmzj 2020-11-19 18:54:42 +08:00
parent 7316c24939
commit 4f53b062ea
1 changed files with 34 additions and 35 deletions

View File

@ -2,33 +2,32 @@
#--------------------------------------------------
# This script is for:
# 1. to download the scripts/binaries/images needed for installing a k8s cluster with kubeasz
# 2. to run kubeasz in a container
# 2. to run kubeasz in a container (optional, not recommend)
# @author: gjmzj
# @usage: ./easzup
# @repo: https://github.com/easzlab/kubeasz
# @ref: https://github.com/kubeasz/dockerfiles
#--------------------------------------------------
set -o nounset
set -o errexit
#set -o xtrace
# default version, can be overridden by cmd line options
export DOCKER_VER=19.03.13
export KUBEASZ_VER=2.2.2
export K8S_BIN_VER=v1.19.3
export EXT_BIN_VER=0.6.0
export SYS_PKG_VER=0.3.3
export CONTAINERD_VER=1.2.6
# default version, can be overridden by cmd line options, see ./easzup
DOCKER_VER=19.03.13
KUBEASZ_VER=2.2.2
K8S_BIN_VER=v1.19.4
EXT_BIN_VER=0.6.0
SYS_PKG_VER=0.3.3
CONTAINERD_VER=1.2.6
# images needed by k8s cluster
export calicoVer=v3.8.8
export corednsVer=1.7.1
export dashboardVer=v2.0.4
export dashboardMetricsScraperVer=v1.0.4
export flannelVer=v0.13.0-amd64
export metricsVer=v0.3.6
export pauseVer=3.2
calicoVer=v3.8.8
corednsVer=1.7.1
dashboardVer=v2.0.4
dashboardMetricsScraperVer=v1.0.4
flannelVer=v0.13.0-amd64
metricsVer=v0.3.6
pauseVer=3.2
function download_docker() {
echo -e "[INFO] \033[33mdownloading docker binaries\033[0m $DOCKER_VER"
@ -50,16 +49,16 @@ function download_docker() {
fi
/bin/mv -f ./docker-${DOCKER_VER}.tgz /etc/ansible/down
fi
tar zxf /etc/ansible/down/docker-${DOCKER_VER}.tgz -C /etc/ansible/down && \
/bin/cp -f /etc/ansible/down/docker/* /etc/ansible/bin && \
/bin/mv -f /etc/ansible/down/docker/* /opt/kube/bin && \
ln -sf /opt/kube/bin/docker /bin/docker
}
function install_docker() {
# check if a container runtime is already installed
systemctl status docker|grep Active|grep -q running && { echo "[WARN] docker is already running."; return 0; }
tar zxf /etc/ansible/down/docker-${DOCKER_VER}.tgz -C /etc/ansible/down && \
/bin/cp -f /etc/ansible/down/docker/* /etc/ansible/bin && \
/bin/mv -f /etc/ansible/down/docker/* /opt/kube/bin && \
ln -sf /opt/kube/bin/docker /bin/docker
echo "[INFO] generate docker service file"
cat > /etc/systemd/system/docker.service << EOF
@ -160,11 +159,11 @@ function get_k8s_bin() {
echo "[INFO] run a temporary container" && \
docker run -d --name temp_k8s_bin easzlab/kubeasz-k8s-bin:${K8S_BIN_VER} && \
echo "[INFO] cp k8s binaries" && \
docker cp temp_k8s_bin:/k8s /k8s_bin_tmp && \
/bin/mv -f /k8s_bin_tmp/* /etc/ansible/bin && \
docker cp temp_k8s_bin:/k8s /etc/ansible/k8s_bin_tmp && \
/bin/mv -f /etc/ansible/k8s_bin_tmp/* /etc/ansible/bin && \
echo "[INFO] stop&remove temporary container" && \
docker rm -f temp_k8s_bin && \
rm -rf /k8s_bin_tmp
rm -rf /etc/ansible/k8s_bin_tmp
}
function get_ext_bin() {
@ -175,11 +174,11 @@ function get_ext_bin() {
echo "[INFO] run a temporary container" && \
docker run -d --name temp_ext_bin easzlab/kubeasz-ext-bin:${EXT_BIN_VER} && \
echo "[INFO] cp extral binaries" && \
docker cp temp_ext_bin:/extra /extra_bin_tmp && \
/bin/mv -f /extra_bin_tmp/* /etc/ansible/bin && \
docker cp temp_ext_bin:/extra /etc/ansible/extra_bin_tmp && \
/bin/mv -f /etc/ansible/extra_bin_tmp/* /etc/ansible/bin && \
echo "[INFO] stop&remove temporary container" && \
docker rm -f temp_ext_bin && \
rm -rf /extra_bin_tmp
rm -rf /etc/ansible/extra_bin_tmp
}
function get_sys_pkg() {
@ -350,7 +349,7 @@ function main() {
[[ "$#" -eq 0 ]] && { usage >&2; exit 1; }
export REGISTRY_MIRROR="CN"
REGISTRY_MIRROR="CN"
ACTION=""
while getopts "CDPSd:e:k:m:p:z:c:" OPTION; do
case "$OPTION" in
@ -367,25 +366,25 @@ function main() {
ACTION="start_kubeasz_docker"
;;
d)
export DOCKER_VER="$OPTARG"
DOCKER_VER="$OPTARG"
;;
e)
export EXT_BIN_VER="$OPTARG"
EXT_BIN_VER="$OPTARG"
;;
k)
export K8S_BIN_VER="$OPTARG"
K8S_BIN_VER="$OPTARG"
;;
m)
export REGISTRY_MIRROR="$OPTARG"
REGISTRY_MIRROR="$OPTARG"
;;
p)
export SYS_PKG_VER="$OPTARG"
SYS_PKG_VER="$OPTARG"
;;
z)
export KUBEASZ_VER="$OPTARG"
KUBEASZ_VER="$OPTARG"
;;
c)
export CONTAINERD_VER="$OPTARG"
CONTAINERD_VER="$OPTARG"
;;
?)
usage