You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
4.1 KiB

9 years ago
  1. ---
  2. - name: Master | restart kubelet
  3. command: /bin/true
  4. notify:
  5. - Master | reload systemd
  6. - Master | reload kubelet
  7. - Master | wait for master static pods
  8. - name: Master | wait for master static pods
  9. command: /bin/true
  10. notify:
  11. - Master | wait for the apiserver to be running
  12. - Master | wait for kube-scheduler
  13. - Master | wait for kube-controller-manager
  14. - name: Master | Restart apiserver
  15. command: /bin/true
  16. notify:
  17. - Master | Remove apiserver container docker
  18. - Master | Remove apiserver container containerd/crio
  19. - Master | wait for the apiserver to be running
  20. - name: Master | Restart kube-scheduler
  21. command: /bin/true
  22. notify:
  23. - Master | Remove scheduler container docker
  24. - Master | Remove scheduler container containerd/crio
  25. - Master | wait for kube-scheduler
  26. - name: Master | Restart kube-controller-manager
  27. command: /bin/true
  28. notify:
  29. - Master | Remove controller manager container docker
  30. - Master | Remove controller manager container containerd/crio
  31. - Master | wait for kube-controller-manager
  32. - name: Master | reload systemd
  33. systemd:
  34. daemon_reload: true
  35. - name: Master | reload kubelet
  36. service:
  37. name: kubelet
  38. state: restarted
  39. - name: Master | Remove apiserver container docker
  40. shell: docker ps -af name=k8s_kube-apiserver* -q | xargs --no-run-if-empty docker rm -f
  41. register: remove_apiserver_container
  42. retries: 10
  43. until: remove_apiserver_container.rc == 0
  44. delay: 1
  45. when: container_manager == "docker"
  46. - name: Master | Remove apiserver container containerd/crio
  47. shell: crictl pods --name kube-apiserver* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
  48. register: remove_apiserver_container
  49. retries: 10
  50. until: remove_apiserver_container.rc == 0
  51. delay: 1
  52. when: container_manager in ['containerd', 'crio']
  53. - name: Master | Remove scheduler container docker
  54. shell: "docker ps -af name=k8s_kube-scheduler* -q | xargs --no-run-if-empty docker rm -f"
  55. register: remove_scheduler_container
  56. retries: 10
  57. until: remove_scheduler_container.rc == 0
  58. delay: 1
  59. when: container_manager == "docker"
  60. - name: Master | Remove scheduler container containerd/crio
  61. shell: crictl pods --name kube-scheduler* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
  62. register: remove_scheduler_container
  63. retries: 10
  64. until: remove_scheduler_container.rc == 0
  65. delay: 1
  66. when: container_manager in ['containerd', 'crio']
  67. - name: Master | Remove controller manager container docker
  68. shell: "docker ps -af name=k8s_kube-controller-manager* -q | xargs --no-run-if-empty docker rm -f"
  69. register: remove_cm_container
  70. retries: 10
  71. until: remove_cm_container.rc == 0
  72. delay: 1
  73. when: container_manager == "docker"
  74. - name: Master | Remove controller manager container containerd/crio
  75. shell: crictl pods --name kube-controller-manager* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
  76. register: remove_cm_container
  77. retries: 10
  78. until: remove_cm_container.rc == 0
  79. delay: 1
  80. when: container_manager in ['containerd', 'crio']
  81. - name: Master | wait for kube-scheduler
  82. uri:
  83. url: https://localhost:10259/healthz
  84. validate_certs: no
  85. register: scheduler_result
  86. until: scheduler_result.status == 200
  87. retries: 60
  88. delay: 1
  89. - name: Master | wait for kube-controller-manager
  90. uri:
  91. url: https://localhost:10257/healthz
  92. validate_certs: no
  93. register: controller_manager_result
  94. until: controller_manager_result.status == 200
  95. retries: 60
  96. delay: 1
  97. - name: Master | wait for the apiserver to be running
  98. uri:
  99. url: "{{ kube_apiserver_endpoint }}/healthz"
  100. validate_certs: no
  101. register: result
  102. until: result.status == 200
  103. retries: 60
  104. delay: 1
  105. - name: Master | set secret_changed
  106. command: /bin/true
  107. notify:
  108. - Master | set secret_changed to true
  109. - Master | Copy new kubeconfig for root user
  110. - name: Master | set secret_changed to true
  111. set_fact:
  112. secret_changed: true
  113. - name: Master | Copy new kubeconfig for root user
  114. copy:
  115. src: "{{ kube_config_dir }}/admin.conf"
  116. dest: "{{ ansible_env.HOME | default('/root') }}/.kube/config"
  117. remote_src: yes
  118. mode: "0600"
  119. backup: yes