diff --git a/roles/kube-master/tasks/main.yml b/roles/kube-master/tasks/main.yml index f437411..088d657 100644 --- a/roles/kube-master/tasks/main.yml +++ b/roles/kube-master/tasks/main.yml @@ -26,30 +26,24 @@ - name: 创建kube-apiserver的systemd unit文件 template: src=kube-apiserver.service.j2 dest=/etc/systemd/system/kube-apiserver.service + tags: restart_master - name: 创建kube-controller-manager的systemd unit文件 template: src=kube-controller-manager.service.j2 dest=/etc/systemd/system/kube-controller-manager.service + tags: restart_master - name: 创建kube-scheduler的systemd unit文件 template: src=kube-scheduler.service.j2 dest=/etc/systemd/system/kube-scheduler.service + tags: restart_master - name: daemon-reload shell: systemctl daemon-reload + tags: restart_master -- name: enable-kube-apiserver - shell: systemctl enable kube-apiserver +- name: 开机启用master服务 + shell: systemctl enable kube-apiserver kube-controller-manager kube-scheduler + ignore_errors: true -- name: enable-kube-controller-manager - shell: systemctl enable kube-controller-manager - -- name: enable-kube-scheduler - shell: systemctl enable kube-scheduler - -- name: start-kube-apiserver - shell: systemctl restart kube-apiserver - -- name: start-kube-controller-manager - shell: systemctl restart kube-controller-manager - -- name: start-kube-scheduler - shell: systemctl restart kube-scheduler +- name: 开启master服务 + shell: systemctl restart kube-apiserver && systemctl restart kube-controller-manager && systemctl restart kube-scheduler + tags: restart_master diff --git a/roles/kube-node/tasks/main.yml b/roles/kube-node/tasks/main.yml index 3c4c0ce..d18bc76 100644 --- a/roles/kube-node/tasks/main.yml +++ b/roles/kube-node/tasks/main.yml @@ -41,9 +41,15 @@ - name: 创建kubelet的systemd unit文件 template: src=kubelet.service.j2 dest=/etc/systemd/system/kubelet.service + tags: restart_node + +- name: 开机启用kubelet 服务 + shell: systemctl enable kubelet + ignore_errors: true - name: 开启kubelet 服务 - shell: systemctl daemon-reload && systemctl enable kubelet && systemctl restart kubelet + shell: systemctl daemon-reload && systemctl restart kubelet + tags: restart_node - name: approve-kubelet-csr shell: "sleep 15 && {{ bin_dir }}/kubectl get csr|grep 'Pending' | awk 'NR>0{print $1}'| xargs {{ bin_dir }}/kubectl certificate approve" @@ -89,12 +95,16 @@ file: name=/var/lib/kube-proxy state=directory - name: 创建kube-proxy 服务文件 - tags: reload-kube-proxy template: src=kube-proxy.service.j2 dest=/etc/systemd/system/kube-proxy.service + tags: restart_node + +- name: 开机启用kube-proxy 服务 + shell: systemctl enable kube-proxy + ignore_errors: true - name: 开启kube-proxy 服务 - tags: reload-kube-proxy - shell: systemctl daemon-reload && systemctl enable kube-proxy && systemctl restart kube-proxy + shell: systemctl daemon-reload && systemctl restart kube-proxy + tags: restart_node ##-------calico-kube-controllers部分---------------- #