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
This commit is contained in:
xujingsong 2020-08-26 17:44:00 +08:00 committed by Roman Dobosz
parent a8e97569a8
commit 257b5a80ab
7 changed files with 41 additions and 18 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash -ex #!/bin/bash -ex
function cleanup() { 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" rm -f "/opt/cni/bin/kuryr-cni"
} }
@ -9,7 +9,11 @@ function deploy() {
# Copy the binary into the designated location # Copy the binary into the designated location
cp /kuryr-cni "/opt/cni/bin/kuryr-cni" cp /kuryr-cni "/opt/cni/bin/kuryr-cni"
chmod +x /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 cleanup

View File

@ -719,8 +719,8 @@ function prepare_kubelet {
kubelet_plugin_dir="/etc/cni/net.d/" kubelet_plugin_dir="/etc/cni/net.d/"
sudo install -o "$STACK_USER" -m 0664 -D \ sudo install -o "$STACK_USER" -m 0664 -D \
"${KURYR_HOME}${kubelet_plugin_dir}/10-kuryr.conf" \ "${KURYR_HOME}${kubelet_plugin_dir}/10-kuryr.conflist" \
"${CNI_CONF_DIR}/10-kuryr.conf" "${CNI_CONF_DIR}/10-kuryr.conflist"
} }
function run_k8s_kubelet { function run_k8s_kubelet {

View File

@ -219,18 +219,22 @@ Link the CNI binary to CNI directory, where kubelet would find it:
$ mkdir -p /opt/cni/bin $ mkdir -p /opt/cni/bin
$ ln -s $(which kuryr-cni) /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 Kubelet would only use the lexicographically first file in that directory, so
make sure that it is kuryr's config file: make sure that it is kuryr's config file:
.. code-block:: json .. code-block:: json
{ {
"cniVersion": "0.3.1", "name": "kuryr",
"name": "kuryr", "cniVersion": "0.3.1",
"type": "kuryr-cni", "plugins": [
"kuryr_conf": "/etc/kuryr/kuryr.conf", {
"debug": true "type": "kuryr-cni",
"kuryr_conf": "/etc/kuryr/kuryr.conf",
"debug": true
}
]
} }
Install ``os-vif`` and ``oslo.privsep`` libraries globally. These modules Install ``os-vif`` and ``oslo.privsep`` libraries globally. These modules

View File

@ -1,7 +0,0 @@
{
"cniVersion": "0.3.1",
"name": "kuryr",
"type": "kuryr-cni",
"kuryr_conf": "/etc/kuryr/kuryr.conf",
"debug": true
}

View File

@ -0,0 +1,11 @@
{
"name": "kuryr",
"cniVersion": "0.3.1",
"plugins": [
{
"type": "kuryr-cni",
"kuryr_conf": "/etc/kuryr/kuryr.conf",
"debug": true
}
]
}

View File

@ -0,0 +1,11 @@
{
"name": "kuryr",
"cniVersion": "0.3.1",
"plugins": [
{
"type": "kuryr-cni",
"kuryr_conf": "/etc/kuryr/kuryr.conf",
"debug": true
}
]
}

View File

@ -20,7 +20,7 @@ import (
const ( const (
// FIXME(dulek): We don't really have a good way to fetch current URL:port binding here. // 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 // 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/" urlBase = "http://localhost:5036/"
addPath = "addNetwork" addPath = "addNetwork"
delPath = "delNetwork" delPath = "delNetwork"