Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Dockerfile.cnm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:14.04.3

# Install dependencies.
RUN apt-get update && apt-get install -y ebtables

# Create plugins directory.
RUN mkdir -p /run/docker/plugins

# Install plugin.
COPY ./out/azure-cnm-plugin /usr/bin
WORKDIR /usr/bin

CMD ["/usr/bin/azure-cnm-plugin"]
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ REPO_PATH = /go/src/github.com/Azure/azure-container-networking
BUILD_CONTAINER_IMAGE = acn-build
BUILD_USER ?= $(shell id -u)

CNM_PLUGIN_IMAGE = ofiliz/azure-cnm-plugin
CNM_PLUGIN_ROOTFS = azure-cnm-plugin-rootfs

VERSION ?= $(shell git describe --tags --always --dirty)

ENSURE_OUTPUTDIR_EXISTS := $(shell mkdir -p $(OUTPUTDIR))
Expand Down Expand Up @@ -67,3 +70,35 @@ build-containerized:
chown -R $(BUILD_USER):$(BUILD_USER) $(OUTPUTDIR) \
'

# Build the Azure CNM plugin image, installable with "docker plugin install".
.PHONY: azure-cnm-plugin-image
azure-cnm-plugin-image: azure-cnm-plugin
# Build the plugin image, keeping any old image during build for cache, but remove it afterwards.
docker images -q $(CNM_PLUGIN_ROOTFS):$(VERSION) > cid
docker build -f Dockerfile.cnm -t $(CNM_PLUGIN_ROOTFS):$(VERSION) .
$(eval CID := `cat cid`)
docker rmi $(CID) || true

# Create a container using the image and export its rootfs.
docker create $(CNM_PLUGIN_ROOTFS):$(VERSION) > cid
$(eval CID := `cat cid`)
mkdir -p $(OUTPUTDIR)/$(CID)/rootfs
docker export $(CID) | tar -x -C $(OUTPUTDIR)/$(CID)/rootfs
docker rm -vf $(CID)

# Copy the plugin configuration and set ownership.
cp cnm/config.json $(OUTPUTDIR)/$(CID)
chgrp -R docker $(OUTPUTDIR)/$(CID)

# Create the plugin.
docker plugin rm $(CNM_PLUGIN_IMAGE):$(VERSION) || true
docker plugin create $(CNM_PLUGIN_IMAGE):$(VERSION) $(OUTPUTDIR)/$(CID)

# Cleanup temporary files.
rm -rf $(OUTPUTDIR)/$(CID)
rm cid

# Publish the Azure CNM plugin image to a Docker registry.
.PHONY: publish-azure-cnm-plugin-image
publish-azure-cnm-plugin-image:
docker plugin push $(CNM_PLUGIN_IMAGE):$(VERSION)
9 changes: 9 additions & 0 deletions cni/azure.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"cniVersion": "0.2.0",
"name": "azure",
"type": "azure-cni-plugin",
"bridge": "azure0",
"ipam": {
"type": "azure-cni-plugin"
}
}
15 changes: 15 additions & 0 deletions cnm/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"description": "Azure network plugin",
"documentation": "https://github.com/Azure/azure-container-networking/",
"entrypoint": ["/usr/bin/azure-cnm-plugin"],
"interface": {
"types": ["docker.networkdriver/1.0", "docker.ipamdriver/1.0"],
"socket": "azurenet.sock"
},
"network": {
"type": "host"
},
"linux": {
"capabilities": ["CAP_SYS_ADMIN", "CAP_NET_ADMIN"]
}
}