Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Add optional hostname argument to weave expose #566

Merged
merged 1 commit into from
Apr 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions site/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ invocation:
host2# weave expose 10.2.1.102/24 10.2.2.102/24
host2# weave hide 10.2.1.102/24 10.2.2.102/24

Finally, exposed addresses can be added to weaveDNS by supplying a
hostname:

host2# weave expose 10.2.1.102/24 -h exposed.weave.local

### <a name="service-export"></a>Service export

Services running in containers on a weave network can be made
Expand Down
16 changes: 14 additions & 2 deletions weave
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ usage() {
echo "weave start <cidr> [<cidr> ...] <container_id>"
echo "weave attach <cidr> [<cidr> ...] <container_id>"
echo "weave detach <cidr> [<cidr> ...] <container_id>"
echo "weave expose <cidr>"
echo "weave expose <cidr> [-h <hostname>]"
echo "weave hide <cidr>"
echo "weave ps [<container_id> ...]"
echo "weave status"
Expand Down Expand Up @@ -760,7 +760,15 @@ case "$COMMAND" in
;;
expose)
[ $# -gt 0 ] || usage
for CIDR; do
collect_cidr_args "$@"
shift $CIDR_COUNT
if [ $# -eq 0 ]; then
FQDN=""
else
[ $# -eq 2 -a "$1" = "-h" ] || usage
FQDN="$2"
fi
for CIDR in $CIDR_ARGS; do
validate_cidr $CIDR
create_bridge --without-ethtool
if ! ip addr show dev $BRIDGE | grep -qF $CIDR
Expand All @@ -769,6 +777,9 @@ case "$COMMAND" in
arp_update $BRIDGE $CIDR
add_iptables_rule nat WEAVE -o $BRIDGE ! -s $CIDR -j MASQUERADE
add_iptables_rule nat WEAVE -s $CIDR ! -o $BRIDGE -j MASQUERADE
if [ "$FQDN" ]; then
http_call $DNS_CONTAINER_NAME $DNS_HTTP_PORT PUT /name/weave:expose/${CIDR%/*} --data-urlencode "fqdn=$FQDN" 2>/dev/null || true
fi
fi
done
;;
Expand All @@ -782,6 +793,7 @@ case "$COMMAND" in
ip addr del dev $BRIDGE $CIDR
delete_iptables_rule nat WEAVE -o $BRIDGE ! -s $CIDR -j MASQUERADE
delete_iptables_rule nat WEAVE -s $CIDR ! -o $BRIDGE -j MASQUERADE
http_call $DNS_CONTAINER_NAME $DNS_HTTP_PORT DELETE /name/weave:expose/${CIDR%/*} 2>/dev/null || true
fi
done
;;
Expand Down