CNI container: parametrize and clean up

Make the CNI config and binary locations parametrized so it is suitable
for more kinds of deployment.

Implements: blueprint kubeadminstallable
Change-Id: I01c7540641fe120faec902008ebd842339b50384
Signed-off-by: Antoni Segura Puimedon <antonisp@celebdor.com>
Co-Authored-By: Michał Dulko <mdulko@redhat.com>
This commit is contained in:
Antoni Segura Puimedon 2017-08-02 16:37:44 +02:00 committed by Michał Dulko
parent 632d32be89
commit 460cab6a99
3 changed files with 38 additions and 14 deletions

View File

@ -7,5 +7,7 @@ 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
VOLUME [ "/sys/fs/cgroup" ]
ENTRYPOINT [ "cni_ds_init" ]

View File

@ -7,7 +7,7 @@ pbr_version=$(find /usr/local/lib/python3.5/site-packages/ -type d \
cat > /opt/kuryr-kubernetes/kuryr-cni << EOF
#!/bin/bash
export PBR_VERSION='$pbr_version'
/opt/cni/bin/kuryr-cni-bin
${CNI_BIN_DIR_PATH}/kuryr-cni-bin
EOF
cp /dist/kuryr-cni /opt/kuryr-kubernetes/kuryr-cni-bin
chmod 744 /opt/kuryr-kubernetes/kuryr-cni

View File

@ -1,16 +1,38 @@
#!/bin/bash -e
rm -f /etc/cni/net.d/10-kuryr.conf
rm -f /etc/cni/net.d/99-loopback.conf
rm -f /opt/cni/bin/kuryr-cni
rm -f /opt/cni/bin/kuryr-cni-bin
rm -rf /etc/kuryr
mkdir /etc/kuryr
cp /var/run/secrets/kubernetes.io/serviceaccount/token /etc/kuryr/token
cp /var/run/secrets/kubernetes.io/serviceaccount/ca.crt /etc/kuryr/ca.crt
cp /opt/kuryr-kubernetes/etc/cni/net.d/* /etc/cni/net.d/
cp /kuryr-cni-bin /opt/cni/bin/kuryr-cni-bin
cp /kuryr-cni /opt/cni/bin/kuryr-cni
cat /tmp/kuryr/* > /etc/kuryr/kuryr.conf
function cleanup() {
local cni_conf_path
local cni_bin_path
cni_conf_path="$1"
cni_bin_path="$2"
while true; do sleep 3600; done
rm -f "${cni_conf_path}/10-kuryr.conf"
rm -f "${cni_conf_path}/99-loopback.conf"
rm -f "${cni_bin_path}/kuryr-cni"
rm -f "${cni_bin_path}/kuryr-cni-bin"
rm -rf /etc/kuryr
}
function deploy() {
local cni_conf_path
local cni_bin_path
local serviceaccount_path
cni_conf_path="$1"
cni_bin_path="$2"
serviceaccount_path="/var/run/secrets/kubernetes.io/serviceaccount"
mkdir -p /etc/kuryr
cp "${serviceaccount_path}/token" /etc/kuryr/token
cp "${serviceaccount_path}/ca.crt" /etc/kuryr/ca.crt
cp /opt/kuryr-kubernetes/etc/cni/net.d/* "$cni_conf_path"
cp /kuryr-cni-bin "${cni_bin_path}/kuryr-cni-bin"
cp /kuryr-cni "${cni_bin_path}/kuryr-cni"
cat /tmp/kuryr/* > /etc/kuryr/kuryr.conf
}
cleanup "$CNI_CONFIG_DIR_PATH" "$CNI_BIN_DIR_PATH"
deploy "$CNI_CONFIG_DIR_PATH" "$CNI_BIN_DIR_PATH"
sleep infinity