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.

314 lines
7.5 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
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_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"]
  85. - inventory_hostname in groups['k8s-cluster']
  86. tags:
  87. - network
  88. - calico
  89. - weave
  90. - canal
  91. - contiv
  92. - bootstrap-os
  93. - import_tasks: resolvconf.yml
  94. when:
  95. - dns_mode != 'none'
  96. - resolvconf_mode == 'host_resolvconf'
  97. tags:
  98. - bootstrap-os
  99. - resolvconf
  100. - name: Update package management cache (YUM)
  101. yum:
  102. update_cache: yes
  103. name: '*'
  104. register: yum_task_result
  105. until: yum_task_result|succeeded
  106. retries: 4
  107. delay: "{{ retry_stagger | random + 3 }}"
  108. when:
  109. - ansible_pkg_mgr == 'yum'
  110. - ansible_distribution != 'RedHat'
  111. - not is_atomic
  112. tags: bootstrap-os
  113. - name: Expire management cache (YUM) for Updation - Redhat
  114. shell: yum clean expire-cache
  115. register: expire_cache_output
  116. until: expire_cache_output|succeeded
  117. retries: 4
  118. delay: "{{ retry_stagger | random + 3 }}"
  119. when:
  120. - ansible_pkg_mgr == 'yum'
  121. - ansible_distribution == 'RedHat'
  122. - not is_atomic
  123. tags: bootstrap-os
  124. - name: Update package management cache (YUM) - Redhat
  125. shell: yum makecache
  126. register: make_cache_output
  127. until: make_cache_output|succeeded
  128. retries: 4
  129. delay: "{{ retry_stagger | random + 3 }}"
  130. when:
  131. - ansible_pkg_mgr == 'yum'
  132. - ansible_distribution == 'RedHat'
  133. - expire_cache_output.rc == 0
  134. - not is_atomic
  135. tags: bootstrap-os
  136. - name: Install latest version of python-apt for Debian distribs
  137. apt:
  138. name: python-apt
  139. state: latest
  140. update_cache: yes
  141. cache_valid_time: 3600
  142. when: ansible_os_family == "Debian"
  143. tags:
  144. - bootstrap-os
  145. - name: Install python-dnf for latest RedHat versions
  146. command: dnf install -y python-dnf yum
  147. register: dnf_task_result
  148. until: dnf_task_result|succeeded
  149. retries: 4
  150. delay: "{{ retry_stagger | random + 3 }}"
  151. when:
  152. - ansible_distribution == "Fedora"
  153. - ansible_distribution_major_version > 21
  154. - not is_atomic
  155. changed_when: False
  156. tags:
  157. - bootstrap-os
  158. - name: Install epel-release on RedHat/CentOS
  159. shell: rpm -qa | grep epel-release || rpm -ivh {{ epel_rpm_download_url }}
  160. register: epel_task_result
  161. until: epel_task_result|succeeded
  162. retries: 4
  163. delay: "{{ retry_stagger | random + 3 }}"
  164. changed_when: False
  165. when:
  166. - ansible_distribution in ["CentOS","RedHat"]
  167. - not is_atomic
  168. - epel_rpm_download_url != ''
  169. - epel_enabled|bool
  170. check_mode: no
  171. tags:
  172. - bootstrap-os
  173. - name: Install packages requirements
  174. action:
  175. module: "{{ ansible_pkg_mgr }}"
  176. name: "{{ item }}"
  177. state: latest
  178. register: pkgs_task_result
  179. until: pkgs_task_result|succeeded
  180. retries: 4
  181. delay: "{{ retry_stagger | random + 3 }}"
  182. with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
  183. when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] or is_atomic)
  184. tags:
  185. - bootstrap-os
  186. # Todo : selinux configuration
  187. - name: Confirm selinux deployed
  188. stat:
  189. path: /etc/selinux/config
  190. when: ansible_os_family == "RedHat"
  191. register: slc
  192. - name: Set selinux policy
  193. selinux:
  194. policy: targeted
  195. state: "{{ preinstall_selinux_state }}"
  196. when:
  197. - ansible_os_family == "RedHat"
  198. - slc.stat.exists == True
  199. changed_when: False
  200. tags:
  201. - bootstrap-os
  202. - name: Disable IPv6 DNS lookup
  203. lineinfile:
  204. dest: /etc/gai.conf
  205. line: "precedence ::ffff:0:0/96 100"
  206. state: present
  207. backup: yes
  208. when:
  209. - disable_ipv6_dns
  210. - not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  211. tags:
  212. - bootstrap-os
  213. - name: set default sysctl file path
  214. set_fact:
  215. sysctl_file_path: "/etc/sysctl.d/99-sysctl.conf"
  216. tags:
  217. - bootstrap-os
  218. - name: Stat sysctl file configuration
  219. stat:
  220. path: "{{sysctl_file_path}}"
  221. register: sysctl_file_stat
  222. tags:
  223. - bootstrap-os
  224. - name: Change sysctl file path to link source if linked
  225. set_fact:
  226. sysctl_file_path: "{{sysctl_file_stat.stat.lnk_source}}"
  227. when:
  228. - sysctl_file_stat.stat.islnk is defined
  229. - sysctl_file_stat.stat.islnk
  230. tags:
  231. - bootstrap-os
  232. - name: Enable ip forwarding
  233. sysctl:
  234. sysctl_file: "{{sysctl_file_path}}"
  235. name: net.ipv4.ip_forward
  236. value: 1
  237. state: present
  238. reload: yes
  239. tags:
  240. - bootstrap-os
  241. - name: Write cloud-config
  242. template:
  243. src: "{{ cloud_provider }}-cloud-config.j2"
  244. dest: "{{ kube_config_dir }}/cloud_config"
  245. group: "{{ kube_cert_group }}"
  246. mode: 0640
  247. when:
  248. - inventory_hostname in groups['k8s-cluster']
  249. - cloud_provider is defined
  250. - cloud_provider in [ 'openstack', 'azure', 'vsphere' ]
  251. tags:
  252. - cloud-provider
  253. - import_tasks: etchosts.yml
  254. tags:
  255. - bootstrap-os
  256. - etchosts
  257. - import_tasks: dhclient-hooks.yml
  258. when:
  259. - dns_mode != 'none'
  260. - resolvconf_mode == 'host_resolvconf'
  261. - not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  262. tags:
  263. - bootstrap-os
  264. - resolvconf
  265. - import_tasks: dhclient-hooks-undo.yml
  266. when:
  267. - dns_mode != 'none'
  268. - resolvconf_mode != 'host_resolvconf'
  269. - not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  270. tags:
  271. - bootstrap-os
  272. - resolvconf
  273. - name: Check if we are running inside a Azure VM
  274. stat:
  275. path: /var/lib/waagent/
  276. register: azure_check
  277. tags:
  278. - bootstrap-os
  279. - import_tasks: growpart-azure-centos-7.yml
  280. when:
  281. - azure_check.stat.exists
  282. - ansible_distribution in ["CentOS","RedHat"]
  283. tags:
  284. - bootstrap-os