From e38258381fd0d111cd339ce3e334920d5898dbe9 Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Mon, 1 Aug 2016 16:12:23 +0300 Subject: [PATCH] Wait for static pods when setting up Fixes #390 --- roles/kubernetes/master/handlers/main.yml | 37 +++++++++++++++++++++-- roles/kubernetes/master/tasks/main.yml | 9 ++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/roles/kubernetes/master/handlers/main.yml b/roles/kubernetes/master/handlers/main.yml index a4082887b..87e3adc69 100644 --- a/roles/kubernetes/master/handlers/main.yml +++ b/roles/kubernetes/master/handlers/main.yml @@ -1,4 +1,35 @@ --- -- name: restart kube-apiserver - set_fact: - restart_apimaster: True +- name: Master | restart kubelet + command: /bin/true + notify: + - Kubelet | reload systemd + - Kubelet | reload kubelet + +- name: wait for master static pods + command: /bin/true + notify: + - wait for kube-scheduler + - wait for kube-controller-manager + +- name: Master | reload systemd + command: systemctl daemon-reload + when: ansible_service_mgr == "systemd" + +- name: Master | reload kubelet + service: + name: kubelet + state: restarted + +- name: wait for kube-scheduler + uri: url=http://localhost:10251/healthz + register: scheduler_result + until: scheduler_result.status == 200 + retries: 15 + delay: 5 + +- name: wait for kube-controller-manager + uri: url=http://localhost:10252/healthz + register: controller_manager_result + until: controller_manager_result.status == 200 + retries: 15 + delay: 5 diff --git a/roles/kubernetes/master/tasks/main.yml b/roles/kubernetes/master/tasks/main.yml index fe984ce17..9140ef36c 100644 --- a/roles/kubernetes/master/tasks/main.yml +++ b/roles/kubernetes/master/tasks/main.yml @@ -19,12 +19,7 @@ src: manifests/kube-apiserver.manifest.j2 dest: "{{ kube_manifest_dir }}/kube-apiserver.manifest" register: apiserver_manifest - -- name: restart kubelet - service: - name: kubelet - state: restarted - when: apiserver_manifest.changed + notify: Master | restart kubelet - name: wait for the apiserver to be running uri: url=http://localhost:8080/healthz @@ -58,8 +53,10 @@ template: src: manifests/kube-controller-manager.manifest.j2 dest: "{{ kube_manifest_dir }}/kube-controller-manager.manifest" + notify: wait for kube-controller-manager - name: Write kube-scheduler manifest template: src: manifests/kube-scheduler.manifest.j2 dest: "{{ kube_manifest_dir }}/kube-scheduler.manifest" + notify: wait for kube-scheduler