Add default CNI configuration

podman needs a pair of configuration files to set up its default
network configuration: a bridge and loopback file.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #161
Approved by: baude
This commit is contained in:
baude
2017-12-20 15:13:52 -06:00
committed by Atomic Bot
parent b08ac1065c
commit 7f531263e6
34 changed files with 16 additions and 123 deletions

View File

@ -94,5 +94,5 @@ if [[ ${PACKAGER} != "yum" ]]; then
fi fi
make TAGS="${TAGS}" make TAGS="${TAGS}"
make TAGS="${TAGS}" install PREFIX=/host/usr make TAGS="${TAGS}" install PREFIX=/host/usr ETCDIR=/host/etc
make TAGS="${TAGS}" test-binaries make TAGS="${TAGS}" test-binaries

View File

@ -79,23 +79,6 @@ RUN set -x \
&& cp bin/* /usr/libexec/cni \ && cp bin/* /usr/libexec/cni \
&& rm -rf "$GOPATH" && rm -rf "$GOPATH"
# Install custom CNI bridge test plugin
# XXX: this plugin is meant to be a replacement for the old "test_plugin_args.bash"
# we need this in testing because sandbox_run now gather IP address and the mock
# plugin wasn't able to properly setup the net ns.
# The bridge is based on the same commit as the one above.
#ENV CNI_COMMIT 6bfe036c38c8e1410f1acaa4b2ee16f1851472e4
ENV CNI_TEST_BRANCH custom-bridge
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/runcom/plugins.git "$GOPATH/src/github.com/containernetworking/plugins" \
&& cd "$GOPATH/src/github.com/containernetworking/plugins" \
&& git checkout -q "$CNI_TEST_BRANCH" \
&& ./build.sh \
&& mkdir -p /opt/cni/bin \
&& cp bin/bridge /opt/cni/bin/bridge-custom \
&& rm -rf "$GOPATH"
# Install crictl # Install crictl
ENV CRICTL_COMMIT 16e6fe4d7199c5689db4630a9330e6a8a12cecd1 ENV CRICTL_COMMIT 16e6fe4d7199c5689db4630a9330e6a8a12cecd1
RUN set -x \ RUN set -x \

View File

@ -10,7 +10,7 @@ PREFIX ?= ${DESTDIR}/usr/local
BINDIR ?= ${PREFIX}/bin BINDIR ?= ${PREFIX}/bin
LIBEXECDIR ?= ${PREFIX}/libexec LIBEXECDIR ?= ${PREFIX}/libexec
MANDIR ?= ${PREFIX}/share/man MANDIR ?= ${PREFIX}/share/man
ETCDIR ?= ${DESTDIR}/etc ETCDIR ?= /etc
ETCDIR_LIBPOD ?= ${ETCDIR}/crio ETCDIR_LIBPOD ?= ${ETCDIR}/crio
BUILDTAGS ?= seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh) $(shell hack/btrfs_installed_tag.sh) $(shell hack/ostree_tag.sh) $(shell hack/selinux_tag.sh) BUILDTAGS ?= seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh) $(shell hack/btrfs_installed_tag.sh) $(shell hack/ostree_tag.sh) $(shell hack/selinux_tag.sh)
@ -135,7 +135,7 @@ docs/%.1: docs/%.1.md .gopathok
docs: $(MANPAGES) docs: $(MANPAGES)
install: .gopathok install.bin install.man install: .gopathok install.bin install.man install.cni
install.bin: install.bin:
install ${SELINUXOPT} -D -m 755 bin/podman $(BINDIR)/podman install ${SELINUXOPT} -D -m 755 bin/podman $(BINDIR)/podman
@ -153,6 +153,10 @@ install.completions:
install ${SELINUXOPT} -d -m 755 ${BASHINSTALLDIR} install ${SELINUXOPT} -d -m 755 ${BASHINSTALLDIR}
install ${SELINUXOPT} -m 644 -D completions/bash/podman ${BASHINSTALLDIR} install ${SELINUXOPT} -m 644 -D completions/bash/podman ${BASHINSTALLDIR}
install.cni:
install ${SELINUXOPT} -D -m 644 cni/98-podman-loopback.conf ${ETCDIR}/cni/net.d/98-podman-loopback.conf
install ${SELINUXOPT} -m 644 cni/97-podman-bridge.conf ${ETCDIR}/cni/net.d/97-podman-bridge.conf
uninstall: uninstall:
rm -f $(LIBEXECDIR)/crio/conmon rm -f $(LIBEXECDIR)/crio/conmon
for i in $(filter %.1,$(MANPAGES)); do \ for i in $(filter %.1,$(MANPAGES)); do \

View File

@ -1,6 +1,6 @@
{ {
"cniVersion": "0.2.0", "cniVersion": "0.3.0",
"name": "crio-bridge", "name": "podman",
"type": "bridge", "type": "bridge",
"bridge": "cni0", "bridge": "cni0",
"isGateway": true, "isGateway": true,

View File

@ -1,16 +0,0 @@
## `contrib/cni` ##
There are a wide variety of different [CNI][cni] network configurations. This
directory just contains some example configurations that can be used as the
basis for your own configurations (distributions should package these files in
example directories).
To use these configurations, place them in `/etc/cni/net.d` (or the directory
specified by `crio.network.network_dir` in your `crio.conf`).
In addition, you need to install the [CNI plugins][cni] necessary into
`/opt/cni/bin` (or the directory specified by `crio.network.plugin_dir`). The
two plugins necessary for the example CNI configurations are `loopback` and
`bridge`.
[cni]: https://github.com/containernetworking/plugins

View File

@ -85,7 +85,7 @@ HOOKS_OPTS="--hooks-dir-path=$HOOKSDIR"
MOUNT_PATH="$TESTDIR/secrets" MOUNT_PATH="$TESTDIR/secrets"
mkdir ${MOUNT_PATH} mkdir ${MOUNT_PATH}
MOUNT_FILE="${MOUNT_PATH}/test.txt" MOUNT_FILE="${MOUNT_PATH}/test.txt"
touch ${MOUNT_FILE} touch ${MOUNT_FILE}}
echo "Testing secrets mounts!" > ${MOUNT_FILE} echo "Testing secrets mounts!" > ${MOUNT_FILE}
DEFAULT_MOUNTS_OPTS="--default-mounts=${MOUNT_PATH}:/container/path1" DEFAULT_MOUNTS_OPTS="--default-mounts=${MOUNT_PATH}:/container/path1"
@ -104,11 +104,16 @@ if [ -e /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
filelabel=$(awk -F'"' '/^file.*=.*/ {print $2}' /etc/selinux/${SELINUXTYPE}/contexts/lxc_contexts) filelabel=$(awk -F'"' '/^file.*=.*/ {print $2}' /etc/selinux/${SELINUXTYPE}/contexts/lxc_contexts)
chcon -R ${filelabel} $TESTDIR chcon -R ${filelabel} $TESTDIR
fi fi
LIBPOD_CNI_CONFIG="$TESTDIR/cni/net.d/"
LIBPOD_CNI_CONFIG="$TESTDIR/etc/cni/net.d/"
LIBPOD_CNI_PLUGIN=${LIBPOD_CNI_PLUGIN:-/opt/cni/bin/} LIBPOD_CNI_PLUGIN=${LIBPOD_CNI_PLUGIN:-/opt/cni/bin/}
POD_CIDR="10.88.0.0/16" POD_CIDR="10.88.0.0/16"
POD_CIDR_MASK="10.88.*.*" POD_CIDR_MASK="10.88.*.*"
# Make sure the cni config dirs are created and populate them with the default configs
mkdir -p ${LIBPOD_CNI_CONFIG}
cp ${CRIO_ROOT}/cni/* ${LIBPOD_CNI_CONFIG}
PODMAN_OPTIONS="--root $TESTDIR/crio $STORAGE_OPTIONS --runroot $TESTDIR/crio-run --runtime ${RUNTIME_BINARY} --conmon ${CONMON_BINARY} --cni-config-dir ${LIBPOD_CNI_CONFIG}" PODMAN_OPTIONS="--root $TESTDIR/crio $STORAGE_OPTIONS --runroot $TESTDIR/crio-run --runtime ${RUNTIME_BINARY} --conmon ${CONMON_BINARY} --cni-config-dir ${LIBPOD_CNI_CONFIG}"
cp "$CONMON_BINARY" "$TESTDIR/conmon" cp "$CONMON_BINARY" "$TESTDIR/conmon"
@ -193,59 +198,6 @@ function is_apparmor_enabled() {
echo 0 echo 0
} }
function prepare_network_conf() {
mkdir -p $LIBPOD_CNI_CONFIG
cat >$LIBPOD_CNI_CONFIG/10-crio.conf <<-EOF
{
"cniVersion": "0.2.0",
"name": "crionet",
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "10.20.40.0/24",
"routes": [
{ "dst": "0.0.0.0/0" }
]
}
}
EOF
cat >$LIBPOD_CNI_CONFIG/99-loopback.conf <<-EOF
{
"cniVersion": "0.2.0",
"type": "loopback"
}
EOF
echo 0
}
function prepare_plugin_test_args_network_conf() {
mkdir -p $LIBPOD_CNI_CONFIG
cat >$LIBPOD_CNI_CONFIG/10-plugin-test-args.conf <<-EOF
{
"cniVersion": "0.2.0",
"name": "crionet_test_args",
"type": "bridge-custom",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "10.20.40.0/24",
"routes": [
{ "dst": "0.0.0.0/0" }
]
}
}
EOF
echo 0
}
function check_pod_cidr() { function check_pod_cidr() {
run crioctl ctr execsync --id $1 ip addr show dev eth0 scope global 2>&1 run crioctl ctr execsync --id $1 ip addr show dev eth0 scope global 2>&1
echo "$output" echo "$output"

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -9,7 +9,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -3,7 +3,6 @@
load helpers load helpers
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -3,7 +3,6 @@
load helpers load helpers
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -4,10 +4,6 @@ load helpers
IMAGE="busybox" IMAGE="busybox"
function setup() {
prepare_network_conf
}
function teardown() { function teardown() {
cleanup_test cleanup_test
} }

View File

@ -9,7 +9,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -3,7 +3,6 @@
load helpers load helpers
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -9,7 +9,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -3,7 +3,6 @@
load helpers load helpers
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -4,7 +4,6 @@ load helpers
IMAGE="redis:alpine" IMAGE="redis:alpine"
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -3,7 +3,6 @@
load helpers load helpers
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -3,7 +3,6 @@
load helpers load helpers
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -7,7 +7,6 @@ function teardown() {
} }
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }

View File

@ -3,7 +3,6 @@
load helpers load helpers
function setup() { function setup() {
prepare_network_conf
copy_images copy_images
} }