增加临时启停集群脚本

pull/708/head
jmgao 2019-10-01 22:32:51 +08:00
parent 77578bb215
commit f26aba455c
2 changed files with 90 additions and 0 deletions

45
91.start.yml 100644
View File

@ -0,0 +1,45 @@
- hosts: etcd
tasks:
- name: starting etcd cluster
service: name=etcd state=started enabled=yes
- hosts: kube-master
tasks:
- name: starting kube-master services
service: name={{ item }} state=started enabled=yes
with_items:
- kube-apiserver
- kube-controller-manager
- kube-scheduler
- hosts:
- kube-master
- kube-node
tasks:
- name: starting docker
service: name=docker state=started enabled=yes
when: "CONTAINER_RUNTIME == 'docker'"
- name: starting containerd
service: name=containerd state=started enabled=yes
when: "CONTAINER_RUNTIME == 'containerd'"
- name: starting haproxy on kube-node
service: name=haproxy state=started enabled=yes
when:
- "inventory_hostname not in groups['kube-master']"
- "groups['kube-master']|length > 1"
- name: starting kube-node services
service: name={{ item }} state=started enabled=yes
with_items:
- kubelet
- kube-proxy
- hosts: ex-lb
tasks:
- name: starting external loadbalance
service: name={{ item }} state=started enabled=yes
with_items:
- haproxy
- keepalived

45
92.stop.yml 100644
View File

@ -0,0 +1,45 @@
- hosts: kube-master
tasks:
- name: stopping kube-master services
service: name={{ item }} state=stopped enabled=no
with_items:
- kube-apiserver
- kube-controller-manager
- kube-scheduler
- hosts: etcd
tasks:
- name: stopping etcd cluster
service: name=etcd state=stopped enabled=no
- hosts: ex-lb
tasks:
- name: stopping external loadbalance
service: name={{ item }} state=stopped enabled=no
with_items:
- haproxy
- keepalived
- hosts:
- kube-master
- kube-node
tasks:
- name: stopping haproxy on kube-node
service: name=haproxy state=stopped enabled=no
when:
- "inventory_hostname not in groups['kube-master']"
- "groups['kube-master']|length > 1"
- name: stopping kube-node services
service: name={{ item }} state=stopped enabled=no
with_items:
- kubelet
- kube-proxy
- name: stopping docker
service: name=docker state=stopped enabled=no
when: "CONTAINER_RUNTIME == 'docker'"
- name: stopping containerd
service: name=containerd state=stopped enabled=no
when: "CONTAINER_RUNTIME == 'containerd'"