Merge pull request #1379 from awh/issues/1369-weave-dns-add-remove-optional-ip
LGTM. Fixes #1369
This commit is contained in:
commit
145a527626
3 files changed
+27
-9
No files matched your search
+6
-4
@@ -148,18 +148,20 @@ If you want to give the container a name in DNS *other* than its
|
|||||||
hostname, you can register it using the `dns-add` command. For example:
|
hostname, you can register it using the `dns-add` command. For example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ C=$(docker run -e WEAVE_CIDR=10.2.1.27/24 -ti ubuntu)
|
$ C=$(docker run -ti ubuntu)
|
||||||
$ weave dns-add 10.2.1.27 $C -h pingme2.weave.local
|
$ weave dns-add $C -h pingme2.weave.local
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also use `dns-add` to add the container's configured hostname
|
You can also use `dns-add` to add the container's configured hostname
|
||||||
and domain, simply by omitting `-h <fqdn>`.
|
and domain simply by omitting `-h <fqdn>`, or specify additional IP
|
||||||
|
addresses to be registered against the container's hostname e.g.
|
||||||
|
`weave dns-add 10.2.1.27 $C`.
|
||||||
|
|
||||||
The inverse operation can be carried out using the `dns-remove`
|
The inverse operation can be carried out using the `dns-remove`
|
||||||
command:
|
command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ weave dns-remove 10.2.1.27 $C
|
$ weave dns-remove $C
|
||||||
```
|
```
|
||||||
|
|
||||||
## <a name="resolve-weavedns-entries-from-host"></a>Resolve weaveDNS entries from host
|
## <a name="resolve-weavedns-entries-from-host"></a>Resolve weaveDNS entries from host
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ weave_on $HOST1 dns-add $C2 c2 -h $NAME2
|
|||||||
assert_dns_record $HOST1 c1 $NAME2 $C2
|
assert_dns_record $HOST1 c1 $NAME2 $C2
|
||||||
|
|
||||||
weave_on $HOST1 dns-add $C1 c1 -h $NAME1
|
weave_on $HOST1 dns-add $C1 c1 -h $NAME1
|
||||||
weave_on $HOST1 dns-add $C1 c1 -h $NAME3
|
weave_on $HOST1 dns-add c1 -h $NAME3
|
||||||
|
|
||||||
assert_dns_a_record $HOST1 c1 $NAME1 $C1
|
assert_dns_a_record $HOST1 c1 $NAME1 $C1
|
||||||
assert_dns_a_record $HOST1 c1 $NAME3 $C1
|
assert_dns_a_record $HOST1 c1 $NAME3 $C1
|
||||||
@@ -30,4 +30,8 @@ weave_on $HOST1 dns-remove $C1 c1 -h $NAME1
|
|||||||
assert_no_dns_record $HOST1 c1 $NAME1
|
assert_no_dns_record $HOST1 c1 $NAME1
|
||||||
assert_dns_a_record $HOST1 c1 $NAME3 $C1
|
assert_dns_a_record $HOST1 c1 $NAME3 $C1
|
||||||
|
|
||||||
|
weave_on $HOST1 dns-remove c1 -h $NAME3
|
||||||
|
|
||||||
|
assert_no_dns_record $HOST1 c1 $NAME3
|
||||||
|
|
||||||
end_suite
|
end_suite
|
||||||
@@ -67,8 +67,8 @@ weave run [--with-dns | --without-dns] [<addr> ...]
|
|||||||
weave start [<addr> ...] <container_id>
|
weave start [<addr> ...] <container_id>
|
||||||
weave attach [<addr> ...] <container_id>
|
weave attach [<addr> ...] <container_id>
|
||||||
weave detach [<addr> ...] <container_id>
|
weave detach [<addr> ...] <container_id>
|
||||||
weave dns-add <ip_address> [<ip_address> ...] <container_id> [-h <fqdn>]
|
weave dns-add [<ip_address> ...] <container_id> [-h <fqdn>]
|
||||||
weave dns-remove <ip_address> [<ip_address> ...] <container_id> [-h <fqdn>]
|
weave dns-remove [<ip_address> ...] <container_id> [-h <fqdn>]
|
||||||
weave dns-lookup <unqualified_name>
|
weave dns-lookup <unqualified_name>
|
||||||
weave expose [<addr> ...] [-h <fqdn>]
|
weave expose [<addr> ...] [-h <fqdn>]
|
||||||
weave hide [<addr> ...]
|
weave hide [<addr> ...]
|
||||||
@@ -735,6 +735,12 @@ echo_addresses() {
|
|||||||
echo $1 $2 $3
|
echo $1 $2 $3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo_ips() {
|
||||||
|
for CIDR in $3; do
|
||||||
|
echo ${3%/*}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
peer_args() {
|
peer_args() {
|
||||||
res=''
|
res=''
|
||||||
sep=''
|
sep=''
|
||||||
@@ -1502,9 +1508,12 @@ case "$COMMAND" in
|
|||||||
dns-add)
|
dns-add)
|
||||||
collect_ip_args "$@"
|
collect_ip_args "$@"
|
||||||
shift $IP_COUNT
|
shift $IP_COUNT
|
||||||
[ $IP_COUNT -gt 0 -a \( $# -eq 1 -o \( $# -eq 3 -a "$2" = "-h" \) \) ] || usage
|
[ $# -eq 1 -o \( $# -eq 3 -a "$2" = "-h" \) ] || usage
|
||||||
check_running $CONTAINER_NAME
|
check_running $CONTAINER_NAME
|
||||||
CONTAINER=$(container_id $1)
|
CONTAINER=$(container_id $1)
|
||||||
|
if [ $IP_COUNT -eq 0 ] ; then
|
||||||
|
IP_ARGS=$(with_container_addresses echo_ips $CONTAINER)
|
||||||
|
fi
|
||||||
if [ $# -eq 1 ] ; then
|
if [ $# -eq 1 ] ; then
|
||||||
with_container_fqdn $CONTAINER put_dns_fqdn $IP_ARGS
|
with_container_fqdn $CONTAINER put_dns_fqdn $IP_ARGS
|
||||||
else
|
else
|
||||||
@@ -1514,9 +1523,12 @@ case "$COMMAND" in
|
|||||||
dns-remove)
|
dns-remove)
|
||||||
collect_ip_args "$@"
|
collect_ip_args "$@"
|
||||||
shift $IP_COUNT
|
shift $IP_COUNT
|
||||||
[ $IP_COUNT -gt 0 -a \( $# -eq 1 -o \( $# -eq 3 -a "$2" = "-h" \) \) ] || usage
|
[ $# -eq 1 -o \( $# -eq 3 -a "$2" = "-h" \) ] || usage
|
||||||
check_running $CONTAINER_NAME
|
check_running $CONTAINER_NAME
|
||||||
CONTAINER=$(container_id $1)
|
CONTAINER=$(container_id $1)
|
||||||
|
if [ $IP_COUNT -eq 0 ] ; then
|
||||||
|
IP_ARGS=$(with_container_addresses echo_ips $CONTAINER)
|
||||||
|
fi
|
||||||
if [ $# -eq 1 ] ; then
|
if [ $# -eq 1 ] ; then
|
||||||
delete_dns $CONTAINER $IP_ARGS
|
delete_dns $CONTAINER $IP_ARGS
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in new issue
Block a user