Add support for restart handlers for control plane on crio/containerd (#5250)

* Add support for restart handlers for control plane on crio/containerd

Change-Id: I8343cc4e9df7f55b732628ed01cc6e7ea5dcee85

* Update main.yml
pull/5279/head
Matthew Mosesohn 2019-10-17 04:58:39 +03:00 committed by Kubernetes Prow Robot
parent db33dc6938
commit ac60786c6f
2 changed files with 75 additions and 15 deletions

View File

@ -16,19 +16,22 @@
- name: Master | Restart apiserver
command: /bin/true
notify:
- Master | Remove apiserver container
- Master | Remove apiserver container docker
- Master | Remove apiserver container containerd/crio
- Master | wait for the apiserver to be running
- name: Master | Restart kube-scheduler
command: /bin/true
notify:
- Master | Remove scheduler container
- Master | Remove scheduler container docker
- Master | Remove scheduler container containerd/crio
- Master | wait for kube-scheduler
- name: Master | Restart kube-controller-manager
command: /bin/true
notify:
- Master | Remove controller manager container
- Master | Remove controller manager container docker
- Master | Remove controller manager container containerd/crio
- Master | wait for kube-controller-manager
- name: Master | reload systemd
@ -40,26 +43,53 @@
name: kubelet
state: restarted
- name: Master | Remove apiserver container
shell: "docker ps -af name=k8s_kube-apiserver* -q | xargs --no-run-if-empty docker rm -f"
- name: Master | Remove apiserver container docker
shell: docker ps -af name=k8s_kube-apiserver* -q | xargs --no-run-if-empty docker rm -f
register: remove_apiserver_container
retries: 10
until: remove_apiserver_container.rc == 0
delay: 1
when: container_manager == "docker"
- name: Master | Remove scheduler container
- name: Master | Remove apiserver container containerd/crio
shell: crictl pods --name kube-apiserver* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
register: remove_apiserver_container
retries: 10
until: remove_apiserver_container.rc == 0
delay: 1
when: container_manager in ['containerd', 'crio']
- name: Master | Remove scheduler container docker
shell: "docker ps -af name=k8s_kube-scheduler* -q | xargs --no-run-if-empty docker rm -f"
register: remove_scheduler_container
retries: 10
until: remove_scheduler_container.rc == 0
delay: 1
when: container_manager == "docker"
- name: Master | Remove controller manager container
- name: Master | Remove scheduler container containerd/crio
shell: crictl pods --name kube-scheduler* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
register: remove_scheduler_container
retries: 10
until: remove_scheduler_container.rc == 0
delay: 1
when: container_manager in ['containerd', 'crio']
- name: Master | Remove controller manager container docker
shell: "docker ps -af name=k8s_kube-controller-manager* -q | xargs --no-run-if-empty docker rm -f"
register: remove_cm_container
retries: 10
until: remove_cm_container.rc == 0
delay: 1
when: container_manager == "docker"
- name: Master | Remove controller manager container containerd/crio
shell: crictl pods --name kube-controller-manager* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
register: remove_cm_container
retries: 10
until: remove_cm_container.rc == 0
delay: 1
when: container_manager in ['containerd', 'crio']
- name: Master | wait for kube-scheduler
uri:

View File

@ -6,8 +6,10 @@
- Preinstall | reload kubelet
- Preinstall | kube-controller configured
- Preinstall | kube-apiserver configured
- Preinstall | restart kube-controller-manager
- Preinstall | restart kube-apiserver
- Preinstall | restart kube-controller-manager docker
- Preinstall | restart kube-controller-manager crio/containerd
- Preinstall | restart kube-apiserver docker
- Preinstall | restart kube-apiserver crio/containerd
when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
# FIXME(bogdando) https://github.com/projectcalico/felix/issues/1185
@ -42,8 +44,10 @@
notify:
- Preinstall | kube-controller configured
- Preinstall | kube-apiserver configured
- Preinstall | restart kube-controller-manager
- Preinstall | restart kube-apiserver
- Preinstall | restart kube-controller-manager docker
- Preinstall | restart kube-controller-manager crio/containerd
- Preinstall | restart kube-apiserver docker
- Preinstall | restart kube-apiserver crio/containerd
when: not dns_early|bool
# FIXME(mattymo): Also restart for kubeadm mode
@ -58,10 +62,36 @@
register: kube_controller_set
when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'
- name: Preinstall | restart kube-controller-manager
- name: Preinstall | restart kube-controller-manager docker
shell: "docker ps -f name=k8s_POD_kube-controller-manager* -q | xargs --no-run-if-empty docker rm -f"
when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf' and kube_controller_set.stat.exists
when:
- container_manager == "docker"
- inventory_hostname in groups['kube-master']
- dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf'
- kube_controller_set.stat.exists
- name: Preinstall | restart kube-apiserver
- name: Preinstall | restart kube-controller-manager crio/containerd
shell: crictl pods --name kube-controller-manager* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
when:
- container_manager in ['crio', 'containerd']
- inventory_hostname in groups['kube-master']
- dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf'
- kube_controller_set.stat.exists
- name: Preinstall | restart kube-apiserver docker
shell: "docker ps -f name=k8s_POD_kube-apiserver* -q | xargs --no-run-if-empty docker rm -f"
when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'
when:
- container_manager == "docker"
- inventory_hostname in groups['kube-master']
- dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf'
- name: Preinstall | restart kube-apiserver crio/containerd
shell: crictl pods --name kube-apiserver* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
when:
- container_manager in ['crio', 'containerd']
- inventory_hostname in groups['kube-master']
- dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf'