diff --git a/README.md b/README.md index 972c054ca61e2fc715e96e1ce756a80be48a580c..dfc740540b833e7dd1c40068180fe7623b20f584 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Note: Upstart/SysV init based OS types are not supported. - [cilium](https://github.com/cilium/cilium) v1.5.5 - [contiv](https://github.com/contiv/install) v1.2.1 - [flanneld](https://github.com/coreos/flannel) v0.11.0 - - [kube-router](https://github.com/cloudnativelabs/kube-router) v0.2.5 + - [kube-router](https://github.com/cloudnativelabs/kube-router) v0.4.0 - [multus](https://github.com/intel/multus-cni) v3.4 - [weave](https://github.com/weaveworks/weave) v2.5.2 - Application diff --git a/roles/download/defaults/main.yml b/roles/download/defaults/main.yml index 83a2c1e2eb01a200a03c5fd78aa38d8cdf6b663e..0188ff8df29c7ff296d18fa0bfa87fc419135bc7 100644 --- a/roles/download/defaults/main.yml +++ b/roles/download/defaults/main.yml @@ -82,7 +82,7 @@ pod_infra_version: 3.1 contiv_version: 1.2.1 cilium_version: "v1.7.1" kube_ovn_version: "v0.6.0" -kube_router_version: "v0.2.5" +kube_router_version: "v0.4.0" multus_version: "v3.4" # Get kubernetes major version (i.e. 1.15.4 => 1.15) diff --git a/roles/network_plugin/kube-router/tasks/main.yml b/roles/network_plugin/kube-router/tasks/main.yml index 83c81f28f4e5652239a276a61b2794bec7220c71..6c4a10508b6220bf0e76b53d9159a618d498f8d6 100644 --- a/roles/network_plugin/kube-router/tasks/main.yml +++ b/roles/network_plugin/kube-router/tasks/main.yml @@ -37,7 +37,7 @@ - name: kube-router | Slurp cni config slurp: - src: /etc/cni/net.d/10-kuberouter.conf + src: /etc/cni/net.d/10-kuberouter.conflist register: cni_config_slurp ignore_errors: true @@ -49,30 +49,24 @@ - name: kube-router | Set host_subnet variable set_fact: - host_subnet: "{{ cni_config.ipam.subnet }}" + host_subnet: "{{ cni_config | json_query('plugins[?bridge==`kube-bridge`].ipam.subnet') | first }}" when: - cni_config is defined - - cni_config.ipam is defined - - cni_config.ipam.subnet is defined - -- name: kube-router | Set wanted cni config variable - set_fact: - wanted_cni_config: "{{ lookup('template', 'cni-conf.json.j2') }}" - -- name: kube-router | Set wanted_cni_config variable - set_fact: - wanted_cni_config: "{{ wanted_cni_config | combine({ 'ipam': { 'subnet': host_subnet }}, recursive=True) }}" - when: host_subnet is defined + - cni_config | json_query('plugins[?bridge==`kube-bridge`].ipam.subnet') | length > 0 - name: kube-router | Create cni config - copy: - content: "{{ wanted_cni_config | to_nice_json }}" - dest: /etc/cni/net.d/10-kuberouter.conf + template: + src: cni-conf.json.j2 + dest: /etc/cni/net.d/10-kuberouter.conflist owner: kube - changed_when: wanted_cni_config != cni_config notify: - reset_kube_router +- name: kube-router | Delete old configuration + file: + path: /etc/cni/net.d/10-kuberouter.conf + state: absent + - name: kube-router | Create manifest template: src: kube-router.yml.j2 diff --git a/roles/network_plugin/kube-router/templates/cni-conf.json.j2 b/roles/network_plugin/kube-router/templates/cni-conf.json.j2 index 7b104812242c27f6b657d198c14e2d4b0e89e366..c5327c1d01d7e8f16b43723593b320e8d1d6e02f 100644 --- a/roles/network_plugin/kube-router/templates/cni-conf.json.j2 +++ b/roles/network_plugin/kube-router/templates/cni-conf.json.j2 @@ -1,13 +1,21 @@ { - "name":"kubernetes", - "cniVersion": "0.2.0", - "type":"bridge", - "bridge":"kube-bridge", - "isDefaultGateway":true, + "cniVersion":"0.3.0", + "name":"kubernetes", + "plugins":[ + { + "name":"kubernetes", + "type":"bridge", + "bridge":"kube-bridge", + "isDefaultGateway":true, {% if kube_router_support_hairpin_mode %} - "hairpinMode":true, + "hairpinMode":true, {% endif %} - "ipam": { - "type":"host-local" - } + "ipam":{ +{% if host_subnet is defined %} + "subnet": "{{ host_subnet }}", +{% endif %} + "type":"host-local" + } + } + ] } diff --git a/roles/network_plugin/kube-router/templates/kube-router.yml.j2 b/roles/network_plugin/kube-router/templates/kube-router.yml.j2 index b791a3e8f0e2c490036a1ac52d443ecd6024a932..127be8a8c0a6d2249079cc7ff1aa994699924420 100644 --- a/roles/network_plugin/kube-router/templates/kube-router.yml.j2 +++ b/roles/network_plugin/kube-router/templates/kube-router.yml.j2 @@ -69,6 +69,8 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName + - name: KUBE_ROUTER_CNI_CONF_FILE + value: /etc/cni/net.d/10-kuberouter.conflist livenessProbe: httpGet: path: /healthz