diff --git a/example/config.yml b/example/config.yml index 5dfa4d8..97bbe9b 100644 --- a/example/config.yml +++ b/example/config.yml @@ -29,6 +29,8 @@ CERT_EXPIRY: "438000h" CLUSTER_NAME: "cluster1" CONTEXT_NAME: "context-{{ CLUSTER_NAME }}" +# k8s version +K8S_VER: "__k8s_ver__" ############################ # role:etcd diff --git a/ezctl b/ezctl index 5cbd5f9..e22c305 100755 --- a/ezctl +++ b/ezctl @@ -140,7 +140,8 @@ function new() { sed -i "s/_cluster_name_/$1/g" "clusters/$1/hosts" cp example/config.yml "clusters/$1/config.yml" - logger debug "set version of common plugins" + logger debug "set versions" + k8sVer=$(grep 'K8S_BIN_VER=v' ezdown|cut -d'v' -f2) calicoVer=$(grep 'calicoVer=' ezdown|cut -d'=' -f2) ciliumVer=$(grep 'ciliumVer=' ezdown|cut -d'=' -f2) flannelVer=$(grep 'flannelVer=' ezdown|cut -d'=' -f2) @@ -160,7 +161,8 @@ function new() { grep registry-mirrors /etc/docker/daemon.json > /dev/null 2>&1 || { logger debug "disable registry mirrors"; registryMirror=false; } - sed -i -e "s/__flannel__/$flannelVer/g" \ + sed -i -e "s/__k8s_ver__/$k8sVer/g" \ + -e "s/__flannel__/$flannelVer/g" \ -e "s/__calico__/$calicoVer/g" \ -e "s/__cilium__/$ciliumVer/g" \ -e "s/__kube_ovn__/$kubeOvnVer/g" \ diff --git a/playbooks/32.delnode.yml b/playbooks/32.delnode.yml index 855cdcf..fe0701c 100644 --- a/playbooks/32.delnode.yml +++ b/playbooks/32.delnode.yml @@ -5,8 +5,23 @@ - fail: msg="you CAN NOT delete the last member of kube_master!" when: "groups['kube_master']|length < 2 and NODE_TO_DEL in groups['kube_master']" + - name: 注册变量 K8S 主版本 + shell: echo {{ K8S_VER }}|awk -F. '{print $1"."$2}' + register: K8S_VER_MAIN + + - name: 设置kubectl drain 参数 + set_fact: DRAIN_OPT="--delete-emptydir-data --ignore-daemonsets --force" + when: "K8S_VER_MAIN.stdout|float > 1.19" + + - name: 设置kubectl drain 参数 + set_fact: DRAIN_OPT="--delete-local-data --ignore-daemonsets --force" + when: "K8S_VER_MAIN.stdout|float < 1.20" + + - name: debug info + debug: var="DRAIN_OPT" + - name: run kubectl drain @{{ NODE_TO_DEL }} - shell: "{{ base_dir }}/bin/kubectl drain {{ NODE_TO_DEL }} --ignore-daemonsets --delete-emptydir-data --force" + shell: "{{ base_dir }}/bin/kubectl drain {{ NODE_TO_DEL }} {{ DRAIN_OPT }}" #ignore_errors: true - name: clean node {{ NODE_TO_DEL }} diff --git a/playbooks/33.delmaster.yml b/playbooks/33.delmaster.yml index 17d25f7..9016288 100644 --- a/playbooks/33.delmaster.yml +++ b/playbooks/33.delmaster.yml @@ -5,8 +5,23 @@ - fail: msg="you CAN NOT delete the last member of kube_master!" when: "groups['kube_master']|length < 2 and NODE_TO_DEL in groups['kube_master']" + - name: 注册变量 K8S 主版本 + shell: echo {{ K8S_VER }}|awk -F. '{print $1"."$2}' + register: K8S_VER_MAIN + + - name: 设置kubectl drain 参数 + set_fact: DRAIN_OPT="--delete-emptydir-data --ignore-daemonsets --force" + when: "K8S_VER_MAIN.stdout|float > 1.19" + + - name: 设置kubectl drain 参数 + set_fact: DRAIN_OPT="--delete-local-data --ignore-daemonsets --force" + when: "K8S_VER_MAIN.stdout|float < 1.20" + + - name: debug info + debug: var="DRAIN_OPT" + - name: run kubectl drain @{{ NODE_TO_DEL }} - shell: "{{ base_dir }}/bin/kubectl drain {{ NODE_TO_DEL }} --ignore-daemonsets --delete-emptydir-data --force" + shell: "{{ base_dir }}/bin/kubectl drain {{ NODE_TO_DEL }} {{ DRAIN_OPT }}" #ignore_errors: true - name: clean node {{ NODE_TO_DEL }} diff --git a/roles/cluster-addon/files/traefik-9.12.3.tgz b/roles/cluster-addon/files/traefik-9.12.3.tgz deleted file mode 100644 index de1859d..0000000 Binary files a/roles/cluster-addon/files/traefik-9.12.3.tgz and /dev/null differ