fix: installation of ex-lb

pull/999/head
gjmzj 2021-03-27 20:47:03 +08:00
parent da63eeedbd
commit a6315758c7
3 changed files with 35 additions and 45 deletions

45
ezctl
View File

@ -110,18 +110,19 @@ function usage-setup(){
echo -e "\033[33mUsage:\033[0m ezctl setup <cluster> <step>" echo -e "\033[33mUsage:\033[0m ezctl setup <cluster> <step>"
cat <<EOF cat <<EOF
available steps: available steps:
01 prepare to prepare CA/certs & kubeconfig & other system settings 01 prepare to prepare CA/certs & kubeconfig & other system settings
02 etcd to setup the etcd cluster 02 etcd to setup the etcd cluster
03 runtime to setup the container runtime(docker or containerd) 03 container-runtime to setup the container runtime(docker or containerd)
04 kube-master to setup the master nodes 04 kube-master to setup the master nodes
05 kube-node to setup the worker nodes 05 kube-node to setup the worker nodes
06 network to setup the network plugin 06 network to setup the network plugin
07 cluster-addon to setup other useful plugins 07 cluster-addon to setup other useful plugins
all to run 01~07 all at once 90 all to run 01~07 all at once
harbor to install a new harbor server or to integrate with an existed one 10 ex-lb to install external loadbalance for accessing k8s from outside
11 harbor to install a new harbor server or to integrate with an existed one
examples: ./ezctl setup test-k8s 01 examples: ./ezctl setup test-k8s 01 (or ./ezctl setup test-k8s prepare)
./ezctl setup test-k8s 02 ./ezctl setup test-k8s 02 (or ./ezctl setup test-k8s etcd)
./ezctl setup test-k8s all ./ezctl setup test-k8s all
EOF EOF
} }
@ -185,34 +186,34 @@ function setup() {
PLAY_BOOK="dummy.yml" PLAY_BOOK="dummy.yml"
case "$2" in case "$2" in
(01) (01|prepare)
PLAY_BOOK="01.prepare.yml" PLAY_BOOK="01.prepare.yml"
;; ;;
(02) (02|etcd)
PLAY_BOOK="02.etcd.yml" PLAY_BOOK="02.etcd.yml"
;; ;;
(03) (03|container-runtime)
PLAY_BOOK="03.runtime.yml" PLAY_BOOK="03.runtime.yml"
;; ;;
(04) (04|kube-master)
PLAY_BOOK="04.kube-master.yml" PLAY_BOOK="04.kube-master.yml"
;; ;;
(05) (05|kube-node)
PLAY_BOOK="05.kube-node.yml" PLAY_BOOK="05.kube-node.yml"
;; ;;
(06) (06|network)
PLAY_BOOK="06.network.yml" PLAY_BOOK="06.network.yml"
;; ;;
(07) (07|cluster-addon)
PLAY_BOOK="07.cluster-addon.yml" PLAY_BOOK="07.cluster-addon.yml"
;; ;;
(90) (90|all)
PLAY_BOOK="90.setup.yml" PLAY_BOOK="90.setup.yml"
;; ;;
(all) (10|ex-lb)
PLAY_BOOK="90.setup.yml" PLAY_BOOK="10.ex-lb.yml"
;; ;;
(harbor) (11|harbor)
PLAY_BOOK="11.harbor.yml" PLAY_BOOK="11.harbor.yml"
;; ;;
(*) (*)

View File

@ -0,0 +1,3 @@
- hosts: ex_lb
roles:
- ex-lb

View File

@ -1,24 +1,18 @@
- hosts: - hosts:
- ex_lb - ex_lb
tasks: tasks:
- block: - name: get service info
- name: stop and disable chrony in Ubuntu shell: 'systemctl list-units --type=service |grep -E "haproxy|keepalived|ssh"'
service: name=chrony state=stopped enabled=no register: service_info
ignore_errors: true
when: 'ansible_distribution in ["Ubuntu","Debian"]'
- name: stop and disable chronyd in CentOS/RedHat - name: remove service haproxy
service: name=chronyd state=stopped enabled=no service: name=haproxy state=stopped enabled=no
ignore_errors: true when: '"haproxy" in service_info.stdout'
when: 'ansible_distribution in ["CentOS","RedHat","Amazon","Aliyun"]'
when: "groups['chrony']|length > 0"
- name: stop keepalived service
service: name=keepalived state=stopped enabled=no
ignore_errors: true ignore_errors: true
- name: stop haproxy service - name: remove service keepalived
service: name=haproxy state=stopped enabled=no service: name=keepalived state=stopped enabled=no
when: '"keepalived" in service_info.stdout'
ignore_errors: true ignore_errors: true
- name: remove files and dirs - name: remove files and dirs
@ -26,11 +20,3 @@
with_items: with_items:
- "/etc/haproxy" - "/etc/haproxy"
- "/etc/keepalived" - "/etc/keepalived"
- name: clean 'ENV PATH'
lineinfile:
dest: ~/.bashrc
state: absent
regexp: '{{ item }}'
with_items:
- 'kubeasz'