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
This commit is contained in:
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 - name: Master | Restart apiserver
command: /bin/true command: /bin/true
notify: notify:
- Master | Remove apiserver container - Master | Remove apiserver container docker
- Master | Remove apiserver container containerd/crio
- Master | wait for the apiserver to be running - Master | wait for the apiserver to be running
- name: Master | Restart kube-scheduler - name: Master | Restart kube-scheduler
command: /bin/true command: /bin/true
notify: notify:
- Master | Remove scheduler container - Master | Remove scheduler container docker
- Master | Remove scheduler container containerd/crio
- Master | wait for kube-scheduler - Master | wait for kube-scheduler
- name: Master | Restart kube-controller-manager - name: Master | Restart kube-controller-manager
command: /bin/true command: /bin/true
notify: 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 - Master | wait for kube-controller-manager
- name: Master | reload systemd - name: Master | reload systemd
@ -40,26 +43,53 @@
name: kubelet name: kubelet
state: restarted state: restarted
- name: Master | Remove apiserver container - name: Master | Remove apiserver container docker
shell: "docker ps -af name=k8s_kube-apiserver* -q | xargs --no-run-if-empty docker rm -f" shell: docker ps -af name=k8s_kube-apiserver* -q | xargs --no-run-if-empty docker rm -f
register: remove_apiserver_container register: remove_apiserver_container
retries: 10 retries: 10
until: remove_apiserver_container.rc == 0 until: remove_apiserver_container.rc == 0
delay: 1 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" shell: "docker ps -af name=k8s_kube-scheduler* -q | xargs --no-run-if-empty docker rm -f"
register: remove_scheduler_container register: remove_scheduler_container
retries: 10 retries: 10
until: remove_scheduler_container.rc == 0 until: remove_scheduler_container.rc == 0
delay: 1 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" shell: "docker ps -af name=k8s_kube-controller-manager* -q | xargs --no-run-if-empty docker rm -f"
register: remove_cm_container register: remove_cm_container
retries: 10 retries: 10
until: remove_cm_container.rc == 0 until: remove_cm_container.rc == 0
delay: 1 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 - name: Master | wait for kube-scheduler
uri: uri:

View file

@ -6,8 +6,10 @@
- Preinstall | reload kubelet - Preinstall | reload kubelet
- Preinstall | kube-controller configured - Preinstall | kube-controller configured
- Preinstall | kube-apiserver configured - Preinstall | kube-apiserver configured
- Preinstall | restart kube-controller-manager - Preinstall | restart kube-controller-manager docker
- Preinstall | restart kube-apiserver - 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"] when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
# FIXME(bogdando) https://github.com/projectcalico/felix/issues/1185 # FIXME(bogdando) https://github.com/projectcalico/felix/issues/1185
@ -42,8 +44,10 @@
notify: notify:
- Preinstall | kube-controller configured - Preinstall | kube-controller configured
- Preinstall | kube-apiserver configured - Preinstall | kube-apiserver configured
- Preinstall | restart kube-controller-manager - Preinstall | restart kube-controller-manager docker
- Preinstall | restart kube-apiserver - Preinstall | restart kube-controller-manager crio/containerd
- Preinstall | restart kube-apiserver docker
- Preinstall | restart kube-apiserver crio/containerd
when: not dns_early|bool when: not dns_early|bool
# FIXME(mattymo): Also restart for kubeadm mode # FIXME(mattymo): Also restart for kubeadm mode
@ -58,10 +62,36 @@
register: kube_controller_set register: kube_controller_set
when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf' 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" 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" 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'