Skip to content

Commit

Permalink
Use Go version of libnetwork-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdee committed Oct 31, 2016
1 parent bb7b33f commit 4c31f4d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 34 deletions.
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
default: help
all: test ## Run all the tests
binary: dist/calicoctl ## Create the calicoctl binary
calico/node: calico_node/.calico_node.created ## Create the calico/node image
calico/node: $(NODE_CONTAINER_CREATED) ## Create the calico/node image
calico/ctl: calicoctl/.calico_ctl.created ## Create the calico/node image
node_image: calico/node
ctl_image: calico/ctl
Expand Down Expand Up @@ -35,13 +35,14 @@ BUILD_CONTAINER_NAME?=calico/build:latest
###############################################################################
NODE_CONTAINER_DIR=calico_node
NODE_CONTAINER_NAME?=calico/node:latest
NODE_CONTAINER_FILES=$(shell find $(NODE_CONTAINER_DIR)/filesystem/{etc,sbin} -type f)
NODE_CONTAINER_FILES=$(shell find $(NODE_CONTAINER_DIR)/filesystem -type f)
# we can pass --build-arg during node image building
NODE_CONTAINER_BUILD_ARGS?=
NODE_CONTAINER_CREATED=$(NODE_CONTAINER_DIR)/.calico_node.created
NODE_CONTAINER_BIN_DIR=$(NODE_CONTAINER_DIR)/filesystem/bin
NODE_CONTAINER_BINARIES=startup allocate-ipip-addr calico-felix bird calico-bgp-daemon confd
NODE_CONTAINER_BINARIES=startup allocate-ipip-addr calico-felix bird calico-bgp-daemon confd libnetwork-plugin
FELIX_CONTAINER_NAME?=calico/felix:latest
LIBNETWORK_PLUGIN_CONTAINER_NAME?=calico/libnetwork-plugin:latest

calico-node.tar: $(NODE_CONTAINER_CREATED)
docker save --output $@ $(NODE_CONTAINER_NAME)
Expand All @@ -51,8 +52,8 @@ calico-node.tar: $(NODE_CONTAINER_CREATED)
calico-node-latest.aci: calico-node.tar
docker2aci $<

# Build calico/node docker image
$(NODE_CONTAINER_CREATED): $(NODE_CONTAINER_DIR)/Dockerfile $(addprefix $(NODE_CONTAINER_BIN_DIR)/,$(NODE_CONTAINER_BINARIES))
# Build calico/node docker image - explicitly depend on the container binaries.
$(NODE_CONTAINER_CREATED): $(NODE_CONTAINER_DIR)/Dockerfile $(NODE_CONTAINER_FILES) $(addprefix $(NODE_CONTAINER_BIN_DIR)/,$(NODE_CONTAINER_BINARIES))
docker build $(NODE_CONTAINER_BUILD_ARGS) -t $(NODE_CONTAINER_NAME) $(NODE_CONTAINER_DIR)
touch $@

Expand All @@ -71,6 +72,15 @@ $(NODE_CONTAINER_BIN_DIR)/calico-felix:
docker cp calico-felix:/code/. $(@D)
-docker rm -f calico-felix

# Get libnetwork-plugin binaries
$(NODE_CONTAINER_BIN_DIR)/libnetwork-plugin:
-docker rm -f calico-$(@F)
# Latest libnetwork-plugin binaries are stored in automated builds of calico/libnetwork-plugin.
# To get them, we pull that image, then copy the binaries out to our host
docker create --name calico-$(@F) $(LIBNETWORK_PLUGIN_CONTAINER_NAME)
docker cp calico-$(@F):/$(@F) $(@D)
-docker rm -f calico-$(@F)

# Get the confd binary
$(NODE_CONTAINER_BIN_DIR)/confd:
curl -L $(CONFD_URL) -o $@
Expand Down
14 changes: 0 additions & 14 deletions calico_node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ MAINTAINER Tom Denham <tom@projectcalico.org>

ARG LIBCALICO_REPO="https://github.com/projectcalico/libcalico.git"
ARG LIBCALICO_VER="master"
ARG LIBNETWORK_REPO="https://github.com/projectcalico/libnetwork-plugin.git"
ARG LIBNETWORK_VER="master"

# Download and install glibc for use by non-static binaries that require it.
RUN apk --no-cache add wget ca-certificates libgcc && \
Expand All @@ -35,22 +33,10 @@ RUN apk add --no-cache --repository "http://alpine.gliderlabs.com/alpine/edge/co
# Install remaining runtime deps required for felix from the global repository
RUN apk add --no-cache ip6tables ipset iputils iproute2 conntrack-tools

# Install Python so libnetwork-plugin can run
RUN apk --no-cache add python py-setuptools

# Copy "shared directory" which can be used to pass custom files (local git repos,
# that can be used by pip install git+file:///)
COPY node_share /tmp/node_share

# Actually install libnetwork-plugin. A python dev environment (and git) is installed so
# libnetwork-plugin can be pip installed.
# Finally the dev environment is removed. Doing this in one image layer minimized the final image size.
RUN apk --no-cache add --virtual temp py-pip git gcc python-dev musl-dev libffi-dev openssl-dev && \
pip install git+$LIBNETWORK_REPO@$LIBNETWORK_VER && \
pip install git+$LIBCALICO_REPO@$LIBCALICO_VER && \
apk del --purge temp && \
rm -rf /tmp/node_share

# Copy in the filesystem - this contains felix, bird, gobgp etc...
COPY filesystem /

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
LOGDIR=/var/log/calico/libnetwork
mkdir -p $LOGDIR
# Prefix each line with a timestamp
exec svlogd -tt $LOGDIR
exec svlogd $LOGDIR
14 changes: 1 addition & 13 deletions calico_node/filesystem/etc/service/available/libnetwork/run
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
#!/bin/sh
exec 2>&1
GUNICORN=/usr/bin/gunicorn
PID=/var/run/gunicorn.pid
APP=libnetwork.driver_plugin:app

if [ -f $PID ]; then rm $PID; fi

exec $GUNICORN --pid=$PID \
-b unix:///run/docker/plugins/calico.sock $APP \
--timeout 5 \
--log-level=info \
--workers 1 \
--worker-class gevent \
--access-logfile -
exec libnetwork-plugin

0 comments on commit 4c31f4d

Please sign in to comment.