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.

182 lines
4.1 KiB

9 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: nginx-proxy.yml
  17. when: is_kube_master == false and loadbalancer_apiserver_localhost
  18. tags:
  19. - nginx
  20. - name: Write kubelet config file (non-kubeadm)
  21. template:
  22. src: kubelet.standard.env.j2
  23. dest: "{{ kube_config_dir }}/kubelet.env"
  24. backup: yes
  25. when: not kubeadm_enabled
  26. notify: restart kubelet
  27. tags:
  28. - kubelet
  29. - name: Write kubelet config file (kubeadm)
  30. template:
  31. src: kubelet.kubeadm.env.j2
  32. dest: "{{ kube_config_dir }}/kubelet.env"
  33. backup: yes
  34. when: kubeadm_enabled
  35. notify: restart kubelet
  36. tags:
  37. - kubelet
  38. - kubeadm
  39. - name: write the kubecfg (auth) file for kubelet
  40. template:
  41. src: "{{ item }}-kubeconfig.yaml.j2"
  42. dest: "{{ kube_config_dir }}/{{ item }}-kubeconfig.yaml"
  43. backup: yes
  44. with_items:
  45. - node
  46. - kube-proxy
  47. when: not kubeadm_enabled
  48. notify: restart kubelet
  49. tags:
  50. - kubelet
  51. - name: Ensure nodePort range is reserved
  52. sysctl:
  53. name: net.ipv4.ip_local_reserved_ports
  54. value: "{{ kube_apiserver_node_port_range }}"
  55. sysctl_set: yes
  56. sysctl_file: "{{ sysctl_file_path }}"
  57. state: present
  58. reload: yes
  59. when: kube_apiserver_node_port_range is defined
  60. tags:
  61. - kube-proxy
  62. - name: Verify if br_netfilter module exists
  63. shell: "modinfo br_netfilter"
  64. register: modinfo_br_netfilter
  65. failed_when: modinfo_br_netfilter.rc not in [0, 1]
  66. changed_when: false
  67. - name: Enable br_netfilter module
  68. modprobe:
  69. name: br_netfilter
  70. state: present
  71. when: modinfo_br_netfilter.rc == 0
  72. - name: Persist br_netfilter module
  73. copy:
  74. dest: /etc/modules-load.d/kubespray-br_netfilter.conf
  75. content: br_netfilter
  76. when: modinfo_br_netfilter.rc == 0
  77. # kube-proxy needs net.bridge.bridge-nf-call-iptables enabled when found if br_netfilter is not a module
  78. - name: Check if bridge-nf-call-iptables key exists
  79. command: "sysctl net.bridge.bridge-nf-call-iptables"
  80. failed_when: false
  81. changed_when: false
  82. register: sysctl_bridge_nf_call_iptables
  83. - name: Enable bridge-nf-call tables
  84. sysctl:
  85. name: "{{ item }}"
  86. state: present
  87. sysctl_file: "{{ sysctl_file_path }}"
  88. value: 1
  89. reload: yes
  90. when: sysctl_bridge_nf_call_iptables.rc == 0
  91. with_items:
  92. - net.bridge.bridge-nf-call-iptables
  93. - net.bridge.bridge-nf-call-arptables
  94. - net.bridge.bridge-nf-call-ip6tables
  95. - name: Modprode Kernel Module for IPVS
  96. modprobe:
  97. name: "{{ item }}"
  98. state: present
  99. when: kube_proxy_mode == 'ipvs'
  100. with_items:
  101. - ip_vs
  102. - ip_vs_rr
  103. - ip_vs_wrr
  104. - ip_vs_sh
  105. - nf_conntrack_ipv4
  106. tags:
  107. - kube-proxy
  108. - name: Persist ip_vs modules
  109. copy:
  110. dest: /etc/modules-load.d/kube_proxy-ipvs.conf
  111. content: |
  112. ip_vs
  113. ip_vs_rr
  114. ip_vs_wrr
  115. ip_vs_sh
  116. nf_conntrack_ipv4
  117. when: kube_proxy_mode == 'ipvs'
  118. tags:
  119. - kube-proxy
  120. - name: Write proxy manifest
  121. template:
  122. src: manifests/kube-proxy.manifest.j2
  123. dest: "{{ kube_manifest_dir }}/kube-proxy.manifest"
  124. when: not kubeadm_enabled
  125. tags:
  126. - kube-proxy
  127. - name: Purge proxy manifest for kubeadm
  128. file:
  129. path: "{{ kube_manifest_dir }}/kube-proxy.manifest"
  130. state: absent
  131. when: kubeadm_enabled
  132. tags:
  133. - kube-proxy
  134. - include_tasks: "{{ cloud_provider }}-credential-check.yml"
  135. when:
  136. - cloud_provider is defined
  137. - cloud_provider in [ 'openstack', 'azure', 'vsphere' ]
  138. tags:
  139. - cloud-provider
  140. - facts
  141. - name: Write cloud-config
  142. template:
  143. src: "{{ cloud_provider }}-cloud-config.j2"
  144. dest: "{{ kube_config_dir }}/cloud_config"
  145. group: "{{ kube_cert_group }}"
  146. mode: 0640
  147. when:
  148. - cloud_provider is defined
  149. - cloud_provider in [ 'openstack', 'azure', 'vsphere' ]
  150. notify: restart kubelet
  151. tags:
  152. - cloud-provider
  153. # reload-systemd
  154. - meta: flush_handlers
  155. - name: Enable kubelet
  156. service:
  157. name: kubelet
  158. enabled: yes
  159. state: started
  160. tags:
  161. - kubelet