Skip to content

Commit a5dd4af

Browse files
authored
Merge pull request #45 from Azure/development
Development
2 parents fc41e75 + 4342cc1 commit a5dd4af

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

Dockerfile.cnm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM ubuntu:14.04.3
2+
3+
# Install dependencies.
4+
RUN apt-get update && apt-get install -y ebtables
5+
6+
# Create plugins directory.
7+
RUN mkdir -p /run/docker/plugins
8+
9+
# Install plugin.
10+
COPY ./out/azure-cnm-plugin /usr/bin
11+
WORKDIR /usr/bin
12+
13+
CMD ["/usr/bin/azure-cnm-plugin"]

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ REPO_PATH = /go/src/github.com/Azure/azure-container-networking
3232
BUILD_CONTAINER_IMAGE = acn-build
3333
BUILD_USER ?= $(shell id -u)
3434

35+
CNM_PLUGIN_IMAGE = ofiliz/azure-cnm-plugin
36+
CNM_PLUGIN_ROOTFS = azure-cnm-plugin-rootfs
37+
3538
VERSION ?= $(shell git describe --tags --always --dirty)
3639

3740
ENSURE_OUTPUTDIR_EXISTS := $(shell mkdir -p $(OUTPUTDIR))
@@ -67,3 +70,35 @@ build-containerized:
6770
chown -R $(BUILD_USER):$(BUILD_USER) $(OUTPUTDIR) \
6871
'
6972

73+
# Build the Azure CNM plugin image, installable with "docker plugin install".
74+
.PHONY: azure-cnm-plugin-image
75+
azure-cnm-plugin-image: azure-cnm-plugin
76+
# Build the plugin image, keeping any old image during build for cache, but remove it afterwards.
77+
docker images -q $(CNM_PLUGIN_ROOTFS):$(VERSION) > cid
78+
docker build -f Dockerfile.cnm -t $(CNM_PLUGIN_ROOTFS):$(VERSION) .
79+
$(eval CID := `cat cid`)
80+
docker rmi $(CID) || true
81+
82+
# Create a container using the image and export its rootfs.
83+
docker create $(CNM_PLUGIN_ROOTFS):$(VERSION) > cid
84+
$(eval CID := `cat cid`)
85+
mkdir -p $(OUTPUTDIR)/$(CID)/rootfs
86+
docker export $(CID) | tar -x -C $(OUTPUTDIR)/$(CID)/rootfs
87+
docker rm -vf $(CID)
88+
89+
# Copy the plugin configuration and set ownership.
90+
cp cnm/config.json $(OUTPUTDIR)/$(CID)
91+
chgrp -R docker $(OUTPUTDIR)/$(CID)
92+
93+
# Create the plugin.
94+
docker plugin rm $(CNM_PLUGIN_IMAGE):$(VERSION) || true
95+
docker plugin create $(CNM_PLUGIN_IMAGE):$(VERSION) $(OUTPUTDIR)/$(CID)
96+
97+
# Cleanup temporary files.
98+
rm -rf $(OUTPUTDIR)/$(CID)
99+
rm cid
100+
101+
# Publish the Azure CNM plugin image to a Docker registry.
102+
.PHONY: publish-azure-cnm-plugin-image
103+
publish-azure-cnm-plugin-image:
104+
docker plugin push $(CNM_PLUGIN_IMAGE):$(VERSION)

cni/azure.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"cniVersion": "0.2.0",
3+
"name": "azure",
4+
"type": "azure-cni-plugin",
5+
"bridge": "azure0",
6+
"ipam": {
7+
"type": "azure-cni-plugin"
8+
}
9+
}

cnm/config.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"description": "Azure network plugin",
3+
"documentation": "https://github.com/Azure/azure-container-networking/",
4+
"entrypoint": ["/usr/bin/azure-cnm-plugin"],
5+
"interface": {
6+
"types": ["docker.networkdriver/1.0", "docker.ipamdriver/1.0"],
7+
"socket": "azurenet.sock"
8+
},
9+
"network": {
10+
"type": "host"
11+
},
12+
"linux": {
13+
"capabilities": ["CAP_SYS_ADMIN", "CAP_NET_ADMIN"]
14+
}
15+
}

0 commit comments

Comments
 (0)