kuryr-kubernetes/cni_ds_init
Michał Dulko 245eb078f4 Implement kuryr-cni in golang
This commit reimplements the kuryr-cni, that is the actual CNI plugin
that gets called by kubelet and passes the request to kuryr-daemon, in
golang. This means that it can injected as a binary without any
dependencies, instead of using a bash script that looks for ID of
kuryr-daemon container and does `docker exec` to run Python kuryr-cni
inside. The obvious advantage of that is removing a constraint of
python, curl and docker/runc binaries being available on any K8s host
that runs Kuryr. This enables integration with Magnum, where kubelet
runs in such a minimal container. Besides that injecting a binary is way
more elegant and less error-prone.

The golang implementation should keep the compatibility with Python one.
Also currently only containerized jobs are switched to use it, so Python
implementation is still kept in the repo. I'm not against removing it in
very near future.

Please note that there is an important limitation in comparison to the
Python implementation - i.e. in case of golang binary running on K8s
host, we don't have an easy access to kuryr.conf, meaning that
localhost:50036 is currently hardcoded as the kuryr-daemon endpoint.
This should be fixed by putting the configured endpoint into
10-kuryr.conf file that gets injected onto the host by cni_ds_init
script.

Implements: blueprint golang-kuryr-cni
Change-Id: Ia241fb5b2937c63d3ed6e3de1ac3003e370e4db6
2019-06-17 12:58:37 +02:00

19 lines
379 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"
}
function deploy() {
# Copy the binary into the designated location
cp /kuryr-cni "/opt/cni/bin/kuryr-cni"
chmod +x /opt/cni/bin/kuryr-cni
cp /etc/kuryr-cni/* /etc/cni/net.d
}
cleanup
deploy
exec kuryr-daemon --config-file /etc/kuryr/kuryr.conf