-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build versioned v2plugin from versioned binaries (#1040)
* Build versioned v2plugin from versioned binaries This enables build and docker image caching on a build machine for the v2plugin. The new target demo-v2plugin-from-local does everything it can locally before spawning the VM, failing much faster on any PR issues, which is good for CI turnaround. It runs a little faster than demo-v2plugin after base image layers are cached. v2plugin_rootfs (called by host-pluginfs-create) builds a docker container runtime with a versioned archive of netplugin binaries, then extracts the entire filesystem from the container, which is now left as a versioned tarball. The versioned archive of netplugin binaries used for v2plugin can now be created in two ways: * run-build (dependency for demo-v2plugin) will compile then version an archive with built assets (runs only on the VM) * tar target (locally or in VM) host-pluginfs-create can be run in the VM or locally The plugin rootfs is left as a tarball because: * docker in a VM had internal issues when creating the plugin when the rootfs was unarchived on the host and exposed though a virtualbox mount, at least on OS X * the rootfs is versioned This adjusted host-plugin-release and demo-v2plugin both use a new target 'host-pluginfs-unpack' Drive-by: * Fix config.template for the CONTIV_V2PLUGIN_NAME replacement * gtar support for OS X * use cp -a for maintaining owner Signed-off-by: Chris Plock <chrisplo@cisco.com> * review feedback * comments, revert a var rename for smaller diff * more dockerignore * comments, and don't remove rootfs * review testing feedback binaries-from-container and host-plugin-update * simplify usage for v2plugin-update * feedback for v2plugin docker version variable
- Loading branch information
Showing
7 changed files
with
150 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Script to create the docker v2 plugin | ||
# run this script from contiv/netplugin directory | ||
|
||
echo "Creating rootfs for v2plugin ", ${CONTIV_V2PLUGIN_NAME} | ||
rm -rf install/v2plugin/rootfs | ||
rm install/v2plugin/config.json | ||
cat install/v2plugin/config.template | grep -v "##" > install/v2plugin/config.json | ||
sed -i "s%PluginName%${CONTIV_V2PLUGIN_NAME}%" install/v2plugin/config.json | ||
cp bin/netplugin bin/netmaster bin/netctl install/v2plugin | ||
docker build -t contivrootfs install/v2plugin | ||
id=$(docker create contivrootfs true) | ||
mkdir -p install/v2plugin/rootfs | ||
sudo docker export "${id}" | sudo tar -x -C install/v2plugin/rootfs | ||
# requires NETPLUGIN_CONTAINER_TAG for contivrootfs image | ||
# requires CONTIV_V2PLUGIN_NAME, the Network Driver name for requests to | ||
# dockerd, should look like contiv/v2plugin:$NETPLUGIN_CONTAINER_TAG | ||
# requires TAR_FILE to point to the netplugin binaries | ||
# requires V2PLUGIN_TAR_FILENAME to point to the v2plugin archive | ||
|
||
set -euxo pipefail | ||
|
||
echo "Creating rootfs for v2plugin: ${CONTIV_V2PLUGIN_NAME}" | ||
|
||
|
||
# config.json is docker's runtime configuration for the container | ||
# delete comments and replace placeholder with ${CONTIV_V2PLUGIN_NAME} | ||
sed '/##/d;s/__CONTIV_V2PLUGIN_NAME__/${CONTIV_V2PLUGIN_NAME}/' \ | ||
install/v2plugin/config.template > install/v2plugin/config.json | ||
|
||
# copy over binaries | ||
cp ${TAR_FILE} install/v2plugin/ | ||
|
||
DOCKER_IMAGE=contivrootfs:${NETPLUGIN_CONTAINER_TAG} | ||
docker build -t ${DOCKER_IMAGE} \ | ||
--build-arg TAR_FILE=$(basename "${TAR_FILE}") install/v2plugin | ||
|
||
rm install/v2plugin/${TAR_FILE} # this was a copy of netplugin archive | ||
|
||
# creates a ready to run container but doesn't run it | ||
id=$(docker create $DOCKER_IMAGE true) | ||
|
||
# create the rootfs archive based on the created container contents | ||
docker export "${id}" > install/v2plugin/${V2PLUGIN_TAR_FILENAME} | ||
|
||
# clean up created container | ||
docker rm -vf "${id}" | ||
docker rmi contivrootfs | ||
rm install/v2plugin/netplugin install/v2plugin/netmaster install/v2plugin/netctl | ||
|
||
echo netplugin\'s docker plugin rootfs is archived at install/v2plugin/${V2PLUGIN_TAR_FILENAME} |