diff --git a/assets/docker/cni/bridge.d/bridge.conf b/assets/docker/cni/bridge.d/bridge.conf new file mode 100644 index 00000000..a090c5e8 --- /dev/null +++ b/assets/docker/cni/bridge.d/bridge.conf @@ -0,0 +1,12 @@ +{ + "name": "bridge", + "type": "bridge", + "bridge": "docker-sys", + "isDefaultGateway": true, + "ipMasq": true, + "hairpinMode": true, + "ipam": { + "type": "host-local", + "subnet": "172.18.42.1/16" + } +} diff --git a/assets/docker/cni/default.d b/assets/docker/cni/default.d new file mode 120000 index 00000000..505083cd --- /dev/null +++ b/assets/docker/cni/default.d @@ -0,0 +1 @@ +bridge.d/ \ No newline at end of file diff --git a/assets/docker/hooks/poststop.d/network.json b/assets/docker/hooks/poststop.d/network.json new file mode 100644 index 00000000..b2eae3cf --- /dev/null +++ b/assets/docker/hooks/poststop.d/network.json @@ -0,0 +1,7 @@ +{ + "path": "/usr/bin/ros", + "args": [ + "cni-glue", + "poststop" + ] +} diff --git a/assets/docker/hooks/prestart.d/network.json b/assets/docker/hooks/prestart.d/network.json new file mode 100644 index 00000000..a38ada87 --- /dev/null +++ b/assets/docker/hooks/prestart.d/network.json @@ -0,0 +1,6 @@ +{ + "path": "/usr/bin/ros", + "args": [ + "cni-glue" + ] +} diff --git a/main.go b/main.go index dee27724..6230dfd4 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,11 @@ package main import ( + "github.com/containernetworking/cni/plugins/ipam/host-local" + "github.com/containernetworking/cni/plugins/main/bridge" "github.com/docker/docker/docker" "github.com/docker/docker/pkg/reexec" + "github.com/rancher/cniglue" "github.com/rancher/docker-from-scratch" "github.com/rancher/os/cmd/cloudinit" "github.com/rancher/os/cmd/control" @@ -33,6 +36,9 @@ var entrypoints = map[string]func(){ "system-docker": systemdocker.Main, "user-docker": userdocker.Main, "wait-for-docker": wait.Main, + "cni-glue": glue.Main, + "bridge": bridge.Main, + "host-local": hostlocal.Main, } func main() { diff --git a/os-config.tpl.yml b/os-config.tpl.yml index 7e7d7f8f..abcd7cae 100644 --- a/os-config.tpl.yml +++ b/os-config.tpl.yml @@ -231,6 +231,7 @@ rancher: labels: io.rancher.os.detach: "false" io.rancher.os.scope: system + net: host privileged: true volumes: - /var/run/system-docker.sock:/var/run/docker.sock @@ -245,6 +246,7 @@ rancher: io.rancher.os.detach: "false" io.rancher.os.scope: system io.rancher.os.after: console + net: host privileged: true volumes: - /var/run/:/var/run/ @@ -348,8 +350,8 @@ rancher: - /sys/fs/cgroup:/host/sys/fs/cgroup system_docker: exec: true - args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay, -b, docker-sys, - --fixed-cidr, 172.18.42.1/16, --restart=false, -g, /var/lib/system-docker, -G, root, + args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay, + --restart=false, -g, /var/lib/system-docker, -G, root, -p, /var/run/system-docker.pid, --exec-root=/var/run/system-docker, --config-file=/etc/docker/system-daemon.json, -H, 'unix:///var/run/system-docker.sock', --userland-proxy=false] upgrade: diff --git a/scripts/layout b/scripts/layout index 525c4b52..c8293fdc 100755 --- a/scripts/layout +++ b/scripts/layout @@ -10,17 +10,20 @@ INITRD_DIR=${BUILD}/initrd echo Create initrd layout in $INITRD_DIR rm -rf ${INITRD_DIR} -mkdir -p ${INITRD_DIR}/usr/{etc,bin,share/ros} +mkdir -p ${INITRD_DIR}/usr/{etc,bin,share/ros,var/lib/cni/bin} ./scripts/template -cp -rf assets/selinux ${INITRD_DIR}/usr/etc -cp build/images.tar ${INITRD_DIR}/usr/share/ros/ -cp bin/ros ${INITRD_DIR}/usr/bin/ -ln -s usr/bin/ros ${INITRD_DIR}/init -ln -s bin ${INITRD_DIR}/usr/sbin -ln -s usr/sbin ${INITRD_DIR}/sbin -ln -s ros ${INITRD_DIR}/usr/bin/system-docker +cp -rf assets/selinux ${INITRD_DIR}/usr/etc +cp -rf assets/docker ${INITRD_DIR}/usr/etc +cp build/images.tar ${INITRD_DIR}/usr/share/ros/ +cp bin/ros ${INITRD_DIR}/usr/bin/ +ln -s usr/bin/ros ${INITRD_DIR}/init +ln -s bin ${INITRD_DIR}/usr/sbin +ln -s usr/sbin ${INITRD_DIR}/sbin +ln -s ros ${INITRD_DIR}/usr/bin/system-docker +ln -s ../../../../usr/bin/ros ${INITRD_DIR}/usr/var/lib/cni/bin/bridge +ln -s ../../../../usr/bin/ros ${INITRD_DIR}/usr/var/lib/cni/bin/host-local tar xvzf ${DOWNLOADS}/docker.tgz -C ${INITRD_DIR}/usr/bin --strip-components=1 diff --git a/trash.conf b/trash.conf index 5324e3eb..1802cba1 100644 --- a/trash.conf +++ b/trash.conf @@ -5,13 +5,15 @@ github.com/boltdb/bolt v1.2.0 github.com/cloudfoundry-incubator/candiedyaml 01cbc92901719f599b11f3a7e3b1768d7002b0bb https://github.com/rancher/candiedyaml github.com/cloudfoundry/gosigar 3ed7c74352dae6dc00bdc8c74045375352e3ec05 github.com/codegangsta/cli 95199f812193f6f1e8bbe0a916d9f3ed50729909 https://github.com/ibuildthecloud/cli-1.git +github.com/containernetworking/cni a8e4fa0dffdac6a236f85be91502603ec06957f9 https://github.com/rancher/cni.git github.com/coreos/coreos-cloudinit v1.11.0-3-gb1c1753 https://github.com/rancher/coreos-cloudinit.git +github.com/coreos/go-iptables fbb73372b87f6e89951c2b6b31470c2c9d5cfae3 github.com/coreos/go-systemd v4 github.com/coreos/yaml 6b16a5714269b2f70720a45406b1babd947a17ef github.com/davecgh/go-spew 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d github.com/docker/containerd 1674135d5e32ea16d2ed0967f00325c7276b984b https://github.com/ibuildthecloud/containerd.git github.com/docker/distribution 467fc068d88aa6610691b7f1a677271a3fac4aac -github.com/docker/docker c030e8ed127f498be702c331337e87e9525e9f76 https://github.com/rancher/docker.git +github.com/docker/docker bf16bd9dcfc3c9fafb7eb7b39ae7ef7abf1ae7f1 https://github.com/rancher/docker.git github.com/docker/engine-api v0.3.3 github.com/docker/go-connections v0.2.0 github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3 @@ -32,8 +34,10 @@ github.com/opencontainers/runc edc34c4a8c1e261b5ce926ff557ecde1aff19ce3 https:// github.com/opencontainers/runtime-spec f955d90e70a98ddfb886bd930ffd076da9b67998 github.com/opencontainers/specs f955d90e70a98ddfb886bd930ffd076da9b67998 github.com/packethost/packngo 92012705236896736875186c9e49557897c6af90 https://github.com/ibuildthecloud/packngo.git +github.com/pkg/errors d62207b3dc916c342cd6a7180fa861d898cf42ee github.com/pmezard/go-difflib d8ed2627bdf02c080bf22230dbb337003b7aba2d -github.com/rancher/docker-from-scratch 24857c88a000ef5e7f9f5f17fa848d695f698239 +github.com/rancher/cniglue 424607e40a480b0cb52f6cd3ec187ae6d61febf1 +github.com/rancher/docker-from-scratch 152ddfa8d618d83238d987e7b8ae7287fc69f327 github.com/rancher/netconf ddd7e35a6aacd7e80991920774083dd4408ec018 github.com/rcrowley/go-metrics eeba7bd0dd01ace6e690fa833b3f22aaec29af43 github.com/ryanuber/go-glob 0067a9abd927e50aed5190662702f81231413ae0 diff --git a/vendor/github.com/containernetworking/cni/.gitignore b/vendor/github.com/containernetworking/cni/.gitignore new file mode 100644 index 00000000..06f78b4b --- /dev/null +++ b/vendor/github.com/containernetworking/cni/.gitignore @@ -0,0 +1,3 @@ +bin/ +gopath/ +*.sw[ponm] diff --git a/vendor/github.com/containernetworking/cni/.travis.yml b/vendor/github.com/containernetworking/cni/.travis.yml new file mode 100644 index 00000000..fb135c93 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/.travis.yml @@ -0,0 +1,29 @@ +language: go +sudo: required +dist: trusty + + +matrix: + include: + - go: 1.5.4 + env: GO15VENDOREXPERIMENT=1 + - go: 1.6.2 + - go: tip + allow_failures: + - go: tip + +env: + global: + - TOOLS_CMD=golang.org/x/tools/cmd + - PATH=$GOROOT/bin:$PATH + +install: + - go get ${TOOLS_CMD}/cover + - go get github.com/modocache/gover + - go get github.com/mattn/goveralls + +script: + - ./test + +notifications: + email: false diff --git a/vendor/github.com/containernetworking/cni/CONTRIBUTING.md b/vendor/github.com/containernetworking/cni/CONTRIBUTING.md new file mode 100644 index 00000000..fc637b15 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/CONTRIBUTING.md @@ -0,0 +1,86 @@ +# How to Contribute + +CNI is [Apache 2.0 licensed](LICENSE) and accepts contributions via GitHub +pull requests. This document outlines some of the conventions on development +workflow, commit message formatting, contact points and other resources to make +it easier to get your contribution accepted. + +We gratefully welcome improvements to documentation as well as to code. + +# Certificate of Origin + +By contributing to this project you agree to the Developer Certificate of +Origin (DCO). This document was created by the Linux Kernel community and is a +simple statement that you, as a contributor, have the legal right to make the +contribution. See the [DCO](DCO) file for details. + +# Email and Chat + +The project uses the the cni-dev email list and IRC chat: +- Email: [cni-dev](https://groups.google.com/forum/#!forum/cni-dev) +- IRC: #[containernetworking](irc://irc.freenode.org:6667/#containernetworking) channel on freenode.org + +Please avoid emailing maintainers found in the MAINTAINERS file directly. They +are very busy and read the mailing lists. + +## Getting Started + +- Fork the repository on GitHub +- Read the [README](README.md) for build and test instructions +- Play with the project, submit bugs, submit pull requests! + +## Contribution workflow + +This is a rough outline of how to prepare a contribution: + +- Create a topic branch from where you want to base your work (usually branched from master). +- Make commits of logical units. +- Make sure your commit messages are in the proper format (see below). +- Push your changes to a topic branch in your fork of the repository. +- If you changed code, make sure the tests pass, and add any new tests as appropriate. +- Make sure any new code files have a license header. +- Submit a pull request to the original repository. + +# Acceptance policy + +These things will make a PR more likely to be accepted: + + * a well-described requirement + * tests for new code + * tests for old code! + * new code follows the conventions in old code + * a good commit message (see below) + +In general, we will merge a PR once two maintainers have endorsed it. +Trivial changes (e.g., corrections to spelling) may get waved through. +For substantial changes, more people may become involved, and you might get asked to resubmit the PR or divide the changes into more than one PR. + +### Format of the Commit Message + +We follow a rough convention for commit messages that is designed to answer two +questions: what changed and why. The subject line should feature the what and +the body of the commit should describe the why. + +``` +scripts: add the test-cluster command + +this uses tmux to setup a test cluster that you can easily kill and +start for debugging. + +Fixes #38 +``` + +The format can be described more formally as follows: + +``` +: + + + +