From 257b5a80abbc8ebdfc7e6ae6709780c8536c97ec Mon Sep 17 00:00:00 2001 From: xujingsong Date: Wed, 26 Aug 2020 17:44:00 +0800 Subject: [PATCH] Update 10-kuryr.conf to 10-kuryr.conflist, and generate the 10-kuryr.conflist file from the template file kuryr.conflist.template 1. Currently kubelet's cni config file uses 10-kuryr.conf in kuryr. The kubernetes can support the config file with two suffixes, ".conf" and ".conflist", the latter can be a list containing multiple cni plugins. So I want to update the 10-kuryr.conf to 10-kuryr.conflist to satisfy the need to use multiple plug-in support. 2. If I install the kuryr-cni by pod, the 10-kuryr.conf will only be copied and overwrited from the kuryr/cni image container. What I expected is we can customize the config file more freely. So I think we can add an other file kuryr.conflist.template as the template, then we generate the 10-kuryr.conflist fron it. Change-Id: Ie3669db4e60a57b24012124cd24b524eb03f55cf --- cni_ds_init | 8 ++++++-- devstack/plugin.sh | 4 ++-- doc/source/installation/manual.rst | 16 ++++++++++------ etc/cni/net.d/10-kuryr.conf | 7 ------- etc/cni/net.d/10-kuryr.conflist | 11 +++++++++++ etc/cni/net.d/kuryr.conflist.template | 11 +++++++++++ kuryr_cni/main.go | 2 +- 7 files changed, 41 insertions(+), 18 deletions(-) delete mode 100644 etc/cni/net.d/10-kuryr.conf create mode 100644 etc/cni/net.d/10-kuryr.conflist create mode 100644 etc/cni/net.d/kuryr.conflist.template diff --git a/cni_ds_init b/cni_ds_init index 517dbe3ae..a7269b0ab 100755 --- a/cni_ds_init +++ b/cni_ds_init @@ -1,7 +1,7 @@ #!/bin/bash -ex function cleanup() { - rm -f "/etc/cni/net.d/10-kuryr.conf" + rm -f "/etc/cni/net.d/10-kuryr.conflist" rm -f "/opt/cni/bin/kuryr-cni" } @@ -9,7 +9,11 @@ function deploy() { # Copy the binary into the designated location cp /kuryr-cni "/opt/cni/bin/kuryr-cni" chmod +x /opt/cni/bin/kuryr-cni - cp /etc/kuryr-cni/* /etc/cni/net.d + if [ -f /etc/cni/net.d/kuryr.conflist.template ]; then + cp /etc/cni/net.d/kuryr.conflist.template /etc/cni/net.d/10-kuryr.conflist + else + cp /etc/kuryr-cni/kuryr.conflist.template /etc/cni/net.d/10-kuryr.conflist + fi } cleanup diff --git a/devstack/plugin.sh b/devstack/plugin.sh index b2be61941..514266844 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -719,8 +719,8 @@ function prepare_kubelet { kubelet_plugin_dir="/etc/cni/net.d/" sudo install -o "$STACK_USER" -m 0664 -D \ - "${KURYR_HOME}${kubelet_plugin_dir}/10-kuryr.conf" \ - "${CNI_CONF_DIR}/10-kuryr.conf" + "${KURYR_HOME}${kubelet_plugin_dir}/10-kuryr.conflist" \ + "${CNI_CONF_DIR}/10-kuryr.conflist" } function run_k8s_kubelet { diff --git a/doc/source/installation/manual.rst b/doc/source/installation/manual.rst index c3992e36b..7c7b00450 100644 --- a/doc/source/installation/manual.rst +++ b/doc/source/installation/manual.rst @@ -219,18 +219,22 @@ Link the CNI binary to CNI directory, where kubelet would find it: $ mkdir -p /opt/cni/bin $ ln -s $(which kuryr-cni) /opt/cni/bin/ -Create the CNI config file for kuryr-cni: ``/etc/cni/net.d/10-kuryr.conf``. +Create the CNI config file for kuryr-cni: ``/etc/cni/net.d/10-kuryr.conflist``. Kubelet would only use the lexicographically first file in that directory, so make sure that it is kuryr's config file: .. code-block:: json { - "cniVersion": "0.3.1", - "name": "kuryr", - "type": "kuryr-cni", - "kuryr_conf": "/etc/kuryr/kuryr.conf", - "debug": true + "name": "kuryr", + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "kuryr-cni", + "kuryr_conf": "/etc/kuryr/kuryr.conf", + "debug": true + } + ] } Install ``os-vif`` and ``oslo.privsep`` libraries globally. These modules diff --git a/etc/cni/net.d/10-kuryr.conf b/etc/cni/net.d/10-kuryr.conf deleted file mode 100644 index 95723d0ed..000000000 --- a/etc/cni/net.d/10-kuryr.conf +++ /dev/null @@ -1,7 +0,0 @@ -{ - "cniVersion": "0.3.1", - "name": "kuryr", - "type": "kuryr-cni", - "kuryr_conf": "/etc/kuryr/kuryr.conf", - "debug": true -} diff --git a/etc/cni/net.d/10-kuryr.conflist b/etc/cni/net.d/10-kuryr.conflist new file mode 100644 index 000000000..94ac4193b --- /dev/null +++ b/etc/cni/net.d/10-kuryr.conflist @@ -0,0 +1,11 @@ +{ + "name": "kuryr", + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "kuryr-cni", + "kuryr_conf": "/etc/kuryr/kuryr.conf", + "debug": true + } + ] +} diff --git a/etc/cni/net.d/kuryr.conflist.template b/etc/cni/net.d/kuryr.conflist.template new file mode 100644 index 000000000..94ac4193b --- /dev/null +++ b/etc/cni/net.d/kuryr.conflist.template @@ -0,0 +1,11 @@ +{ + "name": "kuryr", + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "kuryr-cni", + "kuryr_conf": "/etc/kuryr/kuryr.conf", + "debug": true + } + ] +} diff --git a/kuryr_cni/main.go b/kuryr_cni/main.go index 27dc97401..f28be054e 100644 --- a/kuryr_cni/main.go +++ b/kuryr_cni/main.go @@ -20,7 +20,7 @@ import ( const ( // FIXME(dulek): We don't really have a good way to fetch current URL:port binding here. // I'm hardcoding it for now, but in the future we should probably put it in - // the JSON config in 10-kuryr.conf file that we will get passed on stdin. + // the JSON config in 10-kuryr.conflist file that we will get passed on stdin. urlBase = "http://localhost:5036/" addPath = "addNetwork" delPath = "delNetwork"