78102c9984
This commit changes the way we produce kuryr-cni Docker image. Previously we've distributed the kuryr-driver as pyinstaller binary that contained Python 3 interpreter and all the dependencies. This binary was called from CNI. That approach had some disadvantages, the major being complicated build procedure and having to see false-positive BrokenPipeError tracebacks in kubelet logs. This commit implements distributing kuryr-driver as a virtualenv with kuryr-kubernetes and all the dependecies installed. That virtualenv is then copied onto the host system and CNI can easily activate it and run kuryr-cni binary. This should solve issues caused by pyinstaller. Closes-Bug: 1747058 Change-Id: I65b01ba27cbe39b66f0a972d12f3abc166934e62
38 lines
952 B
Bash
Executable File
38 lines
952 B
Bash
Executable File
#!/bin/bash -ex
|
|
|
|
function cleanup() {
|
|
rm -f "/etc/cni/net.d/10-kuryr.conf"
|
|
rm -f "/opt/cni/bin/kuryr-cni"
|
|
rm -rf "/opt/cni/bin/kuryr-venv"
|
|
rm -rf /etc/kuryr
|
|
}
|
|
|
|
function deploy() {
|
|
local serviceaccount_path
|
|
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/* /etc/cni/net.d
|
|
cp -r /kuryr-kubernetes "/opt/cni/bin/kuryr-venv"
|
|
cat > /kuryr-cni << EOF
|
|
#!/bin/bash
|
|
${CNI_BIN_DIR_PATH}/kuryr-venv/bin/kuryr-cni
|
|
EOF
|
|
cp /kuryr-cni "/opt/cni/bin/kuryr-cni"
|
|
chmod +x /opt/cni/bin/kuryr-cni
|
|
cat /tmp/kuryr/* > /etc/kuryr/kuryr.conf
|
|
}
|
|
|
|
cleanup
|
|
deploy
|
|
|
|
# Start CNI daemon if required
|
|
if [ "$CNI_DAEMON" == "True" ]; then
|
|
/kuryr-kubernetes/bin/kuryr-daemon --config-file /etc/kuryr/kuryr.conf
|
|
else
|
|
sleep infinity
|
|
fi
|