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.

117 lines
4.4 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. - name: Contiv | Load openvswitch kernel module
  3. copy:
  4. dest: /etc/modules-load.d/openvswitch.conf
  5. content: "openvswitch"
  6. notify:
  7. - Contiv | Reload kernel modules
  8. - name: Contiv | Create contiv etcd directories
  9. file:
  10. dest: "{{ item }}"
  11. state: directory
  12. mode: 0750
  13. owner: root
  14. group: root
  15. with_items:
  16. - "{{ contiv_etcd_conf_dir }}"
  17. - "{{ contiv_etcd_data_dir }}"
  18. - set_fact:
  19. contiv_config_dir: "{{ contiv_config_dir }}"
  20. contiv_enable_api_proxy: "{{ contiv_enable_api_proxy }}"
  21. contiv_fabric_mode: "{{ contiv_fabric_mode }}"
  22. contiv_fwd_mode: "{{ contiv_fwd_mode }}"
  23. contiv_netmaster_port: "{{ contiv_netmaster_port }}"
  24. contiv_networks: "{{ contiv_networks }}"
  25. contiv_manifests:
  26. - {name: contiv-config, file: contiv-config.yml, type: configmap}
  27. - {name: contiv-netmaster, file: contiv-netmaster-clusterrolebinding.yml, type: clusterrolebinding}
  28. - {name: contiv-netmaster, file: contiv-netmaster-clusterrole.yml, type: clusterrole}
  29. - {name: contiv-netmaster, file: contiv-netmaster-serviceaccount.yml, type: serviceaccount}
  30. - {name: contiv-netplugin, file: contiv-netplugin-clusterrolebinding.yml, type: clusterrolebinding}
  31. - {name: contiv-netplugin, file: contiv-netplugin-clusterrole.yml, type: clusterrole}
  32. - {name: contiv-netplugin, file: contiv-netplugin-serviceaccount.yml, type: serviceaccount}
  33. - {name: contiv-etcd, file: contiv-etcd.yml, type: daemonset}
  34. - {name: contiv-etcd-proxy, file: contiv-etcd-proxy.yml, type: daemonset}
  35. - {name: contiv-netplugin, file: contiv-netplugin.yml, type: daemonset}
  36. - {name: contiv-netmaster, file: contiv-netmaster.yml, type: daemonset}
  37. - set_fact:
  38. contiv_manifests: |-
  39. {% set _ = contiv_manifests.append({"name": "contiv-api-proxy", "file": "contiv-api-proxy.yml", "type": "daemonset"}) %}
  40. {{ contiv_manifests }}
  41. when: contiv_enable_api_proxy
  42. - name: Contiv | Create /var/contiv
  43. file:
  44. path: /var/contiv
  45. state: directory
  46. - name: Contiv | Create contiv config directory
  47. file:
  48. dest: "{{ contiv_config_dir }}"
  49. state: directory
  50. mode: 0755
  51. owner: root
  52. group: root
  53. - name: Contiv | Install all Kubernetes resources
  54. template:
  55. src: "{{ item.file }}.j2"
  56. dest: "{{ contiv_config_dir }}/{{ item.file }}"
  57. with_items: "{{ contiv_manifests }}"
  58. delegate_to: "{{ groups['kube-master'][0] }}"
  59. run_once: true
  60. register: contiv_manifests_results
  61. - name: Contiv | Generate contiv-api-proxy certificates
  62. script: generate-certificate.sh
  63. args:
  64. creates: /var/contiv/auth_proxy_key.pem
  65. when: "contiv_enable_api_proxy and contiv_generate_certificate"
  66. delegate_to: "{{ groups['kube-master'][0] }}"
  67. run_once: true
  68. - name: Contiv | Fetch the generated certificate
  69. fetch:
  70. src: "/var/contiv/{{ item }}"
  71. dest: "/tmp/kubespray-contiv-{{ item }}"
  72. flat: yes
  73. with_items:
  74. - auth_proxy_key.pem
  75. - auth_proxy_cert.pem
  76. when: "contiv_enable_api_proxy and contiv_generate_certificate"
  77. delegate_to: "{{ groups['kube-master'][0] }}"
  78. run_once: true
  79. - name: Contiv | Copy the generated certificate on nodes
  80. copy:
  81. src: "/tmp/kubespray-contiv-{{ item }}"
  82. dest: "/var/contiv/{{ item }}"
  83. with_items:
  84. - auth_proxy_key.pem
  85. - auth_proxy_cert.pem
  86. when: "inventory_hostname != groups['kube-master'][0]
  87. and inventory_hostname in groups['kube-master']
  88. and contiv_enable_api_proxy and contiv_generate_certificate"
  89. - name: Contiv | Copy cni plugins from hyperkube
  90. command: "{{ docker_bin_dir }}/docker run --rm -v /opt/cni/bin:/cnibindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /bin/bash -c '/bin/cp -a /opt/cni/bin/* /cnibindir/'"
  91. register: cni_task_result
  92. until: cni_task_result.rc == 0
  93. retries: 4
  94. delay: "{{ retry_stagger | random + 3 }}"
  95. changed_when: false
  96. tags: [hyperkube, upgrade]
  97. - name: Contiv | Copy netctl binary from docker container
  98. command: sh -c "{{ docker_bin_dir }}/docker rm -f netctl-binarycopy;
  99. {{ docker_bin_dir }}/docker create --name netctl-binarycopy {{ contiv_image_repo }}:{{ contiv_image_tag }} &&
  100. {{ docker_bin_dir }}/docker cp netctl-binarycopy:/contiv/bin/netctl {{ bin_dir }}/netctl &&
  101. {{ docker_bin_dir }}/docker rm -f netctl-binarycopy"
  102. register: contiv_task_result
  103. until: contiv_task_result.rc == 0
  104. retries: 4
  105. delay: "{{ retry_stagger | random + 3 }}"
  106. changed_when: false