devstack: make cni paths configurable

With this patch, we'll be able to place our cni executables in:

    /opt/stack/cni/bin

It also allows you to put configuration files for the kuryr cni driver
in:

    /opt/stack/cni/conf

For now we are not setting any non standard conf. It is foreseeable
though that some configuration like which host device to base the
ipvlan/vlan/macvlan devices off on container-in-vm environments could go
here (Although it could also be in a kuryr.conf for the cni driver).

Change-Id: I9abc0878612b97795c68c8d773e7a29e891d1a6f
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
This commit is contained in:
Antoni S. Puimedon 2016-11-10 11:52:31 +01:00
parent f0e1c206a9
commit 33e829e820
4 changed files with 22 additions and 5 deletions

View File

@ -254,21 +254,29 @@ function extract_hyperkube {
local tmp_hyperkube_path
tmp_hyperkube_path="/tmp/hyperkube"
tmp_loopback_cni_path="/tmp/loopback"
hyperkube_container="$(docker ps -aq \
-f ancestor="${KURYR_HYPERKUBE_IMAGE}:${KURYR_HYPERKUBE_VERSION}" | \
head -1)"
docker cp "$hyperkube_container:/hyperkube" /tmp/hyperkube
sudo install -o "$STACK_USER" -m 0555 "$tmp_hyperkube_path" \
docker cp "${hyperkube_container}:/hyperkube" "$tmp_hyperkube_path"
docker cp "${hyperkube_container}:/opt/cni/bin/loopback" \
"$tmp_loopback_cni_path"
sudo install -o "$STACK_USER" -m 0555 -D "$tmp_hyperkube_path" \
"$KURYR_HYPERKUBE_BINARY"
sudo install -o "$STACK_USER" -m 0555 -D "$tmp_loopback_cni_path" \
"${CNI_BIN_DIR}/loopback"
}
function prepare_kubelet {
local kubelet_plugin_dir
kubelet_plugin_dir="/usr/libexec/kubernetes/kubelet-plugins/net/exec"
kubelet_plugin_dir="/etc/cni/net.d/"
sudo install -o "$STACK_USER" -m 0664 -D \
"${KURYR_HOME}${kubelet_plugin_dir}/kuryr.conf" \
"${kubelet_plugin_dir}/kuryr.conf"
"${KURYR_HOME}${kubelet_plugin_dir}/10-kuryr.conf" \
"${CNI_CONF_DIR}/10-kuryr.conf"
sudo install -o "$STACK_USER" -m 0664 -D \
"${KURYR_HOME}${kubelet_plugin_dir}/99-loopback.conf" \
"${CNI_CONF_DIR}/99-loopback.conf"
}
function run_k8s_kubelet {
@ -289,6 +297,8 @@ function run_k8s_kubelet {
--address='0.0.0.0' \
--enable-server \
--network-plugin=cni \
--cni-bin-dir=$CNI_BIN_DIR \
--cni-conf-dir=$CNI_CONF_DIR \
--cert-dir=$DATA_DIR/kubelet.cert \
--root-dir=$DATA_DIR/kubelet"
wait_for "Kubernetes API Server" "$KURYR_K8S_API_URL"

View File

@ -1,4 +1,6 @@
KURYR_HOME=${KURYR_HOME:-$DEST/kuryr-kubernetes}
CNI_BIN_DIR=${CNI_BIN_DIR:-$DEST/cni/bin}
CNI_CONF_DIR=${CNI_CONF_DIR:-$DEST/cni/conf}
KURYR_CONFIG_DIR=${KURYR_CONFIG_DIR:-/etc/kuryr}
KURYR_CONFIG=${KURYR_CONFIG:-${KURYR_CONFIG_DIR}/kuryr.conf}

View File

@ -1,4 +1,5 @@
{
"cniVersion": "0.3.0",
"name": "kuryr",
"type": "kuryr"
}

View File

@ -0,0 +1,4 @@
{
"cniVersion": "0.3.0",
"type": "loopback"
}