Clean up ENV vars mistmatches in Dockerfiles
Containerized deployment through DevStack had two bugs related to mismatches in handling environment variables in Dockerfiles: 1. cni.Dockerfile was using ENV vars to define CNI bin and conf directories, but when DevStack was building them it wasn't setting them correctly. This resulted in CNI binaries and configs ending up in wrong directories when deploying through DevStack. This is fixed by passing $CNI_BIN_DIR and $CNI_CONF_DIR into the build function. 2. cni_builder script used $CNI_BIN_DIR_PATH, but it was only defined in cni.Dockerfile and was is missing from cni_builder.Dockerfile. This resulted in malformed kuryr-cni script, that pointed to non-existing "/kuryr-cni-bin" file. This is fixed by adding those ENV vars to cni_builder.Dockerfile Change-Id: I4833124231f256b74f80bd5fee732686bffab77e Closes-Bug: 1718137
This commit is contained in:
parent
aaa5150252
commit
eb428c1170
@ -7,7 +7,9 @@ COPY kuryr-cni /kuryr-cni
|
||||
COPY kuryr-cni-bin /kuryr-cni-bin
|
||||
COPY cni_ds_init /usr/bin/cni_ds_init
|
||||
|
||||
ENV CNI_CONFIG_DIR_PATH /etc/cni/net.d
|
||||
ENV CNI_BIN_DIR_PATH /opt/cni/bin
|
||||
ARG CNI_CONFIG_DIR_PATH=/etc/cni/net.d
|
||||
ENV CNI_CONFIG_DIR_PATH ${CNI_CONFIG_DIR_PATH}
|
||||
ARG CNI_BIN_DIR_PATH=/opt/cni/bin
|
||||
ENV CNI_BIN_DIR_PATH ${CNI_BIN_DIR_PATH}
|
||||
VOLUME [ "/sys/fs/cgroup" ]
|
||||
ENTRYPOINT [ "cni_ds_init" ]
|
||||
|
@ -13,6 +13,10 @@ RUN yum install --setopt=tsflags=nodocs --assumeyes \
|
||||
yum clean all
|
||||
|
||||
ENV LANG en_US.UTF-8
|
||||
ARG CNI_CONFIG_DIR_PATH=/etc/cni/net.d
|
||||
ENV CNI_CONFIG_DIR_PATH ${CNI_CONFIG_DIR_PATH}
|
||||
ARG CNI_BIN_DIR_PATH=/opt/cni/bin
|
||||
ENV CNI_BIN_DIR_PATH ${CNI_BIN_DIR_PATH}
|
||||
|
||||
RUN cd /usr/src \
|
||||
&& wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz \
|
||||
|
@ -285,8 +285,12 @@ EOF
|
||||
# the local docker registry as kuryr/controller:latest and
|
||||
# kuryr/cni:latest respectively
|
||||
function build_kuryr_containers() {
|
||||
local cni_bin_dir
|
||||
local cni_conf_dir
|
||||
local build_dir
|
||||
|
||||
cni_bin_dir=$1
|
||||
cni_conf_dir=$2
|
||||
build_dir="${DEST}/kuryr-kubernetes"
|
||||
pushd "$build_dir"
|
||||
|
||||
@ -294,7 +298,7 @@ function build_kuryr_containers() {
|
||||
sudo docker build -t kuryr/controller -f "controller.Dockerfile" .
|
||||
|
||||
# Build CNI image
|
||||
sudo ./tools/build_cni_daemonset_image
|
||||
sudo ./tools/build_cni_daemonset_image $cni_bin_dir $cni_conf_dir
|
||||
popd
|
||||
}
|
||||
|
||||
@ -423,6 +427,8 @@ EOF
|
||||
|
||||
function generate_cni_daemon_set() {
|
||||
output_dir=$1
|
||||
cni_bin_dir=${2:-/opt/cni/bin}
|
||||
cni_conf_dir=${3:-/etc/cni/net.d}
|
||||
mkdir -p "$output_dir"
|
||||
rm -f ${output_dir}/cni_ds.yml
|
||||
cat >> "${output_dir}/cni_ds.yml" << EOF
|
||||
@ -467,10 +473,10 @@ spec:
|
||||
volumes:
|
||||
- name: bin
|
||||
hostPath:
|
||||
path: /opt/cni/bin
|
||||
path: ${cni_bin_dir}
|
||||
- name: net-conf
|
||||
hostPath:
|
||||
path: /etc/cni/net.d
|
||||
path: ${cni_conf_dir}
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: kuryr-config
|
||||
|
@ -87,7 +87,7 @@ function generate_containerized_kuryr_resources {
|
||||
generate_kuryr_configmap $output_dir $KURYR_CONFIG $KURYR_CNI_CONFIG
|
||||
generate_kuryr_service_account $output_dir
|
||||
generate_controller_deployment $output_dir
|
||||
generate_cni_daemon_set $output_dir
|
||||
generate_cni_daemon_set $output_dir $CNI_BIN_DIR $CNI_CONF_DIR
|
||||
}
|
||||
|
||||
function run_containerized_kuryr_resources {
|
||||
@ -539,7 +539,7 @@ if [[ "$1" == "stack" && "$2" == "extra" ]]; then
|
||||
if [ "$KURYR_K8S_CONTAINERIZED_DEPLOYMENT" == "False" ]; then
|
||||
run_kuryr_kubernetes
|
||||
else
|
||||
build_kuryr_containers
|
||||
build_kuryr_containers $CNI_BIN_DIR $CNI_CONF_DIR
|
||||
generate_containerized_kuryr_resources
|
||||
run_containerized_kuryr_resources
|
||||
fi
|
||||
|
@ -1,10 +1,19 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
CNI_BIN_DIR=$1
|
||||
CNI_CONF_DIR=$2
|
||||
BUILDER_TAG="kuryr/cni-builder"
|
||||
CNI_TAG="kuryr/cni"
|
||||
|
||||
# build the cni image
|
||||
docker build -t "$BUILDER_TAG" -f cni_builder.Dockerfile .
|
||||
if [ -z "$CNI_BIN_DIR" ] && [ -z "$CNI_CONF_DIR" ]; then
|
||||
docker build -t "$BUILDER_TAG" -f cni_builder.Dockerfile .
|
||||
else
|
||||
docker build -t "$BUILDER_TAG" \
|
||||
--build-arg "CNI_BIN_DIR_PATH=$CNI_BIN_DIR" \
|
||||
--build-arg "CNI_CONFIG_DIR_PATH=$CNI_CONF_DIR" \
|
||||
-f cni_builder.Dockerfile .
|
||||
fi
|
||||
docker run \
|
||||
--rm \
|
||||
-v $(pwd):/opt/kuryr-kubernetes \
|
||||
|
Loading…
x
Reference in New Issue
Block a user