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.

193 lines
4.8 KiB

9 years ago
6 years ago
6 years ago
  1. ---
  2. - import_tasks: facts.yml
  3. tags:
  4. - facts
  5. - import_tasks: pre_upgrade.yml
  6. tags:
  7. - kubelet
  8. - name: Ensure /var/lib/cni exists
  9. file:
  10. path: /var/lib/cni
  11. state: directory
  12. mode: 0755
  13. - import_tasks: install.yml
  14. tags:
  15. - kubelet
  16. - import_tasks: loadbalancer/nginx-proxy.yml
  17. when:
  18. - not is_kube_master
  19. - loadbalancer_apiserver_localhost
  20. - loadbalancer_apiserver_type == 'nginx'
  21. tags:
  22. - nginx
  23. - import_tasks: loadbalancer/haproxy.yml
  24. when:
  25. - not is_kube_master
  26. - loadbalancer_apiserver_localhost
  27. - loadbalancer_apiserver_type == 'haproxy'
  28. tags:
  29. - haproxy
  30. - name: Ensure nodePort range is reserved
  31. sysctl:
  32. name: net.ipv4.ip_local_reserved_ports
  33. value: "{{ kube_apiserver_node_port_range }}"
  34. sysctl_set: yes
  35. sysctl_file: "{{ sysctl_file_path }}"
  36. state: present
  37. reload: yes
  38. when: kube_apiserver_node_port_range is defined
  39. tags:
  40. - kube-proxy
  41. - name: Verify if br_netfilter module exists
  42. command: "modinfo br_netfilter"
  43. environment:
  44. PATH: "{{ ansible_env.PATH }}:/sbin" # Make sure we can workaround RH's conservative path management
  45. register: modinfo_br_netfilter
  46. failed_when: modinfo_br_netfilter.rc not in [0, 1]
  47. changed_when: false
  48. - name: Verify br_netfilter module path exists
  49. file:
  50. path: /etc/modules-load.d
  51. state: directory
  52. - name: Enable br_netfilter module
  53. modprobe:
  54. name: br_netfilter
  55. state: present
  56. when: modinfo_br_netfilter.rc == 0
  57. - name: Persist br_netfilter module
  58. copy:
  59. dest: /etc/modules-load.d/kubespray-br_netfilter.conf
  60. content: br_netfilter
  61. when: modinfo_br_netfilter.rc == 0
  62. # kube-proxy needs net.bridge.bridge-nf-call-iptables enabled when found if br_netfilter is not a module
  63. - name: Check if bridge-nf-call-iptables key exists
  64. command: "sysctl net.bridge.bridge-nf-call-iptables"
  65. failed_when: false
  66. changed_when: false
  67. register: sysctl_bridge_nf_call_iptables
  68. - name: Enable bridge-nf-call tables
  69. sysctl:
  70. name: "{{ item }}"
  71. state: present
  72. sysctl_file: "{{ sysctl_file_path }}"
  73. value: "1"
  74. reload: yes
  75. when: sysctl_bridge_nf_call_iptables.rc == 0
  76. with_items:
  77. - net.bridge.bridge-nf-call-iptables
  78. - net.bridge.bridge-nf-call-arptables
  79. - net.bridge.bridge-nf-call-ip6tables
  80. - name: Modprobe Kernel Module for IPVS
  81. modprobe:
  82. name: "{{ item }}"
  83. state: present
  84. with_items:
  85. - ip_vs
  86. - ip_vs_rr
  87. - ip_vs_wrr
  88. - ip_vs_sh
  89. when: kube_proxy_mode == 'ipvs'
  90. tags:
  91. - kube-proxy
  92. - name: Modprobe nf_conntrack_ipv4 for kernels < 4.19
  93. modprobe:
  94. name: nf_conntrack_ipv4
  95. state: present
  96. register: enable_nf_conntrack
  97. when:
  98. - ansible_kernel.split('.')[0:3] | join('.') < '4.19'
  99. - kube_proxy_mode == 'ipvs'
  100. tags:
  101. - kube-proxy
  102. - name: Modprobe nf_conntrack for kernels >= 4.19
  103. modprobe:
  104. name: nf_conntrack
  105. state: present
  106. when:
  107. - ansible_kernel.split('.')[0:3] | join('.') >= '4.19'
  108. - kube_proxy_mode == 'ipvs'
  109. tags:
  110. - kube-proxy
  111. - name: Persist ip_vs modules
  112. copy:
  113. dest: /etc/modules-load.d/kube_proxy-ipvs.conf
  114. content: |
  115. ip_vs
  116. ip_vs_rr
  117. ip_vs_wrr
  118. ip_vs_sh
  119. {% if enable_nf_conntrack is failed -%}
  120. nf_conntrack
  121. {%- else -%}
  122. nf_conntrack_ipv4
  123. {%- endif -%}
  124. when: kube_proxy_mode == 'ipvs'
  125. tags:
  126. - kube-proxy
  127. - include_tasks: "cloud-credentials/{{ cloud_provider }}-credential-check.yml"
  128. when:
  129. - cloud_provider is defined
  130. - cloud_provider in [ 'openstack', 'azure', 'vsphere' ]
  131. tags:
  132. - cloud-provider
  133. - facts
  134. - name: Test if openstack_cacert is a base64 string
  135. set_fact:
  136. openstack_cacert_is_base64: "{% if openstack_cacert | search ('^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$') %}true{% else %}false{% endif %}"
  137. when:
  138. - cloud_provider is defined
  139. - cloud_provider == 'openstack'
  140. - openstack_cacert is defined
  141. - openstack_cacert | length > 0
  142. - name: Write cacert file
  143. copy:
  144. src: "{{ openstack_cacert if not openstack_cacert_is_base64 else omit }}"
  145. content: "{{ openstack_cacert | b64decode if openstack_cacert_is_base64 else omit }}"
  146. dest: "{{ kube_config_dir }}/openstack-cacert.pem"
  147. group: "{{ kube_cert_group }}"
  148. mode: 0640
  149. when:
  150. - cloud_provider is defined
  151. - cloud_provider == 'openstack'
  152. - openstack_cacert is defined
  153. - openstack_cacert | length > 0
  154. tags:
  155. - cloud-provider
  156. - name: Write cloud-config
  157. template:
  158. src: "cloud-configs/{{ cloud_provider }}-cloud-config.j2"
  159. dest: "{{ kube_config_dir }}/cloud_config"
  160. group: "{{ kube_cert_group }}"
  161. mode: 0640
  162. when:
  163. - cloud_provider is defined
  164. - cloud_provider in [ 'openstack', 'azure', 'vsphere', 'aws' ]
  165. notify: Node | restart kubelet
  166. tags:
  167. - cloud-provider
  168. - import_tasks: kubelet.yml
  169. tags:
  170. - kubelet
  171. - kubeadm