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.

308 lines
7.3 KiB

contiv network support (#1914) * Add Contiv support Contiv is a network plugin for Kubernetes and Docker. It supports vlan/vxlan/BGP/Cisco ACI technologies. It support firewall policies, multiple networks and bridging pods onto physical networks. * Update contiv version to 1.1.4 Update contiv version to 1.1.4 and added SVC_SUBNET in contiv-config. * Load openvswitch module to workaround on CentOS7.4 * Set contiv cni version to 0.1.0 Correct contiv CNI version to 0.1.0. * Use kube_apiserver_endpoint for K8S_API_SERVER Use kube_apiserver_endpoint as K8S_API_SERVER to make contiv talks to a available endpoint no matter if there's a loadbalancer or not. * Make contiv use its own etcd Before this commit, contiv is using a etcd proxy mode to k8s etcd, this work fine when the etcd hosts are co-located with contiv etcd proxy, however the k8s peering certs are only in etcd group, as a result the etcd-proxy is not able to peering with the k8s etcd on etcd group, plus the netplugin is always trying to find the etcd endpoint on localhost, this will cause problem for all netplugins not runnign on etcd group nodes. This commit make contiv uses its own etcd, separate from k8s one. on kube-master nodes (where net-master runs), it will run as leader mode and on all rest nodes it will run as proxy mode. * Use cp instead of rsync to copy cni binaries Since rsync has been removed from hyperkube, this commit changes it to use cp instead. * Make contiv-etcd able to run on master nodes * Add rbac_enabled flag for contiv pods * Add contiv into CNI network plugin lists * migrate contiv test to tests/files Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> * Add required rules for contiv netplugin * Better handling json return of fwdMode * Make contiv etcd port configurable * Use default var instead of templating * roles/download/defaults/main.yml: use contiv 1.1.7 Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
7 years ago
  1. ---
  2. - import_tasks: verify-settings.yml
  3. tags:
  4. - asserts
  5. - name: Force binaries directory for Container Linux by CoreOS
  6. set_fact:
  7. bin_dir: "/opt/bin"
  8. when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  9. tags:
  10. - facts
  11. - name: check bin dir exists
  12. file:
  13. path: "{{bin_dir}}"
  14. state: directory
  15. owner: root
  16. become: true
  17. tags:
  18. - bootstrap-os
  19. - import_tasks: set_facts.yml
  20. tags:
  21. - facts
  22. - name: gather os specific variables
  23. include_vars: "{{ item }}"
  24. with_first_found:
  25. - files:
  26. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
  27. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
  28. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
  29. - "{{ ansible_distribution|lower }}.yml"
  30. - "{{ ansible_os_family|lower }}.yml"
  31. - defaults.yml
  32. paths:
  33. - ../vars
  34. skip: true
  35. tags:
  36. - facts
  37. - name: Create kubernetes directories
  38. file:
  39. path: "{{ item }}"
  40. state: directory
  41. owner: kube
  42. when: inventory_hostname in groups['k8s-cluster']
  43. tags:
  44. - kubelet
  45. - k8s-secrets
  46. - kube-controller-manager
  47. - kube-apiserver
  48. - bootstrap-os
  49. - apps
  50. - network
  51. - master
  52. - node
  53. with_items:
  54. - "{{ kube_config_dir }}"
  55. - "{{ kube_config_dir }}/ssl"
  56. - "{{ kube_manifest_dir }}"
  57. - "{{ kube_script_dir }}"
  58. - "{{ local_volume_provisioner_base_dir }}"
  59. - name: check cloud_provider value
  60. fail:
  61. msg: "If set the 'cloud_provider' var must be set either to 'generic', 'gce', 'aws', 'azure', 'openstack', 'vsphere', or external"
  62. when:
  63. - cloud_provider is defined
  64. - cloud_provider not in ['generic', 'gce', 'aws', 'azure', 'openstack', 'vsphere', 'external']
  65. tags:
  66. - cloud-provider
  67. - facts
  68. - include_tasks: "{{ cloud_provider }}-credential-check.yml"
  69. when:
  70. - cloud_provider is defined
  71. - cloud_provider in [ 'openstack', 'azure', 'vsphere' ]
  72. tags:
  73. - cloud-provider
  74. - facts
  75. - name: Create cni directories
  76. file:
  77. path: "{{ item }}"
  78. state: directory
  79. owner: kube
  80. with_items:
  81. - "/etc/cni/net.d"
  82. - "/opt/cni/bin"
  83. when:
  84. - kube_network_plugin in ["calico", "weave", "canal", "flannel", "contiv", "cilium"]
  85. - inventory_hostname in groups['k8s-cluster']
  86. tags:
  87. - network
  88. - cilium
  89. - calico
  90. - weave
  91. - canal
  92. - contiv
  93. - bootstrap-os
  94. - import_tasks: resolvconf.yml
  95. when:
  96. - dns_mode != 'none'
  97. - resolvconf_mode == 'host_resolvconf'
  98. tags:
  99. - bootstrap-os
  100. - resolvconf
  101. - name: Update package management cache (YUM)
  102. yum:
  103. update_cache: yes
  104. name: '*'
  105. register: yum_task_result
  106. until: yum_task_result|succeeded
  107. retries: 4
  108. delay: "{{ retry_stagger | random + 3 }}"
  109. when:
  110. - ansible_pkg_mgr == 'yum'
  111. - ansible_distribution != 'RedHat'
  112. - not is_atomic
  113. tags: bootstrap-os
  114. - name: Expire management cache (YUM) for Updation - Redhat
  115. shell: yum clean expire-cache
  116. register: expire_cache_output
  117. until: expire_cache_output|succeeded
  118. retries: 4
  119. delay: "{{ retry_stagger | random + 3 }}"
  120. when:
  121. - ansible_pkg_mgr == 'yum'
  122. - ansible_distribution == 'RedHat'
  123. - not is_atomic
  124. tags: bootstrap-os
  125. - name: Update package management cache (YUM) - Redhat
  126. shell: yum makecache
  127. register: make_cache_output
  128. until: make_cache_output|succeeded
  129. retries: 4
  130. delay: "{{ retry_stagger | random + 3 }}"
  131. when:
  132. - ansible_pkg_mgr == 'yum'
  133. - ansible_distribution == 'RedHat'
  134. - expire_cache_output.rc == 0
  135. - not is_atomic
  136. tags: bootstrap-os
  137. - name: Update package management cache (APT)
  138. apt:
  139. update_cache: yes
  140. cache_valid_time: 3600
  141. when: ansible_os_family == "Debian"
  142. tags:
  143. - bootstrap-os
  144. - name: Install python-dnf for latest RedHat versions
  145. command: dnf install -y python-dnf yum
  146. register: dnf_task_result
  147. until: dnf_task_result|succeeded
  148. retries: 4
  149. delay: "{{ retry_stagger | random + 3 }}"
  150. when:
  151. - ansible_distribution == "Fedora"
  152. - ansible_distribution_major_version > 21
  153. - not is_atomic
  154. changed_when: False
  155. tags:
  156. - bootstrap-os
  157. - name: Install epel-release on RedHat/CentOS
  158. yum:
  159. name: epel-release
  160. state: present
  161. when:
  162. - ansible_distribution in ["CentOS","RedHat"]
  163. - not is_atomic
  164. - epel_enabled|bool
  165. tags:
  166. - bootstrap-os
  167. - name: Install packages requirements
  168. action:
  169. module: "{{ ansible_pkg_mgr }}"
  170. name: "{{ item }}"
  171. state: latest
  172. register: pkgs_task_result
  173. until: pkgs_task_result|succeeded
  174. retries: 4
  175. delay: "{{ retry_stagger | random + 3 }}"
  176. with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
  177. when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] or is_atomic)
  178. tags:
  179. - bootstrap-os
  180. # Todo : selinux configuration
  181. - name: Confirm selinux deployed
  182. stat:
  183. path: /etc/selinux/config
  184. when: ansible_os_family == "RedHat"
  185. register: slc
  186. - name: Set selinux policy
  187. selinux:
  188. policy: targeted
  189. state: "{{ preinstall_selinux_state }}"
  190. when:
  191. - ansible_os_family == "RedHat"
  192. - slc.stat.exists == True
  193. changed_when: False
  194. tags:
  195. - bootstrap-os
  196. - name: Disable IPv6 DNS lookup
  197. lineinfile:
  198. dest: /etc/gai.conf
  199. line: "precedence ::ffff:0:0/96 100"
  200. state: present
  201. backup: yes
  202. when:
  203. - disable_ipv6_dns
  204. - not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  205. tags:
  206. - bootstrap-os
  207. - name: set default sysctl file path
  208. set_fact:
  209. sysctl_file_path: "/etc/sysctl.d/99-sysctl.conf"
  210. tags:
  211. - bootstrap-os
  212. - name: Stat sysctl file configuration
  213. stat:
  214. path: "{{sysctl_file_path}}"
  215. register: sysctl_file_stat
  216. tags:
  217. - bootstrap-os
  218. - name: Change sysctl file path to link source if linked
  219. set_fact:
  220. sysctl_file_path: "{{sysctl_file_stat.stat.lnk_source}}"
  221. when:
  222. - sysctl_file_stat.stat.islnk is defined
  223. - sysctl_file_stat.stat.islnk
  224. tags:
  225. - bootstrap-os
  226. - name: Enable ip forwarding
  227. sysctl:
  228. sysctl_file: "{{sysctl_file_path}}"
  229. name: net.ipv4.ip_forward
  230. value: 1
  231. state: present
  232. reload: yes
  233. tags:
  234. - bootstrap-os
  235. - name: Write cloud-config
  236. template:
  237. src: "{{ cloud_provider }}-cloud-config.j2"
  238. dest: "{{ kube_config_dir }}/cloud_config"
  239. group: "{{ kube_cert_group }}"
  240. mode: 0640
  241. when:
  242. - inventory_hostname in groups['k8s-cluster']
  243. - cloud_provider is defined
  244. - cloud_provider in [ 'openstack', 'azure', 'vsphere' ]
  245. tags:
  246. - cloud-provider
  247. - import_tasks: etchosts.yml
  248. tags:
  249. - bootstrap-os
  250. - etchosts
  251. - import_tasks: dhclient-hooks.yml
  252. when:
  253. - dns_mode != 'none'
  254. - resolvconf_mode == 'host_resolvconf'
  255. - not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  256. tags:
  257. - bootstrap-os
  258. - resolvconf
  259. - import_tasks: dhclient-hooks-undo.yml
  260. when:
  261. - dns_mode != 'none'
  262. - resolvconf_mode != 'host_resolvconf'
  263. - not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  264. tags:
  265. - bootstrap-os
  266. - resolvconf
  267. - name: Check if we are running inside a Azure VM
  268. stat:
  269. path: /var/lib/waagent/
  270. register: azure_check
  271. tags:
  272. - bootstrap-os
  273. - import_tasks: growpart-azure-centos-7.yml
  274. when:
  275. - azure_check.stat.exists
  276. - ansible_distribution in ["CentOS","RedHat"]
  277. tags:
  278. - bootstrap-os