fix 初始化脚本 tools/easzup

dev1
gjmzj 2019-06-13 23:00:20 +08:00
parent c849650112
commit 90a1fd2c20
2 changed files with 14 additions and 12 deletions

View File

@ -154,8 +154,7 @@
ignore_errors: true ignore_errors: true
- name: cleanup networks2 - name: cleanup networks2
shell: "ip link del docker0; \ shell: "systemctl restart networking; \
systemctl restart networking; \
systemctl restart network" systemctl restart network"
ignore_errors: true ignore_errors: true

View File

@ -2,7 +2,7 @@
set -o nounset set -o nounset
set -o errexit set -o errexit
set -o xtrace #set -o xtrace
function install_docker() { function install_docker() {
systemctl status docker|grep Active|grep -q running && { echo "[WARN] dockerd already running!"; return 0; } systemctl status docker|grep Active|grep -q running && { echo "[WARN] dockerd already running!"; return 0; }
@ -10,7 +10,7 @@ function install_docker() {
systemctl status containerd|grep Active|grep -q running && { echo "[ERROR] containerd running, but unsupported!"; exit 1; } systemctl status containerd|grep Active|grep -q running && { echo "[ERROR] containerd running, but unsupported!"; exit 1; }
mkdir -p /opt/kube/bin /etc/docker mkdir -p /opt/kube/bin /etc/docker
echo "[INFO] downloading docker $DOCKER_VER" echo -e "[INFO] \033[33mdownloading docker\033[0m $DOCKER_VER"
wget -c https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-$DOCKER_VER.tgz wget -c https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-$DOCKER_VER.tgz
tar zxf docker-$DOCKER_VER.tgz tar zxf docker-$DOCKER_VER.tgz
mv docker/* /opt/kube/bin mv docker/* /opt/kube/bin
@ -62,7 +62,7 @@ function get_kubeasz() {
if [ -d "/etc/ansible/roles/kube-node" ];then if [ -d "/etc/ansible/roles/kube-node" ];then
echo "[WARN] kubeasz already Initialized." echo "[WARN] kubeasz already Initialized."
else else
echo "[INFO] downloading kubeasz $KUBEASZ_VER" echo -e "[INFO] \033[33mdownloading kubeasz\033[0m $KUBEASZ_VER"
rm -rf /etc/ansible rm -rf /etc/ansible
docker pull easzlab/kubeasz:$KUBEASZ_VER docker pull easzlab/kubeasz:$KUBEASZ_VER
echo "[INFO] run a temporary container" echo "[INFO] run a temporary container"
@ -78,14 +78,15 @@ function get_k8s_bin() {
if [ -f "/etc/ansible/bin/kubelet" ];then if [ -f "/etc/ansible/bin/kubelet" ];then
echo "[WARN] kubernetes:$K8S_BIN_VER binaries already existed." echo "[WARN] kubernetes:$K8S_BIN_VER binaries already existed."
else else
echo "[INFO] downloading kubernetes:$K8S_BIN_VER binaries" echo -e "[INFO] \033[33mdownloading kubernetes\033[0m $K8S_BIN_VER binaries"
docker pull easzlab/kubeasz-k8s-bin:$K8S_BIN_VER docker pull easzlab/kubeasz-k8s-bin:$K8S_BIN_VER
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 && mv /k8s_bin/* /etc/ansible/bin docker cp temp_k8s_bin:/k8s /k8s_bin_tmp && mv /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
fi fi
} }
@ -93,15 +94,15 @@ function get_ext_bin() {
if [ -f "/etc/ansible/bin/etcdctl" ];then if [ -f "/etc/ansible/bin/etcdctl" ];then
echo "[WARN] extral binaries already existed." echo "[WARN] extral binaries already existed."
else else
echo "[INFO] downloading extral binaries kubeasz-ext-bin:$EXT_BIN_VER" echo -e "[INFO] \033[33mdownloading extral binaries\033[0m kubeasz-ext-bin:$EXT_BIN_VER"
docker pull easzlab/kubeasz-ext-bin:$EXT_BIN_VER docker pull easzlab/kubeasz-ext-bin:$EXT_BIN_VER
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 && mv /extra_bin/* /etc/ansible/bin docker cp temp_ext_bin:/extra /extra_bin_tmp && mv /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
chmod +x /etc/ansible/bin/* rm -rf /extra_bin_tmp
fi fi
} }
@ -119,6 +120,8 @@ function get_offline_image() {
imageDir=/etc/ansible/down imageDir=/etc/ansible/down
[ -d "$imageDir" ] || { echo "[ERROR] $imageDir not existed!"; exit 1; } [ -d "$imageDir" ] || { echo "[ERROR] $imageDir not existed!"; exit 1; }
echo -e "[INFO] \033[33mdownloading offline images\033[0m"
if [ ! -f "$imageDir/calico_${calicoVer}.tar" ];then if [ ! -f "$imageDir/calico_${calicoVer}.tar" ];then
docker pull calico/cni:$calicoVer docker pull calico/cni:$calicoVer
docker pull calico/kube-controllers:$calicoVer docker pull calico/kube-controllers:$calicoVer
@ -197,7 +200,7 @@ function usage() {
cat <<EOF cat <<EOF
Usage: $0 [options] [args] Usage: $0 [options] [args]
option: -{DdekSz} option: -{DdekSz}
-C stop&clean all containers -C stop&clean all local containers
-D download all into /etc/ansible -D download all into /etc/ansible
-S start kubeasz in a container -S start kubeasz in a container
-d <ver> set docker-ce version, default 18.09.6 -d <ver> set docker-ce version, default 18.09.6
@ -230,7 +233,7 @@ fi
# default version, can be overridden by cmd line options # default version, can be overridden by cmd line options
export DOCKER_VER=18.09.6 export DOCKER_VER=18.09.6
export KUBEASZ_VER=1.2.0 export KUBEASZ_VER=1.3.0
export K8S_BIN_VER=v1.14.3 export K8S_BIN_VER=v1.14.3
export EXT_BIN_VER=0.3.0 export EXT_BIN_VER=0.3.0