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