From 19b7e1371c49e0cda5d7022c3e9fd6228d5d27b2 Mon Sep 17 00:00:00 2001 From: Calin Cristian Andrei Date: Sun, 5 Dec 2021 21:16:19 +0000 Subject: [PATCH] Wait for kube-apiserver to come back after pod refresh --- roles/kubernetes/preinstall/handlers/main.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/roles/kubernetes/preinstall/handlers/main.yml b/roles/kubernetes/preinstall/handlers/main.yml index 54a5f6a6708..667465b6fcb 100644 --- a/roles/kubernetes/preinstall/handlers/main.yml +++ b/roles/kubernetes/preinstall/handlers/main.yml @@ -9,6 +9,7 @@ - Preinstall | restart kube-controller-manager crio/containerd - Preinstall | restart kube-apiserver docker - Preinstall | restart kube-apiserver crio/containerd + - Preinstall | wait for the apiserver to be running when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"] and not is_fedora_coreos - name: Preinstall | update resolvconf for Flatcar Container Linux by Kinvolk @@ -101,6 +102,21 @@ - dns_mode != 'none' - resolvconf_mode == 'host_resolvconf' +# When running this as the last phase ensure we wait for kube-apiserver to come up +- name: Preinstall | wait for the apiserver to be running + uri: + url: "{{ kube_apiserver_endpoint }}/healthz" + validate_certs: no + register: result + until: result.status == 200 + retries: 60 + delay: 1 + when: + - dns_late + - inventory_hostname in groups['kube_control_plane'] + - dns_mode != 'none' + - resolvconf_mode == 'host_resolvconf' + - name: Preinstall | Restart systemd-resolved service: name: systemd-resolved