diff --git a/roles/kubernetes/master/handlers/main.yml b/roles/kubernetes/master/handlers/main.yml index e5d5f7739..a4082887b 100644 --- a/roles/kubernetes/master/handlers/main.yml +++ b/roles/kubernetes/master/handlers/main.yml @@ -1,16 +1,4 @@ --- - - name: restart kube-apiserver - command: /bin/true - notify: - - reload systemd - - reload kube-apiserver - -- name: reload systemd - command: systemctl daemon-reload - when: init_system == "systemd" - -- name: reload kube-apiserver - service: - name: kube-apiserver - state: restarted + set_fact: + restart_apimaster: True diff --git a/roles/kubernetes/master/tasks/main.yml b/roles/kubernetes/master/tasks/main.yml index 430fb7c97..5dfa7c49b 100644 --- a/roles/kubernetes/master/tasks/main.yml +++ b/roles/kubernetes/master/tasks/main.yml @@ -76,11 +76,9 @@ - meta: flush_handlers -- name: Enable apiserver - service: - name: kube-apiserver - enabled: yes - state: started +- include: start.yml + with_items: groups['kube-master'] + when: "{{ hostvars[item].inventory_hostname == inventory_hostname }}" # Create kube-system namespace - name: copy 'kube-system' namespace manifest diff --git a/roles/kubernetes/master/tasks/start.yml b/roles/kubernetes/master/tasks/start.yml new file mode 100644 index 000000000..7fa4f2764 --- /dev/null +++ b/roles/kubernetes/master/tasks/start.yml @@ -0,0 +1,21 @@ +--- +- name: Pause + pause: seconds=10 + +- name: reload systemd + command: systemctl daemon-reload + when: init_system == "systemd" and restart_apimaster is defined and restart_apimaster == True + +- name: reload kube-apiserver + service: + name: kube-apiserver + state: restarted + enabled: yes + when: restart_apimaster is defined and restart_apimaster == True + +- name: Enable apiserver + service: + name: kube-apiserver + enabled: yes + state: started + when: restart_apimaster is not defined or restart_apimaster == False \ No newline at end of file