[proxy] --with-ipam -> --no-default-ipam

This commit is contained in:
Paul Bellamy committed 2015-06-17 11:31:33 +01:00
1 parent cf5d8874b6
commit 220c80c3ed
10 files changed
+56 -46

No files matched your search

+1 -1
View File
@@ -31,6 +31,7 @@ func main() {
getopt.BoolVarLong(&justVersion, "version", 0, "print version and exit")
getopt.StringVar(&c.ListenAddr, 'H', fmt.Sprintf("address on which to listen (default %s)", defaultListenAddr))
getopt.StringVar(&c.DockerAddr, 'D', fmt.Sprintf("docker daemon URL to proxy (default %s)", defaultDockerAddr))
getopt.BoolVarLong(&c.NoDefaultIPAM, "no-default-ipam", 0, "do not automatically allocate addresses for containers without a WEAVE_CIDR")
getopt.StringVarLong(&c.TLSConfig.CACert, "tlscacert", 0, "Trust certs signed only by this CA")
getopt.StringVarLong(&c.TLSConfig.Cert, "tlscert", 0, "Path to TLS certificate file")
getopt.BoolVarLong(&c.TLSConfig.Enabled, "tls", 0, "Use TLS; implied by --tlsverify")
@@ -38,7 +39,6 @@ func main() {
getopt.BoolVarLong(&c.TLSConfig.Verify, "tlsverify", 0, "Use TLS and verify the remote")
getopt.BoolVarLong(&c.WithDNS, "with-dns", 'w', "instruct created containers to always use weaveDNS as their nameserver")
getopt.BoolVarLong(&c.WithoutDNS, "without-dns", 0, "instruct created containers to never use weaveDNS as their nameserver")
getopt.BoolVarLong(&c.WithIPAM, "with-ipam", 'i', "automatically allocate addresses for containers without a WEAVE_CIDR")
getopt.Parse()
if justVersion {
+1 -1
View File
@@ -33,7 +33,7 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error {
return err
}
if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || i.proxy.WithIPAM {
if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || !i.proxy.NoDefaultIPAM {
Info.Printf("Creating container with WEAVE_CIDR \"%s\"", strings.Join(cidrs, " "))
if container.HostConfig == nil {
container.HostConfig = &docker.HostConfig{}
+1 -1
View File
@@ -29,7 +29,7 @@ func (i *createExecInterceptor) InterceptRequest(r *http.Request) error {
return err
}
if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || i.proxy.WithIPAM {
if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || !i.proxy.NoDefaultIPAM {
Info.Printf("Exec in container %s with WEAVE_CIDR \"%s\"", container.ID, strings.Join(cidrs, " "))
cmd := append(weaveWaitEntrypoint, "-s")
options.Cmd = append(cmd, options.Cmd...)
+7 -7
View File
@@ -32,13 +32,13 @@ type Proxy struct {
}
type Config struct {
DockerAddr string
ListenAddr string
TLSConfig TLSConfig
Version string
WithDNS bool
WithoutDNS bool
WithIPAM bool
DockerAddr string
ListenAddr string
NoDefaultIPAM bool
TLSConfig TLSConfig
Version string
WithDNS bool
WithoutDNS bool
}
func NewProxy(c Config) (*Proxy, error) {
+1 -1
View File
@@ -22,7 +22,7 @@ func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
}
cidrs, ok := weaveCIDRsFromConfig(container.Config)
if !ok && !i.proxy.WithIPAM {
if !ok && i.proxy.NoDefaultIPAM {
Debug.Print("No Weave CIDR, ignoring")
return nil
}
+31 -25
View File
@@ -68,19 +68,24 @@ revert to the original setting.
When containers are created via the weave proxy, their entrypoint will
be modified to wait for the weave network interface to become
available. When they are started via the weave proxy, any IP addresses
and networks specified in the `WEAVE_CIDR` environment variable will
be attached. We can create and start a container via the weave proxy
available. When they are started via the weave proxy, containers will
be [automatically assigned IP addresses](#ipam) and connected to the
weave network. We can create and start a container via the weave proxy
with
host1$ docker run -e WEAVE_CIDR=10.2.1.1/24 -ti ubuntu
host1$ docker run -ti ubuntu
or, equivalently with
host1$ docker create -e WEAVE_CIDR=10.2.1.1/24 -ti ubuntu
host1$ docker create -ti ubuntu
5ef831df61d50a1a49272357155a976595e7268e590f0a2c75693337b14e1382
host1$ docker start 5ef831df61d50a1a49272357155a976595e7268e590f0a2c75693337b14e1382
Specific IP addresses and networks can be supplied in the `WEAVE_CIDR`
environment variable, e.g.
host1$ docker run -e WEAVE_CIDR=10.2.1.1/24 -ti ubuntu
Multiple IP addresses and networks can be supplied in the `WEAVE_CIDR`
variable by space-separating them, as in
`WEAVE_CIDR="10.2.1.1/24 10.2.2.1/24"`.
@@ -94,27 +99,28 @@ can be started in foreground mode, and can be automatically removed
## <a name="ipam"></a>Automatic IP address assignment
If [automatic IP address assignment](ipam.html) is enabled in weave,
which it is by default, then containers started via the proxy can be
automatically assigned an IP address by providing a blank `WEAVE_CIDR`
environment variable, as in
host1$ docker run -e WEAVE_CIDR= -ti ubuntu
Furthermore, it is possible to configure the proxy such that all
containers started via it are automatically assigned an IP address and
attached to weave network, *without having to specify any special
environment variables or other options*. To do this we launch the
proxy with the `--with-ipam` option, e.g.
host1$ weave launch-proxy --with-ipam
Now any container started via the proxy, e.g. with
which it is by default, then containers started via the proxy will be
automatically assigned an IP address, *without having to specify any
special environment variables or other options*.
host1$ docker run -ti ubuntu
gets attached to the weave network with an automatically assigned IP
address. Containers started with a `WEAVE_CIDR` environment variable
are handled as before.
To use a specific IP, we pass a `WEAVE_CIDR` to the container, e.g.
host1$ docker run -ti -e WEAVE_CIDR=10.2.1.1/24 ubuntu
To start containers without connecting them to the weave network, the
proxy needs to be passed the `--no-default-ipam` flag, e.g.
host1$ docker launch-proxy --no-default-ipam
In this configuration, containers with no `WEAVE_CIDR` environment
variable will not be connected to the weave network. Containers
started with a `WEAVE_CIDR` environment variable are handled as
before. To automatically assign an address in this mode, we start the
container with a blank `WEAVE_CIDR`, e.g.
host1$ docker run -ti -e WEAVE_CIDR= ubuntu
## <a name="dns"></a>Automatic discovery
@@ -143,12 +149,12 @@ to point at the latter:
host1$ weave launch
host1$ weave launch-dns
host1$ weave launch-proxy --with-ipam
host1$ weave launch-proxy
host1$ eval "$(weave proxy-env)"
host2$ weave launch host1
host2$ weave launch-dns
host2$ weave launch-proxy --with-ipam
host2$ weave launch-proxy
host2$ eval "$(weave proxy-env)"
Now let us start a named container on one host, and ping it, by name,
+1 -1
View File
@@ -4,7 +4,7 @@
start_suite "Run docker-py test suite against the proxy"
weave_on $HOST1 launch-proxy
weave_on $HOST1 launch-proxy --no-default-ipam
assert_raises "docker_on $HOST1 ps | grep weaveproxy"
assert_raises "docker_on $HOST1 run \
-e NOT_ON_HOST=true \
+1 -1
View File
@@ -28,7 +28,7 @@ run_container "--entrypoint='grep' false ^1$ /sys/class/net/ethwe/carrier"
weave_on $HOST1 launch -iprange 10.2.2.0/24
docker_on $HOST1 kill weaveproxy
weave_on $HOST1 launch-proxy --with-ipam
weave_on $HOST1 launch-proxy
assert_raises "proxy docker_on $HOST1 run check-ethwe-up"
+11 -7
View File
@@ -9,14 +9,18 @@ start_suite "Ping proxied containers over cross-host weave network (with IPAM)"
weave_on $HOST1 launch -iprange $UNIVERSE
weave_on $HOST1 launch-proxy
weave_on $HOST2 launch -iprange $UNIVERSE $HOST1
weave_on $HOST2 launch-proxy --with-ipam
weave_on $HOST2 launch-proxy --no-default-ipam
proxy docker_on $HOST1 run -e WEAVE_CIDR= --name=c1 -dt $SMALL_IMAGE /bin/sh
proxy docker_on $HOST2 run --name=c2 -dt $SMALL_IMAGE /bin/sh
proxy docker_on $HOST1 run --name=auto -dt $SMALL_IMAGE /bin/sh
proxy docker_on $HOST2 run -e WEAVE_CIDR= --name=explicit -dt $SMALL_IMAGE /bin/sh
proxy docker_on $HOST2 run --name=none -dt $SMALL_IMAGE /bin/sh
C1=$(container_ip $HOST1 c1)
C2=$(container_ip $HOST2 c2)
assert_raises "proxy exec_on $HOST1 c1 $PING $C2"
assert_raises "proxy exec_on $HOST2 c2 $PING $C1"
AUTO=$(container_ip $HOST1 auto)
EXPLICIT=$(container_ip $HOST2 explicit)
assert_raises "proxy exec_on $HOST1 auto $PING $EXPLICIT"
assert_raises "proxy exec_on $HOST2 explicit $PING $AUTO"
assert_raises "container_ip $HOST2 none" 1
assert_raises "proxy exec_on $HOST2 none ip link show | grep -v ethwe"
end_suite
+1 -1
View File
@@ -30,7 +30,7 @@ usage() {
echo " [-iprange <cidr> [-ipsubnet <cidr>]] <peer> ..."
echo "weave launch-dns [<addr>]"
echo "weave launch-proxy [-D <endpoint>] [-H <endpoint>]"
echo " [--with-dns | --without-dns] [--with-ipam]"
echo " [--with-dns | --without-dns] [--no-default-ipam]"
echo "weave connect [--replace] [<peer> ...]"
echo "weave forget <peer> ..."
echo "weave run [--with-dns | --without-dns] [<addr> ...] <docker run args> ..."